diff --git a/CMakeLists.txt b/CMakeLists.txt index c40c92565..f2ba00f5d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,8 +36,8 @@ set(DS_VERSION_MICRO 0) set(DS_VERSION_STRING ${DS_VERSION_MAJOR}.${DS_VERSION_MINOR}.${DS_VERSION_MICRO} ) configure_file ( - ${PROJECT_SOURCE_DIR}/DSView/config.h.in - ${PROJECT_BINARY_DIR}/DSView/config.h + ${PROJECT_SOURCE_DIR}/DSView/src/config.h.in + ${PROJECT_BINARY_DIR}/DSView/src/config.h ) #=============================================================================== @@ -62,7 +62,6 @@ endif() set(DISABLE_WERROR TRUE) #Build without -Werror set(ENABLE_SIGNALS TRUE) #Build with UNIX signals set(ENABLE_COTIRE FALSE) #Enable cotire -set(ENABLE_TESTS FALSE) #Enable unit tests set(STATIC_PKGDEPS_LIBS FALSE) #Statically link to (pkg-config) libraries if(WIN32) @@ -236,278 +235,281 @@ find_package(Threads) #------------------------------------------------------------------------------- set(DSView_SOURCES - DSView/main.cpp - DSView/dsapplication.cpp - DSView/pv/log.cpp - DSView/pv/sigsession.cpp - DSView/pv/mainwindow.cpp - DSView/pv/data/snapshot.cpp - DSView/pv/data/signaldata.cpp - DSView/pv/data/logicsnapshot.cpp - DSView/pv/data/analogsnapshot.cpp - DSView/pv/dialogs/deviceoptions.cpp - DSView/pv/prop/property.cpp - DSView/pv/prop/int.cpp - DSView/pv/prop/enum.cpp - DSView/pv/prop/double.cpp - DSView/pv/prop/bool.cpp - DSView/pv/prop/binding/binding.cpp - DSView/pv/toolbars/samplingbar.cpp - DSView/pv/view/viewport.cpp - DSView/pv/view/view.cpp - DSView/pv/view/timemarker.cpp - DSView/pv/view/signal.cpp - DSView/pv/view/ruler.cpp - DSView/pv/view/logicsignal.cpp - DSView/pv/view/header.cpp - DSView/pv/view/cursor.cpp - DSView/pv/view/analogsignal.cpp - DSView/pv/prop/binding/deviceoptions.cpp - DSView/pv/toolbars/trigbar.cpp - DSView/pv/toolbars/filebar.cpp - DSView/pv/dock/protocoldock.cpp - DSView/pv/dock/triggerdock.cpp - DSView/pv/dock/measuredock.cpp - DSView/pv/dock/searchdock.cpp - DSView/pv/toolbars/logobar.cpp - DSView/pv/dialogs/about.cpp - DSView/pv/dialogs/search.cpp - DSView/pv/data/dsosnapshot.cpp - DSView/pv/view/dsosignal.cpp - DSView/pv/view/dsldial.cpp - DSView/pv/dock/dsotriggerdock.cpp - DSView/pv/view/trace.cpp - DSView/pv/view/selectableitem.cpp - DSView/pv/data/decoderstack.cpp - DSView/pv/data/decode/rowdata.cpp - DSView/pv/data/decode/row.cpp - DSView/pv/data/decode/decoder.cpp - DSView/pv/data/decode/annotation.cpp - DSView/pv/view/decodetrace.cpp - DSView/pv/prop/binding/decoderoptions.cpp - DSView/pv/widgets/fakelineedit.cpp - DSView/pv/widgets/decodermenu.cpp - DSView/pv/widgets/decodergroupbox.cpp - DSView/pv/prop/string.cpp - DSView/pv/dialogs/storeprogress.cpp - DSView/pv/storesession.cpp - DSView/pv/view/devmode.cpp - DSView/pv/dialogs/waitingdialog.cpp - DSView/pv/dialogs/dsomeasure.cpp - DSView/pv/dialogs/calibration.cpp - DSView/pv/data/decodermodel.cpp - DSView/pv/dialogs/protocollist.cpp - DSView/pv/dialogs/protocolexp.cpp - DSView/pv/dialogs/fftoptions.cpp - DSView/pv/data/mathstack.cpp - DSView/pv/view/mathtrace.cpp - DSView/pv/toolbars/titlebar.cpp - DSView/pv/mainframe.cpp - DSView/pv/widgets/border.cpp - DSView/pv/dialogs/dsmessagebox.cpp - DSView/pv/dialogs/shadow.cpp - DSView/pv/dialogs/dsdialog.cpp - DSView/pv/dialogs/interval.cpp - DSView/pv/prop/binding/probeoptions.cpp - DSView/pv/view/viewstatus.cpp - DSView/pv/dialogs/lissajousoptions.cpp - DSView/pv/view/lissajoustrace.cpp - DSView/pv/view/spectrumtrace.cpp - DSView/pv/data/spectrumstack.cpp - DSView/pv/dialogs/mathoptions.cpp - DSView/pv/dialogs/regionoptions.cpp - DSView/pv/view/xcursor.cpp - DSView/pv/dock/protocoldock.cpp - DSView/pv/data/decoderstack.cpp - DSView/pv/data/decode/annotation.cpp - DSView/pv/data/decode/decoder.cpp - DSView/pv/data/decode/row.cpp - DSView/pv/data/decode/rowdata.cpp - DSView/pv/prop/binding/decoderoptions.cpp - DSView/pv/view/decodetrace.cpp - DSView/pv/widgets/decodergroupbox.cpp - DSView/pv/widgets/decodermenu.cpp - DSView/pv/config/appconfig.cpp - DSView/pv/appcontrol.cpp - DSView/pv/dstimer.cpp - DSView/pv/eventobject.cpp - DSView/pv/ZipMaker.cpp - DSView/pv/data/decode/annotationrestable.cpp - DSView/pv/data/decode/decoderstatus.cpp - DSView/pv/dock/protocolitemlayer.cpp - DSView/pv/ui/msgbox.cpp - DSView/pv/ui/dscombobox.cpp - DSView/pv/dsvdef.cpp - DSView/pv/dialogs/applicationpardlg.cpp - DSView/pv/dock/keywordlineedit.cpp - DSView/pv/dock/searchcombobox.cpp - DSView/pv/dialogs/decoderoptionsdlg.cpp - DSView/pv/utility/encoding.cpp - DSView/pv/utility/path.cpp - DSView/pv/utility/array.cpp - DSView/pv/deviceagent.cpp - DSView/pv/ui/langresource.cpp - DSView/pv/ui/fn.cpp + DSView/src/log.cpp + DSView/src/main.cpp + DSView/src/utility/path.cpp + DSView/src/utility/array.cpp + DSView/src/utility/encoding.cpp + DSView/src/config/appconfig.cpp + DSView/src/decode/rowdata.cpp + DSView/src/decode/annotationrestable.cpp + DSView/src/decode/decoder.cpp + DSView/src/decode/row.cpp + DSView/src/decode/annotation.cpp + DSView/src/decode/decoderstatus.cpp + DSView/src/prop/property.cpp + DSView/src/prop/double.cpp + DSView/src/prop/int.cpp + DSView/src/prop/bool.cpp + DSView/src/prop/enum.cpp + DSView/src/prop/string.cpp + DSView/src/prop/binding/deviceoptions.cpp + DSView/src/prop/binding/decoderoptions.cpp + DSView/src/prop/binding/probeoptions.cpp + DSView/src/prop/binding/binding.cpp + DSView/src/dialogs/protocollist.cpp + DSView/src/dialogs/interval.cpp + DSView/src/dialogs/search.cpp + DSView/src/dialogs/fftoptions.cpp + DSView/src/dialogs/waitingdialog.cpp + DSView/src/dialogs/regionoptions.cpp + DSView/src/dialogs/deviceoptions.cpp + DSView/src/dialogs/decoderoptionsdlg.cpp + DSView/src/dialogs/applicationpardlg.cpp + DSView/src/dialogs/storeprogress.cpp + DSView/src/dialogs/shadow.cpp + DSView/src/dialogs/protocolexp.cpp + DSView/src/dialogs/calibration.cpp + DSView/src/dialogs/dsdialog.cpp + DSView/src/dialogs/about.cpp + DSView/src/dialogs/mathoptions.cpp + DSView/src/dialogs/dsmessagebox.cpp + DSView/src/dialogs/lissajousoptions.cpp + DSView/src/dialogs/dsomeasure.cpp + DSView/src/view/viewport.cpp + DSView/src/view/view.cpp + DSView/src/view/groupsignal.cpp + DSView/src/view/devmode.cpp + DSView/src/view/dsosignal.cpp + DSView/src/view/timemarker.cpp + DSView/src/view/viewstatus.cpp + DSView/src/view/mathtrace.cpp + DSView/src/view/trace.cpp + DSView/src/view/logicsignal.cpp + DSView/src/view/dsldial.cpp + DSView/src/view/spectrumtrace.cpp + DSView/src/view/analogsignal.cpp + DSView/src/view/signal.cpp + DSView/src/view/cursor.cpp + DSView/src/view/header.cpp + DSView/src/view/ruler.cpp + DSView/src/view/decodetrace.cpp + DSView/src/view/lissajoustrace.cpp + DSView/src/view/xcursor.cpp + DSView/src/appcore/mainframe.cpp + DSView/src/appcore/appcontrol.cpp + DSView/src/appcore/deviceagent.cpp + DSView/src/appcore/mainwindow.cpp + DSView/src/appcore/eventobject.cpp + DSView/src/appcore/sigsession.cpp + DSView/src/com/storesession.cpp + DSView/src/com/zipmaker.cpp + DSView/src/com/dstimer.cpp + DSView/src/widgets/decodergroupbox.cpp + DSView/src/widgets/decodermenu.cpp + DSView/src/widgets/border.cpp + DSView/src/widgets/fakelineedit.cpp + DSView/src/ui/dscombobox.cpp + DSView/src/ui/langresource.cpp + DSView/src/ui/fn.cpp + DSView/src/ui/msgbox.cpp + DSView/src/dock/triggerdock.cpp + DSView/src/dock/keywordlineedit.cpp + DSView/src/dock/searchcombobox.cpp + DSView/src/dock/measuredock.cpp + DSView/src/dock/dsotriggerdock.cpp + DSView/src/dock/searchdock.cpp + DSView/src/dock/protocolitemlayer.cpp + DSView/src/dock/protocoldock.cpp + DSView/src/toolbars/samplingbar.cpp + DSView/src/toolbars/logobar.cpp + DSView/src/toolbars/trigbar.cpp + DSView/src/toolbars/titlebar.cpp + DSView/src/toolbars/filebar.cpp + DSView/src/data/analogsnapshot.cpp + DSView/src/data/decodermodel.cpp + DSView/src/data/signaldata.cpp + DSView/src/data/snapshot.cpp + DSView/src/data/dsosnapshot.cpp + DSView/src/data/mathstack.cpp + DSView/src/data/logicsnapshot.cpp + DSView/src/data/decoderstack.cpp + DSView/src/data/spectrumstack.cpp ) set(DSView_HEADERS - DSView/mystyle.h - DSView/pv/log.h - DSView/pv/sigsession.h - DSView/pv/mainwindow.h - DSView/pv/dialogs/deviceoptions.h - DSView/pv/prop/property.h - DSView/pv/prop/int.h - DSView/pv/prop/enum.h - DSView/pv/prop/double.h - DSView/pv/prop/bool.h - DSView/pv/toolbars/samplingbar.h - DSView/pv/view/viewport.h - DSView/pv/view/view.h - DSView/pv/view/timemarker.h - DSView/pv/view/ruler.h - DSView/pv/view/header.h - DSView/pv/view/cursor.h - DSView/pv/toolbars/trigbar.h - DSView/pv/toolbars/filebar.h - DSView/pv/dock/protocoldock.h - DSView/pv/dock/triggerdock.h - DSView/pv/dock/measuredock.h - DSView/pv/dock/searchdock.h - DSView/pv/toolbars/logobar.h - DSView/pv/dialogs/about.h - DSView/pv/dialogs/search.h - DSView/pv/dock/dsotriggerdock.h - DSView/pv/view/trace.h - DSView/pv/view/selectableitem.h - DSView/pv/data/decoderstack.h - DSView/pv/view/decodetrace.h - DSView/pv/widgets/fakelineedit.h - DSView/pv/widgets/decodermenu.h - DSView/pv/widgets/decodergroupbox.h - DSView/pv/prop/string.h - DSView/pv/dialogs/storeprogress.h - DSView/pv/storesession.h - DSView/pv/view/devmode.h - DSView/pv/dialogs/waitingdialog.h - DSView/pv/dialogs/dsomeasure.h - DSView/pv/dialogs/calibration.h - DSView/pv/dialogs/protocollist.h - DSView/pv/dialogs/protocolexp.h - DSView/pv/dialogs/fftoptions.h - DSView/pv/data/mathstack.h - DSView/pv/view/mathtrace.h - DSView/pv/view/viewstatus.h - DSView/pv/toolbars/titlebar.h - DSView/pv/mainframe.h - DSView/pv/widgets/border.h - DSView/pv/dialogs/dsmessagebox.h - DSView/pv/dialogs/shadow.h - DSView/pv/dialogs/dsdialog.h - DSView/pv/dialogs/interval.h - DSView/pv/dialogs/lissajousoptions.h - DSView/pv/view/lissajoustrace.h - DSView/pv/view/spectrumtrace.h - DSView/pv/data/spectrumstack.h - DSView/pv/dialogs/mathoptions.h - DSView/pv/dialogs/regionoptions.h - DSView/pv/view/xcursor.h - DSView/pv/view/signal.h - DSView/pv/view/logicsignal.h - DSView/pv/view/analogsignal.h - DSView/pv/view/dsosignal.h - DSView/pv/dock/protocoldock.h - DSView/pv/data/decoderstack.h - DSView/pv/view/decodetrace.h - DSView/pv/widgets/decodergroupbox.h - DSView/pv/widgets/decodermenu.h - DSView/pv/config/appconfig.h - DSView/pv/appcontrol.h - DSView/pv/dstimer.h - DSView/pv/eventobject.h - DSView/pv/ZipMaker.h - DSView/pv/data/decode/annotationrestable.h - DSView/pv/data/decode/decoderstatus.h - DSView/pv/dock/protocolitemlayer.h - DSView/pv/ui/msgbox.h - DSView/pv/ui/dscombobox.h - DSView/pv/dsvdef.h - DSView/pv/dialogs/applicationpardlg.h - DSView/pv/dock/keywordlineedit.h - DSView/pv/dock/searchcombobox.h - DSView/pv/dialogs/decoderoptionsdlg.h - DSView/pv/utility/encoding.h - DSView/pv/utility/path.h - DSView/pv/utility/array.h - DSView/pv/deviceagent.h - DSView/pv/ui/fn.h + DSView/src/log.h + DSView/src/config.h + DSView/src/mystyle.h + DSView/src/basedef.h + DSView/src/utility/encoding.h + DSView/src/utility/path.h + DSView/src/utility/array.h + DSView/src/config/appconfig.h + DSView/src/decode/annotation.h + DSView/src/decode/displaydataformat.h + DSView/src/decode/annotationrestable.h + DSView/src/decode/row.h + DSView/src/decode/rowdata.h + DSView/src/decode/decoderstatus.h + DSView/src/decode/decoder.h + DSView/src/prop/double.h + DSView/src/prop/bool.h + DSView/src/prop/enum.h + DSView/src/prop/property.h + DSView/src/prop/int.h + DSView/src/prop/string.h + DSView/src/prop/binding/deviceoptions.h + DSView/src/prop/binding/probeoptions.h + DSView/src/prop/binding/decoderoptions.h + DSView/src/prop/binding/binding.h + DSView/src/dialogs/deviceoptions.h + DSView/src/dialogs/calibration.h + DSView/src/dialogs/protocollist.h + DSView/src/dialogs/waitingdialog.h + DSView/src/dialogs/applicationpardlg.h + DSView/src/dialogs/search.h + DSView/src/dialogs/regionoptions.h + DSView/src/dialogs/fftoptions.h + DSView/src/dialogs/dsmessagebox.h + DSView/src/dialogs/dsdialog.h + DSView/src/dialogs/dsomeasure.h + DSView/src/dialogs/lissajousoptions.h + DSView/src/dialogs/about.h + DSView/src/dialogs/shadow.h + DSView/src/dialogs/decoderoptionsdlg.h + DSView/src/dialogs/interval.h + DSView/src/dialogs/protocolexp.h + DSView/src/dialogs/storeprogress.h + DSView/src/dialogs/mathoptions.h + DSView/src/view/viewport.h + DSView/src/view/mathtrace.h + DSView/src/view/xcursor.h + DSView/src/view/spectrumtrace.h + DSView/src/view/decodetrace.h + DSView/src/view/devmode.h + DSView/src/view/ruler.h + DSView/src/view/logicsignal.h + DSView/src/view/lissajoustrace.h + DSView/src/view/groupsignal.h + DSView/src/view/signal.h + DSView/src/view/dsldial.h + DSView/src/view/cursor.h + DSView/src/view/viewstatus.h + DSView/src/view/timemarker.h + DSView/src/view/trace.h + DSView/src/view/analogsignal.h + DSView/src/view/dsosignal.h + DSView/src/view/header.h + DSView/src/view/view.h + DSView/src/interface/icallbacks.h + DSView/src/appcore/sigsession.h + DSView/src/appcore/mainframe.h + DSView/src/appcore/eventobject.h + DSView/src/appcore/appcontrol.h + DSView/src/appcore/deviceagent.h + DSView/src/appcore/mainwindow.h + DSView/src/com/dstimer.h + DSView/src/com/zipmaker.h + DSView/src/com/storesession.h + DSView/src/widgets/fakelineedit.h + DSView/src/widgets/decodermenu.h + DSView/src/widgets/decodergroupbox.h + DSView/src/widgets/border.h + DSView/src/ui/langresource.h + DSView/src/ui/msgbox.h + DSView/src/ui/string_ids.h + DSView/src/ui/dscombobox.h + DSView/src/ui/fn.h + DSView/src/dock/searchdock.h + DSView/src/dock/protocolitemlayer.h + DSView/src/dock/searchcombobox.h + DSView/src/dock/triggerdock.h + DSView/src/dock/keywordlineedit.h + DSView/src/dock/protocoldock.h + DSView/src/dock/measuredock.h + DSView/src/dock/dsotriggerdock.h + DSView/src/toolbars/samplingbar.h + DSView/src/toolbars/trigbar.h + DSView/src/toolbars/titlebar.h + DSView/src/toolbars/filebar.h + DSView/src/toolbars/logobar.h + DSView/src/data/logicsnapshot.h + DSView/src/data/analogsnapshot.h + DSView/src/data/decoderstack.h + DSView/src/data/dsosnapshot.h + DSView/src/data/snapshot.h + DSView/src/data/decodermodel.h + DSView/src/data/mathstack.h + DSView/src/data/signaldata.h + DSView/src/data/spectrumstack.h ) #=============================================================================== #= libsigrok4DSL source #------------------------------------------------------------------------------- set(libsigrok4DSL_SOURCES - libsigrok4DSL/version.c - libsigrok4DSL/strutil.c - libsigrok4DSL/std.c - libsigrok4DSL/session_driver.c - libsigrok4DSL/session.c - libsigrok4DSL/log.c - libsigrok4DSL/hwdriver.c - libsigrok4DSL/error.c - libsigrok4DSL/backend.c - libsigrok4DSL/output/output.c - libsigrok4DSL/input/input.c - libsigrok4DSL/hardware/demo/demo.c - libsigrok4DSL/input/in_binary.c - libsigrok4DSL/input/in_vcd.c - libsigrok4DSL/input/in_wav.c - libsigrok4DSL/output/csv.c - libsigrok4DSL/output/gnuplot.c - libsigrok4DSL/output/srzip.c - libsigrok4DSL/output/vcd.c - libsigrok4DSL/hardware/DSL/dslogic.c - libsigrok4DSL/hardware/common/usb.c - libsigrok4DSL/hardware/common/ezusb.c - libsigrok4DSL/trigger.c - libsigrok4DSL/dsdevice.c - libsigrok4DSL/hardware/DSL/dscope.c - libsigrok4DSL/hardware/DSL/command.c - libsigrok4DSL/hardware/DSL/dsl.c - libsigrok4DSL/lib_main.c + libsigrok4DSL/version.c + libsigrok4DSL/strutil.c + libsigrok4DSL/std.c + libsigrok4DSL/session_driver.c + libsigrok4DSL/session.c + libsigrok4DSL/log.c + libsigrok4DSL/hwdriver.c + libsigrok4DSL/error.c + libsigrok4DSL/backend.c + libsigrok4DSL/output/output.c + libsigrok4DSL/input/input.c + libsigrok4DSL/hardware/demo/demo.c + libsigrok4DSL/input/in_binary.c + libsigrok4DSL/input/in_vcd.c + libsigrok4DSL/input/in_wav.c + libsigrok4DSL/output/csv.c + libsigrok4DSL/output/gnuplot.c + libsigrok4DSL/output/srzip.c + libsigrok4DSL/output/vcd.c + libsigrok4DSL/hardware/DSL/dslogic.c + libsigrok4DSL/hardware/common/usb.c + libsigrok4DSL/hardware/common/ezusb.c + libsigrok4DSL/trigger.c + libsigrok4DSL/dsdevice.c + libsigrok4DSL/hardware/DSL/dscope.c + libsigrok4DSL/hardware/DSL/command.c + libsigrok4DSL/hardware/DSL/dsl.c + libsigrok4DSL/lib_main.c ) set(libsigrok4DSL_HEADERS - libsigrok4DSL/version.h - libsigrok4DSL/libsigrok-internal.h - libsigrok4DSL/libsigrok.h - libsigrok4DSL/config.h - libsigrok4DSL/hardware/DSL/command.h - libsigrok4DSL/hardware/DSL/dsl.h + libsigrok4DSL/version.h + libsigrok4DSL/libsigrok-internal.h + libsigrok4DSL/libsigrok.h + libsigrok4DSL/config.h + libsigrok4DSL/hardware/DSL/command.h + libsigrok4DSL/hardware/DSL/dsl.h ) #=============================================================================== #= libsigrokdecode4DSL source #------------------------------------------------------------------------------- set(libsigrokdecode4DSL_SOURCES - libsigrokdecode4DSL/type_decoder.c - libsigrokdecode4DSL/srd.c - libsigrokdecode4DSL/module_sigrokdecode.c - libsigrokdecode4DSL/decoder.c - libsigrokdecode4DSL/error.c - libsigrokdecode4DSL/exception.c - libsigrokdecode4DSL/instance.c - libsigrokdecode4DSL/log.c - libsigrokdecode4DSL/session.c - libsigrokdecode4DSL/util.c - libsigrokdecode4DSL/version.c + libsigrokdecode4DSL/type_decoder.c + libsigrokdecode4DSL/srd.c + libsigrokdecode4DSL/module_sigrokdecode.c + libsigrokdecode4DSL/decoder.c + libsigrokdecode4DSL/error.c + libsigrokdecode4DSL/exception.c + libsigrokdecode4DSL/instance.c + libsigrokdecode4DSL/log.c + libsigrokdecode4DSL/session.c + libsigrokdecode4DSL/util.c + libsigrokdecode4DSL/version.c ) set(libsigrokdecode4DSL_HEADERS - libsigrokdecode4DSL/libsigrokdecode-internal.h - libsigrokdecode4DSL/libsigrokdecode.h - libsigrokdecode4DSL/config.h - libsigrokdecode4DSL/version.h + libsigrokdecode4DSL/libsigrokdecode-internal.h + libsigrokdecode4DSL/libsigrokdecode.h + libsigrokdecode4DSL/config.h + libsigrokdecode4DSL/version.h ) #=============================================================================== @@ -515,17 +517,17 @@ set(libsigrokdecode4DSL_HEADERS #------------------------------------------------------------------------------- set(common_SOURCES - common/minizip/zip.c - common/minizip/unzip.c - common/minizip/ioapi.c - common/log/xlog.c + common/minizip/zip.c + common/minizip/unzip.c + common/minizip/ioapi.c + common/log/xlog.c ) set(common_HEADERS - common/minizip/zip.h - common/minizip/unzip.h - common/minizip/ioapi.h - common/log/xlog.h + common/minizip/zip.h + common/minizip/unzip.h + common/minizip/ioapi.h + common/log/xlog.h ) #=============================================================================== @@ -698,14 +700,4 @@ set(CPACK_SOURCE_GENERATOR "TGZ") include(CPack) -#=============================================================================== -#= Tests -#------------------------------------------------------------------------------- - -if(ENABLE_TESTS) - add_subdirectory(test) - enable_testing() - add_test(test ${CMAKE_CURRENT_BINARY_DIR}/DSView/test/DSView-test) -endif(ENABLE_TESTS) - diff --git a/DSView/config.h b/DSView/config.h deleted file mode 100644 index a377444c9..000000000 --- a/DSView/config.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * This file is part of the PulseView project. - * DSView is based on PulseView. - * - * Copyright (C) 2012 Alexandru Gagniuc - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef _DSVIEW_CONFIG_H -#define _DSVIEW_CONFIG_H - -/* Application details */ -#define DS_TITLE "DSView" -#define DS_DESCRIPTION "A GUI for instruments of DreamSourceLab" -#define DS_BIN_NAME "DSView" - -/* DSView version information */ -#define DS_VERSION_MAJOR 1 -#define DS_VERSION_MINOR 3 -#define DS_VERSION_MICRO 0 -#define DS_VERSION_STRING "1.3.0" - -#endif diff --git a/DSView/config.h.in b/DSView/config.h.in deleted file mode 100644 index 0962573c3..000000000 --- a/DSView/config.h.in +++ /dev/null @@ -1,35 +0,0 @@ -/* - * This file is part of the PulseView project. - * DSView is based on PulseView. - * - * Copyright (C) 2012 Alexandru Gagniuc - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef _DSVIEW_CONFIG_H -#define _DSVIEW_CONFIG_H - -/* Application details */ -#define DS_TITLE "@DS_TITLE@" -#define DS_DESCRIPTION "@DS_DESCRIPTION@" -#define DS_BIN_NAME "@PROJECT_NAME@" - -/* DSView version information */ -#define DS_VERSION_MAJOR @DS_VERSION_MAJOR@ -#define DS_VERSION_MINOR @DS_VERSION_MINOR@ -#define DS_VERSION_MICRO @DS_VERSION_MICRO@ -#define DS_VERSION_STRING "@DS_VERSION_STRING@" - -#endif diff --git a/DSView/dsapplication.cpp b/DSView/dsapplication.cpp deleted file mode 100644 index 98cb68977..000000000 --- a/DSView/dsapplication.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/* - * This file is part of the DSView project. - * DSView is based on PulseView. - * - * Copyright (C) 2016 DreamSourceLab - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "dsapplication.h" - -#include - -DSApplication::DSApplication(int &argc, char **argv): - QApplication(argc, argv) -{ -} - -bool DSApplication::notify(QObject *receiver_, QEvent *event_) -{ - try { - return QApplication::notify(receiver_, event_); - } catch ( std::exception& e ) { - QMessageBox msg(NULL); - msg.setText(tr("Application Error")); - msg.setInformativeText(e.what()); - msg.setStandardButtons(QMessageBox::Ok); - msg.setIcon(QMessageBox::Warning); - msg.exec(); - } catch (...) { - QMessageBox msg(NULL); - msg.setText(tr("Application Error")); - msg.setInformativeText(tr("An unexpected error occurred")); - msg.setStandardButtons(QMessageBox::Ok); - msg.setIcon(QMessageBox::Warning); - msg.exec(); - } - return false; -} diff --git a/DSView/pv/view/selectableitem.h b/DSView/pv/view/selectableitem.h deleted file mode 100644 index 463c49117..000000000 --- a/DSView/pv/view/selectableitem.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * This file is part of the DSView project. - * DSView is based on PulseView. - * - * Copyright (C) 2013 Joel Holdsworth - * Copyright (C) 2014 DreamSourceLab - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef DSVIEW_PV_SELECTABLEITEM_H -#define DSVIEW_PV_SELECTABLEITEM_H - -#include -#include -#include - -class QAction; -class QMenu; -class QWidget; - -namespace pv { - -namespace view { - -//Trace's base class -class SelectableItem : public QObject -{ - Q_OBJECT - -private: - static const int HighlightRadius; - -protected: - SelectableItem(); - -public: - /** - * Returns true if the signal has been selected by the user. - */ - bool selected(); - - /** - * Selects or deselects the signal. - */ - void select(bool select = true); - -protected: - static QPen highlight_pen(); - -private: - bool _selected; -}; - -} // namespace view -} // namespace pv - -#endif // DSVIEW_PV_SELECTABLEITEM_H diff --git a/DSView/pv/appcontrol.cpp b/DSView/src/appcore/appcontrol.cpp similarity index 82% rename from DSView/pv/appcontrol.cpp rename to DSView/src/appcore/appcontrol.cpp index 0e1fec53e..3d5a13e7f 100644 --- a/DSView/pv/appcontrol.cpp +++ b/DSView/src/appcore/appcontrol.cpp @@ -29,16 +29,21 @@ #include #include #include "sigsession.h" -#include "dsvdef.h" -#include "config/appconfig.h" -#include "log.h" -#include "utility/path.h" -#include "utility/encoding.h" +#include "../basedef.h" +#include "../config/appconfig.h" +#include "../log.h" +#include "../utility/path.h" +#include "../utility/encoding.h" + +using namespace dsv::config; + +namespace dsv { +namespace appcore { AppControl::AppControl() { _topWindow = NULL; - _session = new pv::SigSession(); + _session = new SigSession(); } AppControl::AppControl(AppControl &o) @@ -65,28 +70,28 @@ void AppControl::Destroy(){ } bool AppControl::Init() -{ - pv::encoding::init(); +{ + dsv::encoding::init(); QString qs; std::string cs; - qs = GetAppDataDir(); - cs = pv::path::ToUnicodePath(qs); + qs = AppConfig::GetAppDataDir(); + cs = dsv::path::ToUnicodePath(qs); dsv_info("GetAppDataDir:\"%s\"", cs.c_str()); - cs = pv::path::ConvertPath(qs); + cs = dsv::path::ConvertPath(qs); ds_set_user_data_dir(cs.c_str()); - qs = GetFirmwareDir(); - cs = pv::path::ToUnicodePath(qs); + qs = AppConfig::GetFirmwareDir(); + cs = dsv::path::ToUnicodePath(qs); dsv_info("GetFirmwareDir:\"%s\"", cs.c_str()); - qs = GetUserDataDir(); - cs = pv::path::ToUnicodePath(qs); + qs = AppConfig::GetUserDataDir(); + cs = dsv::path::ToUnicodePath(qs); dsv_info("GetUserDataDir:\"%s\"", cs.c_str()); - qs = GetDecodeScriptDir(); - cs = pv::path::ToUnicodePath(qs); + qs = AppConfig::GetDecodeScriptDir(); + cs = dsv::path::ToUnicodePath(qs); dsv_info("GetDecodeScriptDir:\"%s\"", cs.c_str()); //---------------end print directorys. @@ -107,7 +112,7 @@ bool AppControl::Init() //the python script path of decoder char path[256] = {0}; - QString dir = GetDecodeScriptDir(); + QString dir = AppConfig::GetDecodeScriptDir(); strcpy(path, dir.toUtf8().data()); // Initialise libsigrokdecode @@ -176,6 +181,10 @@ void AppControl::remove_font_form(IFontForm *form) void AppControl::update_font_forms() { for (auto f : _font_forms){ - f->update_font(); + f->UpdateFont(); } } + +} //namespace com +} //namespace appcore + diff --git a/DSView/pv/appcontrol.h b/DSView/src/appcore/appcontrol.h similarity index 89% rename from DSView/pv/appcontrol.h rename to DSView/src/appcore/appcontrol.h index a2f32893f..27d86836d 100644 --- a/DSView/pv/appcontrol.h +++ b/DSView/src/appcore/appcontrol.h @@ -23,14 +23,15 @@ #include #include +#include "../uicore/uitypes.h" struct sr_context; class QWidget; -class IFontForm; -namespace pv{ - class SigSession; -} +namespace dsv { +namespace appcore { + +class SigSession; class AppControl { @@ -52,7 +53,7 @@ class AppControl void UnInit(); - inline pv::SigSession* GetSession(){ + inline SigSession* GetSession(){ return _session; } @@ -74,7 +75,10 @@ class AppControl std::string _open_file_name; private: - pv::SigSession *_session; + SigSession *_session; QWidget *_topWindow; std::vector _font_forms; }; + +} //namespace com +} //namespace appcore diff --git a/DSView/pv/deviceagent.cpp b/DSView/src/appcore/deviceagent.cpp similarity index 99% rename from DSView/pv/deviceagent.cpp rename to DSView/src/appcore/deviceagent.cpp index 62ebf10eb..9ae0e6393 100644 --- a/DSView/pv/deviceagent.cpp +++ b/DSView/src/appcore/deviceagent.cpp @@ -21,8 +21,10 @@ #include "deviceagent.h" #include -#include "log.h" +#include "../log.h" +namespace dsv { +namespace appcore { DeviceAgent::DeviceAgent() { @@ -654,5 +656,8 @@ bool DeviceAgent::set_config_double(int key, double value, const sr_channel *ch, return true; } +} //namespace com +} //namespace appcore + //---------------device config end -----------/ diff --git a/DSView/pv/deviceagent.h b/DSView/src/appcore/deviceagent.h similarity index 98% rename from DSView/pv/deviceagent.h rename to DSView/src/appcore/deviceagent.h index ae9132d16..876c947e3 100644 --- a/DSView/pv/deviceagent.h +++ b/DSView/src/appcore/deviceagent.h @@ -28,6 +28,9 @@ #include #include +namespace dsv { +namespace appcore { + class IDeviceAgentCallback { public: @@ -237,5 +240,7 @@ class DeviceAgent IDeviceAgentCallback *_callback; }; +} //namespace com +} //namespace appcore #endif \ No newline at end of file diff --git a/DSView/pv/eventobject.cpp b/DSView/src/appcore/eventobject.cpp similarity index 92% rename from DSView/pv/eventobject.cpp rename to DSView/src/appcore/eventobject.cpp index 5f5b9076b..22aab9313 100644 --- a/DSView/pv/eventobject.cpp +++ b/DSView/src/appcore/eventobject.cpp @@ -21,10 +21,16 @@ #include "eventobject.h" +namespace dsv { +namespace appcore { + EventObject::EventObject(){ } DeviceEventObject::DeviceEventObject() { -} \ No newline at end of file +} + +} //namespace com +} //namespace appcore \ No newline at end of file diff --git a/DSView/pv/eventobject.h b/DSView/src/appcore/eventobject.h similarity index 95% rename from DSView/pv/eventobject.h rename to DSView/src/appcore/eventobject.h index e8d1fe9dc..daa8f4161 100644 --- a/DSView/pv/eventobject.h +++ b/DSView/src/appcore/eventobject.h @@ -24,6 +24,9 @@ #include +namespace dsv { +namespace appcore { + class EventObject : public QObject { Q_OBJECT @@ -62,4 +65,7 @@ class DeviceEventObject : public QObject void device_updated(); }; +} //namespace com +} //namespace appcore + #endif \ No newline at end of file diff --git a/DSView/pv/mainframe.cpp b/DSView/src/appcore/mainframe.cpp similarity index 94% rename from DSView/pv/mainframe.cpp rename to DSView/src/appcore/mainframe.cpp index 1ce355c38..b4df04c70 100644 --- a/DSView/pv/mainframe.cpp +++ b/DSView/src/appcore/mainframe.cpp @@ -20,12 +20,6 @@ */ #include "mainframe.h" - -#include "toolbars/titlebar.h" -#include "dialogs/dsmessagebox.h" -#include "dialogs/dsdialog.h" -#include "mainwindow.h" - #include #include #include @@ -44,17 +38,22 @@ #include #include #include - -#include "dsvdef.h" -#include "config/appconfig.h" -#include "ui/msgbox.h" +#include +#include "mainwindow.h" +#include "../toolbars/titlebar.h" +#include "../dialogs/dsmessagebox.h" +#include "../dialogs/dsdialog.h" +#include "../basedef.h" +#include "../config/appconfig.h" +#include "../ui/msgbox.h" #include "appcontrol.h" -#include "ui/langresource.h" -#include "log.h" +#include "../uicore/langresource.h" +#include "../log.h" -#include +using namespace dsv::config; -namespace pv { +namespace dsv { +namespace appcore { MainFrame::MainFrame() { @@ -430,7 +429,7 @@ void MainFrame::readSettings() AppConfig &app = AppConfig::Instance(); if (app.frameOptions.language > 0){ - _mainWindow->switchLanguage(app.frameOptions.language); + _mainWindow->SwitchLanguage(app.frameOptions.language); } int left = app.frameOptions.left; @@ -514,7 +513,7 @@ void MainFrame::show_doc() dialogs::DSDialog dlg(this, true); dlg.setTitle(L_S(STR_PAGE_DLG, S_ID(IDS_DLG_DOCUMENT), "Document")); - QString path = GetAppDataDir() + "/showDoc" + QString::number(lan)+ ".png"; + QString path = AppConfig::GetAppDataDir() + "/showDoc" + QString::number(lan)+ ".png"; if (!QFile::exists(path)){ path = ":/icons/showDoc"+QString::number(lan)+".png"; } @@ -550,4 +549,5 @@ void MainFrame::show_doc() } } -} // namespace pv +} //namespace com +} //namespace appcore diff --git a/DSView/pv/mainframe.h b/DSView/src/appcore/mainframe.h similarity index 93% rename from DSView/pv/mainframe.h rename to DSView/src/appcore/mainframe.h index 3f8c3dbd8..feba0eef0 100644 --- a/DSView/pv/mainframe.h +++ b/DSView/src/appcore/mainframe.h @@ -23,29 +23,32 @@ #ifndef DSVIEW_PV_MAINFRAME_H #define DSVIEW_PV_MAINFRAME_H -#include "widgets/border.h" - #include #include #include + #ifdef _WIN32 #include #include #endif -namespace pv { - -class MainWindow; +#include "../widgets/border.h" + +namespace dsv { namespace toolbars { -class TitleBar; + class TitleBar; } namespace dialogs { -class DSMessageBox; -class DSDialog; + class DSMessageBox; + class DSDialog; } +namespace appcore { + +class MainWindow; + class MainFrame : public QFrame { Q_OBJECT @@ -118,6 +121,7 @@ public slots: #endif }; -} // namespace pv +} //namespace com +} //namespace appcore #endif // DSVIEW_PV_MAINFRAME_H diff --git a/DSView/pv/mainwindow.cpp b/DSView/src/appcore/mainwindow.cpp similarity index 97% rename from DSView/pv/mainwindow.cpp rename to DSView/src/appcore/mainwindow.cpp index e75746f6d..52789174e 100644 --- a/DSView/pv/mainwindow.cpp +++ b/DSView/src/appcore/mainwindow.cpp @@ -20,6 +20,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "mainwindow.h" #include #include #include @@ -43,68 +44,62 @@ #include #include #include - -//include with qt5 -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) -#include -#endif - -#include "mainwindow.h" - -#include "data/logicsnapshot.h" -#include "data/dsosnapshot.h" -#include "data/analogsnapshot.h" - -#include "dialogs/about.h" -#include "dialogs/deviceoptions.h" -#include "dialogs/storeprogress.h" -#include "dialogs/waitingdialog.h" -#include "dialogs/regionoptions.h" - -#include "toolbars/samplingbar.h" -#include "toolbars/trigbar.h" -#include "toolbars/filebar.h" -#include "toolbars/logobar.h" -#include "toolbars/titlebar.h" - -#include "dock/triggerdock.h" -#include "dock/dsotriggerdock.h" -#include "dock/measuredock.h" -#include "dock/searchdock.h" -#include "dock/protocoldock.h" - -#include "view/view.h" -#include "view/trace.h" -#include "view/signal.h" -#include "view/dsosignal.h" -#include "view/logicsignal.h" -#include "view/analogsignal.h" - /* __STDC_FORMAT_MACROS is required for PRIu64 and friends (in C++). */ #include #include #include #include #include -#include "ui/msgbox.h" -#include "config/appconfig.h" -#include "appcontrol.h" -#include "dsvdef.h" -#include "appcontrol.h" -#include "utility/encoding.h" -#include "utility/path.h" -#include "log.h" +#include +#include + +//include with qt5 +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#include +#endif + +#include "../data/logicsnapshot.h" +#include "../data/dsosnapshot.h" +#include "../data/analogsnapshot.h" +#include "../dialogs/about.h" +#include "../dialogs/deviceoptions.h" +#include "../dialogs/storeprogress.h" +#include "../dialogs/waitingdialog.h" +#include "../dialogs/regionoptions.h" +#include "../toolbars/samplingbar.h" +#include "../toolbars/trigbar.h" +#include "../toolbars/filebar.h" +#include "../toolbars/logobar.h" +#include "../toolbars/titlebar.h" +#include "../dock/triggerdock.h" +#include "../dock/dsotriggerdock.h" +#include "../dock/measuredock.h" +#include "../dock/searchdock.h" +#include "../dock/protocoldock.h" +#include "../view/view.h" +#include "../view/trace.h" +#include "../view/signal.h" +#include "../view/dsosignal.h" +#include "../view/logicsignal.h" +#include "../view/analogsignal.h" +#include "../ui/msgbox.h" +#include "../config/appconfig.h" +#include "../utility/encoding.h" +#include "../utility/path.h" +#include "../log.h" #include "sigsession.h" #include "deviceagent.h" -#include -#include "ZipMaker.h" -#include "ui/langresource.h" +#include "../com/zipmaker.h" +#include "../uicore/langresource.h" #include "mainframe.h" -#include "dsvdef.h" -#include +#include "../basedef.h" +#include "appcontrol.h" + + +using namespace dsv::config; -namespace pv -{ +namespace dsv { +namespace appcore { MainWindow::MainWindow(toolbars::TitleBar *title_bar, QWidget *parent) : QMainWindow(parent) @@ -178,7 +173,7 @@ namespace pv _dso_trigger_dock->setWidget(_dso_trigger_widget); // Setup _view widget - _view = new pv::view::View(_session, _sampling_bar, this); + _view = new dsv::view::View(_session, _sampling_bar, this); _vertical_layout->addWidget(_view); setIconSize(QSize(40, 40)); @@ -243,7 +238,7 @@ namespace pv // defaut language AppConfig &app = AppConfig::Instance(); - switchLanguage(app.frameOptions.language); + SwitchLanguage(app.frameOptions.language); switchTheme(app.frameOptions.style); retranslateUi(); @@ -313,7 +308,7 @@ namespace pv QString ldFileName(AppControl::Instance()->_open_file_name.c_str()); if (ldFileName != "") { - std::string file_name = pv::path::ToUnicodePath(ldFileName); + std::string file_name = dsv::path::ToUnicodePath(ldFileName); if (QFile::exists(ldFileName)) { @@ -413,7 +408,7 @@ namespace pv break; } - pv::dialogs::DSMessageBox msg(this, title); + dsv::dialogs::DSMessageBox msg(this, title); msg.mBox()->setText(details); msg.mBox()->setStandardButtons(QMessageBox::Ok); msg.mBox()->setIcon(QMessageBox::Warning); @@ -448,7 +443,7 @@ namespace pv { AppConfig &app = AppConfig::Instance(); - QString file = GetProfileDir(); + QString file = AppConfig::GetProfileDir(); QDir dir(file); if (dir.exists() == false){ dir.mkpath(file); @@ -598,7 +593,7 @@ namespace pv // save file void MainWindow::on_save() { - using pv::dialogs::StoreProgress; + using dsv::dialogs::StoreProgress; if (_device_agent->have_instance() == false) { @@ -619,7 +614,7 @@ namespace pv void MainWindow::on_export() { - using pv::dialogs::StoreProgress; + using dsv::dialogs::StoreProgress; if (_session->is_working()){ dsv_info("Export data: stop the current device."); @@ -644,7 +639,7 @@ namespace pv _protocol_widget->del_all_protocol(); - std::string file_name = pv::path::ToUnicodePath(file); + std::string file_name = dsv::path::ToUnicodePath(file); dsv_info("Load device profile: \"%s\"", file_name.c_str()); QFile sf(file); @@ -1158,7 +1153,7 @@ namespace pv assert(false); } - std::string file_name = pv::path::ToUnicodePath(name); + std::string file_name = dsv::path::ToUnicodePath(name); dsv_info("Store session to file: \"%s\"", file_name.c_str()); QFile sf(name); @@ -1361,7 +1356,7 @@ namespace pv return false; } - void MainWindow::switchLanguage(int language) + void MainWindow::SwitchLanguage(int language) { if (language == 0) return; @@ -1432,7 +1427,7 @@ namespace pv void MainWindow::openDoc() { - QDir dir(GetAppDataDir()); + QDir dir(AppConfig::GetAppDataDir()); AppConfig &app = AppConfig::Instance(); int lan = app.frameOptions.language; QDesktopServices::openUrl( @@ -1676,7 +1671,7 @@ namespace pv } else if (_device_agent->is_demo()) { - QDir dir(GetFirmwareDir()); + QDir dir(AppConfig::GetFirmwareDir()); if (dir.exists()) { QString ses_name = dir.absolutePath() + "/" @@ -1708,7 +1703,7 @@ namespace pv assert(false); } - auto f_name = pv::path::ConvertPath(file); + auto f_name = dsv::path::ConvertPath(file); ZipReader rd(f_name.c_str()); auto *data = rd.GetInnterFileData("session"); @@ -2152,7 +2147,7 @@ namespace pv void MainWindow::load_demo_decoder_config(QString optname) { - QString file = GetAppDataDir() + "/demo/logic/" + optname + ".demo"; + QString file = AppConfig::GetAppDataDir() + "/demo/logic/" + optname + ".demo"; bool bLoadSurccess = false; QJsonArray deArray = get_decoder_json_from_data_file(file, bLoadSurccess); @@ -2170,4 +2165,5 @@ namespace pv _view->update_all_trace_postion(); } -} // namespace pv +} //namespace com +} //namespace appcore diff --git a/DSView/pv/mainwindow.h b/DSView/src/appcore/mainwindow.h similarity index 84% rename from DSView/pv/mainwindow.h rename to DSView/src/appcore/mainwindow.h index 6d28b65c1..071f7b7e2 100644 --- a/DSView/pv/mainwindow.h +++ b/DSView/src/appcore/mainwindow.h @@ -26,13 +26,13 @@ #include #include -#include -#include "dialogs/dsmessagebox.h" -#include "interface/icallbacks.h" -#include "eventobject.h" +#include #include #include -#include "dstimer.h" +#include "../dialogs/dsmessagebox.h" +#include "../interface/icallbacks.h" +#include "eventobject.h" +#include "../com/dstimer.h" class QAction; class QMenuBar; @@ -42,35 +42,45 @@ class QStatusBar; class QToolBar; class QWidget; class QDockWidget; -class AppControl; -class DeviceAgent; using std::chrono::high_resolution_clock; using std::chrono::milliseconds; -namespace pv { - -class SigSession; - -namespace toolbars { -class SamplingBar; -class TrigBar; -class FileBar; -class LogoBar; -class TitleBar; +namespace dsv{ + namespace appcore{ + class SigSession; + class AppControl; + class DeviceAgent; + } } -namespace dock{ -class ProtocolDock; -class TriggerDock; -class DsoTriggerDock; -class MeasureDock; -class SearchDock; +namespace dsv{ + namespace toolbars { + class SamplingBar; + class TrigBar; + class FileBar; + class LogoBar; + class TitleBar; + } + namespace dock{ + class ProtocolDock; + class TriggerDock; + class DsoTriggerDock; + class MeasureDock; + class SearchDock; + } + namespace view { + class View; + } } +using namespace dsv::toolbars; +using namespace dsv::dock; +using namespace dsv::com; +using namespace dsv::view; -namespace view { -class View; -} +namespace dsv { +namespace appcore { +class SigSession; //The mainwindow,referenced by MainFrame //TODO: create graph view,toolbar,and show device list @@ -129,7 +139,14 @@ private slots: public: //IMainForm - void switchLanguage(int language) override; + void SwitchLanguage(int language) override; + + void AddLangForm(ILangForm *form) override{}; + void RemoveLangForm(ILangForm *form)override{}; + void AddFontForm(IFontForm *form)override{}; + void RemoveFontForm(IFontForm *form)override{}; + void UpdateAllFontForm()override{}; + bool able_to_close(); private: @@ -185,7 +202,7 @@ private slots: void OnMessage(int msg) override; private: - pv::view::View *_view; + dsv::view::View *_view; dialogs::DSMessageBox *_msg; QMenuBar *_menu_bar; @@ -242,6 +259,7 @@ private slots: bool _key_vaild; }; -} // namespace pv +} //namespace com +} //namespace appcore #endif // DSVIEW_PV_MAINWINDOW_H diff --git a/DSView/pv/sigsession.cpp b/DSView/src/appcore/sigsession.cpp similarity index 98% rename from DSView/pv/sigsession.cpp rename to DSView/src/appcore/sigsession.cpp index bf6b800fc..1cd78106c 100644 --- a/DSView/pv/sigsession.cpp +++ b/DSView/src/appcore/sigsession.cpp @@ -20,45 +20,43 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include - #include "sigsession.h" -#include "mainwindow.h" - -#include "data/analogsnapshot.h" -#include "data/dsosnapshot.h" -#include "data/logicsnapshot.h" -#include "data/decoderstack.h" -#include "data/decode/decoder.h" -#include "data/decodermodel.h" -#include "data/spectrumstack.h" -#include "data/mathstack.h" - -#include "view/analogsignal.h" -#include "view/dsosignal.h" -#include "view/logicsignal.h" -#include "view/groupsignal.h" -#include "view/decodetrace.h" -#include "view/spectrumtrace.h" -#include "view/lissajoustrace.h" -#include "view/mathtrace.h" - +#include #include #include #include #include #include +#include "mainwindow.h" +#include "../data/analogsnapshot.h" +#include "../data/dsosnapshot.h" +#include "../data/logicsnapshot.h" +#include "../data/decoderstack.h" +#include "../decode/decoder.h" +#include "../data/decodermodel.h" +#include "../data/spectrumstack.h" +#include "../data/mathstack.h" +#include "../view/analogsignal.h" +#include "../view/dsosignal.h" +#include "../view/logicsignal.h" +#include "../view/groupsignal.h" +#include "../view/decodetrace.h" +#include "../view/spectrumtrace.h" +#include "../view/lissajoustrace.h" +#include "../view/mathtrace.h" +#include "../decode/decoderstatus.h" +#include "../basedef.h" +#include "../log.h" +#include "../config/appconfig.h" +#include "../utility/path.h" +#include "../ui/msgbox.h" +#include "../uicore/langresource.h" + +using namespace dsv::config; + +namespace dsv { +namespace appcore { -#include "data/decode/decoderstatus.h" -#include "dsvdef.h" -#include "log.h" -#include "config/appconfig.h" -#include "utility/path.h" -#include "ui/msgbox.h" -#include "ui/langresource.h" - -namespace pv -{ SessionData::SessionData() { _cur_snap_samplerate = 0; @@ -108,7 +106,7 @@ namespace pv this->add_msg_listener(this); - _decoder_model = new pv::data::DecoderModel(NULL); + _decoder_model = new dsv::data::DecoderModel(NULL); _lissajous_trace = NULL; _math_trace = NULL; @@ -152,8 +150,8 @@ namespace pv ds_set_datafeed_callback(data_feed_callback); // firmware resource directory - QString resdir = GetFirmwareDir(); - std::string res_path = pv::path::ToUnicodePath(resdir); + QString resdir = AppConfig::GetFirmwareDir(); + std::string res_path = dsv::path::ToUnicodePath(resdir); ds_set_firmware_resource_dir(res_path.c_str()); if (ds_lib_init() != SR_OK) @@ -233,7 +231,7 @@ namespace pv set_collect_mode(COLLECT_SINGLE); if (_device_agent.is_file()){ - std::string dev_name = pv::path::ToUnicodePath(_device_agent.name()); + std::string dev_name = dsv::path::ToUnicodePath(_device_agent.name()); dsv_info("Switch to file \"%s\" done.", dev_name.c_str()); } else @@ -296,7 +294,7 @@ namespace pv assert(!_is_saving); assert(!_is_working); - std::string file_name = pv::path::ToUnicodePath(name); + std::string file_name = dsv::path::ToUnicodePath(name); dsv_info("Load file: \"%s\"", file_name.c_str()); std::string file_str = name.toUtf8().toStdString(); @@ -1452,7 +1450,7 @@ namespace pv } bool SigSession::add_decoder(srd_decoder *const dec, bool silent, DecoderStatus *dstatus, - std::list &sub_decoders, view::Trace* &out_trace) + std::list &sub_decoders, view::Trace* &out_trace) { if (dec == NULL) { @@ -2441,4 +2439,5 @@ namespace pv } } -} // namespace pv +} //namespace com +} //namespace appcore diff --git a/DSView/pv/sigsession.h b/DSView/src/appcore/sigsession.h similarity index 92% rename from DSView/pv/sigsession.h rename to DSView/src/appcore/sigsession.h index f41c14e6e..b4d217f32 100644 --- a/DSView/pv/sigsession.h +++ b/DSView/src/appcore/sigsession.h @@ -31,49 +31,60 @@ #include #include #include - -#include "view/mathtrace.h" -#include "data/mathstack.h" -#include "interface/icallbacks.h" -#include "dstimer.h" #include +#include "../view/mathtrace.h" +#include "../data/mathstack.h" +#include "../interface/icallbacks.h" +#include "../com/dstimer.h" #include "deviceagent.h" #include "eventobject.h" -#include "data/logicsnapshot.h" -#include "data/analogsnapshot.h" -#include "data/dsosnapshot.h" +#include "../data/logicsnapshot.h" +#include "../data/analogsnapshot.h" +#include "../data/dsosnapshot.h" struct srd_decoder; struct srd_channel; -class DecoderStatus; typedef std::lock_guard ds_lock_guard; -namespace pv { - +namespace dsv { namespace data { -class SignalData; -class Snapshot; -class AnalogSnapshot; -class DsoSnapshot; -class LogicSnapshot; -class DecoderModel; -class MathStack; + class SignalData; + class Snapshot; + class AnalogSnapshot; + class DsoSnapshot; + class LogicSnapshot; + class DecoderModel; + class MathStack; +} namespace decode { class Decoder; - } + class DecoderStatus; } namespace view { -class Signal; -class GroupSignal; -class DecodeTrace; -class SpectrumTrace; -class LissajousTrace; -class MathTrace; + class Signal; + class GroupSignal; + class DecodeTrace; + class SpectrumTrace; + class LissajousTrace; + class MathTrace; } +namespace com{ + class DsTimer; +} +} + +using namespace dsv::view; +using namespace dsv::com; +using namespace dsv::decode; +using namespace dsv::data; + +namespace dsv { +namespace appcore { + enum DEVICE_STATUS_TYPE { ST_INIT = 0, @@ -117,8 +128,6 @@ class SessionData data::DsoSnapshot dso; }; -using namespace pv::data; - //created by MainWindow class SigSession: public IMessageListener, @@ -210,7 +219,7 @@ class SigSession: std::vector& get_signals(); bool add_decoder(srd_decoder *const dec, bool silent, DecoderStatus *dstatus, - std::list &sub_decoders, view::Trace* &out_trace); + std::list &sub_decoders, view::Trace* &out_trace); int get_trace_index_by_key_handel(void *handel); void remove_decoder(int index); void remove_decoder_by_key_handel(void *handel); @@ -222,7 +231,7 @@ class SigSession: void rst_decoder(int index); void rst_decoder_by_key_handel(void *handel); - inline pv::data::DecoderModel* get_decoder_model(){ + inline dsv::data::DecoderModel* get_decoder_model(){ return _decoder_model; } @@ -251,8 +260,8 @@ class SigSession: void lissajous_rebuild(bool enable, int xindex, int yindex, double percent); void lissajous_disable(); - void math_rebuild(bool enable,pv::view::DsoSignal *dsoSig1, - pv::view::DsoSignal *dsoSig2, + void math_rebuild(bool enable,dsv::view::DsoSignal *dsoSig1, + dsv::view::DsoSignal *dsoSig2, data::MathStack::MathType type); inline bool trigd(){ @@ -535,7 +544,7 @@ class SigSession: std::vector _signals; std::vector _decode_traces; std::vector _decode_tasks; - pv::data::DecoderModel *_decoder_model; + dsv::data::DecoderModel *_decoder_model; std::vector _spectrum_traces; view::LissajousTrace *_lissajous_trace; view::MathTrace *_math_trace; @@ -602,6 +611,7 @@ class SigSession: static SigSession *_session; }; -} // namespace pv +} //namespace com +} //namespace appcore #endif // DSVIEW_PV_SIGSESSION_H diff --git a/DSView/pv/dsvdef.h b/DSView/src/basedef.h similarity index 76% rename from DSView/pv/dsvdef.h rename to DSView/src/basedef.h index c52ffb03c..53508a4f1 100644 --- a/DSView/pv/dsvdef.h +++ b/DSView/src/basedef.h @@ -1,8 +1,9 @@ + /* * This file is part of the DSView project. * DSView is based on PulseView. * - * Copyright (C) 2021 DreamSourceLab + * Copyright (C) 2023 DreamSourceLab * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,9 +20,19 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#pragma once +#ifndef DSV_BASE_DEF_H +#define DSV_BASE_DEF_H + +#ifdef _WIN32 + #define DSV_EXPORT __declspec(dllexport) + #define DSV_IMPORT __declspec(dllimport) + #define DSV_HIDDEN +#else + #define DSV_EXPORT __attribute__((visibility("default"))) + #define DSV_IMPORT __attribute__((visibility("default"))) + #define DSV_HIDDEN __attribute__((visibility("hidden"))) +#endif -#include "../config.h" #define countof(x) (sizeof(x)/sizeof(x[0])) @@ -34,16 +45,6 @@ enum View_type { ALL_VIEW }; - -#ifdef DS_DEBUG_TRACE - void ds_print(const char *s); - - #define ds_debug(x) ds_print((x)) -#else - #define ds_debug(x) -#endif - - #define DESTROY_OBJECT(p) if((p)){delete (p); p = NULL;} #define DESTROY_QT_OBJECT(p) if((p)){((p))->deleteLater(); p = NULL;} #define DESTROY_QT_LATER(p) ((p))->deleteLater(); @@ -58,16 +59,4 @@ enum View_type { #define SESSION_FORMAT_VERSION 3 #define HEADER_FORMAT_VERSION 3 -namespace DecoderDataFormat -{ - enum _data_format - { - hex=0, - dec=1, - oct=2, - bin=3, - ascii=4 - }; - - int Parse(const char *name); -} +#endif \ No newline at end of file diff --git a/DSView/pv/dstimer.cpp b/DSView/src/com/dstimer.cpp similarity index 97% rename from DSView/pv/dstimer.cpp rename to DSView/src/com/dstimer.cpp index 405a21e65..de1486240 100644 --- a/DSView/pv/dstimer.cpp +++ b/DSView/src/com/dstimer.cpp @@ -22,7 +22,9 @@ #include "dstimer.h" #include - +namespace dsv { +namespace com { + DsTimer::DsTimer() { _binded = false; @@ -106,3 +108,6 @@ void DsTimer::SetCallback(CALLBACL_FUNC f) { _beginTime = high_resolution_clock::now(); } + +} //namespace com +} //namespace dsv diff --git a/DSView/pv/dstimer.h b/DSView/src/com/dstimer.h similarity index 93% rename from DSView/pv/dstimer.h rename to DSView/src/com/dstimer.h index 276bc6421..999d26f91 100644 --- a/DSView/pv/dstimer.h +++ b/DSView/src/com/dstimer.h @@ -19,19 +19,21 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef _DS_TIMER_H -#define _DS_TIMER_H +#ifndef COM_DS_TIMER_H +#define COM_DS_TIMER_H #include #include #include #include -using std::chrono::high_resolution_clock; -using std::chrono::milliseconds; +namespace dsv { +namespace com { typedef std::function CALLBACL_FUNC; +using std::chrono::high_resolution_clock; +using std::chrono::milliseconds; class DsTimer : protected QObject { @@ -71,4 +73,7 @@ private slots: CALLBACL_FUNC _call; }; +} //namespace com +} //namespace dsv + #endif diff --git a/DSView/pv/storesession.cpp b/DSView/src/com/storesession.cpp similarity index 97% rename from DSView/pv/storesession.cpp rename to DSView/src/com/storesession.cpp index 7a0c1ed1b..fb0ae5083 100644 --- a/DSView/pv/storesession.cpp +++ b/DSView/src/com/storesession.cpp @@ -24,21 +24,6 @@ #define __STDC_FORMAT_MACROS #include "storesession.h" -#include "sigsession.h" - -#include "data/logicsnapshot.h" -#include "data/dsosnapshot.h" -#include "data/analogsnapshot.h" -#include "data/decoderstack.h" -#include "data/decode/decoder.h" -#include "data/decode/row.h" -#include "view/trace.h" -#include "view/signal.h" -#include "view/logicsignal.h" -#include "view/dsosignal.h" -#include "view/decodetrace.h" -#include "dock/protocoldock.h" - #include #include #include @@ -48,23 +33,39 @@ #include #include #include +#include + +#include "../appcore/sigsession.h" +#include "../data/logicsnapshot.h" +#include "../data/dsosnapshot.h" +#include "../data/analogsnapshot.h" +#include "../data/decoderstack.h" +#include "../decode/decoder.h" +#include "../decode/row.h" +#include "../view/trace.h" +#include "../view/signal.h" +#include "../view/logicsignal.h" +#include "../view/dsosignal.h" +#include "../view/decodetrace.h" +#include "../dock/protocoldock.h" #ifdef _WIN32 #include #endif -#include -#include "config/appconfig.h" -#include "dsvdef.h" -#include "utility/encoding.h" -#include "utility/path.h" -#include "log.h" - -#include "ui/langresource.h" +#include "../config/appconfig.h" +#include "../basedef.h" +#include "../utility/encoding.h" +#include "../utility/path.h" +#include "../log.h" +#include "../uicore/langresource.h" #define DEOCDER_CONFIG_VERSION 2 - -namespace pv { + +using namespace dsv::config; + +namespace dsv { +namespace com { StoreSession::StoreSession(SigSession *session) : _session(session), @@ -210,7 +211,7 @@ bool StoreSession::save_start() return false; } -void StoreSession::save_logic(pv::data::LogicSnapshot *logic_snapshot) +void StoreSession::save_logic(dsv::data::LogicSnapshot *logic_snapshot) { char chunk_name[20] = {0}; uint16_t to_save_probes = 0; @@ -294,7 +295,7 @@ void StoreSession::save_logic(pv::data::LogicSnapshot *logic_snapshot) } } -void StoreSession::save_analog(pv::data::AnalogSnapshot *analog_snapshot) +void StoreSession::save_analog(dsv::data::AnalogSnapshot *analog_snapshot) { char chunk_name[20] = {0}; int num = 0; @@ -381,7 +382,7 @@ void StoreSession::save_analog(pv::data::AnalogSnapshot *analog_snapshot) } } -void StoreSession::save_dso(pv::data::DsoSnapshot *dso_snapshot) +void StoreSession::save_dso(dsv::data::DsoSnapshot *dso_snapshot) { char chunk_name[20] = {0}; int ret = SR_ERR; @@ -1093,7 +1094,7 @@ bool StoreSession::gen_decoders_json(QJsonArray &array) auto rows = stack->get_rows_gshow(); for (auto i = rows.begin(); i != rows.end(); i++) { - pv::data::decode::Row _row = (*i).first; + dsv::decode::Row _row = (*i).first; QString kn = _row.title_id(); show_obj[kn] = QJsonValue::fromVariant((*i).second); } @@ -1124,7 +1125,7 @@ bool StoreSession::load_decoders(dock::ProtocolDock *widget, QJsonArray &dec_arr { QJsonObject dec_obj = dec_value.toObject(); std::vector &pre_dsigs = _session->get_decode_signals(); - std::list sub_decoders; + std::list sub_decoders; //get sub decoders if (dec_obj.contains("stacked decoders")) { @@ -1137,7 +1138,7 @@ bool StoreSession::load_decoders(dock::ProtocolDock *widget, QJsonArray &dec_arr assert(d); if (QString::fromUtf8(d->id) == stacked_obj["id"].toString()) { - sub_decoders.push_back(new data::decode::Decoder(d)); + sub_decoders.push_back(new decode::Decoder(d)); break; } } @@ -1324,7 +1325,7 @@ bool StoreSession::load_decoders(dock::ProtocolDock *widget, QJsonArray &dec_arr if (dec_obj.contains("show")) { QJsonObject show_obj = dec_obj["show"].toObject(); - std::map rows = stack->get_rows_gshow(); + std::map rows = stack->get_rows_gshow(); for (auto i = rows.begin();i != rows.end(); i++) { QString key; @@ -1336,7 +1337,7 @@ bool StoreSession::load_decoders(dock::ProtocolDock *widget, QJsonArray &dec_arr if (show_obj.contains(key)) { bool bShow = show_obj[key].toBool(); - const pv::data::decode::Row r = (*i).first; + const dsv::decode::Row r = (*i).first; stack->set_rows_gshow(r, bShow); } } @@ -1560,4 +1561,5 @@ void StoreSession::MakeChunkName(char *chunk_name, int chunk_num, int index, int } } -} // pv +} //namespace com +} //namespace dsv diff --git a/DSView/pv/storesession.h b/DSView/src/com/storesession.h similarity index 77% rename from DSView/pv/storesession.h rename to DSView/src/com/storesession.h index 67974edf0..dd3760462 100644 --- a/DSView/pv/storesession.h +++ b/DSView/src/com/storesession.h @@ -27,27 +27,33 @@ #include #include #include -#include +#include +#include "../interface/icallbacks.h" +#include "zipmaker.h" -#include "interface/icallbacks.h" - -#include "ZipMaker.h" - -namespace pv { - -class SigSession; - -namespace data { -class Snapshot; -class LogicSnapshot; -class AnalogSnapshot; -class DsoSnapshot; +namespace dsv +{ + namespace data { + class Snapshot; + class LogicSnapshot; + class AnalogSnapshot; + class DsoSnapshot; +} +namespace appcore{ + class SigSession; } - namespace dock { -class ProtocolDock; + class ProtocolDock; +} } +using namespace dsv::appcore; +using namespace dsv::data; +using namespace dsv::dock; + +namespace dsv { +namespace com { + class StoreSession : public QObject { Q_OBJECT @@ -72,12 +78,12 @@ class StoreSession : public QObject void cancel(); private: - void save_proc(pv::data::Snapshot *snapshot); - void save_logic(pv::data::LogicSnapshot *logic_snapshot); - void save_analog(pv::data::AnalogSnapshot *analog_snapshot); - void save_dso(pv::data::DsoSnapshot *dso_snapshot); + void save_proc(dsv::data::Snapshot *snapshot); + void save_logic(dsv::data::LogicSnapshot *logic_snapshot); + void save_analog(dsv::data::AnalogSnapshot *analog_snapshot); + void save_dso(dsv::data::DsoSnapshot *dso_snapshot); bool meta_gen(data::Snapshot *snapshot, std::string &str); - void export_proc(pv::data::Snapshot *snapshot); + void export_proc(dsv::data::Snapshot *snapshot); bool decoders_gen(std::string &str); @@ -121,6 +127,7 @@ class StoreSession : public QObject ZipMaker m_zipDoc; }; -} // pv +} //namespace com +} //namespace dsv #endif // DSVIEW_PV_STORESESSION_H diff --git a/DSView/pv/ZipMaker.cpp b/DSView/src/com/zipmaker.cpp similarity index 98% rename from DSView/pv/ZipMaker.cpp rename to DSView/src/com/zipmaker.cpp index e81e3df73..45e9e9b62 100644 --- a/DSView/pv/ZipMaker.cpp +++ b/DSView/src/com/zipmaker.cpp @@ -19,12 +19,15 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "ZipMaker.h" +#include "zipmaker.h" #include #include #include #include #include + +namespace dsv { +namespace com { ZipMaker::ZipMaker() : m_zDoc(NULL) @@ -240,4 +243,7 @@ void ZipReader::ReleaseInnerFileData(ZipInnerFileData *data) if (data){ delete data; } -} \ No newline at end of file +} + +} //namespace com +} //namespace dsv \ No newline at end of file diff --git a/DSView/pv/ZipMaker.h b/DSView/src/com/zipmaker.h similarity index 97% rename from DSView/pv/ZipMaker.h rename to DSView/src/com/zipmaker.h index f8eec3f53..8cbc7f3d0 100644 --- a/DSView/pv/ZipMaker.h +++ b/DSView/src/com/zipmaker.h @@ -27,6 +27,9 @@ #include +namespace dsv { +namespace com { + class ZipMaker { public: @@ -99,4 +102,7 @@ class ZipReader{ private: unzFile m_archive; }; + +} //namespace com +} //namespace dsv diff --git a/DSView/pv/config/appconfig.cpp b/DSView/src/config/appconfig.cpp similarity index 97% rename from DSView/pv/config/appconfig.cpp rename to DSView/src/config/appconfig.cpp index 99141b89b..2b723b129 100644 --- a/DSView/pv/config/appconfig.cpp +++ b/DSView/src/config/appconfig.cpp @@ -27,9 +27,12 @@ #include #include #include "../log.h" - + #define MAX_PROTOCOL_FORMAT_LIST 15 +namespace dsv { +namespace config { + StringPair::StringPair(const std::string &key, const std::string &value) { m_key = key; @@ -386,7 +389,7 @@ std::string AppConfig::GetProtocolFormat(const std::string &protocolName) } //-------------api -QString GetIconPath() +QString AppConfig::GetIconPath() { QString style = AppConfig::Instance().frameOptions.style; if (style == ""){ @@ -395,7 +398,7 @@ QString GetIconPath() return ":/icons/" + style; } -QString GetAppDataDir() +QString AppConfig::GetAppDataDir() { //applicationDirPath not end with '/' #ifdef Q_OS_LINUX @@ -431,7 +434,7 @@ QString GetAppDataDir() #endif } -QString GetFirmwareDir() +QString AppConfig::GetFirmwareDir() { QDir dir1 = GetAppDataDir() + "/res"; // ./res @@ -450,16 +453,16 @@ QString GetFirmwareDir() return dir1.absolutePath(); } -QString GetUserDataDir() +QString AppConfig::GetUserDataDir() { - #if QT_VERSION >= 0x050400 +#if QT_VERSION >= 0x050400 return QStandardPaths::writableLocation(QStandardPaths::AppDataLocation); - #else +#else return QStandardPaths::writableLocation(QStandardPaths::DataLocation); - #endif +#endif } -QString GetDecodeScriptDir() +QString AppConfig::GetDecodeScriptDir() { QString path = GetAppDataDir() + "/decoders"; @@ -474,16 +477,19 @@ QString GetDecodeScriptDir() // ../share/libsigrokdecode4DSL/decoders if (dir.cd("..") && dir.cd("share") && dir.cd("libsigrokdecode4DSL") && dir.cd("decoders")) { - return dir.absolutePath(); + return dir.absolutePath(); } return ""; } -QString GetProfileDir() +QString AppConfig::GetProfileDir() { - #if QT_VERSION >= 0x050400 +#if QT_VERSION >= 0x050400 return QStandardPaths::writableLocation(QStandardPaths::AppDataLocation); - #else +#else return QStandardPaths::writableLocation(QStandardPaths::DataLocation); - #endif +#endif } + +} //config +} //dsv diff --git a/DSView/pv/config/appconfig.h b/DSView/src/config/appconfig.h similarity index 90% rename from DSView/pv/config/appconfig.h rename to DSView/src/config/appconfig.h index e34b91ea3..08d6c2af9 100644 --- a/DSView/pv/config/appconfig.h +++ b/DSView/src/config/appconfig.h @@ -19,7 +19,9 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#pragma once + +#ifndef CONFIG_APPCONIFG_H +#define CONFIG_APPCONIFG_H #include #include @@ -31,18 +33,10 @@ #define THEME_STYLE_DARK "dark" #define THEME_STYLE_LIGHT "light" - #define APP_NAME "DSView" - -//--------------------api--- -QString GetIconPath(); -QString GetAppDataDir(); -QString GetFirmwareDir(); -QString GetUserDataDir(); -QString GetDecodeScriptDir(); -QString GetProfileDir(); - -//------------------class + +namespace dsv { +namespace config { class StringPair { @@ -52,7 +46,6 @@ class StringPair std::string m_value; }; - struct AppOptions { bool quickScroll; @@ -146,8 +139,20 @@ class AppConfig return frameOptions.language == LAN_CN; } + static QString GetIconPath(); + static QString GetAppDataDir(); + static QString GetFirmwareDir(); + static QString GetUserDataDir(); + static QString GetDecodeScriptDir(); + static QString GetProfileDir(); + public: AppOptions appOptions; UserHistory userHistory; FrameOptions frameOptions; }; + +} //config +} //dsv + +#endif diff --git a/DSView/pv/data/analogsnapshot.cpp b/DSView/src/data/analogsnapshot.cpp similarity index 99% rename from DSView/pv/data/analogsnapshot.cpp rename to DSView/src/data/analogsnapshot.cpp index 0e5e82966..4bb905625 100644 --- a/DSView/pv/data/analogsnapshot.cpp +++ b/DSView/src/data/analogsnapshot.cpp @@ -20,18 +20,17 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "analogsnapshot.h" #include #include #include #include #include - -#include "analogsnapshot.h" -#include "../dsvdef.h" +#include "../basedef.h" using namespace std; -namespace pv { +namespace dsv { namespace data { const int AnalogSnapshot::EnvelopeScalePower = 4; @@ -404,4 +403,4 @@ void* AnalogSnapshot::get_data(){ } } // namespace data -} // namespace pv +} // namespace dsv diff --git a/DSView/pv/data/analogsnapshot.h b/DSView/src/data/analogsnapshot.h similarity index 95% rename from DSView/pv/data/analogsnapshot.h rename to DSView/src/data/analogsnapshot.h index 3356f89ad..3ee7db658 100644 --- a/DSView/pv/data/analogsnapshot.h +++ b/DSView/src/data/analogsnapshot.h @@ -25,16 +25,11 @@ #define DSVIEW_PV_DATA_ANALOGSNAPSHOT_H #include -#include "snapshot.h" - #include #include +#include "snapshot.h" -namespace AnalogSnapshotTest { -class Basic; -} - -namespace pv { +namespace dsv { namespace data { class AnalogSnapshot : public Snapshot @@ -118,11 +113,10 @@ class AnalogSnapshot : public Snapshot private: void *_data; - struct Envelope _envelope_levels[DS_MAX_ANALOG_PROBES_NUM][ScaleStepCount]; - friend class AnalogSnapshotTest::Basic; + struct Envelope _envelope_levels[DS_MAX_ANALOG_PROBES_NUM][ScaleStepCount]; }; } // namespace data -} // namespace pv +} // namespace dsv #endif // DSVIEW_PV_DATA_ANALOGSNAPSHOT_H diff --git a/DSView/pv/data/decodermodel.cpp b/DSView/src/data/decodermodel.cpp similarity index 94% rename from DSView/pv/data/decodermodel.cpp rename to DSView/src/data/decodermodel.cpp index af62d7b9f..bf2092258 100644 --- a/DSView/pv/data/decodermodel.cpp +++ b/DSView/src/data/decodermodel.cpp @@ -19,17 +19,17 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "decodermodel.h" #include - -#include "decode/annotation.h" -#include "decode/rowdata.h" #include "decoderstack.h" -#include "decodermodel.h" +#include "../decode/annotation.h" +#include "../decode/rowdata.h" + using namespace boost; using namespace std; -namespace pv { +namespace dsv { namespace data { DecoderModel::DecoderModel(QObject *parent) @@ -69,7 +69,7 @@ QVariant DecoderModel::data(const QModelIndex &index, int role) const return int(Qt::AlignLeft | Qt::AlignVCenter); } else if (role == Qt::DisplayRole) { if (_decoder_stack) { - pv::data::decode::Annotation ann; + dsv::decode::Annotation ann; if (_decoder_stack->list_annotation(ann, index.column(), index.row())) { return ann.annotations().at(0); } @@ -97,4 +97,4 @@ QVariant DecoderModel::headerData(int section, } } // namespace data -} // namespace pv +} // namespace dsv diff --git a/DSView/pv/data/decodermodel.h b/DSView/src/data/decodermodel.h similarity index 93% rename from DSView/pv/data/decodermodel.h rename to DSView/src/data/decodermodel.h index d35849f42..592d9eaa7 100644 --- a/DSView/pv/data/decodermodel.h +++ b/DSView/src/data/decodermodel.h @@ -24,19 +24,20 @@ #include -#include "decode/rowdata.h" +#include "../decode/rowdata.h" -namespace pv { -namespace data { - -class DecoderStack; +namespace dsv { namespace decode { -class Annotation; -class Decoder; -class Row; + class Annotation; + class Decoder; + class Row; } +namespace data { + +class DecoderStack; + class DecoderModel : public QAbstractTableModel { public: @@ -58,6 +59,6 @@ class DecoderModel : public QAbstractTableModel }; } // namespace data -} // namespace pv +} // namespace dsv #endif // DSVIEW_PV_DATA_DECODERMODEL_H diff --git a/DSView/pv/data/decoderstack.cpp b/DSView/src/data/decoderstack.cpp similarity index 96% rename from DSView/pv/data/decoderstack.cpp rename to DSView/src/data/decoderstack.cpp index 7e0e33b65..d79a22b77 100644 --- a/DSView/pv/data/decoderstack.cpp +++ b/DSView/src/data/decoderstack.cpp @@ -20,38 +20,36 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ - +#include "decoderstack.h" #include #include #include - -#include "decoderstack.h" +#include #include "logicsnapshot.h" -#include "decode/decoder.h" -#include "decode/annotation.h" -#include "decode/rowdata.h" -#include "../sigsession.h" +#include "../decode/decoder.h" +#include "../decode/annotation.h" +#include "../decode/rowdata.h" +#include "../appcore/sigsession.h" #include "../view/logicsignal.h" -#include "../dsvdef.h" +#include "../basedef.h" #include "../log.h" -#include "../ui/langresource.h" -#include +#include "../uicore/langresource.h" -using namespace pv::data::decode; using namespace std; using namespace boost; -namespace pv { +namespace dsv { namespace data { - + const double DecoderStack::DecodeMargin = 1.0; const double DecoderStack::DecodeThreshold = 0.2; const int64_t DecoderStack::DecodeChunkLength = 4 * 1024; const unsigned int DecoderStack::DecodeNotifyPeriod = 1024; -DecoderStack::DecoderStack(pv::SigSession *session, - const srd_decoder *const dec, DecoderStatus *decoder_status) : - _session(session) +DecoderStack::DecoderStack(SigSession *session, + const srd_decoder *dec, DecoderStatus *decoder_status) : + _session(session), + m_decoder(dec) { assert(session); assert(dec); @@ -167,10 +165,12 @@ void DecoderStack::build_row() std::map::const_iterator iter = _rows_gshow.find(row); if (iter == _rows_gshow.end()) { _rows_gshow[row] = true; + if (row.title().contains("bit", Qt::CaseInsensitive) || row.title().contains("warning", Qt::CaseInsensitive)) { _rows_lshow[row] = false; - } else { + } + else { _rows_lshow[row] = true; } } @@ -216,7 +216,7 @@ int64_t DecoderStack::samples_decoded() } void DecoderStack::get_annotation_subset( - std::vector &dest, + std::vector &dest, const Row &row, uint64_t start_sample, uint64_t end_sample) { @@ -333,7 +333,7 @@ uint64_t DecoderStack::list_annotation_size(uint16_t row_index) return 0; } -bool DecoderStack::list_annotation(pv::data::decode::Annotation &ann, +bool DecoderStack::list_annotation(dsv::decode::Annotation &ann, uint16_t row_index, uint64_t col_index) { for (auto i = _rows.begin(); i != _rows.end(); i++) { @@ -348,7 +348,6 @@ bool DecoderStack::list_annotation(pv::data::decode::Annotation &ann, return false; } - bool DecoderStack::list_row_title(int row, QString &title) { for (auto i = _rows.begin();i != _rows.end(); i++) { @@ -442,7 +441,7 @@ void DecoderStack::do_decode_work() for(auto s : _session->get_signals()) { if(s->get_index() == (*dec->channels().begin()).second && s->signal_type() == SR_CHANNEL_LOGIC) { - _snapshot = ((pv::view::LogicSignal*)s)->data(); + _snapshot = ((dsv::view::LogicSignal*)s)->data(); if (_snapshot != NULL) break; } @@ -783,6 +782,13 @@ void DecoderStack::annotation_callback(srd_proto_data *pdata, void *self) return; } + if (pdata->pdo->di->decoder != d->m_decoder){ + // dsv_err("ERROR:Is a invalid decoder instance.%p,%p", + // pdata->pdo->di->decoder, + // d->m_decoder); + // assert(false); + } + Annotation *a = new Annotation(pdata, d->_decoder_status); if (a == NULL){ d->_no_memory = true; @@ -793,7 +799,7 @@ void DecoderStack::annotation_callback(srd_proto_data *pdata, void *self) assert(pdata->pdo); assert(pdata->pdo->di); const srd_decoder *const decc = pdata->pdo->di->decoder; - assert(decc); + assert(decc); auto row_iter = d->_rows.end(); @@ -871,4 +877,4 @@ const char* DecoderStack::get_root_decoder_id() } } // namespace data -} // namespace pv +} // namespace dsv diff --git a/DSView/pv/data/decoderstack.h b/DSView/src/data/decoderstack.h similarity index 88% rename from DSView/pv/data/decoderstack.h rename to DSView/src/data/decoderstack.h index 310161a2d..6e60ea219 100644 --- a/DSView/pv/data/decoderstack.h +++ b/DSView/src/data/decoderstack.h @@ -29,34 +29,31 @@ #include #include #include - -#include "decode/row.h" -#include "../data/signaldata.h" -#include "decode/decoderstatus.h" - - -namespace DecoderStackTest { -class TwoDecoderStack; +#include "../decode/row.h" +#include "signaldata.h" +#include "../decode/decoderstatus.h" + +namespace dsv{ + namespace decode { + class Annotation; + class Decoder; + class RowData; + } + namespace appcore { + class SigSession; + } + namespace view { + class LogicSignal; + } } +using namespace dsv::appcore; +using namespace dsv::view; +using namespace dsv::decode; -namespace pv { - -class SigSession; - -namespace view { -class LogicSignal; -} - +namespace dsv { namespace data { class LogicSnapshot; - -namespace decode { -class Annotation; -class Decoder; -class RowData; -} - class DecoderStack; struct decode_task_status @@ -84,8 +81,8 @@ class DecoderStack : public QObject, public SignalData }; public: - DecoderStack(pv::SigSession *_session, - const srd_decoder *const decoder, DecoderStatus *decoder_status); + DecoderStack(SigSession *_session, + const srd_decoder *decoder, DecoderStatus *decoder_status); public: @@ -109,7 +106,7 @@ class DecoderStack : public QObject, public SignalData * Extracts sorted annotations between two period into a vector. */ void get_annotation_subset( - std::vector &dest, + std::vector &dest, const decode::Row &row, uint64_t start_sample, uint64_t end_sample); @@ -193,7 +190,7 @@ class DecoderStack : public QObject, public SignalData private: std::list _stack; - pv::data::LogicSnapshot *_snapshot; + dsv::data::LogicSnapshot *_snapshot; std::map _rows; std::map _rows_gshow; @@ -216,11 +213,10 @@ class DecoderStack : public QObject, public SignalData bool _is_capture_end; int _progress; bool _is_decoding; - - friend class DecoderStackTest::TwoDecoderStack; + const srd_decoder *m_decoder; }; } // namespace data -} // namespace pv +} // namespace dsv #endif // DSVIEW_PV_DATA_DECODERSTACK_H diff --git a/DSView/pv/data/dsosnapshot.cpp b/DSView/src/data/dsosnapshot.cpp similarity index 99% rename from DSView/pv/data/dsosnapshot.cpp rename to DSView/src/data/dsosnapshot.cpp index 3186d4fa4..5a719864e 100644 --- a/DSView/pv/data/dsosnapshot.cpp +++ b/DSView/src/data/dsosnapshot.cpp @@ -19,19 +19,18 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "dsosnapshot.h" #include #include #include #include #include - -#include "dsosnapshot.h" -#include "../dsvdef.h" +#include "../basedef.h" #include "../log.h" using namespace std; -namespace pv { +namespace dsv { namespace data { const int DsoSnapshot::EnvelopeScalePower = 8; @@ -551,4 +550,4 @@ int DsoSnapshot::get_ch_order(int sig_index) } } // namespace data -} // namespace pv +} // namespace dsv diff --git a/DSView/pv/data/dsosnapshot.h b/DSView/src/data/dsosnapshot.h similarity index 97% rename from DSView/pv/data/dsosnapshot.h rename to DSView/src/data/dsosnapshot.h index 01955321b..a70a1f4fd 100644 --- a/DSView/pv/data/dsosnapshot.h +++ b/DSView/src/data/dsosnapshot.h @@ -25,15 +25,10 @@ #include #include - #include #include "snapshot.h" - -namespace DsoSnapshotTest { -class Basic; -} -namespace pv { +namespace dsv { namespace data { class DsoSnapshot : public Snapshot @@ -151,11 +146,9 @@ class DsoSnapshot : public Snapshot float _data_scale1 = 0; float _data_scale2 = 0; bool _is_file; - - friend class DsoSnapshotTest::Basic; }; } // namespace data -} // namespace pv +} // namespace dsv #endif // DSVIEW_PV_DATA_DSOSNAPSHOT_H diff --git a/DSView/pv/data/logicsnapshot.cpp b/DSView/src/data/logicsnapshot.cpp similarity index 99% rename from DSView/pv/data/logicsnapshot.cpp rename to DSView/src/data/logicsnapshot.cpp index 36b0ef259..b89df178c 100644 --- a/DSView/pv/data/logicsnapshot.cpp +++ b/DSView/src/data/logicsnapshot.cpp @@ -19,20 +19,19 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ - + +#include "logicsnapshot.h" #include #include #include #include - -#include "logicsnapshot.h" -#include "../dsvdef.h" +#include "../basedef.h" #include "../log.h" #include "../utility/array.h" using namespace std; -namespace pv { +namespace dsv { namespace data { const uint64_t LogicSnapshot::LevelMask[LogicSnapshot::ScaleLevel] = { @@ -1494,4 +1493,4 @@ void LogicSnapshot::free_head_blocks(int count) } } // namespace data -} // namespace pv +} // namespace dsv diff --git a/DSView/pv/data/logicsnapshot.h b/DSView/src/data/logicsnapshot.h similarity index 95% rename from DSView/pv/data/logicsnapshot.h rename to DSView/src/data/logicsnapshot.h index 91741301c..de4584136 100644 --- a/DSView/pv/data/logicsnapshot.h +++ b/DSView/src/data/logicsnapshot.h @@ -25,23 +25,15 @@ #define DSVIEW_PV_DATA_LOGICSNAPSHOT_H #include -#include "snapshot.h" #include #include #include #include +#include "snapshot.h" #define CHANNEL_MAX_COUNT 64 -namespace LogicSnapshotTest { -class Pow2; -class Basic; -class LargeData; -class Pulses; -class LongPulses; -} - -namespace pv { +namespace dsv { namespace data { class LogicSnapshot : public Snapshot @@ -252,15 +244,9 @@ class LogicSnapshot : public Snapshot std::vector _free_block_list; struct BlockIndex _cur_ref_block_indexs[CHANNEL_MAX_COUNT]; int _lst_free_block_index; - - friend class LogicSnapshotTest::Pow2; - friend class LogicSnapshotTest::Basic; - friend class LogicSnapshotTest::LargeData; - friend class LogicSnapshotTest::Pulses; - friend class LogicSnapshotTest::LongPulses; }; } // namespace data -} // namespace pv +} // namespace dsv #endif // DSVIEW_PV_DATA_LOGICSNAPSHOT_H diff --git a/DSView/pv/data/mathstack.cpp b/DSView/src/data/mathstack.cpp similarity index 99% rename from DSView/pv/data/mathstack.cpp rename to DSView/src/data/mathstack.cpp index 01474aea3..3f0eae88d 100644 --- a/DSView/pv/data/mathstack.cpp +++ b/DSView/src/data/mathstack.cpp @@ -20,17 +20,18 @@ */ #include "mathstack.h" +#include #include "dsosnapshot.h" -#include "../sigsession.h" +#include "../appcore/sigsession.h" #include "../view/dsosignal.h" -#include + #define PI 3.1415 using namespace boost; using namespace std; -namespace pv { +namespace dsv { namespace data { const int MathStack::EnvelopeScalePower = 8; @@ -72,7 +73,7 @@ const QString MathStack::vDialDivUnit[MathStack::vDialUnitCount] = { "V/V", }; -MathStack::MathStack(pv::SigSession *session, +MathStack::MathStack(SigSession *session, view::DsoSignal* dsoSig1, view::DsoSignal* dsoSig2, MathType type) : @@ -473,4 +474,4 @@ void MathStack::append_to_envelope_level(bool header) } } // namespace data -} // namespace pv +} // namespace dsv diff --git a/DSView/pv/data/mathstack.h b/DSView/src/data/mathstack.h similarity index 92% rename from DSView/pv/data/mathstack.h rename to DSView/src/data/mathstack.h index 3b175f1c4..4864a6cd2 100644 --- a/DSView/pv/data/mathstack.h +++ b/DSView/src/data/mathstack.h @@ -22,25 +22,25 @@ #ifndef DSVIEW_PV_DATA_MATHSTACK_H #define DSVIEW_PV_DATA_MATHSTACK_H -#include "signaldata.h" - #include - -#include - - #include #include +#include +#include "signaldata.h" -namespace pv { - -class SigSession; - -namespace view { -class DsoSignal; -class dslDial; +namespace dsv{ + namespace appcore{ + class SigSession; + } + namespace view{ + class DsoSignal; + class dslDial; + } } +using namespace dsv::appcore; +using namespace dsv::view; +namespace dsv { namespace data { class DsoSnapshot; @@ -101,7 +101,7 @@ class MathStack : public QObject, public SignalData static const QString vDialDivUnit[vDialUnitCount]; public: - MathStack(pv::SigSession *_session, + MathStack(SigSession *_session, view::DsoSignal *dsoSig1, view::DsoSignal *dsoSig2, MathType type); virtual ~MathStack(); @@ -131,7 +131,7 @@ class MathStack : public QObject, public SignalData signals: private: - pv::SigSession *_session; + SigSession *_session; view::DsoSignal *_dsoSig1; view::DsoSignal *_dsoSig2; @@ -148,6 +148,6 @@ class MathStack : public QObject, public SignalData }; } // namespace data -} // namespace pv +} // namespace dsv #endif // DSVIEW_PV_DATA_MATHSTACK_H diff --git a/DSView/pv/data/signaldata.cpp b/DSView/src/data/signaldata.cpp similarity index 97% rename from DSView/pv/data/signaldata.cpp rename to DSView/src/data/signaldata.cpp index 31c609377..31a5cc98c 100644 --- a/DSView/pv/data/signaldata.cpp +++ b/DSView/src/data/signaldata.cpp @@ -24,7 +24,7 @@ #include "signaldata.h" -namespace pv { +namespace dsv { namespace data { SignalData::SignalData() : @@ -42,4 +42,4 @@ void SignalData::set_samplerate(double samplerate) } } // namespace data -} // namespace pv +} // namespace dsv diff --git a/DSView/pv/data/signaldata.h b/DSView/src/data/signaldata.h similarity index 97% rename from DSView/pv/data/signaldata.h rename to DSView/src/data/signaldata.h index f32694217..b1ccd559c 100644 --- a/DSView/pv/data/signaldata.h +++ b/DSView/src/data/signaldata.h @@ -27,7 +27,7 @@ #include #include -namespace pv { +namespace dsv { namespace data { class SignalData @@ -50,6 +50,6 @@ class SignalData }; } // namespace data -} // namespace pv +} // namespace dsv #endif // DSVIEW_PV_DATA_SIGNALDATA_H diff --git a/DSView/pv/data/snapshot.cpp b/DSView/src/data/snapshot.cpp similarity index 98% rename from DSView/pv/data/snapshot.cpp rename to DSView/src/data/snapshot.cpp index 026690255..2c666331e 100644 --- a/DSView/pv/data/snapshot.cpp +++ b/DSView/src/data/snapshot.cpp @@ -26,7 +26,7 @@ #include #include -namespace pv { +namespace dsv { namespace data { Snapshot::Snapshot(int unit_size, uint64_t total_sample_count, unsigned int channel_num) @@ -119,4 +119,4 @@ void Snapshot::set_samplerate(double samplerate) } } // namespace data -} // namespace pv +} // namespace dsv diff --git a/DSView/pv/data/snapshot.h b/DSView/src/data/snapshot.h similarity index 98% rename from DSView/pv/data/snapshot.h rename to DSView/src/data/snapshot.h index fa7bce4b6..e1441f262 100644 --- a/DSView/pv/data/snapshot.h +++ b/DSView/src/data/snapshot.h @@ -26,7 +26,7 @@ #include #include -namespace pv { +namespace dsv { namespace data { class Snapshot @@ -110,6 +110,6 @@ class Snapshot }; } // namespace data -} // namespace pv +} // namespace dsv #endif // DSVIEW_PV_DATA_SNAPSHOT_H diff --git a/DSView/pv/data/spectrumstack.cpp b/DSView/src/data/spectrumstack.cpp similarity index 95% rename from DSView/pv/data/spectrumstack.cpp rename to DSView/src/data/spectrumstack.cpp index 1d887bded..a4abfea14 100644 --- a/DSView/pv/data/spectrumstack.cpp +++ b/DSView/src/data/spectrumstack.cpp @@ -19,19 +19,18 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "spectrumstack.h" - +#include "spectrumstack.h" +#include #include "dsosnapshot.h" -#include "../sigsession.h" +#include "../appcore/sigsession.h" #include "../view/dsosignal.h" -#include #define PI 3.1415 using namespace boost; using namespace std; -namespace pv { +namespace dsv { namespace data { const QString SpectrumStack::windows_support[5] = { @@ -50,7 +49,7 @@ const uint64_t SpectrumStack::length_support[5] = { 16384, }; -SpectrumStack::SpectrumStack(pv::SigSession *session, int index) : +SpectrumStack::SpectrumStack(SigSession *session, int index) : _session(session), _index(index), _dc_ignore(true), @@ -169,8 +168,8 @@ void SpectrumStack::calc_fft() { _spectrum_state = Running; // Get the dso data - pv::data::DsoSnapshot *data = NULL; - pv::view::DsoSignal *dsoSig = NULL; + dsv::data::DsoSnapshot *data = NULL; + dsv::view::DsoSignal *dsoSig = NULL; for(auto s : _session->get_signals()) { if (s->signal_type() == SR_CHANNEL_DSO) { @@ -238,4 +237,4 @@ double SpectrumStack::window(uint64_t i, int type) } } // namespace data -} // namespace pv +} // namespace dsv diff --git a/DSView/pv/data/spectrumstack.h b/DSView/src/data/spectrumstack.h similarity index 87% rename from DSView/pv/data/spectrumstack.h rename to DSView/src/data/spectrumstack.h index 58b441278..d53917ce7 100644 --- a/DSView/pv/data/spectrumstack.h +++ b/DSView/src/data/spectrumstack.h @@ -22,25 +22,25 @@ #ifndef DSVIEW_PV_DATA_SPECTRUMSTACK_H #define DSVIEW_PV_DATA_SPECTRUMSTACK_H -#include "signaldata.h" - #include - -#include - +#include #include - #include #include +#include "signaldata.h" -namespace pv { - -class SigSession; - -namespace view { -class DsoSignal; +namespace dsv{ + namespace appcore { + class SigSession; + } + namespace view { + class DsoSignal; + } } +using namespace dsv::appcore; +using namespace dsv::view; +namespace dsv { namespace data { class DsoSnapshot; @@ -61,7 +61,7 @@ class SpectrumStack : public QObject, public SignalData }; public: - SpectrumStack(pv::SigSession *_session, int index); + SpectrumStack(SigSession *_session, int index); virtual ~SpectrumStack(); void clear(); void init(); @@ -93,7 +93,7 @@ class SpectrumStack : public QObject, public SignalData signals: private: - pv::SigSession *_session; + SigSession *_session; int _index; uint64_t _sample_num; @@ -109,6 +109,6 @@ class SpectrumStack : public QObject, public SignalData }; } // namespace data -} // namespace pv +} // namespace dsv #endif // DSVIEW_PV_DATA_SPECTRUMSTACK_H diff --git a/DSView/pv/data/decode/annotation.cpp b/DSView/src/decode/annotation.cpp similarity index 97% rename from DSView/pv/data/decode/annotation.cpp rename to DSView/src/decode/annotation.cpp index 8574136dd..54af513e6 100644 --- a/DSView/pv/data/decode/annotation.cpp +++ b/DSView/src/decode/annotation.cpp @@ -31,14 +31,12 @@ #include #include #include - -#include "../../config/appconfig.h" +#include "../config/appconfig.h" #include "decoderstatus.h" -#include "../../dsvdef.h" +#include "../basedef.h" -namespace pv { -namespace data { +namespace dsv { namespace decode { Annotation::Annotation(const srd_proto_data *const pdata, DecoderStatus *status) @@ -185,5 +183,4 @@ bool Annotation::is_numberic() } } // namespace decode -} // namespace data -} // namespace pv +} // namespace dsv diff --git a/DSView/pv/data/decode/annotation.h b/DSView/src/decode/annotation.h similarity index 90% rename from DSView/pv/data/decode/annotation.h rename to DSView/src/decode/annotation.h index a5b0e4409..95f0b5ef9 100644 --- a/DSView/pv/data/decode/annotation.h +++ b/DSView/src/decode/annotation.h @@ -20,23 +20,21 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef DSVIEW_PV_VIEW_DECODE_ANNOTATION_H -#define DSVIEW_PV_VIEW_DECODE_ANNOTATION_H +#ifndef DECODE_ANNOTATION_H +#define DECODE_ANNOTATION_H #include - #include #include -class AnnotationResTable; -class DecoderStatus; - struct srd_proto_data; -namespace pv { -namespace data { +namespace dsv { namespace decode { +class AnnotationResTable; +class DecoderStatus; + //create at DecoderStack.annotation_callback class Annotation { @@ -75,8 +73,7 @@ class Annotation DecoderStatus *_status; /*a global variable*/ }; -} // namespace decode -} // namespace data -} // namespace pv +} //namespace decode +} //namespace dsv #endif // DSVIEW_PV_VIEW_DECODE_ANNOTATION_H diff --git a/DSView/pv/data/decode/annotationrestable.cpp b/DSView/src/decode/annotationrestable.cpp similarity index 94% rename from DSView/pv/data/decode/annotationrestable.cpp rename to DSView/src/decode/annotationrestable.cpp index 6f2ec96ab..b5df2155a 100644 --- a/DSView/pv/data/decode/annotationrestable.cpp +++ b/DSView/src/decode/annotationrestable.cpp @@ -23,8 +23,12 @@ #include #include #include -#include "../../log.h" -#include "../../dsvdef.h" +#include "../log.h" +#include "../basedef.h" +#include "displaydataformat.h" + +namespace dsv { +namespace decode { const char g_bin_cvt_table[] = "0000000100100011010001010110011110001001101010111100110111101111"; @@ -137,7 +141,7 @@ const char* AnnotationResTable::format_to_string(const char *hex_str, int fmt) { //flow, convert to oct\dec\bin format const char *data = hex_str; - if (data[0] == 0 || fmt == DecoderDataFormat::hex){ + if (data[0] == 0 || fmt == DisplayDataFormat::hex){ return data; } @@ -186,19 +190,19 @@ const char* AnnotationResTable::format_to_string(const char *hex_str, int fmt) } //get bin format - if (fmt == DecoderDataFormat::bin){ + if (fmt == DisplayDataFormat::bin){ return buf; } //get oct format - if (fmt == DecoderDataFormat::oct){ + if (fmt == DisplayDataFormat::oct){ char *oct_buf = bin2oct_string(g_oct_format_tmp_buffer, sizeof(g_oct_format_tmp_buffer), buf, len * 4); return oct_buf; } //64 bit integer - if (fmt == DecoderDataFormat::dec && len * 4 <= 64){ + if (fmt == DisplayDataFormat::dec && len * 4 <= 64){ long long lv = bin2long_string(buf, len * 4); g_number_tmp_64[0] = 0; sprintf(g_number_tmp_64, "%lld", lv); @@ -206,7 +210,7 @@ const char* AnnotationResTable::format_to_string(const char *hex_str, int fmt) } //ascii - if (fmt == DecoderDataFormat::ascii && len < 30 - 3){ + if (fmt == DisplayDataFormat::ascii && len < 30 - 3){ if (len == 2){ int lv = (int)bin2long_string(buf, len * 4); //can display chars @@ -229,7 +233,7 @@ const char* AnnotationResTable::format_numberic(const char *hex_str, int fmt) { assert(hex_str); - if (hex_str[0] == 0 || fmt == DecoderDataFormat::hex){ + if (hex_str[0] == 0 || fmt == DisplayDataFormat::hex){ return hex_str; } @@ -396,4 +400,7 @@ void AnnotationResTable::decimalToBinString(unsigned long long num, int bitSize, wr--; } } + +} //namespace decode +} //namespace dsv diff --git a/DSView/pv/data/decode/annotationrestable.h b/DSView/src/decode/annotationrestable.h similarity index 93% rename from DSView/pv/data/decode/annotationrestable.h rename to DSView/src/decode/annotationrestable.h index 740c56f74..9da1f39b1 100644 --- a/DSView/pv/data/decode/annotationrestable.h +++ b/DSView/src/decode/annotationrestable.h @@ -19,16 +19,21 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#pragma once #include #include #include #include +#ifndef DECODE_ANNOTATION_RES_TABLE_H +#define DECODE_ANNOTATION_RES_TABLE_H + #define DECODER_MAX_DATA_BLOCK_LEN 256 #define CONVERT_STR_MAX_LEN 150 +namespace dsv { +namespace decode { + struct AnnotationSourceItem { bool is_numeric; @@ -70,3 +75,8 @@ class AnnotationResTable char g_number_tmp_64[30]; char g_all_buf[CONVERT_STR_MAX_LEN + 1]; }; + +} //namespace decode +} //namespace dsv + +#endif diff --git a/DSView/pv/data/decode/decoder.cpp b/DSView/src/decode/decoder.cpp similarity index 97% rename from DSView/pv/data/decode/decoder.cpp rename to DSView/src/decode/decoder.cpp index c51d9cf3d..37b5dde4d 100644 --- a/DSView/pv/data/decode/decoder.cpp +++ b/DSView/src/decode/decoder.cpp @@ -24,10 +24,8 @@ #include "decoder.h" #include - -namespace pv { -namespace data { -namespace decode { +namespace dsv{ +namespace decode{ Decoder::Decoder(const srd_decoder *const dec): _decoder(dec) @@ -139,6 +137,5 @@ srd_decoder_inst* Decoder::create_decoder_inst(srd_session *session) } -} // decode -} // data -} // pv +} //namespace decode +} //namespace dsv diff --git a/DSView/pv/data/decode/decoder.h b/DSView/src/decode/decoder.h similarity index 91% rename from DSView/pv/data/decode/decoder.h rename to DSView/src/decode/decoder.h index 268ff1341..2442a4490 100644 --- a/DSView/pv/data/decode/decoder.h +++ b/DSView/src/decode/decoder.h @@ -20,15 +20,14 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef DSVIEW_PV_DATA_DECODE_DECODER_H -#define DSVIEW_PV_DATA_DECODE_DECODER_H +#ifndef DECODE_DECODER_H +#define DECODE_DECODER_H #include #include #include #include -#include - +#include #include struct srd_decoder; @@ -36,9 +35,8 @@ struct srd_decoder_inst; struct srd_channel; struct srd_session; -namespace pv { -namespace data { -namespace decode { +namespace dsv{ +namespace decode{ class Decoder { @@ -118,8 +116,7 @@ class Decoder bool _shown; }; -} // namespace decode -} // namespace data -} // namespace pv +} //namespace decode +} //namespace dsv -#endif // DSVIEW_PV_DATA_DECODE_DECODER_H +#endif diff --git a/DSView/pv/data/decode/decoderstatus.cpp b/DSView/src/decode/decoderstatus.cpp similarity index 93% rename from DSView/pv/data/decode/decoderstatus.cpp rename to DSView/src/decode/decoderstatus.cpp index ea2c45bd5..c43c0a0ec 100644 --- a/DSView/pv/data/decode/decoderstatus.cpp +++ b/DSView/src/decode/decoderstatus.cpp @@ -21,6 +21,9 @@ #include "decoderstatus.h" +namespace dsv{ +namespace decode{ + DecoderStatus::DecoderStatus() { m_bNumeric = false; @@ -33,3 +36,6 @@ void DecoderStatus::clear() m_resTable.reset(); m_bNumeric = false; } + +} //namespace decode +} //namespace dsv diff --git a/DSView/pv/data/decode/decoderstatus.h b/DSView/src/decode/decoderstatus.h similarity index 87% rename from DSView/pv/data/decode/decoderstatus.h rename to DSView/src/decode/decoderstatus.h index bf09d81d0..28d130445 100644 --- a/DSView/pv/data/decode/decoderstatus.h +++ b/DSView/src/decode/decoderstatus.h @@ -19,10 +19,14 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#pragma once +#ifndef DECODE_DECODER_STATUS_H +#define DECODE_DECODER_STATUS_H #include "annotationrestable.h" +namespace dsv{ +namespace decode{ + class DecoderStatus { public: @@ -36,3 +40,8 @@ class DecoderStatus void *sdr_decoder_handle; AnnotationResTable m_resTable; }; + +} //namespace decode +} //namespace dsv + +#endif //DECODE_DECODER_STATUS_H diff --git a/DSView/pv/dsvdef.cpp b/DSView/src/decode/displaydataformat.h similarity index 75% rename from DSView/pv/dsvdef.cpp rename to DSView/src/decode/displaydataformat.h index d54f53f4c..5150b67ad 100644 --- a/DSView/pv/dsvdef.cpp +++ b/DSView/src/decode/displaydataformat.h @@ -2,7 +2,7 @@ * This file is part of the DSView project. * DSView is based on PulseView. * - * Copyright (C) 2021 DreamSourceLab + * Copyright (C) 2023 DreamSourceLab * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,19 +19,30 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "dsvdef.h" +#ifndef DECODE_DISPLAY_DATA_FORMAT_H +#define DECODE_DISPLAY_DATA_FORMAT_H + #include -#ifdef DS_DEBUG_TRACE -#include - void ds_print(const char *s){ - printf(s); - } -#endif +namespace dsv{ +namespace decode{ -namespace DecoderDataFormat + +class DisplayDataFormat { - int Parse(const char *name){ + +public: + enum + { + hex=0, + dec=1, + oct=2, + bin=3, + ascii=4 + }; + + static inline int Parse(const char *name) + { if (strcmp(name, "dec") == 0){ return (int)dec; } @@ -49,4 +60,9 @@ namespace DecoderDataFormat } return (int)hex; } -} +}; + +#endif + +} //namespace decode +} //namespace dsv \ No newline at end of file diff --git a/DSView/pv/data/decode/row.cpp b/DSView/src/decode/row.cpp similarity index 96% rename from DSView/pv/data/decode/row.cpp rename to DSView/src/decode/row.cpp index b54b402db..a44e9262b 100644 --- a/DSView/pv/data/decode/row.cpp +++ b/DSView/src/decode/row.cpp @@ -24,9 +24,8 @@ #include #include -namespace pv { -namespace data { -namespace decode { +namespace dsv{ +namespace decode{ Row::Row() : _decoder(NULL), @@ -97,6 +96,5 @@ bool Row::operator<(const Row &other) const (_decoder == other._decoder && _order < other._order); } -} // decode -} // data -} // pv +} //namespace decode +} //namespace dsv \ No newline at end of file diff --git a/DSView/pv/data/decode/row.h b/DSView/src/decode/row.h similarity index 88% rename from DSView/pv/data/decode/row.h rename to DSView/src/decode/row.h index 81c1e5cd8..cf09c7956 100644 --- a/DSView/pv/data/decode/row.h +++ b/DSView/src/decode/row.h @@ -19,19 +19,17 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef DSVIEW_PV_DATA_DECODE_ROW_H -#define DSVIEW_PV_DATA_DECODE_ROW_H +#ifndef DECODE_ROW_H +#define DECODE_ROW_H #include - #include "annotation.h" struct srd_decoder; struct srd_decoder_annotation_row; -namespace pv { -namespace data { -namespace decode { +namespace dsv{ +namespace decode{ //map find key data class Row @@ -69,8 +67,7 @@ class Row int _order; }; -} // decode -} // data -} // pv +} //namespace decode +} //namespace dsv -#endif // DSVIEW_PV_DATA_DECODE_ROW_H +#endif // DECODE_ROW_H diff --git a/DSView/pv/data/decode/rowdata.cpp b/DSView/src/decode/rowdata.cpp similarity index 95% rename from DSView/pv/data/decode/rowdata.cpp rename to DSView/src/decode/rowdata.cpp index dc4d0a026..b311916b7 100644 --- a/DSView/pv/data/decode/rowdata.cpp +++ b/DSView/src/decode/rowdata.cpp @@ -29,9 +29,8 @@ using std::max; using std::min; using std::vector; -namespace pv { -namespace data { -namespace decode { +namespace dsv{ +namespace decode{ std::mutex RowData::_global_visitor_mutex; @@ -82,7 +81,7 @@ uint64_t RowData::get_min_annotation() return _min_annotation; } -void RowData::get_annotation_subset(std::vector &dest, +void RowData::get_annotation_subset(std::vector &dest, uint64_t start_sample, uint64_t end_sample) { std::lock_guard lock(_global_visitor_mutex); @@ -150,6 +149,5 @@ bool RowData::get_annotation(Annotation &ann, uint64_t index) } } -} // decode -} // data -} // pv +} //namespace decode +} //namespace dsv \ No newline at end of file diff --git a/DSView/pv/data/decode/rowdata.h b/DSView/src/decode/rowdata.h similarity index 83% rename from DSView/pv/data/decode/rowdata.h rename to DSView/src/decode/rowdata.h index 8314eb6b6..ee349dd4e 100644 --- a/DSView/pv/data/decode/rowdata.h +++ b/DSView/src/decode/rowdata.h @@ -20,17 +20,16 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef DSVIEW_PV_DATA_DECODE_ROWDATA_H -#define DSVIEW_PV_DATA_DECODE_ROWDATA_H +#ifndef DECODE_ROWDATA_H +#define DECODE_ROWDATA_H #include #include #include "annotation.h" -namespace pv { -namespace data { -namespace decode { +namespace dsv{ +namespace decode{ class RowData { @@ -52,12 +51,12 @@ class RowData return _item_count; } - bool get_annotation(pv::data::decode::Annotation &ann, uint64_t index); + bool get_annotation(Annotation &ann, uint64_t index); /** * Extracts sorted annotations between two period into a vector. */ - void get_annotation_subset(std::vector &dest, + void get_annotation_subset(std::vector &dest, uint64_t start_sample, uint64_t end_sample); void clear(); @@ -70,8 +69,7 @@ class RowData static std::mutex _global_visitor_mutex; }; -} -} // data -} // pv +} //namespace decode +} //namespace dsv -#endif // DSVIEW_PV_DATA_DECODE_ROWDATA_H +#endif // DECODE_ROWDATA_H diff --git a/DSView/pv/dialogs/about.cpp b/DSView/src/dialogs/about.cpp similarity index 96% rename from DSView/pv/dialogs/about.cpp rename to DSView/src/dialogs/about.cpp index 09cf27aa2..63e3b8d4e 100644 --- a/DSView/pv/dialogs/about.cpp +++ b/DSView/src/dialogs/about.cpp @@ -32,11 +32,13 @@ #include #include "../config/appconfig.h" -#include "../dsvdef.h" +#include "../basedef.h" #include "../utility/encoding.h" -#include "../ui/langresource.h" +#include "../uicore/langresource.h" -namespace pv { +using namespace dsv::config; + +namespace dsv { namespace dialogs { About::About(QWidget *parent) : @@ -84,7 +86,7 @@ About::About(QWidget *parent) : QString changlogs = tr("Changelogs
"); - QDir dir(GetAppDataDir()); + QDir dir(AppConfig::GetAppDataDir()); AppConfig &app = AppConfig::Instance(); int lan = app.frameOptions.language; @@ -127,4 +129,4 @@ About::~About() } } // namespace dialogs -} // namespace pv +} // namespace dsv diff --git a/DSView/pv/dialogs/about.h b/DSView/src/dialogs/about.h similarity index 97% rename from DSView/pv/dialogs/about.h rename to DSView/src/dialogs/about.h index a86ca1278..cfbf09ef0 100644 --- a/DSView/pv/dialogs/about.h +++ b/DSView/src/dialogs/about.h @@ -28,7 +28,7 @@ #include "dsdialog.h" -namespace pv { +namespace dsv { namespace dialogs { class About : public DSDialog @@ -41,6 +41,6 @@ class About : public DSDialog }; } // namespace dialogs -} // namespace pv +} // namespace dsv #endif // DSVIEW_PV_ABOUT_H diff --git a/DSView/pv/dialogs/applicationpardlg.cpp b/DSView/src/dialogs/applicationpardlg.cpp similarity index 97% rename from DSView/pv/dialogs/applicationpardlg.cpp rename to DSView/src/dialogs/applicationpardlg.cpp index d2cc9fe75..208ff2ae1 100644 --- a/DSView/pv/dialogs/applicationpardlg.cpp +++ b/DSView/src/dialogs/applicationpardlg.cpp @@ -31,16 +31,17 @@ #include #include #include - #include "../config/appconfig.h" -#include "../ui/langresource.h" -#include "../appcontrol.h" -#include "../sigsession.h" +#include "../uicore/langresource.h" +#include "../appcore/appcontrol.h" +#include "../appcore/sigsession.h" #include "../ui/dscombobox.h" #include "../log.h" -namespace pv -{ +using namespace dsv::appcore; +using namespace dsv::config; + +namespace dsv{ namespace dialogs { diff --git a/DSView/pv/dialogs/applicationpardlg.h b/DSView/src/dialogs/applicationpardlg.h similarity index 85% rename from DSView/pv/dialogs/applicationpardlg.h rename to DSView/src/dialogs/applicationpardlg.h index 7c0291a1a..24ff113c8 100644 --- a/DSView/pv/dialogs/applicationpardlg.h +++ b/DSView/src/dialogs/applicationpardlg.h @@ -27,21 +27,9 @@ class QComboBox; -struct FontBindInfo +namespace dsv{ +namespace dialogs { - QComboBox *name_box; - QComboBox *size_box; - QString lang_id; - char *lang_def; - QString *ptr_name; - float *ptr_size; -}; - -namespace pv -{ - namespace dialogs -{ - class ApplicationParamDlg { public: diff --git a/DSView/pv/dialogs/calibration.cpp b/DSView/src/dialogs/calibration.cpp similarity index 98% rename from DSView/pv/dialogs/calibration.cpp rename to DSView/src/dialogs/calibration.cpp index 8103be85a..238a9d945 100644 --- a/DSView/pv/dialogs/calibration.cpp +++ b/DSView/src/dialogs/calibration.cpp @@ -19,26 +19,24 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "calibration.h" - +#include "calibration.h" #include #include #include #include #include #include - #include "../view/trace.h" #include "../dialogs/dsmessagebox.h" -#include "../dsvdef.h" -#include "../appcontrol.h" -#include "../sigsession.h" -#include "../ui/langresource.h" +#include "../basedef.h" +#include "../appcore/appcontrol.h" +#include "../appcore/sigsession.h" +#include "../uicore/langresource.h" #include "../ui/msgbox.h" using namespace std; -namespace pv { +namespace dsv { namespace dialogs { const QString Calibration::VGAIN = QT_TR_NOOP(" VGAIN"); @@ -350,4 +348,4 @@ void Calibration::on_reset() } } // namespace dialogs -} // namespace pv +} // namespace dsv diff --git a/DSView/pv/dialogs/calibration.h b/DSView/src/dialogs/calibration.h similarity index 92% rename from DSView/pv/dialogs/calibration.h rename to DSView/src/dialogs/calibration.h index 4bbdbf46f..5e665ffb2 100644 --- a/DSView/pv/dialogs/calibration.h +++ b/DSView/src/dialogs/calibration.h @@ -33,10 +33,15 @@ #include "../toolbars/titlebar.h" #include "dsdialog.h" -class DeviceAgent; - -namespace pv { - +namespace dsv{ + namespace appcore{ + class SigSession; + class DeviceAgent; + } +} +using namespace dsv::appcore; + +namespace dsv { namespace dialogs { class Calibration : public DSDialog @@ -82,6 +87,6 @@ private slots: }; } // namespace dialogs -} // namespace pv +} // namespace dsv #endif // DSVIEW_PV_CALIBRATION_H diff --git a/DSView/pv/dialogs/decoderoptionsdlg.cpp b/DSView/src/dialogs/decoderoptionsdlg.cpp similarity index 96% rename from DSView/pv/dialogs/decoderoptionsdlg.cpp rename to DSView/src/dialogs/decoderoptionsdlg.cpp index 127a8a298..00a90cf07 100644 --- a/DSView/pv/dialogs/decoderoptionsdlg.cpp +++ b/DSView/src/dialogs/decoderoptionsdlg.cpp @@ -33,26 +33,25 @@ #include #include #include - #include "../data/decoderstack.h" #include "../prop/binding/decoderoptions.h" -#include "../data/decode/decoder.h" +#include "../decode/decoder.h" #include "../ui/dscombobox.h" #include "../view/logicsignal.h" -#include "../appcontrol.h" -#include "../sigsession.h" +#include "../appcore/appcontrol.h" +#include "../appcore/sigsession.h" #include "../view/view.h" #include "../view/cursor.h" #include "../widgets/decodergroupbox.h" #include "../view/decodetrace.h" #include "../ui/msgbox.h" - -#include "../ui/langresource.h" +#include "../uicore/langresource.h" #include "../config/appconfig.h" -namespace pv { -namespace dialogs { +using namespace dsv::config; +namespace dsv { +namespace dialogs { DecoderOptionsDlg::DecoderOptionsDlg(QWidget *parent) :DSDialog(parent) @@ -207,7 +206,7 @@ void DecoderOptionsDlg::load_options_view() confirm_button_box->addWidget(button_box, 0, Qt::AlignRight); form->addRow(confirm_button_box); - this->update_font(); + this->UpdateFont(); int real_content_width = _content_width; int content_height = _contentHeight; @@ -262,8 +261,7 @@ void DecoderOptionsDlg::load_options_view() } void DecoderOptionsDlg::load_decoder_forms(QWidget *container) -{ - using pv::data::decode::Decoder; +{ assert(container); int dex = 0; @@ -285,14 +283,14 @@ void DecoderOptionsDlg::load_decoder_forms(QWidget *container) DsComboBox* DecoderOptionsDlg::create_probe_selector( - QWidget *parent, const data::decode::Decoder *dec, + QWidget *parent, const Decoder *dec, const srd_channel *const pdch) { assert(dec); const auto &sigs = AppControl::Instance()->GetSession()->get_signals(); - data::decode::Decoder *_dec = const_cast(dec); + auto _dec = const_cast(dec); auto probe_iter = _dec->channels().find(pdch); DsComboBox *selector = new DsComboBox(parent); selector->addItem("-", QVariant::fromValue(-1)); @@ -383,7 +381,7 @@ void DecoderOptionsDlg::update_decode_range() void DecoderOptionsDlg::create_decoder_form( - data::decode::Decoder *dec, QWidget *parent, + Decoder *dec, QWidget *parent, QFormLayout *form) { const GSList *l; @@ -472,7 +470,7 @@ void DecoderOptionsDlg::create_decoder_form( binding->add_properties_to_form(decoder_form, true, font); _bindings.push_back(binding); - auto group = new pv::widgets::DecoderGroupBox(_trace->decoder(), + auto group = new dsv::widgets::DecoderGroupBox(_trace->decoder(), dec, decoder_form, parent, font); @@ -496,7 +494,7 @@ void DecoderOptionsDlg::on_probe_selected(int) commit_probes(); } -void DecoderOptionsDlg::commit_decoder_probes(data::decode::Decoder *dec) +void DecoderOptionsDlg::commit_decoder_probes(decode::Decoder *dec) { assert(dec); diff --git a/DSView/pv/dialogs/decoderoptionsdlg.h b/DSView/src/dialogs/decoderoptionsdlg.h similarity index 85% rename from DSView/pv/dialogs/decoderoptionsdlg.h rename to DSView/src/dialogs/decoderoptionsdlg.h index f1632e578..54944ed7c 100644 --- a/DSView/pv/dialogs/decoderoptionsdlg.h +++ b/DSView/src/dialogs/decoderoptionsdlg.h @@ -35,13 +35,12 @@ struct srd_channel; #include "dsdialog.h" -namespace pv { +namespace dsv{ namespace data{ - class DecoderStack; - - namespace decode{ - class Decoder; - } + class DecoderStack; + } + namespace decode{ + class Decoder; } namespace prop{ namespace binding{ @@ -53,10 +52,14 @@ namespace pv { class Cursor; class DecodeTrace; } +} +using namespace dsv::data; +using namespace dsv::decode; +using namespace dsv::view; +namespace dsv { namespace dialogs { - class DecoderOptionsDlg: public DSDialog { Q_OBJECT @@ -65,7 +68,7 @@ class DecoderOptionsDlg: public DSDialog struct ProbeSelector { const DsComboBox *_combo; - const pv::data::decode::Decoder *_decoder; + const Decoder *_decoder; const srd_channel *_pdch; }; @@ -85,7 +88,7 @@ class DecoderOptionsDlg: public DSDialog cursor2 = _cursor2; } - void load_options(view::DecodeTrace *trace); + void load_options(DecodeTrace *trace); inline bool is_reload_form(){ return _is_reload_form; @@ -96,14 +99,14 @@ class DecoderOptionsDlg: public DSDialog void load_decoder_forms(QWidget *container); - DsComboBox* create_probe_selector(QWidget *parent, const data::decode::Decoder *dec, + DsComboBox* create_probe_selector(QWidget *parent, const Decoder *dec, const srd_channel *const pdch); - void create_decoder_form(pv::data::decode::Decoder *dec, + void create_decoder_form(Decoder *dec, QWidget *parent, QFormLayout *form); void commit_probes(); - void commit_decoder_probes(data::decode::Decoder *dec); + void commit_decoder_probes(Decoder *dec); void update_decode_range(); private slots: @@ -116,7 +119,7 @@ private slots: std::vector _bindings; DsComboBox *_start_comboBox; DsComboBox *_end_comboBox; - view::DecodeTrace *_trace; + DecodeTrace *_trace; uint64_t _cursor1; //cursor key uint64_t _cursor2; int _contentHeight; diff --git a/DSView/pv/dialogs/deviceoptions.cpp b/DSView/src/dialogs/deviceoptions.cpp similarity index 98% rename from DSView/pv/dialogs/deviceoptions.cpp rename to DSView/src/dialogs/deviceoptions.cpp index 6277338de..5abd51b01 100644 --- a/DSView/pv/dialogs/deviceoptions.cpp +++ b/DSView/src/dialogs/deviceoptions.cpp @@ -20,8 +20,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "deviceoptions.h" - +#include "deviceoptions.h" #include #include #include @@ -30,19 +29,19 @@ #include #include #include - #include "dsmessagebox.h" #include "../prop/property.h" -#include "../dsvdef.h" +#include "../basedef.h" #include "../config/appconfig.h" -#include "../appcontrol.h" -#include "../sigsession.h" -#include "../ui/langresource.h" +#include "../appcore/appcontrol.h" +#include "../appcore/sigsession.h" +#include "../uicore/langresource.h" #include "../log.h" #include "../ui/msgbox.h" using namespace boost; using namespace std; +using namespace dsv::config; //--------------------------ChannelLabel @@ -84,7 +83,7 @@ void ChannelLabel::on_checked() //--------------------------DeviceOptions -namespace pv { +namespace dsv{ namespace dialogs { DeviceOptions::DeviceOptions(QWidget *parent) : @@ -399,7 +398,7 @@ void DeviceOptions::logic_probes(QVBoxLayout &layout) enable_all_probes->setMaximumWidth(bt_width); disable_all_probes->setMaximumWidth(bt_width); - this->update_font(); + this->UpdateFont(); contentHeight += enable_all_probes->sizeHint().height(); contentHeight += channel_line_height * row2 + 50; @@ -689,7 +688,7 @@ void DeviceOptions::analog_probes(QGridLayout &layout) probe_layout->addWidget(en_label, 0, 0, 1, 1); probe_layout->addWidget(probe_checkBox, 0, 1, 1, 3); - auto *probe_options_binding = new pv::prop::binding::ProbeOptions(probe); + auto *probe_options_binding = new dsv::prop::binding::ProbeOptions(probe); const auto &properties = probe_options_binding->properties(); int i = 1; @@ -735,7 +734,7 @@ void DeviceOptions::analog_probes(QGridLayout &layout) layout.addWidget(tabWidget, 0, 0, 1, 1); - this->update_font(); + this->UpdateFont(); _groupHeight2 = tabWidget->sizeHint().height() + 10; _dynamic_panel->setFixedHeight(_groupHeight2); @@ -837,7 +836,7 @@ void DeviceOptions::build_dynamic_panel() int bb = 0; void DeviceOptions::try_resize_scroll() { - this->update_font(); + this->UpdateFont(); // content area height int contentHeight = _groupHeight1 + _groupHeight2 + 20; // +space @@ -892,4 +891,4 @@ void DeviceOptions::try_resize_scroll() } } // namespace dialogs -} // namespace pv +} // namespace dsv diff --git a/DSView/pv/dialogs/deviceoptions.h b/DSView/src/dialogs/deviceoptions.h similarity index 92% rename from DSView/pv/dialogs/deviceoptions.h rename to DSView/src/dialogs/deviceoptions.h index 202fae814..9338c9903 100644 --- a/DSView/pv/dialogs/deviceoptions.h +++ b/DSView/src/dialogs/deviceoptions.h @@ -46,6 +46,14 @@ class QScrollArea; +namespace dsv{ + namespace appcore{ + class SigSession; + class DeviceAgent; + } +} +using namespace dsv::appcore; + class IChannelCheck { public: @@ -78,10 +86,7 @@ struct ChannelModePair int value; }; -class DeviceAgent; - -namespace pv { - +namespace dsv { namespace dialogs { class DeviceOptions : public DSDialog, public IChannelCheck @@ -145,13 +150,13 @@ private slots: int _cur_analog_tag_index; QString _demo_operation_mode; - pv::prop::binding::DeviceOptions _device_options_binding; - std::vector _probe_options_binding_list; + dsv::prop::binding::DeviceOptions _device_options_binding; + std::vector _probe_options_binding_list; std::vector _channel_mode_indexs; std::vector _dso_channel_list; }; } // namespace dialogs -} // namespace pv +} // namespace dsv #endif // DSVIEW_PV_DEVICEOPTIONS_H diff --git a/DSView/pv/dialogs/dsdialog.cpp b/DSView/src/dialogs/dsdialog.cpp similarity index 96% rename from DSView/pv/dialogs/dsdialog.cpp rename to DSView/src/dialogs/dsdialog.cpp index 4a410e3e5..98d7a7c0f 100644 --- a/DSView/pv/dialogs/dsdialog.cpp +++ b/DSView/src/dialogs/dsdialog.cpp @@ -21,18 +21,19 @@ #include "dsdialog.h" -#include "shadow.h" - #include #include #include #include #include -#include "../dsvdef.h" +#include "shadow.h" +#include "../basedef.h" #include "../config/appconfig.h" #include "../ui/fn.h" -namespace pv { +using namespace dsv::config; + +namespace dsv { namespace dialogs { DSDialog::DSDialog() : @@ -128,7 +129,7 @@ int DSDialog::exec() connect(_base_button, SIGNAL(accepted()), this, SLOT(accept())); } - update_font(); + UpdateFont(); return QDialog::exec(); } @@ -174,23 +175,23 @@ void DSDialog::build_base(bool hasClose) _main_layout->setContentsMargins(10,5,10,10); } -void DSDialog::update_font() +void DSDialog::UpdateFont() { QFont font = this->font(); font.setPointSizeF(AppConfig::Instance().appOptions.fontSize); ui::set_form_font(this, font); if (_titlebar != NULL){ - _titlebar->update_font(); + _titlebar->UpdateFont(); } } void DSDialog::show() { - update_font(); + UpdateFont(); QWidget::show(); } } // namespace dialogs -} // namespace pv +} // namespace dsv diff --git a/DSView/pv/dialogs/dsdialog.h b/DSView/src/dialogs/dsdialog.h similarity index 96% rename from DSView/pv/dialogs/dsdialog.h rename to DSView/src/dialogs/dsdialog.h index af94c8d6b..5dc74ab02 100644 --- a/DSView/pv/dialogs/dsdialog.h +++ b/DSView/src/dialogs/dsdialog.h @@ -27,14 +27,14 @@ #include #include #include - #include "../toolbars/titlebar.h" #include "../interface/icallbacks.h" +#include "../uicore/uitypes.h" class QDialogButtonBox; -namespace pv { +namespace dsv { namespace dialogs { class Shadow; @@ -68,7 +68,7 @@ class DSDialog : public QDialog, IFontForm void SetTitleSpace(int h); //IFontForm - void update_font() override; + void UpdateFont() override; void show(); @@ -96,6 +96,6 @@ class DSDialog : public QDialog, IFontForm }; } // namespace dialogs -} // namespace pv +} // namespace dsv #endif // DSVIEW_PV_DSDIALOG_H diff --git a/DSView/pv/dialogs/dsmessagebox.cpp b/DSView/src/dialogs/dsmessagebox.cpp similarity index 95% rename from DSView/pv/dialogs/dsmessagebox.cpp rename to DSView/src/dialogs/dsmessagebox.cpp index 05e0f3f96..fdf74bfef 100644 --- a/DSView/pv/dialogs/dsmessagebox.cpp +++ b/DSView/src/dialogs/dsmessagebox.cpp @@ -21,19 +21,20 @@ #include "dsmessagebox.h" -#include "shadow.h" - #include #include #include #include #include -#include "../dsvdef.h" -#include "../ui/langresource.h" +#include "shadow.h" +#include "../basedef.h" +#include "../uicore/langresource.h" #include "../config/appconfig.h" #include "../ui/fn.h" -namespace pv { +using namespace dsv::config; + +namespace dsv { namespace dialogs { DSMessageBox::DSMessageBox(QWidget *parent,const QString title) : @@ -135,11 +136,11 @@ int DSMessageBox::exec() ui::set_form_font(this, font); if (_titlebar != NULL){ - _titlebar->update_font(); + _titlebar->UpdateFont(); } return QDialog::exec(); } } // namespace dialogs -} // namespace pv +} // namespace dsv diff --git a/DSView/pv/dialogs/dsmessagebox.h b/DSView/src/dialogs/dsmessagebox.h similarity index 97% rename from DSView/pv/dialogs/dsmessagebox.h rename to DSView/src/dialogs/dsmessagebox.h index 254dee386..edf042092 100644 --- a/DSView/pv/dialogs/dsmessagebox.h +++ b/DSView/src/dialogs/dsmessagebox.h @@ -27,13 +27,12 @@ #include #include #include - #include "../toolbars/titlebar.h" -namespace pv { +namespace dsv { namespace dialogs { - class Shadow; + class Shadow; class DSMessageBox : public QDialog { @@ -70,6 +69,6 @@ private slots: }; } // namespace dialogs -} // namespace pv +} // namespace dsv #endif // DSVIEW_PV_DSMESSAGEBOX_H diff --git a/DSView/pv/dialogs/dsomeasure.cpp b/DSView/src/dialogs/dsomeasure.cpp similarity index 96% rename from DSView/pv/dialogs/dsomeasure.cpp rename to DSView/src/dialogs/dsomeasure.cpp index 09f881191..003263802 100644 --- a/DSView/pv/dialogs/dsomeasure.cpp +++ b/DSView/src/dialogs/dsomeasure.cpp @@ -20,23 +20,20 @@ */ #include "dsomeasure.h" -#include "../sigsession.h" -#include "../view/view.h" - #include #include #include #include -#include - -#include "../dsvdef.h" - -#include "../ui/langresource.h" +#include +#include "../appcore/sigsession.h" +#include "../view/view.h" +#include "../basedef.h" +#include "../uicore/langresource.h" using namespace std; -using namespace pv::view; +using namespace dsv::view; -namespace pv { +namespace dsv { namespace dialogs { DsoMeasure::DsoMeasure(SigSession *session, View &parent, @@ -92,7 +89,7 @@ void DsoMeasure::add_measure(QWidget *widget, const view::DsoSignal *dsoSig) QGridLayout *layout = new QGridLayout(widget); layout->setSpacing(0); - pv::view::DsoSignal *psig = const_cast(dsoSig); + dsv::view::DsoSignal *psig = const_cast(dsoSig); for (int i=DSO_MS_BEGIN+1; i #include -#include "../sigsession.h" +#include "../appcore/sigsession.h" #include "../data/spectrumstack.h" #include "../view/trace.h" #include "../view/dsosignal.h" #include "../view/spectrumtrace.h" -#include "../dsvdef.h" +#include "../basedef.h" #include "../log.h" - -#include "../ui/langresource.h" +#include "../uicore/langresource.h" using namespace boost; using namespace std; -namespace pv { +namespace dsv { namespace dialogs { FftOptions::FftOptions(QWidget *parent, SigSession *session) : @@ -286,4 +285,4 @@ void FftOptions::len_changed(int index) } } // namespace dialogs -} // namespace pv +} // namespace dsv diff --git a/DSView/pv/dialogs/fftoptions.h b/DSView/src/dialogs/fftoptions.h similarity index 93% rename from DSView/pv/dialogs/fftoptions.h rename to DSView/src/dialogs/fftoptions.h index 9fe526b6c..0cefcd196 100644 --- a/DSView/pv/dialogs/fftoptions.h +++ b/DSView/src/dialogs/fftoptions.h @@ -28,15 +28,18 @@ #include #include #include - #include "../toolbars/titlebar.h" #include "dsdialog.h" #include "../ui/dscombobox.h" -namespace pv { - -class SigSession; +namespace dsv{ + namespace appcore{ + class SigSession; + } +} +using namespace dsv::appcore; +namespace dsv { namespace dialogs { class FftOptions : public DSDialog @@ -80,6 +83,6 @@ private slots: }; } // namespace dialogs -} // namespace pv +} // namespace dsv #endif // DSVIEW_PV_FFTOPTIONS_H diff --git a/DSView/pv/dialogs/interval.cpp b/DSView/src/dialogs/interval.cpp similarity index 97% rename from DSView/pv/dialogs/interval.cpp rename to DSView/src/dialogs/interval.cpp index f9bdec2d3..68d3d0582 100644 --- a/DSView/pv/dialogs/interval.cpp +++ b/DSView/src/dialogs/interval.cpp @@ -20,12 +20,10 @@ */ #include "interval.h" - #include +#include "../uicore/langresource.h" -#include "../ui/langresource.h" - -namespace pv { +namespace dsv { namespace dialogs { Interval::Interval(QWidget *parent) : @@ -106,4 +104,4 @@ void Interval::on_inputbox_changed(double value) } } // namespace dialogs -} // namespace pv +} // namespace dsv diff --git a/DSView/pv/dialogs/interval.h b/DSView/src/dialogs/interval.h similarity index 94% rename from DSView/pv/dialogs/interval.h rename to DSView/src/dialogs/interval.h index 825c03309..436f66ce0 100644 --- a/DSView/pv/dialogs/interval.h +++ b/DSView/src/dialogs/interval.h @@ -27,12 +27,9 @@ #include #include #include - -#include "../sigsession.h" -#include "../toolbars/titlebar.h" #include "dsdialog.h" -namespace pv { +namespace dsv { namespace dialogs { class Interval : public DSDialog @@ -68,6 +65,6 @@ private Q_SLOTS: }; } // namespace dialogs -} // namespace pv +} // namespace dsv #endif // DSVIEW_PV_INTERVAL_H diff --git a/DSView/pv/dialogs/lissajousoptions.cpp b/DSView/src/dialogs/lissajousoptions.cpp similarity index 97% rename from DSView/pv/dialogs/lissajousoptions.cpp rename to DSView/src/dialogs/lissajousoptions.cpp index 05c27184c..dbc345cc3 100644 --- a/DSView/pv/dialogs/lissajousoptions.cpp +++ b/DSView/src/dialogs/lissajousoptions.cpp @@ -20,25 +20,23 @@ */ #include "lissajousoptions.h" -#include "../sigsession.h" -#include "../view/view.h" -#include "../view/lissajoustrace.h" - #include #include #include #include #include #include - -#include "../ui/langresource.h" +#include "../appcore/sigsession.h" +#include "../view/view.h" +#include "../view/lissajoustrace.h" +#include "../uicore/langresource.h" using namespace boost; using namespace std; -using namespace pv::view; +using namespace dsv::view; -namespace pv { +namespace dsv { namespace dialogs { LissajousOptions::LissajousOptions(SigSession *session, QWidget *parent) : @@ -201,4 +199,4 @@ void LissajousOptions::reject() } } // namespace dialogs -} // namespace pv +} // namespace dsv diff --git a/DSView/pv/dialogs/lissajousoptions.h b/DSView/src/dialogs/lissajousoptions.h similarity index 96% rename from DSView/pv/dialogs/lissajousoptions.h rename to DSView/src/dialogs/lissajousoptions.h index edb6ce685..79f597b50 100644 --- a/DSView/pv/dialogs/lissajousoptions.h +++ b/DSView/src/dialogs/lissajousoptions.h @@ -31,15 +31,15 @@ #include #include #include - - #include "../view/dsosignal.h" #include "../toolbars/titlebar.h" #include "dsdialog.h" -namespace pv { +namespace dsv { -class SigSession; +namespace appcore { + class SigSession; +} namespace view { class View; @@ -80,6 +80,6 @@ class LissajousOptions : public DSDialog }; } // namespace dialogs -} // namespace pv +} // namespace dsv #endif // DSVIEW_PV_LISSAJOUSOPTIONS_H diff --git a/DSView/pv/dialogs/mathoptions.cpp b/DSView/src/dialogs/mathoptions.cpp similarity index 98% rename from DSView/pv/dialogs/mathoptions.cpp rename to DSView/src/dialogs/mathoptions.cpp index e8b29580d..2a3251b00 100644 --- a/DSView/pv/dialogs/mathoptions.cpp +++ b/DSView/src/dialogs/mathoptions.cpp @@ -20,25 +20,22 @@ */ #include "mathoptions.h" -#include "../sigsession.h" -#include "../view/view.h" -#include "../view/mathtrace.h" -#include "../data/mathstack.h" - #include #include #include #include #include - -#include "../ui/langresource.h" +#include "../appcore/sigsession.h" +#include "../view/view.h" +#include "../view/mathtrace.h" +#include "../data/mathstack.h" +#include "../uicore/langresource.h" - using namespace boost; using namespace std; -using namespace pv::view; +using namespace dsv::view; -namespace pv { +namespace dsv { namespace dialogs { MathOptions::MathOptions(SigSession *session, QWidget *parent) : @@ -229,4 +226,4 @@ void MathOptions::reject() } } // namespace dialogs -} // namespace pv +} // namespace dsv diff --git a/DSView/pv/dialogs/mathoptions.h b/DSView/src/dialogs/mathoptions.h similarity index 90% rename from DSView/pv/dialogs/mathoptions.h rename to DSView/src/dialogs/mathoptions.h index ed6aa2fbe..243ac9ad3 100644 --- a/DSView/pv/dialogs/mathoptions.h +++ b/DSView/src/dialogs/mathoptions.h @@ -37,14 +37,18 @@ #include "../toolbars/titlebar.h" #include "dsdialog.h" -namespace pv { - -class SigSession; - -namespace view { -class View; +namespace dsv{ + namespace appcore{ + class SigSession; + } + namespace view { + class View; + } } +using namespace dsv::appcore; +using namespace dsv::view; +namespace dsv { namespace dialogs { class MathOptions : public DSDialog @@ -80,6 +84,6 @@ class MathOptions : public DSDialog }; } // namespace dialogs -} // namespace pv +} // namespace dsv #endif // DSVIEW_PV_MATHOPTIONS_H diff --git a/DSView/pv/dialogs/protocolexp.cpp b/DSView/src/dialogs/protocolexp.cpp similarity index 95% rename from DSView/pv/dialogs/protocolexp.cpp rename to DSView/src/dialogs/protocolexp.cpp index 3f09b7811..844b36ad6 100644 --- a/DSView/pv/dialogs/protocolexp.cpp +++ b/DSView/src/dialogs/protocolexp.cpp @@ -20,7 +20,6 @@ */ #include "protocolexp.h" - #include #include #include @@ -30,25 +29,24 @@ #include #include #include - -#include "../sigsession.h" +#include "../appcore/sigsession.h" #include "../data/decoderstack.h" -#include "../data/decode/row.h" -#include "../data/decode/annotation.h" +#include "../decode/row.h" +#include "../decode/annotation.h" #include "../view/decodetrace.h" #include "../data/decodermodel.h" #include "../config/appconfig.h" -#include "../dsvdef.h" +#include "../basedef.h" #include "../utility/encoding.h" #include "../utility/path.h" #include "../log.h" -#include "../ui/langresource.h" +#include "../uicore/langresource.h" #define EXPORT_DEC_ROW_COUNT_MAX 20 -using namespace pv::data::decode; +using namespace dsv::config; -namespace pv { +namespace dsv { namespace dialogs { ProtocolExp::ProtocolExp(QWidget *parent, SigSession *session) : @@ -70,7 +68,7 @@ ProtocolExp::ProtocolExp(QWidget *parent, SigSession *session) : _flayout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow); _flayout->addRow(new QLabel(L_S(STR_PAGE_DLG, S_ID(IDS_DLG_EXPORT_FORMAT), "Export Format: "), this), _format_combobox); - pv::data::DecoderModel* decoder_model = _session->get_decoder_model(); + dsv::data::DecoderModel* decoder_model = _session->get_decoder_model(); const auto decoder_stack = decoder_model->getDecoderStack(); if (decoder_stack) { @@ -216,7 +214,7 @@ void ProtocolExp::save_proc() return; } - pv::data::DecoderModel *decoder_model = _session->get_decoder_model(); + dsv::data::DecoderModel *decoder_model = _session->get_decoder_model(); const auto decoder_stack = decoder_model->getDecoderStack(); int fd_row_dex = 0; @@ -319,8 +317,8 @@ void ProtocolExp::save_proc() file.close(); } -bool ProtocolExp::compare_ann_index(const data::decode::Annotation *a, - const data::decode::Annotation *b) +bool ProtocolExp::compare_ann_index(const decode::Annotation *a, + const decode::Annotation *b) { assert(a); assert(b); @@ -340,4 +338,4 @@ void ProtocolExp::cancel_export() } } // namespace dialogs -} // namespace pv +} // namespace dsv diff --git a/DSView/pv/dialogs/protocolexp.h b/DSView/src/dialogs/protocolexp.h similarity index 84% rename from DSView/pv/dialogs/protocolexp.h rename to DSView/src/dialogs/protocolexp.h index f8afc8446..9c3cd39ee 100644 --- a/DSView/pv/dialogs/protocolexp.h +++ b/DSView/src/dialogs/protocolexp.h @@ -35,19 +35,21 @@ #include "dsdialog.h" #include "../ui/dscombobox.h" -namespace pv { - -class SigSession; - -namespace data { -namespace decode { -class Row; -class Annotation; -} +namespace dsv{ + namespace appcore{ + class SigSession; + } + namespace decode { + class Row; + class Annotation; + } } +using namespace dsv::appcore; +using namespace dsv::decode; +namespace dsv { namespace dialogs { - + class ProtocolExp : public DSDialog { Q_OBJECT @@ -56,7 +58,7 @@ class ProtocolExp : public DSDialog struct ExportRowInfo { QString title; - const data::decode::Row *row; + const decode::Row *row; int row_index; uint64_t read_index; }; @@ -68,8 +70,8 @@ class ProtocolExp : public DSDialog void accept(); void reject(); void save_proc(); - static bool compare_ann_index(const data::decode::Annotation *a, - const data::decode::Annotation *b); + static bool compare_ann_index(const decode::Annotation *a, + const decode::Annotation *b); signals: void export_progress(int percent); @@ -93,6 +95,6 @@ private slots: }; } // namespace dialogs -} // namespace pv +} // namespace dsv #endif // DSVIEW_PV_PROTOCOLEXP_H diff --git a/DSView/pv/dialogs/protocollist.cpp b/DSView/src/dialogs/protocollist.cpp similarity index 92% rename from DSView/pv/dialogs/protocollist.cpp rename to DSView/src/dialogs/protocollist.cpp index 9c65f9605..4f171d179 100644 --- a/DSView/pv/dialogs/protocollist.cpp +++ b/DSView/src/dialogs/protocollist.cpp @@ -20,23 +20,19 @@ */ #include "protocollist.h" - - #include #include - -#include "../sigsession.h" +#include "../appcore/sigsession.h" #include "../data/decoderstack.h" -#include "../data/decode/row.h" +#include "../decode/row.h" #include "../view/decodetrace.h" #include "../data/decodermodel.h" - -#include "../ui/langresource.h" +#include "../uicore/langresource.h" using namespace boost; using namespace std; -namespace pv { +namespace dsv { namespace dialogs { ProtocolList::ProtocolList(QWidget *parent, SigSession *session) : @@ -45,7 +41,7 @@ ProtocolList::ProtocolList(QWidget *parent, SigSession *session) : _button_box(QDialogButtonBox::Ok, Qt::Horizontal, this) { - pv::data::DecoderModel* decoder_model = _session->get_decoder_model(); + dsv::data::DecoderModel* decoder_model = _session->get_decoder_model(); _map_zoom_combobox = new DsComboBox(this); _map_zoom_combobox->addItem(L_S(STR_PAGE_DLG, S_ID(IDS_DLG_FIT_TO_WINDOW), "Fit to Window")); @@ -129,7 +125,7 @@ void ProtocolList::set_protocol(int index) } _show_label_list.clear(); - pv::data::DecoderStack *decoder_stack = NULL; + dsv::data::DecoderStack *decoder_stack = NULL; const auto &decode_sigs = _session->get_decode_signals(); int cur_index = 0; @@ -171,7 +167,7 @@ void ProtocolList::on_row_check(bool show) QVariant id = sc->property("index"); int index = id.toInt(); - pv::data::DecoderStack *decoder_stack = NULL; + dsv::data::DecoderStack *decoder_stack = NULL; const auto &decode_sigs = _session->get_decode_signals(); int cur_index = 0; @@ -186,8 +182,8 @@ void ProtocolList::on_row_check(bool show) if (!decoder_stack) return; - std::map rows = decoder_stack->get_rows_lshow(); - for (std::map::const_iterator i = rows.begin(); + std::map rows = decoder_stack->get_rows_lshow(); + for (std::map::const_iterator i = rows.begin(); i != rows.end(); i++) { if (index-- == 0) { decoder_stack->set_rows_lshow((*i).first, show); @@ -204,4 +200,4 @@ void ProtocolList::on_row_check(bool show) } } // namespace dialogs -} // namespace pv +} // namespace dsv diff --git a/DSView/pv/dialogs/protocollist.h b/DSView/src/dialogs/protocollist.h similarity index 93% rename from DSView/pv/dialogs/protocollist.h rename to DSView/src/dialogs/protocollist.h index 1357d38fd..467199aa6 100644 --- a/DSView/pv/dialogs/protocollist.h +++ b/DSView/src/dialogs/protocollist.h @@ -28,16 +28,19 @@ #include #include #include - #include "../prop/binding/deviceoptions.h" #include "../toolbars/titlebar.h" #include "dsdialog.h" #include "../ui/dscombobox.h" -namespace pv { - -class SigSession; +namespace dsv{ + namespace appcore{ + class SigSession; + } +} +using namespace dsv::appcore; +namespace dsv { namespace dialogs { class ProtocolList : public DSDialog @@ -71,6 +74,6 @@ private slots: }; } // namespace dialogs -} // namespace pv +} // namespace dsv #endif // DSVIEW_PV_PROTOCOLLIST_H diff --git a/DSView/pv/dialogs/regionoptions.cpp b/DSView/src/dialogs/regionoptions.cpp similarity index 96% rename from DSView/pv/dialogs/regionoptions.cpp rename to DSView/src/dialogs/regionoptions.cpp index c4d2ea725..d7e67c1ab 100644 --- a/DSView/pv/dialogs/regionoptions.cpp +++ b/DSView/src/dialogs/regionoptions.cpp @@ -19,18 +19,16 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "regionoptions.h" - -#include "../sigsession.h" +#include "regionoptions.h" +#include "../appcore/sigsession.h" #include "../view/cursor.h" #include "../view/view.h" - -#include "../ui/langresource.h" +#include "../uicore/langresource.h" using namespace boost; using namespace std; -namespace pv { +namespace dsv { namespace dialogs { const QString RegionOptions::RegionStart = QT_TR_NOOP("Start"); @@ -114,4 +112,4 @@ void RegionOptions::set_region() } } // namespace dialogs -} // namespace pv +} // namespace dsv diff --git a/DSView/pv/dialogs/regionoptions.h b/DSView/src/dialogs/regionoptions.h similarity index 87% rename from DSView/pv/dialogs/regionoptions.h rename to DSView/src/dialogs/regionoptions.h index a66b2811a..6d47594c8 100644 --- a/DSView/pv/dialogs/regionoptions.h +++ b/DSView/src/dialogs/regionoptions.h @@ -26,20 +26,26 @@ #include #include #include -#include - +#include #include "../toolbars/titlebar.h" #include "dsdialog.h" #include "../ui/dscombobox.h" -namespace pv { - -class SigSession; +namespace dsv{ + namespace appcore{ + class SigSession; + } +} +using namespace dsv::appcore; -namespace view { -class View; +namespace dsv{ + namespace view{ + class View; + } } +using namespace dsv::view; +namespace dsv { namespace dialogs { class RegionOptions : public DSDialog @@ -67,6 +73,6 @@ private slots: }; } // namespace dialogs -} // namespace pv +} // namespace dsv #endif // DSVIEW_PV_REGIONOPTIONS_H diff --git a/DSView/pv/dialogs/search.cpp b/DSView/src/dialogs/search.cpp similarity index 97% rename from DSView/pv/dialogs/search.cpp rename to DSView/src/dialogs/search.cpp index 8392b0215..083e344a3 100644 --- a/DSView/pv/dialogs/search.cpp +++ b/DSView/src/dialogs/search.cpp @@ -20,15 +20,13 @@ */ #include "search.h" -#include "../view/logicsignal.h" - #include #include - -#include "../ui/langresource.h" +#include "../uicore/langresource.h" +#include "../view/logicsignal.h" +#include "../appcore/sigsession.h" - -namespace pv { +namespace dsv { namespace dialogs { Search::Search(QWidget *parent, SigSession *session, std::map pattern) : @@ -124,4 +122,4 @@ std::map Search::get_pattern() } } // namespace dialogs -} // namespace pv +} // namespace dsv diff --git a/DSView/pv/dialogs/search.h b/DSView/src/dialogs/search.h similarity index 92% rename from DSView/pv/dialogs/search.h rename to DSView/src/dialogs/search.h index ff79bfbab..17c6167c3 100644 --- a/DSView/pv/dialogs/search.h +++ b/DSView/src/dialogs/search.h @@ -28,12 +28,17 @@ #include #include #include - -#include "../sigsession.h" #include "../toolbars/titlebar.h" #include "dsdialog.h" -namespace pv { +namespace dsv{ + namespace appcore{ + class SigSession; + } +} +using namespace dsv::appcore; + +namespace dsv { namespace dialogs { class Search : public DSDialog @@ -64,6 +69,6 @@ private slots: }; } // namespace dialogs -} // namespace pv +} // namespace dsv #endif // DSVIEW_PV_SEARCH_H diff --git a/DSView/pv/dialogs/shadow.cpp b/DSView/src/dialogs/shadow.cpp similarity index 98% rename from DSView/pv/dialogs/shadow.cpp rename to DSView/src/dialogs/shadow.cpp index 0fc91ee46..ecb1704c3 100644 --- a/DSView/pv/dialogs/shadow.cpp +++ b/DSView/src/dialogs/shadow.cpp @@ -27,7 +27,7 @@ QT_BEGIN_NAMESPACE extern Q_WIDGETS_EXPORT void qt_blurImage(QPainter *p, QImage &blurImage, qreal radius, bool quality, bool alphaOnly, int transposed = 0 ); QT_END_NAMESPACE -namespace pv { +namespace dsv { namespace dialogs { Shadow::Shadow(QObject *parent) : @@ -101,4 +101,4 @@ QRectF Shadow::boundingRectFor(const QRectF& rect) const } } // namespace dialogs -} // namespace pv +} // namespace dsv diff --git a/DSView/pv/dialogs/shadow.h b/DSView/src/dialogs/shadow.h similarity index 98% rename from DSView/pv/dialogs/shadow.h rename to DSView/src/dialogs/shadow.h index e37bbbad7..50a43cc3e 100644 --- a/DSView/pv/dialogs/shadow.h +++ b/DSView/src/dialogs/shadow.h @@ -26,7 +26,7 @@ #include #include -namespace pv { +namespace dsv { namespace dialogs { class Shadow : public QGraphicsEffect @@ -54,6 +54,6 @@ class Shadow : public QGraphicsEffect }; } // namespace dialogs -} // namespace pv +} // namespace dsv #endif // DSVIEW_PV_SHADOW_H diff --git a/DSView/pv/dialogs/storeprogress.cpp b/DSView/src/dialogs/storeprogress.cpp similarity index 98% rename from DSView/pv/dialogs/storeprogress.cpp rename to DSView/src/dialogs/storeprogress.cpp index 032ad6f0d..7cd05a7a9 100644 --- a/DSView/pv/dialogs/storeprogress.cpp +++ b/DSView/src/dialogs/storeprogress.cpp @@ -21,21 +21,22 @@ */ #include "storeprogress.h" -#include "../sigsession.h" #include #include #include #include #include #include +#include "../appcore/sigsession.h" #include "../ui/msgbox.h" #include "../config/appconfig.h" #include "../interface/icallbacks.h" #include "../log.h" +#include "../uicore/langresource.h" -#include "../ui/langresource.h" +using namespace dsv::config; -namespace pv { +namespace dsv { namespace dialogs { StoreProgress::StoreProgress(SigSession *session, QWidget *parent) : diff --git a/DSView/pv/dialogs/storeprogress.h b/DSView/src/dialogs/storeprogress.h similarity index 89% rename from DSView/pv/dialogs/storeprogress.h rename to DSView/src/dialogs/storeprogress.h index a519135b8..f4c096166 100644 --- a/DSView/pv/dialogs/storeprogress.h +++ b/DSView/src/dialogs/storeprogress.h @@ -24,7 +24,7 @@ #define DSVIEW_PV_DIALOGS_SAVEPROGRESS_H #include -#include "../storesession.h" +#include "../com/storesession.h" #include "../dialogs/dsdialog.h" #include "../interface/icallbacks.h" @@ -34,10 +34,18 @@ class QGridLayout; class QPushButton; class QWidget; -namespace pv { - -class SigSession; - +namespace dsv{ + namespace appcore{ + class SigSession; + } + namespace com{ + class StoreSession; + } +} +using namespace dsv::appcore; +using namespace dsv::com; + +namespace dsv { namespace dialogs { class StoreProgress : public DSDialog @@ -74,7 +82,7 @@ private slots: void on_ck_compress(bool ck); private: - pv::StoreSession _store_session; + StoreSession _store_session; QProgressBar _progress; bool _done; bool _isExport; diff --git a/DSView/pv/dialogs/waitingdialog.cpp b/DSView/src/dialogs/waitingdialog.cpp similarity index 96% rename from DSView/pv/dialogs/waitingdialog.cpp rename to DSView/src/dialogs/waitingdialog.cpp index 836bb4be8..75c77fb7f 100644 --- a/DSView/pv/dialogs/waitingdialog.cpp +++ b/DSView/src/dialogs/waitingdialog.cpp @@ -20,25 +20,24 @@ */ #include "waitingdialog.h" - - #include #include #include #include #include #include - #include "../view/trace.h" #include "../view/dsosignal.h" #include "../config/appconfig.h" -#include "../ui/langresource.h" -#include "../appcontrol.h" +#include "../uicore/langresource.h" +#include "../appcore/appcontrol.h" +#include "../appcore/sigsession.h" using namespace boost; using namespace std; +using namespace dsv::config; -namespace pv { +namespace dsv { namespace dialogs { const QString WaitingDialog::TIPS_WAIT = "Waiting"; @@ -65,7 +64,7 @@ WaitingDialog::WaitingDialog(QWidget *parent, SigSession *session, int key) : warning_tips->setFont(font); warning_tips->setAlignment(Qt::AlignCenter); - QString iconPath = GetIconPath(); + QString iconPath = AppConfig::GetIconPath(); label = new QLabel(this); movie = new QMovie(iconPath+"/wait.gif"); label->setMovie(movie); @@ -214,4 +213,4 @@ void WaitingDialog::changeText() } } // namespace dialogs -} // namespace pv +} // namespace dsv diff --git a/DSView/pv/dialogs/waitingdialog.h b/DSView/src/dialogs/waitingdialog.h similarity index 92% rename from DSView/pv/dialogs/waitingdialog.h rename to DSView/src/dialogs/waitingdialog.h index 8bfa4b18c..ae8e42339 100644 --- a/DSView/pv/dialogs/waitingdialog.h +++ b/DSView/src/dialogs/waitingdialog.h @@ -27,15 +27,19 @@ #include #include #include - -#include "../sigsession.h" #include "../toolbars/titlebar.h" #include "dsdialog.h" -class DeviceAgent; -namespace pv { +namespace dsv{ + namespace appcore{ + class SigSession; + class DeviceAgent; + } +} +using namespace dsv::appcore; +namespace dsv { namespace dialogs { class WaitingDialog : public DSDialog @@ -81,6 +85,6 @@ private slots: }; } // namespace dialogs -} // namespace pv +} // namespace dsv #endif // DSVIEW_PV_WAITINGDIALOG_H diff --git a/DSView/pv/dock/dsotriggerdock.cpp b/DSView/src/dock/dsotriggerdock.cpp similarity index 98% rename from DSView/pv/dock/dsotriggerdock.cpp rename to DSView/src/dock/dsotriggerdock.cpp index ed4fd4781..91731190e 100644 --- a/DSView/pv/dock/dsotriggerdock.cpp +++ b/DSView/src/dock/dsotriggerdock.cpp @@ -20,9 +20,6 @@ */ #include "dsotriggerdock.h" -#include "../sigsession.h" -#include "../dialogs/dsmessagebox.h" -#include "../view/dsosignal.h" #include #include #include @@ -32,7 +29,10 @@ #include #include #include -#include "../ui/langresource.h" +#include "../appcore/sigsession.h" +#include "../dialogs/dsmessagebox.h" +#include "../view/dsosignal.h" +#include "../uicore/langresource.h" #include "../log.h" #include "../ui/msgbox.h" #include "../config/appconfig.h" @@ -40,8 +40,9 @@ using namespace boost; using namespace std; +using namespace dsv::config; -namespace pv { +namespace dsv { namespace dock { DsoTriggerDock::DsoTriggerDock(QWidget *parent, SigSession *session) : @@ -172,7 +173,7 @@ DsoTriggerDock::DsoTriggerDock(QWidget *parent, SigSession *session) : retranslateUi(); - update_font(); + UpdateFont(); } DsoTriggerDock::~DsoTriggerDock() @@ -487,7 +488,7 @@ void DsoTriggerDock::update_view() connect(_margin_slider, SIGNAL(valueChanged(int)), this, SLOT(margin_changed(int))); } -void DsoTriggerDock::update_font() +void DsoTriggerDock::UpdateFont() { QFont font = this->font(); font.setPointSizeF(AppConfig::Instance().appOptions.fontSize); @@ -497,4 +498,4 @@ void DsoTriggerDock::update_font() } } // namespace dock -} // namespace pv +} // namespace dsv diff --git a/DSView/pv/dock/dsotriggerdock.h b/DSView/src/dock/dsotriggerdock.h similarity index 93% rename from DSView/pv/dock/dsotriggerdock.h rename to DSView/src/dock/dsotriggerdock.h index 4c5c3f276..8cb31b240 100644 --- a/DSView/pv/dock/dsotriggerdock.h +++ b/DSView/src/dock/dsotriggerdock.h @@ -29,16 +29,19 @@ #include #include #include - #include - #include "../ui/dscombobox.h" #include "../interface/icallbacks.h" +#include "../uicore/uitypes.h" -namespace pv { - -class SigSession; +namespace dsv{ + namespace appcore{ + class SigSession; + } +} +using namespace dsv::appcore; +namespace dsv { namespace dock { class DsoTriggerDock : public QScrollArea, public IFontForm @@ -61,7 +64,7 @@ class DsoTriggerDock : public QScrollArea, public IFontForm bool check_trig_channel(); //IFontForm - void update_font() override; + void UpdateFont() override; signals: void set_trig_pos(int percent); @@ -111,6 +114,6 @@ private slots: }; } // namespace dock -} // namespace pv +} // namespace dsv #endif // DSVIEW_PV_DSOTRIGGERDOCK_H diff --git a/DSView/pv/dock/keywordlineedit.cpp b/DSView/src/dock/keywordlineedit.cpp similarity index 100% rename from DSView/pv/dock/keywordlineedit.cpp rename to DSView/src/dock/keywordlineedit.cpp diff --git a/DSView/pv/dock/keywordlineedit.h b/DSView/src/dock/keywordlineedit.h similarity index 100% rename from DSView/pv/dock/keywordlineedit.h rename to DSView/src/dock/keywordlineedit.h diff --git a/DSView/pv/dock/measuredock.cpp b/DSView/src/dock/measuredock.cpp similarity index 98% rename from DSView/pv/dock/measuredock.cpp rename to DSView/src/dock/measuredock.cpp index 4fa44743d..f7947eedc 100644 --- a/DSView/pv/dock/measuredock.cpp +++ b/DSView/src/dock/measuredock.cpp @@ -19,10 +19,10 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include - #include "measuredock.h" -#include "../sigsession.h" +#include +#include +#include #include "../view/cursor.h" #include "../view/view.h" #include "../view/viewport.h" @@ -34,21 +34,20 @@ #include "../dialogs/dsdialog.h" #include "../dialogs/dsmessagebox.h" #include "../config/appconfig.h" -#include "../ui/langresource.h" +#include "../uicore/langresource.h" #include "../ui/msgbox.h" -#include -#include -#include "../appcontrol.h" +#include "../appcore/appcontrol.h" +#include "../appcore/sigsession.h" #include "../ui/fn.h" #include "../log.h" using namespace boost; +using namespace dsv::config; +using namespace dsv::view; -namespace pv { +namespace dsv { namespace dock { - -using namespace pv::view; - + MeasureDock::MeasureDock(QWidget *parent, View &view, SigSession *session) : QScrollArea(parent), _session(session), @@ -151,7 +150,7 @@ MeasureDock::MeasureDock(QWidget *parent, View &view, SigSession *session) : connect(_fen_checkBox, SIGNAL(stateChanged(int)), &_view, SLOT(set_measure_en(int))); connect(&_view, SIGNAL(measure_updated()), this, SLOT(measure_updated())); - update_font(); + UpdateFont(); } MeasureDock::~MeasureDock() @@ -188,7 +187,7 @@ void MeasureDock::retranslateUi() void MeasureDock::reStyle() { - QString iconPath = GetIconPath(); + QString iconPath = AppConfig::GetIconPath(); _dist_add_btn->setIcon(QIcon(iconPath+"/add.svg")); _edge_add_btn->setIcon(QIcon(iconPath+"/add.svg")); @@ -268,7 +267,7 @@ void MeasureDock::build_dist_pannel() row_layout->setSpacing(0); row_widget->setLayout(row_layout); - QString iconPath = GetIconPath(); + QString iconPath = AppConfig::GetIconPath(); QToolButton *del_btn = new QToolButton(row_widget); del_btn->setIcon(QIcon(iconPath+"/del.svg")); del_btn->setCheckable(true); @@ -391,7 +390,7 @@ void MeasureDock::build_edge_pannel() row_layout->setSpacing(0); row_widget->setLayout(row_layout); - QString iconPath = GetIconPath(); + QString iconPath = AppConfig::GetIconPath(); QToolButton *del_btn = new QToolButton(row_widget); del_btn->setIcon(QIcon(iconPath+"/del.svg")); del_btn->setCheckable(true); @@ -749,7 +748,7 @@ void MeasureDock::goto_cursor() void MeasureDock::cursor_update() { - using namespace pv::data; + using namespace dsv::data; for(auto it = _opt_row_list.begin(); it != _opt_row_list.end(); it++) { @@ -771,7 +770,7 @@ void MeasureDock::cursor_update() int index = 1; int cursor_dex = 0; - QString iconPath = GetIconPath(); + QString iconPath = AppConfig::GetIconPath(); auto &cursor_list = _view.get_cursorList(); for(auto it = cursor_list.begin(); it != cursor_list.end(); it++) { @@ -828,7 +827,7 @@ void MeasureDock::del_cursor() _view.update(); } -void MeasureDock::update_font() +void MeasureDock::UpdateFont() { QFont font = this->font(); font.setPointSizeF(AppConfig::Instance().appOptions.fontSize); @@ -838,4 +837,4 @@ void MeasureDock::update_font() } } // namespace dock -} // namespace pv +} // namespace dsv diff --git a/DSView/pv/dock/measuredock.h b/DSView/src/dock/measuredock.h similarity index 91% rename from DSView/pv/dock/measuredock.h rename to DSView/src/dock/measuredock.h index 04442dbfe..8f936fc44 100644 --- a/DSView/pv/dock/measuredock.h +++ b/DSView/src/dock/measuredock.h @@ -38,19 +38,23 @@ #include #include #include - #include "../ui/dscombobox.h" #include "../interface/icallbacks.h" - -namespace pv { - -class SigSession; - -namespace view { - class Cursor; - class View; +#include "../uicore/uitypes.h" + +namespace dsv{ + namespace appcore{ + class SigSession; + } + namespace view { + class Cursor; + class View; + } } +using namespace dsv::appcore; +using namespace dsv::view; +namespace dsv { namespace dock { struct cursor_row_info @@ -80,7 +84,7 @@ class MeasureDock : public QScrollArea, public IFontForm static const int Max_Measure_Limits = 15; public: - MeasureDock(QWidget *parent, pv::view::View &view, SigSession *session); + MeasureDock(QWidget *parent, dsv::view::View &view, SigSession *session); ~MeasureDock(); void reload(); @@ -91,7 +95,7 @@ class MeasureDock : public QScrollArea, public IFontForm void reStyle(); //IFontForm - void update_font() override; + void UpdateFont() override; void build_dist_pannel(); void build_edge_pannel(); @@ -159,6 +163,6 @@ public slots: }; } // namespace dock -} // namespace pv +} // namespace dsv #endif // DSVIEW_PV_MEASUREDOCK_H diff --git a/DSView/pv/dock/protocoldock.cpp b/DSView/src/dock/protocoldock.cpp similarity index 94% rename from DSView/pv/dock/protocoldock.cpp rename to DSView/src/dock/protocoldock.cpp index eeb58903c..819d52bb1 100644 --- a/DSView/pv/dock/protocoldock.cpp +++ b/DSView/src/dock/protocoldock.cpp @@ -20,14 +20,6 @@ */ #include "protocoldock.h" -#include "../sigsession.h" -#include "../view/decodetrace.h" -#include "../data/decodermodel.h" -#include "../data/decoderstack.h" -#include "../dialogs/protocollist.h" -#include "../dialogs/protocolexp.h" -#include "../view/view.h" - #include #include #include @@ -47,19 +39,29 @@ #include #include #include +#include "../appcore/sigsession.h" +#include "../view/decodetrace.h" +#include "../data/decodermodel.h" +#include "../data/decoderstack.h" +#include "../dialogs/protocollist.h" +#include "../dialogs/protocolexp.h" +#include "../view/view.h" #include "../ui/msgbox.h" -#include "../dsvdef.h" +#include "../basedef.h" #include "../config/appconfig.h" -#include "../data/decode/decoderstatus.h" -#include "../data/decode/decoder.h" +#include "../decode/decoderstatus.h" +#include "../decode/decoder.h" #include "../log.h" -#include "../ui/langresource.h" -#include "../appcontrol.h" +#include "../uicore/langresource.h" +#include "../appcore/appcontrol.h" #include "../ui/fn.h" +#include "../decode/displaydataformat.h" using namespace std; +using namespace dsv::config; +using namespace dsv::decode; -namespace pv { +namespace dsv { namespace dock { ProtocolDock::ProtocolDock(QWidget *parent, view::View &view, SigSession *session) : @@ -224,7 +226,7 @@ ProtocolDock::ProtocolDock(QWidget *parent, view::View &view, SigSession *sessio connect(_pro_search_button, SIGNAL(clicked()), this, SLOT(show_protocol_select())); - update_font(); + UpdateFont(); } ProtocolDock::~ProtocolDock() @@ -249,7 +251,7 @@ void ProtocolDock::retranslateUi() void ProtocolDock::reStyle() { - QString iconPath = GetIconPath(); + QString iconPath = AppConfig::GetIconPath(); if (_pro_add_button == NULL) { @@ -317,7 +319,7 @@ void ProtocolDock::on_add_protocol() //check the base protocol srd_decoder *const dec = (srd_decoder *)(_decoderInfoList[dex]->_data_handle); QString pro_id(dec->id); - std::list sub_decoders; + std::list sub_decoders; assert(dec->inputs); @@ -328,7 +330,7 @@ void ProtocolDock::on_add_protocol() pro_id = ""; //reset base protocol int base_dex = get_output_protocol_by_id(input_id); - sub_decoders.push_front(new data::decode::Decoder(dec)); + sub_decoders.push_front(new decode::Decoder(dec)); while (base_dex != -1) { @@ -344,7 +346,7 @@ void ProtocolDock::on_add_protocol() break; } - sub_decoders.push_front(new data::decode::Decoder(base_dec)); + sub_decoders.push_front(new decode::Decoder(base_dec)); pro_id = ""; //reset base protocol base_dex = get_output_protocol_by_id(input_id); } @@ -365,7 +367,7 @@ void ProtocolDock::on_add_protocol() add_protocol_by_id(pro_id, false, sub_decoders); } -bool ProtocolDock::add_protocol_by_id(QString id, bool silent, std::list &sub_decoders) +bool ProtocolDock::add_protocol_by_id(QString id, bool silent, std::list &sub_decoders) { if (_session->get_device()->get_work_mode() != LOGIC) { dsv_info("Protocol Analyzer\nProtocol Analyzer is only valid in Digital Mode!"); @@ -380,7 +382,7 @@ bool ProtocolDock::add_protocol_by_id(QString id, bool silent, std::list_data_handle); DecoderStatus *dstatus = new DecoderStatus(); - dstatus->m_format = (int)DecoderDataFormat::hex; + dstatus->m_format = (int)DisplayDataFormat::hex; QString protocolName(decoder->name); QString protocolId(decoder->id); @@ -392,7 +394,7 @@ bool ProtocolDock::add_protocol_by_id(QString id, bool silent, std::listdecoder()->id); } - pv::view::Trace *trace = NULL; + dsv::view::Trace *trace = NULL; if (_session->add_decoder(decoder, silent, dstatus, sub_decoders, trace) == false){ return false; @@ -411,7 +413,7 @@ bool ProtocolDock::add_protocol_by_id(QString id, bool silent, std::listSetProtocolFormat(fmt.c_str()); - dstatus->m_format = DecoderDataFormat::Parse(fmt.c_str()); + dstatus->m_format = DisplayDataFormat::Parse(fmt.c_str()); } // progress connection @@ -484,7 +486,7 @@ void ProtocolDock::decoded_progress(int progress) void ProtocolDock::set_model() { - pv::dialogs::ProtocolList *protocollist_dlg = new pv::dialogs::ProtocolList(this, _session); + dsv::dialogs::ProtocolList *protocollist_dlg = new dsv::dialogs::ProtocolList(this, _session); protocollist_dlg->exec(); resize_table_view(_session->get_decoder_model()); _model_proxy.setSourceModel(_session->get_decoder_model()); @@ -500,7 +502,7 @@ void ProtocolDock::set_model() void ProtocolDock::update_model() { - pv::data::DecoderModel *decoder_model = _session->get_decoder_model(); + dsv::data::DecoderModel *decoder_model = _session->get_decoder_model(); const auto &decode_sigs = _session->get_decode_signals(); if (decode_sigs.size() == 0) @@ -543,11 +545,11 @@ void ProtocolDock::resize_table_view(data::DecoderModel* decoder_model) void ProtocolDock::item_clicked(const QModelIndex &index) { - pv::data::DecoderModel *decoder_model = _session->get_decoder_model(); + dsv::data::DecoderModel *decoder_model = _session->get_decoder_model(); auto decoder_stack = decoder_model->getDecoderStack(); if (decoder_stack) { - pv::data::decode::Annotation ann; + dsv::decode::Annotation ann; if (decoder_stack->list_annotation(ann, index.column(), index.row())) { const auto &decode_sigs = _session->get_decode_signals(); @@ -603,7 +605,7 @@ void ProtocolDock::column_resize(int index, int old_size, int new_size) (void)index; (void)old_size; (void)new_size; - pv::data::DecoderModel *decoder_model = _session->get_decoder_model(); + dsv::data::DecoderModel *decoder_model = _session->get_decoder_model(); if (decoder_model->getDecoderStack()) { int top_row = _table_view->rowAt(0); int bom_row = _table_view->rowAt(_table_view->height()); @@ -616,21 +618,21 @@ void ProtocolDock::column_resize(int index, int old_size, int new_size) void ProtocolDock::export_table_view() { - pv::dialogs::ProtocolExp *protocolexp_dlg = new pv::dialogs::ProtocolExp(this, _session); + dsv::dialogs::ProtocolExp *protocolexp_dlg = new dsv::dialogs::ProtocolExp(this, _session); protocolexp_dlg->exec(); } void ProtocolDock::nav_table_view() { uint64_t row_index = 0; - pv::data::DecoderModel *decoder_model = _session->get_decoder_model(); + dsv::data::DecoderModel *decoder_model = _session->get_decoder_model(); auto decoder_stack = decoder_model->getDecoderStack(); if (decoder_stack) { uint64_t offset = _view.offset() * (decoder_stack->samplerate() * _view.scale()); - std::map rows = decoder_stack->get_rows_lshow(); + std::map rows = decoder_stack->get_rows_lshow(); int column = _model_proxy.filterKeyColumn(); - for (std::map::const_iterator i = rows.begin(); + for (std::map::const_iterator i = rows.begin(); i != rows.end(); i++) { if ((*i).second && column-- == 0) { row_index = decoder_stack->get_annotation_index((*i).first, offset); @@ -642,7 +644,7 @@ void ProtocolDock::nav_table_view() _table_view->scrollTo(index); _table_view->setCurrentIndex(index); - pv::data::decode::Annotation ann; + dsv::decode::Annotation ann; decoder_stack->list_annotation(ann, index.column(), index.row()); const auto &decode_sigs = _session->get_decode_signals(); @@ -671,7 +673,7 @@ void ProtocolDock::search_pre() int i = 0; uint64_t rowCount = _model_proxy.rowCount(); QModelIndex matchingIndex; - pv::data::DecoderModel *decoder_model = _session->get_decoder_model(); + dsv::data::DecoderModel *decoder_model = _session->get_decoder_model(); auto decoder_stack = decoder_model->getDecoderStack(); do { @@ -685,7 +687,7 @@ void ProtocolDock::search_pre() i = 1; uint64_t row = matchingIndex.row() + 1; uint64_t col = matchingIndex.column(); - pv::data::decode::Annotation ann; + dsv::decode::Annotation ann; bool ann_valid; while(i < _str_list.size()) { QString nxt = _str_list.at(i); @@ -731,7 +733,7 @@ void ProtocolDock::search_nxt() int i = 0; uint64_t rowCount = _model_proxy.rowCount(); QModelIndex matchingIndex; - pv::data::DecoderModel *decoder_model = _session->get_decoder_model(); + dsv::data::DecoderModel *decoder_model = _session->get_decoder_model(); auto decoder_stack = decoder_model->getDecoderStack(); if (decoder_stack == NULL){ @@ -752,7 +754,7 @@ void ProtocolDock::search_nxt() i = 1; uint64_t row = matchingIndex.row() + 1; uint64_t col = matchingIndex.column(); - pv::data::decode::Annotation ann; + dsv::decode::Annotation ann; bool ann_valid; while(i < _str_list.size()) { @@ -807,7 +809,7 @@ void ProtocolDock::search_update() if (!_search_edited) return; - pv::data::DecoderModel *decoder_model = _session->get_decoder_model(); + dsv::data::DecoderModel *decoder_model = _session->get_decoder_model(); auto decoder_stack = decoder_model->getDecoderStack(); if (!decoder_stack) @@ -880,7 +882,7 @@ void ProtocolDock::OnProtocolFormatChanged(QString format, void *handle){ if (lay->m_decoderStatus != NULL) { - lay->m_decoderStatus->m_format = DecoderDataFormat::Parse(format.toStdString().c_str()); + lay->m_decoderStatus->m_format = DisplayDataFormat::Parse(format.toStdString().c_str()); protocol_updated(); } @@ -1039,7 +1041,7 @@ bool ProtocolDock::protocol_sort_callback(const DecoderInfoItem *o1, const Decod } } - void ProtocolDock::update_font() + void ProtocolDock::UpdateFont() { QFont font = this->font(); font.setPointSizeF(AppConfig::Instance().appOptions.fontSize); @@ -1047,7 +1049,7 @@ bool ProtocolDock::protocol_sort_callback(const DecoderInfoItem *o1, const Decod _table_view->setFont(font); for(auto lay : _protocol_lay_items){ - lay->update_font(); + lay->UpdateFont(); } font.setPointSizeF(font.pointSizeF() + 1); @@ -1056,4 +1058,4 @@ bool ProtocolDock::protocol_sort_callback(const DecoderInfoItem *o1, const Decod } } // namespace dock -} // namespace pv +} // namespace dsv diff --git a/DSView/pv/dock/protocoldock.h b/DSView/src/dock/protocoldock.h similarity index 90% rename from DSView/pv/dock/protocoldock.h rename to DSView/src/dock/protocoldock.h index adbaa233e..f3407157b 100644 --- a/DSView/pv/dock/protocoldock.h +++ b/DSView/src/dock/protocoldock.h @@ -36,38 +36,42 @@ #include #include #include - #include #include #include - #include "../data/decodermodel.h" #include "protocolitemlayer.h" #include "keywordlineedit.h" #include "searchcombobox.h" #include "../interface/icallbacks.h" +#include "../uicore/uitypes.h" -struct DecoderInfoItem{ - void *_data_handle; //srd_decoder* type -}; - -namespace pv { - -class SigSession; - -namespace data { - class DecoderModel; +namespace dsv{ + namespace appcore{ + class SigSession; + } namespace decode{ class Decoder; } + namespace data { + class DecoderModel; + } + namespace view { + class View; + } } +using namespace dsv::appcore; +using namespace dsv::decode; +using namespace dsv::data; +using namespace dsv::view; -namespace view { -class View; -} - +namespace dsv { namespace dock { - + +struct DecoderInfoItem{ + void *_data_handle; //srd_decoder* type +}; + class ProtocolDock : public QScrollArea, public IProtocolItemLayerCallback, public IKeywordActive, @@ -85,7 +89,7 @@ public IFontForm ~ProtocolDock(); void del_all_protocol(); - bool add_protocol_by_id(QString id, bool silent, std::list &sub_decoders); + bool add_protocol_by_id(QString id, bool silent, std::list &sub_decoders); void reset_view(); void update_view_status(); @@ -117,7 +121,7 @@ public IFontForm void update_deocder_item_name(void *trace_handel, const char *name) override; //IFontForm - void update_font() override; + void UpdateFont() override; signals: void protocol_updated(); @@ -176,6 +180,6 @@ private slots: }; } // namespace dock -} // namespace pv +} // namespace dsv #endif // DSVIEW_PV_PROTOCOLDOCK_H diff --git a/DSView/pv/dock/protocolitemlayer.cpp b/DSView/src/dock/protocolitemlayer.cpp similarity index 93% rename from DSView/pv/dock/protocolitemlayer.cpp rename to DSView/src/dock/protocolitemlayer.cpp index c347ad313..8bb02e946 100644 --- a/DSView/pv/dock/protocolitemlayer.cpp +++ b/DSView/src/dock/protocolitemlayer.cpp @@ -20,11 +20,15 @@ */ #include "protocolitemlayer.h" -#include "../dsvdef.h" +#include "../basedef.h" #include #include "../config/appconfig.h" +#include "../decode/displaydataformat.h" +#include "../uicore/uitypes.h" + +using namespace dsv::config; -namespace pv { +namespace dsv { namespace dock { ProtocolItemLayer::ProtocolItemLayer(QWidget *parent, QString protocolName, IProtocolItemLayerCallback *callback) @@ -44,7 +48,7 @@ ProtocolItemLayer::ProtocolItemLayer(QWidget *parent, QString protocolName, IPro _del_button = new QPushButton(parent); _format_combox = new DsComboBox(parent); - QString iconPath = GetIconPath(); + QString iconPath = AppConfig::GetIconPath(); _del_button->setFlat(true); _del_button->setIcon(QIcon(iconPath + "/del.svg")); _set_button->setFlat(true); @@ -70,7 +74,7 @@ ProtocolItemLayer::ProtocolItemLayer(QWidget *parent, QString protocolName, IPro connect(_set_button, SIGNAL(clicked()),this, SLOT(on_set_protocol())); connect(_format_combox, SIGNAL(currentIndexChanged(int)),this, SLOT(on_format_select_changed(int))); - update_font(); + UpdateFont(); } ProtocolItemLayer::~ProtocolItemLayer(){ @@ -115,7 +119,7 @@ void ProtocolItemLayer::on_format_select_changed(int index){ } void ProtocolItemLayer::ResetStyle(){ - QString iconPath = GetIconPath(); + QString iconPath = AppConfig::GetIconPath(); _del_button->setIcon(QIcon(iconPath + "/del.svg")); _set_button->setIcon(QIcon(iconPath + "/gear.svg")); } @@ -147,7 +151,7 @@ void ProtocolItemLayer::LoadFormatSelect(bool bSingle) assert(format); m_bSetting = true; - int dex = DecoderDataFormat::Parse(format); + int dex = DisplayDataFormat::Parse(format); if (dex < (int)_format_combox->count()){ _format_combox->setCurrentIndex(dex); } @@ -164,7 +168,7 @@ void ProtocolItemLayer::LoadFormatSelect(bool bSingle) _protocol_label->setText(name); } - void ProtocolItemLayer::update_font() + void ProtocolItemLayer::UpdateFont() { QFont font = _protocol_label->font(); font.setPointSizeF(AppConfig::Instance().appOptions.fontSize); diff --git a/DSView/pv/dock/protocolitemlayer.h b/DSView/src/dock/protocolitemlayer.h similarity index 91% rename from DSView/pv/dock/protocolitemlayer.h rename to DSView/src/dock/protocolitemlayer.h index 38de97a6f..1d2954c0f 100644 --- a/DSView/pv/dock/protocolitemlayer.h +++ b/DSView/src/dock/protocolitemlayer.h @@ -27,14 +27,18 @@ #include #include "../ui/dscombobox.h" -class DecoderStatus; - -namespace pv{ - -namespace view{ - class Trace; +namespace dsv{ + namespace decode{ + class DecoderStatus; + } + namespace view{ + class Trace; + } } +using namespace dsv::decode; +using namespace dsv::view; +namespace dsv{ namespace dock{ class IProtocolItemLayerCallback @@ -67,7 +71,7 @@ class ProtocolItemLayer: public QHBoxLayout void set_label_name(QString name); - void update_font(); + void UpdateFont(); private slots: void on_set_protocol(); @@ -77,7 +81,7 @@ private slots: public: DecoderStatus *m_decoderStatus; //DecoderStatus QString m_protocolId; - pv::view::Trace *_trace; + dsv::view::Trace *_trace; private: QLabel *_protocol_label; diff --git a/DSView/pv/dock/searchcombobox.cpp b/DSView/src/dock/searchcombobox.cpp similarity index 98% rename from DSView/pv/dock/searchcombobox.cpp rename to DSView/src/dock/searchcombobox.cpp index 5aa7fb38d..050caa344 100644 --- a/DSView/pv/dock/searchcombobox.cpp +++ b/DSView/src/dock/searchcombobox.cpp @@ -26,9 +26,12 @@ #include #include #include "../config/appconfig.h" -#include "../appcontrol.h" +#include "../appcore/appcontrol.h" #include "../ui/fn.h" +using namespace dsv::appcore; +using namespace dsv::config; + //----------------------ComboButtonItem ComboButtonItem::ComboButtonItem(QWidget *parent, ISearchItemClick *click, void *data_handle) diff --git a/DSView/pv/dock/searchcombobox.h b/DSView/src/dock/searchcombobox.h similarity index 100% rename from DSView/pv/dock/searchcombobox.h rename to DSView/src/dock/searchcombobox.h diff --git a/DSView/pv/dock/searchdock.cpp b/DSView/src/dock/searchdock.cpp similarity index 96% rename from DSView/pv/dock/searchdock.cpp rename to DSView/src/dock/searchdock.cpp index a5cd1c15f..8e2b3680f 100644 --- a/DSView/pv/dock/searchdock.cpp +++ b/DSView/src/dock/searchdock.cpp @@ -20,16 +20,6 @@ */ #include "searchdock.h" -#include "../sigsession.h" -#include "../view/cursor.h" -#include "../view/view.h" -#include "../view/timemarker.h" -#include "../view/ruler.h" -#include "../dialogs/search.h" -#include "../data/snapshot.h" -#include "../data/logicsnapshot.h" -#include "../dialogs/dsmessagebox.h" - #include #include #include @@ -38,17 +28,28 @@ #include #include #include +#include "../appcore/sigsession.h" +#include "../view/cursor.h" +#include "../view/view.h" +#include "../view/timemarker.h" +#include "../view/ruler.h" +#include "../dialogs/search.h" +#include "../data/snapshot.h" +#include "../data/logicsnapshot.h" +#include "../dialogs/dsmessagebox.h" #include "../config/appconfig.h" -#include "../ui/langresource.h" +#include "../uicore/langresource.h" #include "../ui/msgbox.h" -#include "../appcontrol.h" +#include "../appcore/appcontrol.h" #include "../ui/fn.h" -namespace pv { +using namespace dsv::config; + +namespace dsv { namespace dock { -using namespace pv::view; -using namespace pv::widgets; +using namespace dsv::view; +using namespace dsv::widgets; SearchDock::SearchDock(QWidget *parent, View &view, SigSession *session) : QWidget(parent), @@ -84,7 +85,7 @@ SearchDock::SearchDock(QWidget *parent, View &view, SigSession *session) : retranslateUi(); - update_font(); + UpdateFont(); connect(&_pre_button, SIGNAL(clicked()), this, SLOT(on_previous())); connect(&_nxt_button, SIGNAL(clicked()),this, SLOT(on_next())); @@ -110,7 +111,7 @@ void SearchDock::retranslateUi() void SearchDock::reStyle() { - QString iconPath = GetIconPath(); + QString iconPath = AppConfig::GetIconPath(); _pre_button.setIcon(QIcon(iconPath+"/pre.svg")); _nxt_button.setIcon(QIcon(iconPath+"/next.svg")); @@ -253,7 +254,7 @@ void SearchDock::on_set() } } -void SearchDock::update_font() +void SearchDock::UpdateFont() { QFont font = this->font(); font.setPointSizeF(AppConfig::Instance().appOptions.fontSize); @@ -261,4 +262,4 @@ void SearchDock::update_font() } } // namespace dock -} // namespace pv +} // namespace dsv diff --git a/DSView/pv/dock/searchdock.h b/DSView/src/dock/searchdock.h similarity index 82% rename from DSView/pv/dock/searchdock.h rename to DSView/src/dock/searchdock.h index 4eb5c300f..9b5e54034 100644 --- a/DSView/pv/dock/searchdock.h +++ b/DSView/src/dock/searchdock.h @@ -33,30 +33,32 @@ #include #include #include - #include #include #include #include - #include - #include "../widgets/fakelineedit.h" #include "../ui/dscombobox.h" #include "../interface/icallbacks.h" - -namespace pv { - -class SigSession; - -namespace view { - class View; -} - -namespace widgets { - class FakeLineEdit; +#include "../uicore/uitypes.h" + +namespace dsv{ + namespace appcore{ + class SigSession; + } + namespace view { + class View; + } + namespace widgets { + class FakeLineEdit; + } } +using namespace dsv::appcore; +using namespace dsv::view; +using namespace dsv::widgets; +namespace dsv { namespace dock { class SearchDock : public QWidget, public IFontForm @@ -64,7 +66,7 @@ class SearchDock : public QWidget, public IFontForm Q_OBJECT public: - SearchDock(QWidget *parent, pv::view::View &view, SigSession *session); + SearchDock(QWidget *parent, dsv::view::View &view, SigSession *session); ~SearchDock(); void paintEvent(QPaintEvent *); @@ -75,7 +77,7 @@ class SearchDock : public QWidget, public IFontForm void reStyle(); //IFontForm - void update_font() override; + void UpdateFont() override; public slots: void on_previous(); @@ -94,6 +96,6 @@ public slots: }; } // namespace dock -} // namespace pv +} // namespace dsv #endif // DSVIEW_PV_SEARCHDOCK_H diff --git a/DSView/pv/dock/triggerdock.cpp b/DSView/src/dock/triggerdock.cpp similarity index 99% rename from DSView/pv/dock/triggerdock.cpp rename to DSView/src/dock/triggerdock.cpp index 0ca413299..501cd6232 100644 --- a/DSView/pv/dock/triggerdock.cpp +++ b/DSView/src/dock/triggerdock.cpp @@ -20,10 +20,6 @@ */ #include "triggerdock.h" -#include "../sigsession.h" -#include "../dialogs/dsmessagebox.h" -#include "../view/view.h" - #include #include #include @@ -44,17 +40,22 @@ #include #endif +#include "../appcore/sigsession.h" +#include "../dialogs/dsmessagebox.h" +#include "../view/view.h" #include "../config/appconfig.h" -#include "../deviceagent.h" +#include "../appcore/deviceagent.h" #include "../view/logicsignal.h" -#include "../ui/langresource.h" +#include "../uicore/langresource.h" #include "../ui/msgbox.h" #include "../log.h" -#include "../data/decode/annotationrestable.h" -#include "../appcontrol.h" +#include "../decode/annotationrestable.h" +#include "../appcore/appcontrol.h" #include "../ui/fn.h" -namespace pv { +using namespace dsv::config; + +namespace dsv { namespace dock { const int TriggerDock::MinTrigPosition = 1; @@ -133,7 +134,7 @@ TriggerDock::TriggerDock(QWidget *parent, SigSession *session) : retranslateUi(); - update_font(); + UpdateFont(); } TriggerDock::~TriggerDock() @@ -1071,7 +1072,7 @@ void TriggerDock::on_serial_hex_changed() _is_serial_val_setting = false; } -void TriggerDock::update_font() +void TriggerDock::UpdateFont() { QFont font = this->font(); font.setPointSizeF(AppConfig::Instance().appOptions.fontSize); @@ -1081,4 +1082,4 @@ void TriggerDock::update_font() } } // namespace dock -} // namespace pv +} // namespace dsv diff --git a/DSView/pv/dock/triggerdock.h b/DSView/src/dock/triggerdock.h similarity index 95% rename from DSView/pv/dock/triggerdock.h rename to DSView/src/dock/triggerdock.h index edc157d30..2af49befd 100644 --- a/DSView/pv/dock/triggerdock.h +++ b/DSView/src/dock/triggerdock.h @@ -34,7 +34,6 @@ #include #include #include - #include #include #include @@ -42,11 +41,16 @@ #include #include "../ui/dscombobox.h" #include "../interface/icallbacks.h" +#include "../uicore/uitypes.h" -namespace pv { - -class SigSession; +namespace dsv{ + namespace appcore{ + class SigSession; + } +} +using namespace dsv::appcore; +namespace dsv { namespace dock { class TriggerDock : public QScrollArea, public IFontForm @@ -87,7 +91,7 @@ class TriggerDock : public QScrollArea, public IFontForm bool commit_trigger(); //IFontForm - void update_font() override; + void UpdateFont() override; private slots: void simple_trigger(); @@ -160,6 +164,6 @@ private slots: }; } // namespace dock -} // namespace pv +} // namespace dsv #endif // DSVIEW_PV_TRIGGERDOCK_H diff --git a/DSView/pv/interface/icallbacks.h b/DSView/src/interface/icallbacks.h similarity index 95% rename from DSView/pv/interface/icallbacks.h rename to DSView/src/interface/icallbacks.h index 2cfed68f9..db040596c 100644 --- a/DSView/pv/interface/icallbacks.h +++ b/DSView/src/interface/icallbacks.h @@ -59,11 +59,6 @@ class IDlgCallback virtual void OnDlgResult(bool bYes)=0; }; -class IMainForm{ -public: - virtual void switchLanguage(int language)=0; -}; - #define DSV_MSG_START_COLLECT_WORK_PREV 5001 #define DSV_MSG_START_COLLECT_WORK 5002 @@ -108,10 +103,4 @@ class IDecoderPannel virtual void update_deocder_item_name(void *trace_handel, const char *name)=0; }; -class IFontForm -{ -public: - virtual void update_font()=0; -}; - #endif diff --git a/DSView/pv/log.cpp b/DSView/src/log.cpp similarity index 90% rename from DSView/pv/log.cpp rename to DSView/src/log.cpp index c92f1fdab..bc3f577bf 100644 --- a/DSView/pv/log.cpp +++ b/DSView/src/log.cpp @@ -26,7 +26,11 @@ #include "utility/path.h" #include +using namespace dsv::config; + xlog_writer *dsv_log = nullptr; + +namespace dsv{ static xlog_context *log_ctx = nullptr; static bool b_logfile = false; static int log_file_index = -1; @@ -67,7 +71,7 @@ void dsv_log_enalbe_logfile(bool append) dsv_info("%s\"%s\"", "Store log to file: ", lf.toUtf8().data()); - std::string log_file = pv::path::ToUnicodePath(lf); + std::string log_file = dsv::path::ToUnicodePath(lf); int ret = xlog_add_receiver_from_file(log_ctx, log_file.c_str(), &log_file_index, append); if (ret != 0){ @@ -81,7 +85,7 @@ void dsv_clear_log_file() if (b_logfile && log_ctx) { QString lf = get_dsv_log_path(); - std::string log_file = pv::path::ToUnicodePath(lf); + std::string log_file = dsv::path::ToUnicodePath(lf); int ret = xlog_reset_log_file(log_ctx, log_file_index, log_file.c_str()); if (ret != 0){ @@ -125,12 +129,14 @@ QString get_dsv_log_path() #endif #ifdef _WIN32 - lf = GetUserDataDir() + "/DSView.log"; + lf = AppConfig::GetUserDataDir() + "/DSView.log"; #endif #ifdef Q_OS_DARWIN - lf = GetUserDataDir() + "/DSView.log"; + lf = AppConfig::GetUserDataDir() + "/DSView.log"; #endif return lf; -} \ No newline at end of file +} + +} //namespace dsv \ No newline at end of file diff --git a/DSView/pv/log.h b/DSView/src/log.h similarity index 97% rename from DSView/pv/log.h rename to DSView/src/log.h index a69433ef1..e565db07e 100644 --- a/DSView/pv/log.h +++ b/DSView/src/log.h @@ -27,6 +27,15 @@ extern xlog_writer *dsv_log; +#define LOG_PREFIX "" +#define dsv_err(fmt, args...) xlog_err(dsv_log, LOG_PREFIX fmt, ## args) +#define dsv_warn(fmt, args...) xlog_warn(dsv_log, LOG_PREFIX fmt, ## args) +#define dsv_info(fmt, args...) xlog_info(dsv_log, LOG_PREFIX fmt, ## args) +#define dsv_dbg(fmt, args...) xlog_dbg(dsv_log, LOG_PREFIX fmt, ## args) +#define dsv_detail(fmt, args...) xlog_detail(dsv_log, LOG_PREFIX fmt, ## args) + +namespace dsv{ + void dsv_log_init(); void dsv_log_uninit(); @@ -40,11 +49,6 @@ void dsv_set_log_file_enable(bool flag); QString get_dsv_log_path(); -#define LOG_PREFIX "" -#define dsv_err(fmt, args...) xlog_err(dsv_log, LOG_PREFIX fmt, ## args) -#define dsv_warn(fmt, args...) xlog_warn(dsv_log, LOG_PREFIX fmt, ## args) -#define dsv_info(fmt, args...) xlog_info(dsv_log, LOG_PREFIX fmt, ## args) -#define dsv_dbg(fmt, args...) xlog_dbg(dsv_log, LOG_PREFIX fmt, ## args) -#define dsv_detail(fmt, args...) xlog_detail(dsv_log, LOG_PREFIX fmt, ## args) +} //namespace dsv #endif \ No newline at end of file diff --git a/DSView/main.cpp b/DSView/src/main.cpp similarity index 90% rename from DSView/main.cpp rename to DSView/src/main.cpp index 1278f99c7..e86d00596 100644 --- a/DSView/main.cpp +++ b/DSView/src/main.cpp @@ -27,14 +27,13 @@ #include #include #include -#include "dsapplication.h" #include "mystyle.h" -#include "pv/mainframe.h" -#include "pv/config/appconfig.h" +#include "appcore/mainframe.h" +#include "config/appconfig.h" #include "config.h" -#include "pv/appcontrol.h" -#include "pv/log.h" -#include "pv/ui/langresource.h" +#include "appcore/appcontrol.h" +#include "log.h" +#include "uicore/langresource.h" #include #include #include @@ -176,36 +175,36 @@ bool bHighScale = true; QApplication::setOrganizationDomain("www.DreamSourceLab.com"); //----------------------init log - dsv_log_init(); // Don't call before QApplication be inited + dsv::dsv_log_init(); // Don't call before QApplication be inited if (bStoreLog && logLevel < XLOG_LEVEL_DBG){ logLevel = XLOG_LEVEL_DBG; } if (logLevel != -1){ - dsv_log_level(logLevel); + dsv::dsv_log_level(logLevel); } #ifdef DEBUG_INFO if (XLOG_LEVEL_INFO > logLevel){ - dsv_log_level(XLOG_LEVEL_INFO); // on develop mode, set the default log level + dsv::dsv_log_level(XLOG_LEVEL_INFO); // on develop mode, set the default log level logLevel = XLOG_LEVEL_INFO; } #endif if (bStoreLog){ - dsv_log_enalbe_logfile(true); + dsv::dsv_log_enalbe_logfile(true); } - AppControl *control = AppControl::Instance(); - AppConfig &app = AppConfig::Instance(); + auto control = dsv::appcore::AppControl::Instance(); + dsv::config::AppConfig &app = dsv::config::AppConfig::Instance(); app.LoadAll(); //load app config LangResource::Instance()->Load(app.frameOptions.language); if (app.appOptions.ableSaveLog){ - dsv_log_enalbe_logfile(app.appOptions.appendLogMode); + dsv::dsv_log_enalbe_logfile(app.appOptions.appendLogMode); if (app.appOptions.logLevel >= logLevel){ - dsv_log_level(app.appOptions.logLevel); + dsv::dsv_log_level(app.appOptions.logLevel); } } @@ -235,7 +234,7 @@ bool bHighScale = true; try { - pv::MainFrame w; + dsv::appcore::MainFrame w; control->Start(); w.show(); w.readSettings(); @@ -257,7 +256,7 @@ bool bHighScale = true; dsv_info("Uninit log."); - dsv_log_uninit(); + dsv::dsv_log_uninit(); return ret; } diff --git a/DSView/mystyle.h b/DSView/src/mystyle.h similarity index 100% rename from DSView/mystyle.h rename to DSView/src/mystyle.h diff --git a/DSView/pv/prop/binding/binding.cpp b/DSView/src/prop/binding/binding.cpp similarity index 99% rename from DSView/pv/prop/binding/binding.cpp rename to DSView/src/prop/binding/binding.cpp index fb5f9f106..623e43edd 100644 --- a/DSView/pv/prop/binding/binding.cpp +++ b/DSView/src/prop/binding/binding.cpp @@ -20,15 +20,13 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ - +#include "binding.h" #include #include - #include "../property.h" -#include "binding.h" - -namespace pv { + +namespace dsv { namespace prop { namespace binding { diff --git a/DSView/pv/prop/binding/binding.h b/DSView/src/prop/binding/binding.h similarity index 99% rename from DSView/pv/prop/binding/binding.h rename to DSView/src/prop/binding/binding.h index 22f94c01a..74791c275 100644 --- a/DSView/pv/prop/binding/binding.h +++ b/DSView/src/prop/binding/binding.h @@ -25,7 +25,6 @@ #define DSVIEW_PV_PROP_BINDING_BINDING_H #include - #include #include #include @@ -34,7 +33,7 @@ class QFormLayout; class QWidget; -namespace pv { +namespace dsv { namespace prop { class Property; diff --git a/DSView/pv/prop/binding/decoderoptions.cpp b/DSView/src/prop/binding/decoderoptions.cpp similarity index 94% rename from DSView/pv/prop/binding/decoderoptions.cpp rename to DSView/src/prop/binding/decoderoptions.cpp index f5da31378..e63b72e60 100644 --- a/DSView/pv/prop/binding/decoderoptions.cpp +++ b/DSView/src/prop/binding/decoderoptions.cpp @@ -19,29 +19,29 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include - #include "decoderoptions.h" +#include #include #include - -#include "../../data/decoderstack.h" -#include "../../data/decode/decoder.h" #include "../double.h" #include "../enum.h" #include "../int.h" #include "../string.h" -#include "../../ui/langresource.h" +#include "../../data/decoderstack.h" +#include "../../decode/decoder.h" +#include "../../uicore/langresource.h" #include "../../config/appconfig.h" using namespace boost; using namespace std; +using namespace dsv::config; +using namespace dsv::appcore; -namespace pv { +namespace dsv { namespace prop { namespace binding { -DecoderOptions::DecoderOptions(pv::data::DecoderStack* decoder_stack, data::decode::Decoder *decoder) : +DecoderOptions::DecoderOptions(DecoderStack* decoder_stack, Decoder *decoder): Binding(), _decoder(decoder) { diff --git a/DSView/pv/prop/binding/decoderoptions.h b/DSView/src/prop/binding/decoderoptions.h similarity index 85% rename from DSView/pv/prop/binding/decoderoptions.h rename to DSView/src/prop/binding/decoderoptions.h index 6e0835281..55659294d 100644 --- a/DSView/pv/prop/binding/decoderoptions.h +++ b/DSView/src/prop/binding/decoderoptions.h @@ -24,28 +24,31 @@ #include "binding.h" #include - #include "../property.h" struct srd_decoder_option; -namespace pv { +namespace dsv{ + namespace decode{ + class Decoder; + } -namespace data { -class DecoderStack; -namespace decode { -class Decoder; -} + namespace data{ + class DecoderStack; + } } +using namespace dsv::data; +using namespace dsv::decode; + +namespace dsv { namespace prop { namespace binding { class DecoderOptions : public Binding { public: - DecoderOptions(pv::data::DecoderStack *decoder_stack, - pv::data::decode::Decoder* decoder); + DecoderOptions(DecoderStack *decoder_stack, Decoder* decoder); GVariant* getter(const char *id); @@ -59,7 +62,7 @@ class DecoderOptions : public Binding private: - pv::data::decode::Decoder *_decoder; + Decoder *_decoder; }; } // binding diff --git a/DSView/pv/prop/binding/deviceoptions.cpp b/DSView/src/prop/binding/deviceoptions.cpp similarity index 90% rename from DSView/pv/prop/binding/deviceoptions.cpp rename to DSView/src/prop/binding/deviceoptions.cpp index 4fe6b22e4..eb467d466 100644 --- a/DSView/pv/prop/binding/deviceoptions.cpp +++ b/DSView/src/prop/binding/deviceoptions.cpp @@ -21,7 +21,6 @@ */ #include "deviceoptions.h" - #include #include #include @@ -31,14 +30,15 @@ #include "../int.h" #include "../../config/appconfig.h" #include "../../log.h" -#include "../../appcontrol.h" -#include "../../sigsession.h" -#include "../../deviceagent.h" -#include "../../ui/langresource.h" +#include "../../appcore/appcontrol.h" +#include "../../appcore/sigsession.h" +#include "../../appcore/deviceagent.h" +#include "../../uicore/langresource.h" using namespace std; +using namespace dsv::appcore; -namespace pv { +namespace dsv { namespace prop { namespace binding { @@ -47,10 +47,10 @@ DeviceOptions::DeviceOptions() GVariant *gvar_opts, *gvar_list; gsize num_opts; - SigSession *session = AppControl::Instance()->GetSession(); - _device_agent = session->get_device(); + auto session = AppControl::Instance()->GetSession(); + auto device_agent = session->get_device(); - gvar_opts = _device_agent->get_config_list(NULL, SR_CONF_DEVICE_OPTIONS); + gvar_opts = device_agent->get_config_list(NULL, SR_CONF_DEVICE_OPTIONS); if (gvar_opts == NULL) /* Driver supports no device instance options. */ @@ -61,14 +61,14 @@ DeviceOptions::DeviceOptions() for (unsigned int i = 0; i < num_opts; i++) { const struct sr_config_info *const info = - _device_agent->get_config_info(options[i]); + device_agent->get_config_info(options[i]); if (!info) continue; const int key = info->key; - gvar_list = _device_agent->get_config_list(NULL, key); + gvar_list = device_agent->get_config_list(NULL, key); const QString name(info->name); const char *label_char = info->name; @@ -143,16 +143,16 @@ DeviceOptions::DeviceOptions() GVariant* DeviceOptions::config_getter(int key) { - SigSession *session = AppControl::Instance()->GetSession(); - DeviceAgent *_device_agent = session->get_device(); - return _device_agent->get_config(key); + auto session = AppControl::Instance()->GetSession(); + auto device_agent = session->get_device(); + return device_agent->get_config(key); } void DeviceOptions::config_setter(int key, GVariant* value) { - SigSession *session = AppControl::Instance()->GetSession(); - DeviceAgent *_device_agent = session->get_device(); - _device_agent->set_config(key, value); + auto session = AppControl::Instance()->GetSession(); + auto device_agent = session->get_device(); + device_agent->set_config(key, value); } void DeviceOptions::bind_bool(const QString &name, const QString label, int key) @@ -317,7 +317,9 @@ void DeviceOptions::bind_bandwidths(const QString &name, const QString label, in plist = (struct sr_list_item*)g_variant_get_uint64(gvar_list); assert(plist); - _device_agent->get_config_bool(SR_CONF_BANDWIDTH, bw_limit); + auto session = AppControl::Instance()->GetSession(); + auto device_agent = session->get_device(); + device_agent->get_config_bool(SR_CONF_BANDWIDTH, bw_limit); if (bw_limit == false){ return; diff --git a/DSView/pv/prop/binding/deviceoptions.h b/DSView/src/prop/binding/deviceoptions.h similarity index 97% rename from DSView/pv/prop/binding/deviceoptions.h rename to DSView/src/prop/binding/deviceoptions.h index f23be5dab..0f7cf96b1 100644 --- a/DSView/pv/prop/binding/deviceoptions.h +++ b/DSView/src/prop/binding/deviceoptions.h @@ -26,15 +26,11 @@ #include #include - #include #include #include "binding.h" -class DeviceAgent; - -namespace pv { - +namespace dsv { namespace prop { namespace binding { @@ -79,9 +75,6 @@ class DeviceOptions : public Binding void bind_bandwidths(const QString &name, const QString label, int key,GVariant *const gvar_list, boost::function printer = print_gvariant); - -private: - DeviceAgent *_device_agent; }; diff --git a/DSView/pv/prop/binding/probeoptions.cpp b/DSView/src/prop/binding/probeoptions.cpp similarity index 88% rename from DSView/pv/prop/binding/probeoptions.cpp rename to DSView/src/prop/binding/probeoptions.cpp index bfd2381ad..8375658bf 100644 --- a/DSView/pv/prop/binding/probeoptions.cpp +++ b/DSView/src/prop/binding/probeoptions.cpp @@ -29,13 +29,14 @@ #include "../int.h" #include "../../config/appconfig.h" #include "../../log.h" -#include "../../appcontrol.h" -#include "../../sigsession.h" -#include "../../ui/langresource.h" +#include "../../appcore/appcontrol.h" +#include "../../appcore/sigsession.h" +#include "../../uicore/langresource.h" using namespace std; +using namespace dsv::appcore; -namespace pv { +namespace dsv { namespace prop { namespace binding { @@ -46,10 +47,10 @@ ProbeOptions::ProbeOptions(struct sr_channel *probe) : GVariant *gvar_opts; gsize num_opts; - SigSession *session = AppControl::Instance()->GetSession(); - _device_agent = session->get_device(); + auto session = AppControl::Instance()->GetSession(); + auto device_agent = session->get_device(); - gvar_opts = _device_agent->get_config_list(NULL, SR_CONF_PROBE_CONFIGS); + gvar_opts = device_agent->get_config_list(NULL, SR_CONF_PROBE_CONFIGS); if (gvar_opts == NULL){ /* Driver supports no device instance options. */ return; @@ -61,14 +62,14 @@ ProbeOptions::ProbeOptions(struct sr_channel *probe) : for (unsigned int i = 0; i < num_opts; i++) { const struct sr_config_info *const info = - _device_agent->get_config_info(options[i]); + device_agent->get_config_info(options[i]); if (!info) continue; const int key = info->key; - GVariant *gvar_list = _device_agent->get_config_list(NULL, key); + GVariant *gvar_list = device_agent->get_config_list(NULL, key); const QString name(info->name); const char *label_char = LangResource::Instance()->get_lang_text(STR_PAGE_DSL, info->name, info->name); @@ -107,16 +108,16 @@ ProbeOptions::ProbeOptions(struct sr_channel *probe) : GVariant* ProbeOptions::config_getter(const struct sr_channel *probe, int key) { - SigSession *session = AppControl::Instance()->GetSession(); - DeviceAgent *_device_agent = session->get_device(); - return _device_agent->get_config(key, probe, NULL); + auto session = AppControl::Instance()->GetSession(); + auto device_agent = session->get_device(); + return device_agent->get_config(key, probe, NULL); } void ProbeOptions::config_setter(struct sr_channel *probe, int key, GVariant* value) { - SigSession *session = AppControl::Instance()->GetSession(); - DeviceAgent *_device_agent = session->get_device(); - _device_agent->set_config(key, value, probe, NULL); + auto session = AppControl::Instance()->GetSession(); + auto device_agent = session->get_device(); + device_agent->set_config(key, value, probe, NULL); } void ProbeOptions::bind_bool(const QString &name, const QString label, int key) diff --git a/DSView/pv/prop/binding/probeoptions.h b/DSView/src/prop/binding/probeoptions.h similarity index 97% rename from DSView/pv/prop/binding/probeoptions.h rename to DSView/src/prop/binding/probeoptions.h index 4ba29c2a2..743177ddf 100644 --- a/DSView/pv/prop/binding/probeoptions.h +++ b/DSView/src/prop/binding/probeoptions.h @@ -25,14 +25,12 @@ #include #include - #include #include #include "binding.h" -class DeviceAgent; -namespace pv { +namespace dsv { namespace prop { namespace binding { @@ -72,7 +70,6 @@ class ProbeOptions : public Binding protected: struct sr_channel *const _probe; - DeviceAgent *_device_agent; }; } // binding diff --git a/DSView/pv/prop/bool.cpp b/DSView/src/prop/bool.cpp similarity index 99% rename from DSView/pv/prop/bool.cpp rename to DSView/src/prop/bool.cpp index b31369c2b..42a91231d 100644 --- a/DSView/pv/prop/bool.cpp +++ b/DSView/src/prop/bool.cpp @@ -19,17 +19,14 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ - +#include "bool.h" #include - #include -#include "bool.h" - using namespace std; using namespace boost; -namespace pv { +namespace dsv { namespace prop { Bool::Bool(QString name, QString label, Getter getter, Setter setter) : diff --git a/DSView/pv/prop/bool.h b/DSView/src/prop/bool.h similarity index 98% rename from DSView/pv/prop/bool.h rename to DSView/src/prop/bool.h index 5603914c0..f70bd438e 100644 --- a/DSView/pv/prop/bool.h +++ b/DSView/src/prop/bool.h @@ -27,7 +27,7 @@ class QCheckBox; -namespace pv { +namespace dsv { namespace prop { class Bool : public Property diff --git a/DSView/pv/prop/double.cpp b/DSView/src/prop/double.cpp similarity index 99% rename from DSView/pv/prop/double.cpp rename to DSView/src/prop/double.cpp index b5c7c3d7d..0f6f30a9c 100644 --- a/DSView/pv/prop/double.cpp +++ b/DSView/src/prop/double.cpp @@ -19,17 +19,14 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ - +#include "double.h" #include - #include -#include "double.h" - using namespace std; using namespace boost; -namespace pv { +namespace dsv { namespace prop { Double::Double(QString name, QString label, diff --git a/DSView/pv/prop/double.h b/DSView/src/prop/double.h similarity index 99% rename from DSView/pv/prop/double.h rename to DSView/src/prop/double.h index f80d5170f..81f63cd91 100644 --- a/DSView/pv/prop/double.h +++ b/DSView/src/prop/double.h @@ -24,14 +24,12 @@ #define DSVIEW_PV_PROP_DOUBLE_H #include - #include - #include "property.h" class QDoubleSpinBox; -namespace pv { +namespace dsv { namespace prop { class Double : public Property diff --git a/DSView/pv/prop/enum.cpp b/DSView/src/prop/enum.cpp similarity index 99% rename from DSView/pv/prop/enum.cpp rename to DSView/src/prop/enum.cpp index 78e2a6f75..8cdb71ae9 100644 --- a/DSView/pv/prop/enum.cpp +++ b/DSView/src/prop/enum.cpp @@ -19,18 +19,15 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ - +#include "enum.h" #include - #include - -#include "enum.h" #include "../ui/dscombobox.h" using namespace boost; using namespace std; -namespace pv { +namespace dsv { namespace prop { Enum::Enum(QString name, QString label, diff --git a/DSView/pv/prop/enum.h b/DSView/src/prop/enum.h similarity index 98% rename from DSView/pv/prop/enum.h rename to DSView/src/prop/enum.h index 416062712..0e3909389 100644 --- a/DSView/pv/prop/enum.h +++ b/DSView/src/prop/enum.h @@ -25,12 +25,11 @@ #include #include - #include "property.h" class DsComboBox; -namespace pv { +namespace dsv { namespace prop { class Enum : public Property diff --git a/DSView/pv/prop/int.cpp b/DSView/src/prop/int.cpp similarity index 99% rename from DSView/pv/prop/int.cpp rename to DSView/src/prop/int.cpp index 3648193d5..3fbc9a670 100644 --- a/DSView/pv/prop/int.cpp +++ b/DSView/src/prop/int.cpp @@ -19,14 +19,12 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ - +#include "int.h" #include #include #include - #include -#include "int.h" using boost::optional; using namespace std; @@ -46,7 +44,7 @@ using namespace std; //#define UINT32_MAX 0xffffffff //#define UINT64_MAX 0xffffffffffffffff -namespace pv { +namespace dsv { namespace prop { Int::Int(QString name, QString label, diff --git a/DSView/pv/prop/int.h b/DSView/src/prop/int.h similarity index 98% rename from DSView/pv/prop/int.h rename to DSView/src/prop/int.h index 0e747540f..d6037178e 100644 --- a/DSView/pv/prop/int.h +++ b/DSView/src/prop/int.h @@ -24,14 +24,12 @@ #define DSVIEW_PV_PROP_INT_H #include - #include - #include "property.h" class QSpinBox; -namespace pv { +namespace dsv { namespace prop { class Int : public Property diff --git a/DSView/pv/prop/property.cpp b/DSView/src/prop/property.cpp similarity index 98% rename from DSView/pv/prop/property.cpp rename to DSView/src/prop/property.cpp index 7933398f7..af3346323 100644 --- a/DSView/pv/prop/property.cpp +++ b/DSView/src/prop/property.cpp @@ -22,7 +22,7 @@ #include "property.h" -namespace pv { +namespace dsv { namespace prop { Property::Property(QString name, QString label, Getter getter, Setter setter) : diff --git a/DSView/pv/prop/property.h b/DSView/src/prop/property.h similarity index 99% rename from DSView/pv/prop/property.h rename to DSView/src/prop/property.h index 5ba344be8..cdd503c16 100644 --- a/DSView/pv/prop/property.h +++ b/DSView/src/prop/property.h @@ -24,15 +24,13 @@ #define DSVIEW_PV_PROP_PROPERTY_H #include - #include - #include #include class QWidget; -namespace pv { +namespace dsv { namespace prop { class Property : public QObject diff --git a/DSView/pv/prop/string.cpp b/DSView/src/prop/string.cpp similarity index 99% rename from DSView/pv/prop/string.cpp rename to DSView/src/prop/string.cpp index 04648e688..3ef390444 100644 --- a/DSView/pv/prop/string.cpp +++ b/DSView/src/prop/string.cpp @@ -26,7 +26,7 @@ #include "string.h" -namespace pv { +namespace dsv { namespace prop { String::String(QString name, QString label, diff --git a/DSView/pv/prop/string.h b/DSView/src/prop/string.h similarity index 98% rename from DSView/pv/prop/string.h rename to DSView/src/prop/string.h index 1cd0de25f..d73f8d4bb 100644 --- a/DSView/pv/prop/string.h +++ b/DSView/src/prop/string.h @@ -26,7 +26,7 @@ class QLineEdit; -namespace pv { +namespace dsv { namespace prop { class String : public Property diff --git a/DSView/pv/toolbars/filebar.cpp b/DSView/src/toolbars/filebar.cpp similarity index 96% rename from DSView/pv/toolbars/filebar.cpp rename to DSView/src/toolbars/filebar.cpp index a8b9bdf14..d0d191733 100644 --- a/DSView/pv/toolbars/filebar.cpp +++ b/DSView/src/toolbars/filebar.cpp @@ -19,21 +19,23 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "filebar.h" #include #include #include #include #include - -#include "filebar.h" #include "../ui/msgbox.h" #include "../config/appconfig.h" #include "../utility/path.h" -#include "../ui/langresource.h" +#include "../uicore/langresource.h" #include "../log.h" #include "../ui/fn.h" +#include "../appcore/sigsession.h" + +using namespace dsv::config; -namespace pv { +namespace dsv { namespace toolbars { FileBar::FileBar(SigSession *session, QWidget *parent) : @@ -94,7 +96,7 @@ FileBar::FileBar(SigSession *session, QWidget *parent) : connect(_action_export, SIGNAL(triggered()), this, SIGNAL(sig_export())); connect(_action_capture, SIGNAL(triggered()), this, SLOT(on_actionCapture_triggered())); - update_font(); + UpdateFont(); } void FileBar::changeEvent(QEvent *event) @@ -121,7 +123,7 @@ void FileBar::retranslateUi() void FileBar::reStyle() { - QString iconPath = GetIconPath(); + QString iconPath = AppConfig::GetIconPath(); _action_load->setIcon(QIcon(iconPath+"/open.svg")); _action_store->setIcon(QIcon(iconPath+"/save.svg")); @@ -187,7 +189,7 @@ void FileBar::on_actionLoad_triggered() void FileBar::on_actionDefault_triggered() { - QDir dir(GetFirmwareDir()); + QDir dir(AppConfig::GetFirmwareDir()); if (!dir.exists()) { MsgBox::Show(NULL, L_S(STR_PAGE_MSG, S_ID(IDS_MSG_NOT_FOND_DEFAULT_PROFILE), "Cannot find default profile for this device!"), this); @@ -201,7 +203,7 @@ void FileBar::on_actionDefault_triggered() QString FileBar::genDefaultSessionFile() { - QDir dir(GetFirmwareDir()); + QDir dir(AppConfig::GetFirmwareDir()); QString driver_name = _session->get_device()->driver_name(); QString mode_name = QString::number(_session->get_device()->get_work_mode()); @@ -254,7 +256,7 @@ void FileBar::update_view_status() _menu_session->setEnabled(bEnable && is_hardware); } -void FileBar::update_font() +void FileBar::UpdateFont() { QFont font = this->font(); font.setPointSizeF(AppConfig::Instance().appOptions.fontSize); @@ -262,4 +264,4 @@ void FileBar::update_font() } } // namespace toolbars -} // namespace pv +} // namespace dsv diff --git a/DSView/pv/toolbars/filebar.h b/DSView/src/toolbars/filebar.h similarity index 92% rename from DSView/pv/toolbars/filebar.h rename to DSView/src/toolbars/filebar.h index 6982ec1f5..4035b8062 100644 --- a/DSView/pv/toolbars/filebar.h +++ b/DSView/src/toolbars/filebar.h @@ -27,11 +27,17 @@ #include #include #include - -#include "../sigsession.h" #include "../interface/icallbacks.h" +#include "../uicore/uitypes.h" + +namespace dsv{ + namespace appcore{ + class SigSession; + } +} +using namespace dsv::appcore; -namespace pv { +namespace dsv { namespace toolbars { //toolbar button,referenced by MainWindow @@ -53,7 +59,7 @@ class FileBar : public QToolBar, public IFontForm void reStyle(); //IFontForm - void update_font() override; + void UpdateFont() override; signals: void sig_load_file(QString); @@ -86,6 +92,6 @@ private slots: }; } // namespace toolbars -} // namespace pv +} // namespace dsv #endif // DSVIEW_PV_TOOLBARS_FILEBAR_H diff --git a/DSView/pv/toolbars/logobar.cpp b/DSView/src/toolbars/logobar.cpp similarity index 96% rename from DSView/pv/toolbars/logobar.cpp rename to DSView/src/toolbars/logobar.cpp index f6120e18e..8785368a5 100644 --- a/DSView/pv/toolbars/logobar.cpp +++ b/DSView/src/toolbars/logobar.cpp @@ -19,9 +19,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "logobar.h" #include - - #include #include #include @@ -36,19 +35,20 @@ #include #include #include - -#include "logobar.h" #include "../dialogs/about.h" #include "../dialogs/dsmessagebox.h" #include "../config/appconfig.h" #include "../dialogs/dsdialog.h" -#include "../appcontrol.h" +#include "../appcore/appcontrol.h" #include "../log.h" -#include "../ui/langresource.h" +#include "../uicore/langresource.h" #include "../ui/msgbox.h" #include "../ui/fn.h" +#include "../appcore/sigsession.h" + +using namespace dsv::config; -namespace pv { +namespace dsv { namespace toolbars { LogoBar::LogoBar(SigSession *session, QWidget *parent) : @@ -124,7 +124,7 @@ LogoBar::LogoBar(SigSession *session, QWidget *parent) : connect(_update, SIGNAL(triggered()), this, SLOT(on_action_update())); connect(_log, SIGNAL(triggered()), this, SLOT(on_action_setting_log())); - update_font(); + UpdateFont(); } void LogoBar::changeEvent(QEvent *event) @@ -158,7 +158,7 @@ void LogoBar::retranslateUi() void LogoBar::reStyle() { - QString iconPath = GetIconPath(); + QString iconPath = AppConfig::GetIconPath(); _about->setIcon(QIcon(iconPath+"/about.svg")); _manual->setIcon(QIcon(iconPath+"/manual.svg")); @@ -175,7 +175,7 @@ void LogoBar::reStyle() void LogoBar::dsl_connected(bool conn) { _connected = conn; - QString iconPath = GetIconPath(); + QString iconPath = AppConfig::GetIconPath(); if (_connected) _logo_button.setIcon(QIcon(iconPath+"/logo_color.svg")); else @@ -188,7 +188,7 @@ void LogoBar::on_actionEn_triggered() QIcon(":/icons/English.svg"))); assert(_mainForm); - _mainForm->switchLanguage(LAN_EN); + _mainForm->SwitchLanguage(LAN_EN); } void LogoBar::on_actionCn_triggered() @@ -196,7 +196,7 @@ void LogoBar::on_actionCn_triggered() _language->setIcon(QIcon::fromTheme("file", QIcon(":/icons/Chinese.svg"))); assert(_mainForm); - _mainForm->switchLanguage(LAN_CN); + _mainForm->SwitchLanguage(LAN_CN); } void LogoBar::on_actionAbout_triggered() @@ -207,7 +207,7 @@ void LogoBar::on_actionAbout_triggered() void LogoBar::on_actionManual_triggered() { - QDir dir(GetAppDataDir()); + QDir dir(AppConfig::GetAppDataDir()); QDesktopServices::openUrl( QUrl("file:///"+dir.absolutePath() + "/ug.pdf")); } @@ -348,7 +348,7 @@ void LogoBar::on_clear_log_file() } } -void LogoBar::update_font() +void LogoBar::UpdateFont() { QFont font = this->font(); font.setPointSizeF(AppConfig::Instance().appOptions.fontSize); @@ -356,4 +356,4 @@ void LogoBar::update_font() } } // namespace toolbars -} // namespace pv +} // namespace dsv diff --git a/DSView/pv/toolbars/logobar.h b/DSView/src/toolbars/logobar.h similarity index 93% rename from DSView/pv/toolbars/logobar.h rename to DSView/src/toolbars/logobar.h index 8d3f2d081..b6776b7c3 100644 --- a/DSView/pv/toolbars/logobar.h +++ b/DSView/src/toolbars/logobar.h @@ -29,11 +29,17 @@ #include #include #include - -#include "../sigsession.h" #include "../interface/icallbacks.h" +#include "../uicore/uitypes.h" + +namespace dsv{ + namespace appcore{ + class SigSession; + } +} +using namespace dsv::appcore; -namespace pv { +namespace dsv { namespace toolbars { //The tool button for help,is a ui class,referenced by MainWindow @@ -60,7 +66,7 @@ class LogoBar : public QToolBar, public IFontForm void reStyle(); //IFontForm - void update_font() override; + void UpdateFont() override; signals: //post event message to open user help document, MainWindow class receive it @@ -103,6 +109,6 @@ private slots: }; } // namespace toolbars -} // namespace pv +} // namespace dsv #endif // DSVIEW_PV_TOOLBARS_LOGOBAR_H diff --git a/DSView/pv/toolbars/samplingbar.cpp b/DSView/src/toolbars/samplingbar.cpp similarity index 98% rename from DSView/pv/toolbars/samplingbar.cpp rename to DSView/src/toolbars/samplingbar.cpp index d525f3429..0a68aa0a2 100644 --- a/DSView/pv/toolbars/samplingbar.cpp +++ b/DSView/src/toolbars/samplingbar.cpp @@ -32,13 +32,14 @@ #include "../view/dsosignal.h" #include "../dialogs/interval.h" #include "../config/appconfig.h" -#include "../dsvdef.h" +#include "../basedef.h" #include "../log.h" -#include "../deviceagent.h" +#include "../appcore/deviceagent.h" #include "../ui/msgbox.h" -#include "../ui/langresource.h" +#include "../uicore/langresource.h" #include "../view/view.h" #include "../ui/fn.h" +#include "../appcore/sigsession.h" #define SINGLE_ACTION_ICON "/once.svg" #define REPEAT_ACTION_ICON "/repeat.svg" @@ -48,8 +49,9 @@ using std::map; using std::max; using std::min; using std::string; +using namespace dsv::config; -namespace pv +namespace dsv { namespace toolbars { @@ -128,7 +130,7 @@ namespace pv _instant_action = addWidget(&_instant_button); update_view_status(); - update_font(); + UpdateFont(); connect(&_device_selector, SIGNAL(currentIndexChanged(int)), this, SLOT(on_device_selected())); connect(&_configure_button, SIGNAL(clicked()), this, SLOT(on_configure())); @@ -237,7 +239,7 @@ namespace pv if (true) { - QString iconPath = GetIconPath(); + QString iconPath = AppConfig::GetIconPath(); _configure_button.setIcon(QIcon(iconPath + "/params.svg")); QString icon2 = _session->is_working() ? "stop.svg" : "start.svg"; @@ -264,7 +266,7 @@ namespace pv _session->broadcast_msg(DSV_MSG_BEGIN_DEVICE_OPTIONS); - pv::dialogs::DeviceOptions dlg(this); + dsv::dialogs::DeviceOptions dlg(this); connect(_session->device_event_object(), SIGNAL(device_updated()), &dlg, SLOT(reject())); ret = dlg.exec(); @@ -342,7 +344,7 @@ namespace pv if (_session->is_working() == false) _session->start_capture(false); - pv::dialogs::WaitingDialog wait(this, _session, SR_CONF_ZERO); + dsv::dialogs::WaitingDialog wait(this, _session, SR_CONF_ZERO); if (wait.start() == QDialog::Rejected) { for (auto s : _session->get_signals()) @@ -992,7 +994,7 @@ namespace pv void SamplingBar::reload() { - QString iconPath = GetIconPath(); + QString iconPath = AppConfig::GetIconPath(); _action_loop->setVisible(false); @@ -1039,7 +1041,7 @@ namespace pv void SamplingBar::on_collect_mode() { - QString iconPath = GetIconPath(); + QString iconPath = AppConfig::GetIconPath(); QAction *act = qobject_cast(sender()); if (act == _action_single) @@ -1059,7 +1061,7 @@ namespace pv _session->set_collect_mode(COLLECT_REPEAT); } else{ - pv::dialogs::Interval interval_dlg(this); + dsv::dialogs::Interval interval_dlg(this); interval_dlg.set_interval(_session->get_repeat_intvl()); interval_dlg.exec(); @@ -1199,7 +1201,7 @@ namespace pv _instant_button.setEnabled(true); } - QString iconPath = GetIconPath(); + QString iconPath = AppConfig::GetIconPath(); if (_is_run_as_instant) _instant_button.setIcon(!bEnable ? QIcon(iconPath + "/stop.svg") : QIcon(iconPath + "/single.svg")); @@ -1234,7 +1236,7 @@ namespace pv void SamplingBar::update_mode_icon() { - QString iconPath = GetIconPath(); + QString iconPath = AppConfig::GetIconPath(); if (_session->is_repeat_mode()) _mode_button.setIcon(QIcon(iconPath + REPEAT_ACTION_ICON)); @@ -1255,7 +1257,7 @@ namespace pv on_instant_stop(); } - void SamplingBar::update_font() + void SamplingBar::UpdateFont() { QFont font = this->font(); font.setPointSizeF(AppConfig::Instance().appOptions.fontSize); @@ -1263,4 +1265,4 @@ namespace pv } } // namespace toolbars -} // namespace pv +} // namespace dsv diff --git a/DSView/pv/toolbars/samplingbar.h b/DSView/src/toolbars/samplingbar.h similarity index 92% rename from DSView/pv/toolbars/samplingbar.h rename to DSView/src/toolbars/samplingbar.h index e8aa63f43..e33545b6c 100644 --- a/DSView/pv/toolbars/samplingbar.h +++ b/DSView/src/toolbars/samplingbar.h @@ -22,42 +22,48 @@ #ifndef DSVIEW_PV_TOOLBARS_SAMPLINGBAR_H #define DSVIEW_PV_TOOLBARS_SAMPLINGBAR_H -#include "../sigsession.h" - +#include #include #include -#include - +#include #include #include #include #include +#include #include "../ui/dscombobox.h" #include "../interface/icallbacks.h" -#include +#include "../uicore/uitypes.h" struct st_dev_inst; class QAction; struct ds_device_info; -class DeviceAgent; - -namespace pv -{ - class SigSession; - - namespace view{ - class View; - } - - namespace dialogs - { +namespace dsv{ + namespace appcore{ + class SigSession; + class DeviceAgent; + } +} +using namespace dsv::appcore; + +namespace dsv{ + namespace view{ + class View; + } +} +using namespace dsv::view; + +namespace dsv{ + namespace dialogs{ class deviceoptions; class Calibration; } +} +using namespace dsv::dialogs; - namespace toolbars - { +namespace dsv{ +namespace toolbars{ class SamplingBar : public QToolBar, public IFontForm { @@ -124,7 +130,7 @@ namespace pv bool action_instant_stop(); //IFontForm - void update_font() override; + void UpdateFont() override; private slots: void on_collect_mode(); @@ -172,6 +178,6 @@ namespace pv }; } // namespace toolbars -} // namespace pv +} // namespace dsv #endif // DSVIEW_PV_TOOLBARS_SAMPLINGBAR_H diff --git a/DSView/pv/toolbars/titlebar.cpp b/DSView/src/toolbars/titlebar.cpp similarity index 95% rename from DSView/pv/toolbars/titlebar.cpp rename to DSView/src/toolbars/titlebar.cpp index abeab20b5..beffbc087 100644 --- a/DSView/pv/toolbars/titlebar.cpp +++ b/DSView/src/toolbars/titlebar.cpp @@ -20,7 +20,6 @@ */ #include "titlebar.h" - #include #include #include @@ -32,11 +31,14 @@ #include #include #include "../config/appconfig.h" -#include "../appcontrol.h" -#include "../dsvdef.h" +#include "../appcore/appcontrol.h" +#include "../basedef.h" #include "../ui/fn.h" -namespace pv { +using namespace dsv::appcore; +using namespace dsv::config; + +namespace dsv { namespace toolbars { TitleBar::TitleBar(bool top, QWidget *parent, bool hasClose) : @@ -91,7 +93,7 @@ TitleBar::TitleBar(bool top, QWidget *parent, bool hasClose) : setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); - update_font(); + UpdateFont(); } TitleBar::~TitleBar(){ @@ -108,8 +110,8 @@ void TitleBar::changeEvent(QEvent *event) } void TitleBar::reStyle() -{ - QString iconPath = GetIconPath(); +{ + QString iconPath = AppConfig::GetIconPath(); if (_isTop) { _minimizeButton->setIcon(QIcon(iconPath+"/minimize.svg")); @@ -169,7 +171,7 @@ QString TitleBar::title() void TitleBar::showMaxRestore() { - QString iconPath = GetIconPath(); + QString iconPath = AppConfig::GetIconPath(); if (parentWidget()->isMaximized()) { _maximizeButton->setIcon(QIcon(iconPath+"/maximize.svg")); normalShow(); @@ -181,7 +183,7 @@ void TitleBar::showMaxRestore() void TitleBar::setRestoreButton(bool max) { - QString iconPath = GetIconPath(); + QString iconPath = AppConfig::GetIconPath(); if (!max) { _maximizeButton->setIcon(QIcon(iconPath+"/maximize.svg")); } else { @@ -236,7 +238,7 @@ void TitleBar::mouseDoubleClickEvent(QMouseEvent *event) QWidget::mouseDoubleClickEvent(event); } -void TitleBar::update_font() +void TitleBar::UpdateFont() { QFont font = this->font(); font.setPointSizeF(AppConfig::Instance().appOptions.fontSize); @@ -244,4 +246,4 @@ void TitleBar::update_font() } } // namespace toolbars -} // namespace pv +} // namespace dsv diff --git a/DSView/pv/toolbars/titlebar.h b/DSView/src/toolbars/titlebar.h similarity index 94% rename from DSView/pv/toolbars/titlebar.h rename to DSView/src/toolbars/titlebar.h index 1d577bd03..6824209c7 100644 --- a/DSView/pv/toolbars/titlebar.h +++ b/DSView/src/toolbars/titlebar.h @@ -23,13 +23,14 @@ #define DSVIEW_PV_TOOLBARS_TITLEBAR_H #include - #include "../interface/icallbacks.h" +#include "../interface/icallbacks.h" +#include "../uicore/uitypes.h" class QToolButton; class QHBoxLayout; class QLabel; -namespace pv { +namespace dsv { namespace toolbars { class TitleBar : public QWidget, public IFontForm @@ -44,7 +45,7 @@ class TitleBar : public QWidget, public IFontForm QString title(); //IFontForm - void update_font() override; + void UpdateFont() override; private: void changeEvent(QEvent *event); @@ -81,6 +82,6 @@ public slots: }; } // namespace toolbars -} // namespace pv +} // namespace dsv #endif // DSVIEW_PV_TOOLBARS_TITLEBAR_H diff --git a/DSView/pv/toolbars/trigbar.cpp b/DSView/src/toolbars/trigbar.cpp similarity index 95% rename from DSView/pv/toolbars/trigbar.cpp rename to DSView/src/toolbars/trigbar.cpp index 02f7b5009..547c6d354 100644 --- a/DSView/pv/toolbars/trigbar.cpp +++ b/DSView/src/toolbars/trigbar.cpp @@ -20,22 +20,22 @@ */ #include "trigbar.h" - #include #include #include - -#include "../sigsession.h" +#include "../appcore/sigsession.h" #include "../dialogs/fftoptions.h" #include "../dialogs/lissajousoptions.h" #include "../dialogs/mathoptions.h" #include "../view/trace.h" #include "../dialogs/applicationpardlg.h" -#include "../ui/langresource.h" +#include "../uicore/langresource.h" #include "../config/appconfig.h" #include "../ui/fn.h" -namespace pv { +using namespace dsv::config; + +namespace dsv { namespace toolbars { TrigBar::TrigBar(SigSession *session, QWidget *parent) : @@ -123,7 +123,7 @@ TrigBar::TrigBar(SigSession *session, QWidget *parent) : connect(_light_style, SIGNAL(triggered()), this, SLOT(on_actionLight_triggered())); connect(_action_dispalyOptions, SIGNAL(triggered()), this, SLOT(on_display_setting())); - update_font(); + UpdateFont(); } //语言变化 @@ -160,7 +160,7 @@ void TrigBar::retranslateUi() void TrigBar::reStyle() { - QString iconPath = GetIconPath(); + QString iconPath = AppConfig::GetIconPath(); _trig_button.setIcon(QIcon(iconPath+"/trigger.svg")); _protocol_button.setIcon(QIcon(iconPath+"/protocol.svg")); @@ -285,39 +285,39 @@ void TrigBar::reload() void TrigBar::on_actionFft_triggered() { - pv::dialogs::FftOptions fft_dlg(this, _session); + dsv::dialogs::FftOptions fft_dlg(this, _session); fft_dlg.exec(); } void TrigBar::on_actionMath_triggered() { - pv::dialogs::MathOptions math_dlg(_session, this); + dsv::dialogs::MathOptions math_dlg(_session, this); math_dlg.exec(); } void TrigBar::on_actionDark_triggered() { sig_setTheme(THEME_STYLE_DARK); - QString icon = GetIconPath() + "/" + THEME_STYLE_DARK + ".svg"; + QString icon = AppConfig::GetIconPath() + "/" + THEME_STYLE_DARK + ".svg"; _themes->setIcon(QIcon(icon)); } void TrigBar::on_actionLight_triggered() { sig_setTheme(THEME_STYLE_LIGHT); - QString icon = GetIconPath() + "/" + THEME_STYLE_LIGHT +".svg"; + QString icon = AppConfig::GetIconPath() + "/" + THEME_STYLE_LIGHT +".svg"; _themes->setIcon(QIcon(icon)); } void TrigBar::on_actionLissajous_triggered() { - pv::dialogs::LissajousOptions lissajous_dlg(_session, this); + dsv::dialogs::LissajousOptions lissajous_dlg(_session, this); lissajous_dlg.exec(); } void TrigBar::on_display_setting() { - pv::dialogs::ApplicationParamDlg dlg; + dsv::dialogs::ApplicationParamDlg dlg; dlg.ShowDlg(this); } @@ -371,7 +371,7 @@ void TrigBar::update_checked_status() _search_button.setChecked(opt->searchDock); } -void TrigBar::update_font() +void TrigBar::UpdateFont() { QFont font = this->font(); font.setPointSizeF(AppConfig::Instance().appOptions.fontSize); @@ -379,4 +379,4 @@ void TrigBar::update_font() } } // namespace toolbars -} // namespace pv +} // namespace dsv diff --git a/DSView/pv/toolbars/trigbar.h b/DSView/src/toolbars/trigbar.h similarity index 92% rename from DSView/pv/toolbars/trigbar.h rename to DSView/src/toolbars/trigbar.h index 53c913faf..ab58cb7c2 100644 --- a/DSView/pv/toolbars/trigbar.h +++ b/DSView/src/toolbars/trigbar.h @@ -28,13 +28,22 @@ #include #include #include "../interface/icallbacks.h" +#include "../uicore/uitypes.h" -class DockOptions; +namespace dsv { + namespace config{ + class DockOptions; + } -namespace pv { + namespace appcore{ + class SigSession; + } +} -class SigSession; +using namespace dsv::appcore; +using namespace dsv::config; +namespace dsv { namespace toolbars { //boolbar, referenced by MainWindow @@ -56,7 +65,7 @@ class TrigBar : public QToolBar, public IFontForm void update_checked_status(); //IFontForm - void update_font() override; + void UpdateFont() override; signals: void sig_setTheme(QString style); @@ -109,6 +118,6 @@ public slots: }; } // namespace toolbars -} // namespace pv +} // namespace dsv #endif // DSVIEW_PV_TOOLBARS_TRIGBAR_H diff --git a/DSView/pv/ui/dscombobox.cpp b/DSView/src/ui/dscombobox.cpp similarity index 98% rename from DSView/pv/ui/dscombobox.cpp rename to DSView/src/ui/dscombobox.cpp index d1ca0194f..1043fd73d 100644 --- a/DSView/pv/ui/dscombobox.cpp +++ b/DSView/src/ui/dscombobox.cpp @@ -25,8 +25,9 @@ #include #include #include - #include "../config/appconfig.h" + +using namespace dsv::config; DsComboBox::DsComboBox(QWidget *parent) : QComboBox(parent) { diff --git a/DSView/pv/ui/dscombobox.h b/DSView/src/ui/dscombobox.h similarity index 100% rename from DSView/pv/ui/dscombobox.h rename to DSView/src/ui/dscombobox.h diff --git a/DSView/pv/ui/fn.cpp b/DSView/src/ui/fn.cpp similarity index 93% rename from DSView/pv/ui/fn.cpp rename to DSView/src/ui/fn.cpp index 3dda68902..256566ba2 100644 --- a/DSView/pv/ui/fn.cpp +++ b/DSView/src/ui/fn.cpp @@ -34,21 +34,10 @@ #include #include #include - #include "../config/appconfig.h" namespace ui { - - void set_font_param(QFont &font, struct FontParam ¶m) - { - font.setPointSizeF(param.size >= 9.0f ? param.size : 9.0f); - - if (param.name != ""){ - font.setFamily(param.name); - } - } - void set_toolbar_font(QToolBar *bar, QFont font) { assert(bar); diff --git a/DSView/pv/ui/fn.h b/DSView/src/ui/fn.h similarity index 92% rename from DSView/pv/ui/fn.h rename to DSView/src/ui/fn.h index 68458902a..c3850e3df 100644 --- a/DSView/pv/ui/fn.h +++ b/DSView/src/ui/fn.h @@ -24,15 +24,11 @@ #include -struct FontParam; - class QToolBar; class QWidget; namespace ui -{ - void set_font_param(QFont &font, struct FontParam ¶m); - +{ void set_toolbar_font(QToolBar *bar, QFont font); void set_form_font(QWidget *wid, QFont font); diff --git a/DSView/pv/ui/msgbox.cpp b/DSView/src/ui/msgbox.cpp similarity index 85% rename from DSView/pv/ui/msgbox.cpp rename to DSView/src/ui/msgbox.cpp index d7946e9b1..a5967ad43 100644 --- a/DSView/pv/ui/msgbox.cpp +++ b/DSView/src/ui/msgbox.cpp @@ -20,12 +20,12 @@ */ #include "msgbox.h" -#include "../dialogs/dsmessagebox.h" #include #include -#include "../dsvdef.h" -#include "../appcontrol.h" -#include "langresource.h" +#include "../dialogs/dsmessagebox.h" +#include "../basedef.h" +#include "../appcore/appcontrol.h" +#include "../uicore/langresource.h" //QMessageBox::information(NULL, "Title", "Content",QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes); //QMessageBox::information(NULL, "Title", "Content",QMessageBox::Yes|QMessageBox::No); @@ -48,13 +48,13 @@ void Show(const QString title, const QString text, const QString infoText) } void MsgBox::Show(const QString title, const QString text, - QWidget *parent, pv::dialogs::DSMessageBox **box) + QWidget *parent, dsv::dialogs::DSMessageBox **box) { MsgBox::Show(title, text, "", parent, box); } void MsgBox::Show(const QString title, const QString text, const QString infoText, - QWidget *parent, pv::dialogs::DSMessageBox **box) + QWidget *parent, dsv::dialogs::DSMessageBox **box) { assert(!text.isEmpty()); @@ -63,10 +63,10 @@ void MsgBox::Show(const QString title, const QString text, const QString infoTex str.append(text); if (parent == NULL){ - parent = AppControl::Instance()->GetTopWindow(); + parent = dsv::appcore::AppControl::Instance()->GetTopWindow(); } - pv::dialogs::DSMessageBox msg(parent, title); + dsv::dialogs::DSMessageBox msg(parent, title); if (box != NULL){ *box = &msg; @@ -89,7 +89,7 @@ bool MsgBox::Confirm(const QString text, QWidget *parent) } bool MsgBox::Confirm(const QString text, const QString infoText, - pv::dialogs::DSMessageBox **box, QWidget *parent) + dsv::dialogs::DSMessageBox **box, QWidget *parent) { assert(!text.isEmpty()); @@ -98,11 +98,11 @@ bool MsgBox::Confirm(const QString text, const QString infoText, str.append(text); if (parent == NULL){ - parent = AppControl::Instance()->GetTopWindow(); + parent = dsv::appcore::AppControl::Instance()->GetTopWindow(); } const char *title = L_S(STR_PAGE_MSG, S_ID(IDS_MSG_BOX_CONFIRM), "Confirm"); - pv::dialogs::DSMessageBox msg(parent, title); + dsv::dialogs::DSMessageBox msg(parent, title); msg.mBox()->setText(str); msg.mBox()->setStandardButtons(QMessageBox::Yes | QMessageBox::No); msg.mBox()->setIcon(QMessageBox::Question); diff --git a/DSView/pv/ui/msgbox.h b/DSView/src/ui/msgbox.h similarity index 88% rename from DSView/pv/ui/msgbox.h rename to DSView/src/ui/msgbox.h index a067916bc..24ecb1d8a 100644 --- a/DSView/pv/ui/msgbox.h +++ b/DSView/src/ui/msgbox.h @@ -25,7 +25,7 @@ class QWidget; -namespace pv{ +namespace dsv{ namespace dialogs{ class DSMessageBox; } @@ -37,9 +37,9 @@ class MsgBox static void Show(const QString text); static void Show(const QString title, const QString text, QWidget *parent=0); static void Show(const QString title, const QString text, const QString infoText); - static void Show(const QString title, const QString text, QWidget *parent, pv::dialogs::DSMessageBox **box); - static void Show(const QString title, const QString text, const QString infoText, QWidget *parent, pv::dialogs::DSMessageBox **box); + static void Show(const QString title, const QString text, QWidget *parent, dsv::dialogs::DSMessageBox **box); + static void Show(const QString title, const QString text, const QString infoText, QWidget *parent, dsv::dialogs::DSMessageBox **box); static bool Confirm(const QString text, QWidget *parent=0); - static bool Confirm(const QString text, const QString infoText, pv::dialogs::DSMessageBox **box=0, QWidget *parent=0); + static bool Confirm(const QString text, const QString infoText, dsv::dialogs::DSMessageBox **box=0, QWidget *parent=0); }; \ No newline at end of file diff --git a/DSView/pv/ui/string_ids.h b/DSView/src/uicore/lang_page_ids.h similarity index 86% rename from DSView/pv/ui/string_ids.h rename to DSView/src/uicore/lang_page_ids.h index 2fdd88199..2175e533a 100644 --- a/DSView/pv/ui/string_ids.h +++ b/DSView/src/uicore/lang_page_ids.h @@ -2,7 +2,7 @@ * This file is part of the DSView project. * DSView is based on PulseView. * - * Copyright (C) 2022 DreamSourceLab + * Copyright (C) 2023 DreamSourceLab * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,14 +19,17 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef STRING_IDS_H -#define STRING_IDS_H +#ifndef LANG_PAGE_IDS_H +#define LANG_PAGE_IDS_H +/** + * Language resource page code. +*/ #define STR_PAGE_MSG 1 #define STR_PAGE_TOOLBAR 2 #define STR_PAGE_DLG 3 #define STR_PAGE_DSL 100 #define STR_PAGE_DECODER 101 -#define IDS_MSG_LOG_LEVEL + #endif \ No newline at end of file diff --git a/DSView/src/uicore/langitemlist.cpp b/DSView/src/uicore/langitemlist.cpp new file mode 100644 index 000000000..4f9a64036 --- /dev/null +++ b/DSView/src/uicore/langitemlist.cpp @@ -0,0 +1,84 @@ +/* + * This file is part of the DSView project. + * DSView is based on PulseView. + * + * Copyright (C) 2023 DreamSourceLab + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "langitemlist.h" +#include +#include "langresource.h" + +LangItemList::LangItemList() +{ + +} + +LangItemList::~LangItemList() +{ + Clear(); +} + +void LangItemList::Clear() +{ + for(auto it = m_items.begin(); it != m_items.end(); it++) + { + delete (*it).setter; + } + m_items.clear(); +} + +void LangItemList::AddItem(int page_id, const char *key_id, const char *defaultStr, ILangSetter *setter) +{ + assert(key_id); + assert(defaultStr); + assert(setter); + + LangItemInfo item = {page_id, key_id, defaultStr, setter}; + m_items.push_back(item); +} + +void LangItemList::RemoveItemBySetterHandle(void *setterHandle) +{ + assert(setterHandle); + + for(auto it = m_items.begin(); it != m_items.end(); it++) + { + if ((*it).setter->GetControlHandle() == setterHandle){ + m_items.erase(it); + break; + } + } +} + +void LangItemList::LoadAllText() +{ + for(auto it = m_items.begin(); it != m_items.end(); it++) + { + int page_id = (*it).lang_page_id; + const char *key_id = (*it).key_id; + const char *def_str = (*it).default_str; + ILangSetter *setter = (*it).setter; + + const char *str = LangResource::Instance()->get_lang_text(page_id, key_id, def_str); + if (str == NULL){ + str = def_str; + } + + setter->SetLangText(str); + } +} \ No newline at end of file diff --git a/DSView/dsapplication.h b/DSView/src/uicore/langitemlist.h similarity index 57% rename from DSView/dsapplication.h rename to DSView/src/uicore/langitemlist.h index 7e8047456..1a3346f2a 100644 --- a/DSView/dsapplication.h +++ b/DSView/src/uicore/langitemlist.h @@ -2,7 +2,7 @@ * This file is part of the DSView project. * DSView is based on PulseView. * - * Copyright (C) 2016 DreamSourceLab + * Copyright (C) 2023 DreamSourceLab * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,19 +19,37 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef DSVIEW_DSAPPLICATION_H -#define DSVIEW_DSAPPLICATION_H +#ifndef LANG_ITEM_LIST_H +#define LANG_ITEM_LIST_H -#include -#include +#include +#include "uitypes.h" +#include "lang_page_ids.h" -class DSApplication : public QApplication +struct LangItemInfo +{ + int lang_page_id; + const char *key_id; + const char *default_str; + ILangSetter *setter; +}; + +class LangItemList { public: - DSApplication(int &argc, char ** argv); - // ~MyApplication(); + LangItemList(); + ~LangItemList(); + + void Clear(); + + void AddItem(int page_id, const char *key_id, const char *defaultStr, ILangSetter *setter); + + void RemoveItemBySetterHandle(void *setterHandle); + + void LoadAllText(); + private: - bool notify(QObject *receiver_, QEvent *event_); + std::vector m_items; }; -#endif // DSVIEW_DSAPPLICATION_H +#endif \ No newline at end of file diff --git a/DSView/pv/ui/langresource.cpp b/DSView/src/uicore/langresource.cpp similarity index 98% rename from DSView/pv/ui/langresource.cpp rename to DSView/src/uicore/langresource.cpp index 957e3ac18..6935a99e0 100644 --- a/DSView/pv/ui/langresource.cpp +++ b/DSView/src/uicore/langresource.cpp @@ -21,8 +21,6 @@ #include "langresource.h" #include -#include "../log.h" -#include "../config/appconfig.h" #include #include #include @@ -30,6 +28,10 @@ #include #include #include +#include "../log.h" +#include "../config/appconfig.h" + +using namespace dsv::config; //---------------Lang_resource_page Lang_resource_page::Lang_resource_page() @@ -149,7 +151,7 @@ void LangResource::load_page(Lang_resource_page &p) QStringList files = fileNmae.split(","); for (int x=0; x #include #include -#include "string_ids.h" #include +#include "lang_page_ids.h" struct lang_key_item { diff --git a/DSView/pv/view/selectableitem.cpp b/DSView/src/uicore/uitypes.h similarity index 54% rename from DSView/pv/view/selectableitem.cpp rename to DSView/src/uicore/uitypes.h index ed23e2ff7..fe3f90688 100644 --- a/DSView/pv/view/selectableitem.cpp +++ b/DSView/src/uicore/uitypes.h @@ -2,8 +2,7 @@ * This file is part of the DSView project. * DSView is based on PulseView. * - * Copyright (C) 2013 Joel Holdsworth - * Copyright (C) 2014 DreamSourceLab + * Copyright (C) 2023 DreamSourceLab * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,38 +19,37 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "selectableitem.h" - -#include -#include -#include +#ifndef UICORE_UI_TYPES_H +#define UICORE_UI_TYPES_H -namespace pv { -namespace view { - -const int SelectableItem::HighlightRadius = 6; - -SelectableItem::SelectableItem() : - _selected(false) +class ILangSetter { -} +public: + virtual void SetLangText(const char *szText)=0; + virtual void* GetControlHandle()=0; +}; -bool SelectableItem::selected() +class ILangForm { - return _selected; -} +public: + virtual void LoadLangText()=0; +}; -void SelectableItem::select(bool select) +class IFontForm { - _selected = select; -} +public: + virtual void UpdateFont()=0; +}; -QPen SelectableItem::highlight_pen() +class IMainForm { - return QPen(QApplication::palette().brush( - QPalette::Highlight), HighlightRadius, - Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); -} - -} // namespace view -} // namespace pv +public: + virtual void SwitchLanguage(int language)=0; + virtual void AddLangForm(ILangForm *form)=0; + virtual void RemoveLangForm(ILangForm *form)=0; + virtual void AddFontForm(IFontForm *form)=0; + virtual void RemoveFontForm(IFontForm *form)=0; + virtual void UpdateAllFontForm()=0; +}; + +#endif \ No newline at end of file diff --git a/DSView/pv/utility/array.cpp b/DSView/src/utility/array.cpp similarity index 99% rename from DSView/pv/utility/array.cpp rename to DSView/src/utility/array.cpp index 87513c37e..866a462a5 100644 --- a/DSView/pv/utility/array.cpp +++ b/DSView/src/utility/array.cpp @@ -21,7 +21,7 @@ #include "array.h" #include -namespace pv +namespace dsv { namespace array { diff --git a/DSView/pv/utility/array.h b/DSView/src/utility/array.h similarity index 98% rename from DSView/pv/utility/array.h rename to DSView/src/utility/array.h index 681c0624b..39b92b44f 100644 --- a/DSView/pv/utility/array.h +++ b/DSView/src/utility/array.h @@ -24,7 +24,7 @@ #include -namespace pv +namespace dsv { namespace array { diff --git a/DSView/pv/utility/encoding.cpp b/DSView/src/utility/encoding.cpp similarity index 98% rename from DSView/pv/utility/encoding.cpp rename to DSView/src/utility/encoding.cpp index a891f8c6f..d0670c8e9 100644 --- a/DSView/pv/utility/encoding.cpp +++ b/DSView/src/utility/encoding.cpp @@ -32,7 +32,7 @@ #include #endif -namespace pv{ +namespace dsv{ namespace encoding{ void init() diff --git a/DSView/pv/utility/encoding.h b/DSView/src/utility/encoding.h similarity index 98% rename from DSView/pv/utility/encoding.h rename to DSView/src/utility/encoding.h index 158714f26..21ea60139 100644 --- a/DSView/pv/utility/encoding.h +++ b/DSView/src/utility/encoding.h @@ -24,7 +24,7 @@ class QTextStream; -namespace pv{ +namespace dsv{ namespace encoding{ void init(); diff --git a/DSView/pv/utility/path.cpp b/DSView/src/utility/path.cpp similarity index 99% rename from DSView/pv/utility/path.cpp rename to DSView/src/utility/path.cpp index 7ca423224..ecf54a7b8 100644 --- a/DSView/pv/utility/path.cpp +++ b/DSView/src/utility/path.cpp @@ -26,7 +26,7 @@ #include #endif -namespace pv{ +namespace dsv{ namespace path{ std::string ConvertPath(QString fileName) diff --git a/DSView/pv/utility/path.h b/DSView/src/utility/path.h similarity index 98% rename from DSView/pv/utility/path.h rename to DSView/src/utility/path.h index f5841f292..7c08586b8 100644 --- a/DSView/pv/utility/path.h +++ b/DSView/src/utility/path.h @@ -25,7 +25,7 @@ #include #include -namespace pv{ +namespace dsv{ namespace path{ std::string ConvertPath(QString fileName); diff --git a/DSView/pv/view/analogsignal.cpp b/DSView/src/view/analogsignal.cpp similarity index 97% rename from DSView/pv/view/analogsignal.cpp rename to DSView/src/view/analogsignal.cpp index 39f7faa6a..7ca3e7c32 100644 --- a/DSView/pv/view/analogsignal.cpp +++ b/DSView/src/view/analogsignal.cpp @@ -20,18 +20,19 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "analogsignal.h" #include -#include "../view/analogsignal.h" #include "../data/analogsnapshot.h" -#include "../view/view.h" -#include "../dsvdef.h" +#include "view.h" +#include "../basedef.h" #include "../log.h" +#include "../appcore/sigsession.h" using namespace std; #define byte(x) uint##x##_t -namespace pv { +namespace dsv { namespace view { const QColor AnalogSignal::SignalColours[4] = { @@ -83,7 +84,7 @@ AnalogSignal::AnalogSignal(data::AnalogSnapshot *data, sr_channel *probe) : } } -AnalogSignal::AnalogSignal(view::AnalogSignal *s, pv::data::AnalogSnapshot *data, sr_channel *probe) : +AnalogSignal::AnalogSignal(view::AnalogSignal *s, dsv::data::AnalogSnapshot *data, sr_channel *probe) : Signal(*s, probe), _data(data), _rects(NULL), @@ -464,7 +465,7 @@ void AnalogSignal::paint_fore(QPainter &p, int left, int right, QColor fore, QCo } void AnalogSignal::paint_trace(QPainter &p, - const pv::data::AnalogSnapshot *snapshot, + const dsv::data::AnalogSnapshot *snapshot, int zeroY, const int start_pixel, const uint64_t start_index, const int64_t sample_count, const double samples_per_pixel, const int order, @@ -472,7 +473,7 @@ void AnalogSignal::paint_trace(QPainter &p, { (void)width; - pv::data::AnalogSnapshot *pshot = const_cast(snapshot); + dsv::data::AnalogSnapshot *pshot = const_cast(snapshot); int64_t channel_num = (int64_t)pshot->get_channel_num(); if (sample_count > 0) { @@ -510,15 +511,15 @@ void AnalogSignal::paint_trace(QPainter &p, } void AnalogSignal::paint_envelope(QPainter &p, - const pv::data::AnalogSnapshot *snapshot, + const dsv::data::AnalogSnapshot *snapshot, int zeroY, const int start_pixel, const uint64_t start_index, const int64_t sample_count, const double samples_per_pixel, const int order, const float top, const float bottom, const int width) { using namespace Qt; - using pv::data::AnalogSnapshot; - pv::data::AnalogSnapshot *pshot = const_cast(snapshot); + using dsv::data::AnalogSnapshot; + dsv::data::AnalogSnapshot *pshot = const_cast(snapshot); AnalogSnapshot::EnvelopeSection e; pshot->get_envelope_section(e, start_index, sample_count, @@ -668,4 +669,4 @@ void AnalogSignal::set_data(data::AnalogSnapshot *data) } } // namespace view -} // namespace pv +} // namespace dsv diff --git a/DSView/pv/view/analogsignal.h b/DSView/src/view/analogsignal.h similarity index 94% rename from DSView/pv/view/analogsignal.h rename to DSView/src/view/analogsignal.h index 7ae93f6aa..0fbe1515e 100644 --- a/DSView/pv/view/analogsignal.h +++ b/DSView/src/view/analogsignal.h @@ -24,18 +24,18 @@ #define DSVIEW_PV_ANALOGSIGNAL_H #include "signal.h" - -namespace pv { - -namespace data { -class AnalogSnapshot; +namespace dsv{ + namespace data { + class AnalogSnapshot; + } } +using namespace dsv::data; +namespace dsv { namespace view { //when device is data acquisition model, to draw signal trace -//created by SigSession class AnalogSignal : public Signal { Q_OBJECT @@ -147,14 +147,14 @@ class AnalogSignal : public Signal private: void paint_trace(QPainter &p, - const pv::data::AnalogSnapshot *snapshot, + const dsv::data::AnalogSnapshot *snapshot, int zeroY, const int start_pixel, const uint64_t start_index, const int64_t sample_count, const double samples_per_pixel, const int order, const float top, const float bottom, const int width); void paint_envelope(QPainter &p, - const pv::data::AnalogSnapshot *snapshot, + const dsv::data::AnalogSnapshot *snapshot, int zeroY, const int start_pixel, const uint64_t start_index, const int64_t sample_count, const double samples_per_pixel, const int order, @@ -163,17 +163,14 @@ class AnalogSignal : public Signal void paint_hover_measure(QPainter &p, QColor fore, QColor back); private: - pv::data::AnalogSnapshot *_data; - + AnalogSnapshot *_data; QRectF *_rects; - float _scale; double _zero_vrate; int _zero_offset; int _bits; double _ref_min; double _ref_max; - bool _hover_en; uint64_t _hover_index; QPointF _hover_point; @@ -181,6 +178,6 @@ class AnalogSignal : public Signal }; } // namespace view -} // namespace pv +} // namespace dsv #endif // DSVIEW_PV_ANALOGSIGNAL_H diff --git a/DSView/pv/view/cursor.cpp b/DSView/src/view/cursor.cpp similarity index 97% rename from DSView/pv/view/cursor.cpp rename to DSView/src/view/cursor.cpp index e9a11af58..67d18d66e 100644 --- a/DSView/pv/view/cursor.cpp +++ b/DSView/src/view/cursor.cpp @@ -21,10 +21,6 @@ */ #include "cursor.h" - -#include "ruler.h" -#include "view.h" - #include #include #include @@ -32,9 +28,12 @@ #include #include #include -#include "../dsvdef.h" +#include "ruler.h" +#include "view.h" +#include "../basedef.h" +#include "../appcore/sigsession.h" -namespace pv { +namespace dsv { namespace view { const QColor Cursor::LineColour(32, 74, 135); @@ -86,7 +85,7 @@ void Cursor::paint_label(QPainter &p, const QRect &rect, { assert(index > 0); - using pv::view::Ruler; + using dsv::view::Ruler; bool visible; compute_text_size(p, prefix); @@ -130,7 +129,7 @@ void Cursor::paint_label(QPainter &p, const QRect &rect, void Cursor::paint_fix_label(QPainter &p, const QRect &rect, unsigned int prefix, QChar label, QColor color, bool has_hoff) { - using pv::view::Ruler; + using dsv::view::Ruler; bool visible; compute_text_size(p, prefix); @@ -166,4 +165,4 @@ void Cursor::compute_text_size(QPainter &p, unsigned int prefix) } } // namespace view -} // namespace pv +} // namespace dsv diff --git a/DSView/pv/view/cursor.h b/DSView/src/view/cursor.h similarity index 98% rename from DSView/pv/view/cursor.h rename to DSView/src/view/cursor.h index b01f53c2a..8b273dbe2 100644 --- a/DSView/pv/view/cursor.h +++ b/DSView/src/view/cursor.h @@ -24,14 +24,13 @@ #ifndef DSVIEW_PV_VIEW_CURSOR_H #define DSVIEW_PV_VIEW_CURSOR_H -#include "timemarker.h" - #include #include +#include "timemarker.h" class QPainter; -namespace pv { +namespace dsv { namespace view { //created by View @@ -101,6 +100,6 @@ class Cursor : public TimeMarker }; } // namespace view -} // namespace pv +} // namespace dsv #endif // DSVIEW_PV_VIEW_CURSOR_H diff --git a/DSView/pv/view/decodetrace.cpp b/DSView/src/view/decodetrace.cpp similarity index 95% rename from DSView/pv/view/decodetrace.cpp rename to DSView/src/view/decodetrace.cpp index 49dddf108..047b2083b 100644 --- a/DSView/pv/view/decodetrace.cpp +++ b/DSView/src/view/decodetrace.cpp @@ -20,8 +20,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "decodetrace.h" #include -#include "../dsvdef.h" #include #include #include @@ -32,31 +32,30 @@ #include #include #include -#include "decodetrace.h" -#include "../sigsession.h" +#include "logicsignal.h" +#include "view.h" +#include "cursor.h" +#include "../appcore/sigsession.h" #include "../data/decoderstack.h" -#include "../data/decode/decoder.h" +#include "../decode/decoder.h" #include "../data/logicsnapshot.h" -#include "../data/decode/annotation.h" -#include "../view/logicsignal.h" -#include "../view/view.h" +#include "../decode/annotation.h" #include "../widgets/decodergroupbox.h" #include "../widgets/decodermenu.h" -#include "../view/cursor.h" #include "../toolbars/titlebar.h" -#include "../dsvdef.h" #include "../ui/dscombobox.h" #include "../ui/msgbox.h" -#include "../appcontrol.h" +#include "../appcore/appcontrol.h" #include "../dialogs/decoderoptionsdlg.h" -#include "../ui/langresource.h" +#include "../uicore/langresource.h" #include "../config/appconfig.h" #include "../log.h" +#include "../basedef.h" using namespace boost; using namespace std; -namespace pv { +namespace dsv { namespace view { const QColor DecodeTrace::DecodeColours[4] = { @@ -114,8 +113,8 @@ const QColor DecodeTrace::OutlineColours[16] = { const QString DecodeTrace::RegionStart = QT_TR_NOOP("Start"); const QString DecodeTrace::RegionEnd = QT_TR_NOOP("End "); -DecodeTrace::DecodeTrace(pv::SigSession *session, - pv::data::DecoderStack *decoder_stack, int index) : +DecodeTrace::DecodeTrace(SigSession *session, + DecoderStack *decoder_stack, int index) : Trace(QString::fromUtf8(decoder_stack->stack().front()->decoder()->name), index, SR_CHANNEL_DECODER) { assert(decoder_stack); @@ -147,7 +146,7 @@ bool DecodeTrace::enabled() return true; } -void DecodeTrace::set_view(pv::view::View *view) +void DecodeTrace::set_view(View *view) { assert(view); Trace::set_view(view); @@ -215,9 +214,7 @@ void DecodeTrace::paint_back(QPainter &p, int left, int right, QColor fore, QCol } void DecodeTrace::paint_mid(QPainter &p, int left, int right, QColor fore, QColor back) -{ - using namespace pv::data::decode; - +{ assert(_decoder_stack); const QString err = _decoder_stack->error_message(); if (!err.isEmpty()) @@ -263,8 +260,8 @@ void DecodeTrace::paint_mid(QPainter &p, int left, int right, QColor fore, QColo for(auto dec :_decoder_stack->stack()) { if (dec->shown()) { - const std::map rows = _decoder_stack->get_rows_gshow(); - for (std::map::const_iterator i = rows.begin(); + const std::map rows = _decoder_stack->get_rows_gshow(); + for (std::map::const_iterator i = rows.begin(); i != rows.end(); i++) { if ((*i).first.decoder() == dec->decoder() && _decoder_stack->has_annotations((*i).first)) { @@ -315,9 +312,7 @@ void DecodeTrace::paint_mid(QPainter &p, int left, int right, QColor fore, QColo } void DecodeTrace::paint_fore(QPainter &p, int left, int right, QColor fore, QColor back) -{ - using namespace pv::data::decode; - +{ (void)p; (void)left; (void)right; @@ -325,7 +320,7 @@ void DecodeTrace::paint_fore(QPainter &p, int left, int right, QColor fore, QCol (void)back; } -void DecodeTrace::draw_annotation(const pv::data::decode::Annotation &a, +void DecodeTrace::draw_annotation(const Annotation &a, QPainter &p, QColor text_color, int h, int left, int right, double samples_per_pixel, double pixels_offset, int y, size_t base_colour, double min_annWidth, QColor fore, QColor back, double &last_x) @@ -423,7 +418,7 @@ void DecodeTrace::draw_nodetail(QPainter &p, p.drawText(nodetail_rect, Qt::AlignCenter | Qt::AlignVCenter, info); } -void DecodeTrace::draw_instant(const pv::data::decode::Annotation &a, QPainter &p, +void DecodeTrace::draw_instant(const Annotation &a, QPainter &p, QColor fill, QColor outline, QColor text_color, int h, double x, int y, double min_annWidth) { (void)outline; @@ -444,7 +439,7 @@ void DecodeTrace::draw_instant(const pv::data::decode::Annotation &a, QPainter & p.drawText(rect, Qt::AlignCenter | Qt::AlignVCenter, text); } -void DecodeTrace::draw_range(const pv::data::decode::Annotation &a, QPainter &p, +void DecodeTrace::draw_range(const Annotation &a, QPainter &p, QColor fill, QColor outline, QColor text_color, int h, double start, double end, int y, QColor fore, QColor back) { @@ -567,8 +562,7 @@ void DecodeTrace::on_decode_done() } int DecodeTrace::rows_size() -{ - using pv::data::decode::Decoder; +{ int size = 0; for(auto dec : _decoder_stack->stack()) { @@ -576,7 +570,7 @@ int DecodeTrace::rows_size() auto rows = _decoder_stack->get_rows_gshow(); for (auto i = rows.begin(); i != rows.end(); i++) { - pv::data::decode::Row _row = (*i).first; + Row _row = (*i).first; if (_row.decoder() == dec->decoder() && _decoder_stack->has_annotations((*i).first) && (*i).second) @@ -703,4 +697,4 @@ bool DecodeTrace::create_popup(bool isnew) } } // namespace view -} // namespace pv +} // namespace dsv diff --git a/DSView/pv/view/decodetrace.h b/DSView/src/view/decodetrace.h similarity index 85% rename from DSView/pv/view/decodetrace.h rename to DSView/src/view/decodetrace.h index 29ebe571d..bed366508 100644 --- a/DSView/pv/view/decodetrace.h +++ b/DSView/src/view/decodetrace.h @@ -30,30 +30,32 @@ #include #include #include - #include "trace.h" #include "../prop/binding/decoderoptions.h" #include "../dialogs/dsdialog.h" struct srd_channel; -struct srd_decoder; - +struct srd_decoder; class DsComboBox; -namespace pv { - -class SigSession; - -namespace data { -class DecoderStack; - -namespace decode { -class Annotation; -class Decoder; -class Row; -} +namespace dsv{ + namespace appcore{ + class SigSession; + } + namespace data { + class DecoderStack; + } + namespace decode { + class Annotation; + class Decoder; + class Row; + } } +using namespace dsv::appcore; +using namespace dsv::data; +using namespace dsv::decode; +namespace dsv { namespace view { //create by SigSession @@ -86,21 +88,21 @@ class DecodeTrace : public Trace static const QString RegionEnd; public: - DecodeTrace(pv::SigSession *session, - pv::data::DecoderStack *decoder_stack, - int index); + DecodeTrace(SigSession *session, + DecoderStack *decoder_stack, + int index); public: ~DecodeTrace(); bool enabled(); - inline pv::data::DecoderStack* decoder() + inline DecoderStack* decoder() { return _decoder_stack; } - void set_view(pv::view::View *view); + void set_view(View *view); /** * Paints the background layer of the trace with a QPainter @@ -146,7 +148,7 @@ class DecodeTrace : public Trace private: - void draw_annotation(const pv::data::decode::Annotation &a, QPainter &p, + void draw_annotation(const Annotation &a, QPainter &p, QColor text_colour, int text_height, int left, int right, double samples_per_pixel, double pixels_offset, int y, size_t base_colour, double min_annWidth, QColor fore, QColor back, double &last_x); @@ -155,11 +157,11 @@ class DecodeTrace : public Trace int text_height, int left, int right, int y, size_t base_colour, QColor fore, QColor back); - void draw_instant(const pv::data::decode::Annotation &a, QPainter &p, + void draw_instant(const Annotation &a, QPainter &p, QColor fill, QColor outline, QColor text_color, int h, double x, int y, double min_annWidth); - void draw_range(const pv::data::decode::Annotation &a, QPainter &p, + void draw_range(const Annotation &a, QPainter &p, QColor fill, QColor outline, QColor text_color, int h, double start, double end, int y, QColor fore, QColor back); @@ -182,20 +184,16 @@ private slots: volatile bool _delete_flag; //destroy it when deocde task end private: - pv::SigSession *_session; - pv::data::DecoderStack *_decoder_stack; - + SigSession *_session; + DecoderStack *_decoder_stack; uint64_t _decode_start; - uint64_t _decode_end; - + uint64_t _decode_end; uint64_t _decode_cursor1; // the cursor key, sample start index - uint64_t _decode_cursor2; - + uint64_t _decode_cursor2; std::vector _cur_row_headings; - }; } // namespace view -} // namespace pv +} // namespace dsv #endif // DSVIEW_PV_VIEW_DECODETRACE_H diff --git a/DSView/pv/view/devmode.cpp b/DSView/src/view/devmode.cpp similarity index 95% rename from DSView/pv/view/devmode.cpp rename to DSView/src/view/devmode.cpp index 015936f3b..7a58c70b5 100644 --- a/DSView/pv/view/devmode.cpp +++ b/DSView/src/view/devmode.cpp @@ -20,24 +20,26 @@ */ #include "devmode.h" -#include "view.h" -#include "trace.h" -#include "../sigsession.h" - #include #include #include #include #include #include - +#include "view.h" +#include "trace.h" +#include "../appcore/sigsession.h" #include "../config/appconfig.h" #include "../ui/msgbox.h" #include "../log.h" -#include "../ui/langresource.h" -#include "../appcontrol.h" +#include "../uicore/langresource.h" +#include "../appcore/appcontrol.h" #include "../ui/fn.h" +using namespace dsv::config; + +namespace dsv { +namespace view { static const struct dev_mode_name dev_mode_name_list[] = { @@ -45,9 +47,6 @@ static const struct dev_mode_name dev_mode_name_list[] = {ANALOG, "daq.svg"}, {DSO, "osc.svg"}, }; - -namespace pv { -namespace view { DevMode::DevMode(QWidget *parent, SigSession *session) : QWidget(parent) @@ -90,7 +89,7 @@ DevMode::DevMode(QWidget *parent, SigSession *session) : layout->setStretch(1, 100); setLayout(layout); - update_font(); + UpdateFont(); connect(_close_button, SIGNAL(clicked()), this, SLOT(on_close())); } @@ -126,7 +125,7 @@ void DevMode::set_device() _close_button->setIcon(QIcon()); _close_button->setDisabled(true); - QString iconPath = GetIconPath() + "/"; + QString iconPath = AppConfig::GetIconPath() + "/"; auto dev_mode_list = _device_agent->get_device_mode_list(); for (const GSList *l = dev_mode_list; l; l = l->next) @@ -173,13 +172,13 @@ void DevMode::set_device() _bFile = true; } - update_font(); + UpdateFont(); update(); } void DevMode::paintEvent(QPaintEvent*) { - using pv::view::Trace; + using dsv::view::Trace; QStyleOption o; o.initFrom(this); @@ -199,7 +198,7 @@ void DevMode::on_mode_change() return; } - QString iconPath = GetIconPath(); + QString iconPath = AppConfig::GetIconPath(); for(auto i = _mode_list.begin();i != _mode_list.end(); i++) { @@ -232,7 +231,7 @@ void DevMode::on_mode_change() } } - update_font(); + UpdateFont(); } void DevMode::on_close() @@ -280,7 +279,7 @@ const struct dev_mode_name* DevMode::get_mode_name(int mode) assert(false); } -void DevMode::update_font() +void DevMode::UpdateFont() { QFont font = this->font(); font.setPointSizeF(AppConfig::Instance().appOptions.fontSize); @@ -298,4 +297,4 @@ void DevMode::update_font() } } // namespace view -} // namespace pv +} // namespace dsv diff --git a/DSView/pv/view/devmode.h b/DSView/src/view/devmode.h similarity index 87% rename from DSView/pv/view/devmode.h rename to DSView/src/view/devmode.h index 319fceefd..b64df43ca 100644 --- a/DSView/pv/view/devmode.h +++ b/DSView/src/view/devmode.h @@ -33,21 +33,24 @@ #include #include #include - #include "../interface/icallbacks.h" +#include "../uicore/uitypes.h" + +namespace dsv{ + namespace appcore{ + class SigSession; + class DeviceAgent; + } +} +using namespace dsv::appcore; + +namespace dsv { +namespace view { struct dev_mode_name{ int _mode; const char *_logo; }; - -class DeviceAgent; - -namespace pv { - -class SigSession; - -namespace view { //devece work mode select list class DevMode : public QWidget, public IFontForm @@ -62,26 +65,20 @@ class DevMode : public QWidget, public IFontForm private: void paintEvent(QPaintEvent *event); - -private: void mousePressEvent(QMouseEvent * event); void mouseReleaseEvent(QMouseEvent *event); void mouseMoveEvent(QMouseEvent *event); void leaveEvent(QEvent *event); void changeEvent(QEvent *event); - const dev_mode_name* get_mode_name(int mode); + const struct dev_mode_name* get_mode_name(int mode); //IFontForm - void update_font() override; + void UpdateFont() override; public slots: void set_device(); void on_mode_change(); - void on_close(); - -private slots: - - + void on_close(); private: SigSession *_session; @@ -96,6 +93,6 @@ private slots: }; } // namespace view -} // namespace pv +} // namespace dsv #endif // DSVIEW_PV_VIEW_DEVMODE_H diff --git a/DSView/pv/view/dsldial.cpp b/DSView/src/view/dsldial.cpp similarity index 99% rename from DSView/pv/view/dsldial.cpp rename to DSView/src/view/dsldial.cpp index 3ac842f1e..b17806b6b 100644 --- a/DSView/pv/view/dsldial.cpp +++ b/DSView/src/view/dsldial.cpp @@ -24,7 +24,7 @@ #include #include -namespace pv { +namespace dsv { namespace view { dslDial::dslDial(const uint64_t div, const uint64_t step, @@ -185,4 +185,4 @@ uint64_t dslDial::get_factor() } } // namespace view -} // namespace pv +} // namespace dsv diff --git a/DSView/pv/view/dsldial.h b/DSView/src/view/dsldial.h similarity index 98% rename from DSView/pv/view/dsldial.h rename to DSView/src/view/dsldial.h index 6379bb7fd..3c0a53105 100644 --- a/DSView/pv/view/dsldial.h +++ b/DSView/src/view/dsldial.h @@ -26,7 +26,7 @@ #include #include -namespace pv { +namespace dsv { namespace view { //when device is oscilloscope model, to draw the dail on the left @@ -79,6 +79,6 @@ class dslDial : public QObject }; } // namespace view -} // namespace pv +} // namespace dsv #endif // DSVIEW_PV_VIEW_DSLDIAL_H diff --git a/DSView/pv/view/dsosignal.cpp b/DSView/src/view/dsosignal.cpp similarity index 99% rename from DSView/pv/view/dsosignal.cpp rename to DSView/src/view/dsosignal.cpp index 1ac02efcd..39299edae 100644 --- a/DSView/pv/view/dsosignal.cpp +++ b/DSView/src/view/dsosignal.cpp @@ -24,17 +24,16 @@ #include #include #include - #include "view.h" -#include "../dsvdef.h" +#include "../basedef.h" #include "../data/dsosnapshot.h" -#include "../sigsession.h" +#include "../appcore/sigsession.h" #include "../log.h" -#include "../appcontrol.h" +#include "../appcore/appcontrol.h" using namespace std; -namespace pv { +namespace dsv { namespace view { const QString DsoSignal::vDialUnit[DsoSignal::vDialUnitCount] = { @@ -962,7 +961,7 @@ QRectF DsoSignal::get_trig_rect(int left, int right) } void DsoSignal::paint_trace(QPainter &p, - const pv::data::DsoSnapshot *snapshot, + const dsv::data::DsoSnapshot *snapshot, int zeroY, int left, const int64_t start, const int64_t end, int hw_offset, const double pixels_offset, const double samples_per_pixel, uint64_t num_channels) { @@ -971,7 +970,7 @@ void DsoSignal::paint_trace(QPainter &p, const int64_t sample_count = end - start + 1; if (sample_count > 0) { - pv::data::DsoSnapshot *pshot = const_cast(snapshot); + dsv::data::DsoSnapshot *pshot = const_cast(snapshot); const uint8_t *const samples_buffer = pshot->get_samples(start, end, get_index());; assert(samples_buffer); @@ -1012,12 +1011,12 @@ void DsoSignal::paint_trace(QPainter &p, } void DsoSignal::paint_envelope(QPainter &p, - const pv::data::DsoSnapshot *snapshot, + const dsv::data::DsoSnapshot *snapshot, int zeroY, int left, const int64_t start, const int64_t end, int hw_offset, const double pixels_offset, const double samples_per_pixel, uint64_t num_channels) { using namespace Qt; - using pv::data::DsoSnapshot; + using dsv::data::DsoSnapshot; data::DsoSnapshot *pshot = const_cast(snapshot); @@ -1550,4 +1549,4 @@ void DsoSignal::set_data(data::DsoSnapshot *data) } } // namespace view -} // namespace pv +} // namespace dsv diff --git a/DSView/pv/view/dsosignal.h b/DSView/src/view/dsosignal.h similarity index 96% rename from DSView/pv/view/dsosignal.h rename to DSView/src/view/dsosignal.h index 660c9bb7e..e64caceca 100644 --- a/DSView/pv/view/dsosignal.h +++ b/DSView/src/view/dsosignal.h @@ -24,11 +24,14 @@ #define DSVIEW_PV_DSOSIGNAL_H #include "signal.h" -#include "../dstimer.h" +#include "../com/dstimer.h" + +using namespace dsv::com; -namespace pv { +namespace dsv { + namespace data { -class DsoSnapshot; + class DsoSnapshot; } namespace view { @@ -82,7 +85,7 @@ class DsoSignal : public Signal static const uint16_t MS_RectHeight = 25; public: - DsoSignal(pv::data::DsoSnapshot *data, + DsoSignal(dsv::data::DsoSnapshot *data, sr_channel *probe); virtual ~DsoSignal(); @@ -248,13 +251,13 @@ class DsoSignal : public Signal private: void paint_trace(QPainter &p, - const pv::data::DsoSnapshot* snapshot, + const dsv::data::DsoSnapshot* snapshot, int zeroY, int left, const int64_t start, const int64_t end, int hw_offset, const double pixels_offset, const double samples_per_pixel, uint64_t num_channels); void paint_envelope(QPainter &p, - const pv::data::DsoSnapshot *snapshot, + const dsv::data::DsoSnapshot *snapshot, int zeroY, int left, const int64_t start, const int64_t end, int hw_offset, const double pixels_offset, const double samples_per_pixel, uint64_t num_channels); @@ -265,7 +268,7 @@ class DsoSignal : public Signal void call_auto_end(); private: - pv::data::DsoSnapshot *_data; + dsv::data::DsoSnapshot *_data; float _scale; float _stop_scale = 1; bool _en_lock; @@ -310,6 +313,6 @@ class DsoSignal : public Signal }; } // namespace view -} // namespace pv +} // namespace dsv #endif // DSVIEW_PV_DSOSIGNAL_H diff --git a/DSView/pv/view/groupsignal.cpp b/DSView/src/view/groupsignal.cpp similarity index 95% rename from DSView/pv/view/groupsignal.cpp rename to DSView/src/view/groupsignal.cpp index ac8458e99..22eb74e47 100644 --- a/DSView/pv/view/groupsignal.cpp +++ b/DSView/src/view/groupsignal.cpp @@ -20,14 +20,14 @@ */ /* -#include "../dsvdef.h" +#include "../basedef.h" #include "groupsignal.h" #include "view.h" #include using namespace std; -namespace pv { +namespace dsv { namespace view { const QColor GroupSignal::SignalColours[4] = { @@ -56,7 +56,7 @@ bool GroupSignal::enabled() return true; } -pv::data::SignalData* GroupSignal::data() +dsv::data::SignalData* GroupSignal::data() { return NULL; } @@ -95,6 +95,6 @@ QRectF GroupSignal::get_rect(GroupSetRegions type, int y, int right) } } // namespace view -} // namespace pv +} // namespace dsv */ diff --git a/DSView/pv/view/groupsignal.h b/DSView/src/view/groupsignal.h similarity index 96% rename from DSView/pv/view/groupsignal.h rename to DSView/src/view/groupsignal.h index 2984bfa72..9cf243afb 100644 --- a/DSView/pv/view/groupsignal.h +++ b/DSView/src/view/groupsignal.h @@ -28,7 +28,7 @@ #include -namespace pv { +namespace dsv { namespace view { @@ -53,7 +53,7 @@ class GroupSignal : public Trace bool enabled(); - pv::data::SignalData* data(); + dsv::data::SignalData* data(); void set_scale(float scale); @@ -78,7 +78,7 @@ class GroupSignal : public Trace }; } // namespace view -} // namespace pv +} // namespace dsv */ diff --git a/DSView/pv/view/header.cpp b/DSView/src/view/header.cpp similarity index 97% rename from DSView/pv/view/header.cpp rename to DSView/src/view/header.cpp index f94551980..4342871f7 100644 --- a/DSView/pv/view/header.cpp +++ b/DSView/src/view/header.cpp @@ -20,8 +20,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "header.h" - +#include "header.h" #include #include #include @@ -33,7 +32,6 @@ #include #include #include - #include "view.h" #include "trace.h" #include "dsosignal.h" @@ -41,16 +39,17 @@ #include "analogsignal.h" #include "groupsignal.h" #include "decodetrace.h" -#include "../sigsession.h" -#include "../dsvdef.h" -#include "../ui/langresource.h" -#include "../appcontrol.h" +#include "../appcore/sigsession.h" +#include "../basedef.h" +#include "../uicore/langresource.h" +#include "../appcore/appcontrol.h" #include "../config/appconfig.h" #include "../ui/fn.h" using namespace std; +using namespace dsv::config; -namespace pv { +namespace dsv { namespace view { Header::Header(View &parent) : @@ -95,7 +94,7 @@ int Header::get_nameEditWidth() return 0; } -pv::view::Trace* Header::get_mTrace(int &action, const QPoint &pt) +dsv::view::Trace* Header::get_mTrace(int &action, const QPoint &pt) { const int w = width(); std::vector traces; @@ -112,7 +111,7 @@ pv::view::Trace* Header::get_mTrace(int &action, const QPoint &pt) void Header::paintEvent(QPaintEvent*) { - using pv::view::Trace; + using dsv::view::Trace; QStyleOption o; o.initFrom(this); @@ -503,4 +502,4 @@ void Header::header_resize() } // namespace view -} // namespace pv +} // namespace dsv diff --git a/DSView/pv/view/header.h b/DSView/src/view/header.h similarity index 95% rename from DSView/pv/view/header.h rename to DSView/src/view/header.h index d9a9ffe67..2a832db9a 100644 --- a/DSView/pv/view/header.h +++ b/DSView/src/view/header.h @@ -26,11 +26,10 @@ #include #include - #include #include -namespace pv { +namespace dsv { namespace view { class Trace; @@ -46,7 +45,7 @@ class Header : public QWidget Header(View &parent); private: - pv::view::Trace* get_mTrace(int &action, const QPoint &pt); + dsv::view::Trace* get_mTrace(int &action, const QPoint &pt); private: void changeEvent(QEvent *event); @@ -97,6 +96,6 @@ private slots: }; } // namespace view -} // namespace pv +} // namespace dsv #endif // DSVIEW_PV_VIEW_HEADER_H diff --git a/DSView/pv/view/lissajoustrace.cpp b/DSView/src/view/lissajoustrace.cpp similarity index 97% rename from DSView/pv/view/lissajoustrace.cpp rename to DSView/src/view/lissajoustrace.cpp index cba662101..781adcd5c 100644 --- a/DSView/pv/view/lissajoustrace.cpp +++ b/DSView/src/view/lissajoustrace.cpp @@ -19,21 +19,18 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ - +#include "lissajoustrace.h" #include #include - #include "view.h" -#include "../dsvdef.h" -#include "lissajoustrace.h" +#include "../basedef.h" #include "../data/dsosnapshot.h" -#include "../sigsession.h" - -#include "../ui/langresource.h" +#include "../appcore/sigsession.h" +#include "../uicore/langresource.h" using namespace std; -namespace pv { +namespace dsv { namespace view { LissajousTrace::LissajousTrace(bool enable, @@ -173,4 +170,4 @@ void LissajousTrace::paint_label(QPainter &p, int right, const QPoint pt, QColor } } // namespace view -} // namespace pv +} // namespace dsv diff --git a/DSView/pv/view/lissajoustrace.h b/DSView/src/view/lissajoustrace.h similarity index 92% rename from DSView/pv/view/lissajoustrace.h rename to DSView/src/view/lissajoustrace.h index 27a6efd50..b3592e9c8 100644 --- a/DSView/pv/view/lissajoustrace.h +++ b/DSView/src/view/lissajoustrace.h @@ -25,7 +25,7 @@ #include "trace.h" -namespace pv { +namespace dsv { namespace data { class DsoSnapshot; @@ -43,7 +43,7 @@ class LissajousTrace : public Trace static const int DIV_NUM = 10; public: - LissajousTrace(bool enable, pv::data::DsoSnapshot *data, + LissajousTrace(bool enable, dsv::data::DsoSnapshot *data, int xIndex, int yIndex, int percent); virtual ~LissajousTrace(); @@ -68,11 +68,11 @@ class LissajousTrace : public Trace return _percent; } - inline pv::data::DsoSnapshot* get_data(){ + inline dsv::data::DsoSnapshot* get_data(){ return _data; } - inline void set_data(pv::data::DsoSnapshot* data){ + inline void set_data(dsv::data::DsoSnapshot* data){ _data = data; } @@ -107,7 +107,7 @@ class LissajousTrace : public Trace void paint_label(QPainter &p, int right, const QPoint pt, QColor fore); private: - pv::data::DsoSnapshot *_data; + dsv::data::DsoSnapshot *_data; bool _enable; int _xIndex; @@ -117,6 +117,6 @@ class LissajousTrace : public Trace }; } // namespace view -} // namespace pv +} // namespace dsv #endif // DSVIEW_PV_LISSAJOUSTRACE_H diff --git a/DSView/pv/view/logicsignal.cpp b/DSView/src/view/logicsignal.cpp similarity index 98% rename from DSView/pv/view/logicsignal.cpp rename to DSView/src/view/logicsignal.cpp index d027159bc..4867f14b5 100644 --- a/DSView/pv/view/logicsignal.cpp +++ b/DSView/src/view/logicsignal.cpp @@ -20,18 +20,18 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "logicsignal.h" #include #include -#include "logicsignal.h" -#include "view.h" #include "../data/logicsnapshot.h" #include "view.h" -#include "../dsvdef.h" +#include "../basedef.h" #include "../log.h" +#include "../appcore/sigsession.h" using namespace std; -namespace pv { +namespace dsv { namespace view { //const float LogicSignal::Oversampling = 2.0f; @@ -107,7 +107,7 @@ void LogicSignal::paint_mid_align_sample(QPainter &p, int left, int right, QColo void LogicSignal::paint_mid_align(QPainter &p, int left, int right, QColor fore, QColor back, uint64_t end_align_sample) { - using pv::view::View; + using dsv::view::View; (void)back; @@ -199,7 +199,7 @@ void LogicSignal::paint_caps(QPainter &p, QLineF *const lines, uint64_t curX = 0; uint64_t nxtX = 0; - for (std::vector::const_iterator i = + for (std::vector::const_iterator i = edges.begin(); i != (edges.end() - 1); i++) if ((*i).second == level) { curX = ((*i).first / samples_per_pixel - @@ -526,4 +526,4 @@ void LogicSignal::set_data(data::LogicSnapshot* data) } } // namespace view -} // namespace pv +} // namespace dsv diff --git a/DSView/pv/view/logicsignal.h b/DSView/src/view/logicsignal.h similarity index 86% rename from DSView/pv/view/logicsignal.h rename to DSView/src/view/logicsignal.h index d902d13a2..fbc01430c 100644 --- a/DSView/pv/view/logicsignal.h +++ b/DSView/src/view/logicsignal.h @@ -25,15 +25,20 @@ #define DSVIEW_PV_LOGICSIGNAL_H #include "signal.h" - #include -namespace pv { - -namespace data { - class LogicSnapshot; -} - +namespace dsv{ + namespace appcore{ + class SigSession; + } + namespace data { + class LogicSnapshot; + } +} +using namespace dsv::appcore; +using namespace dsv::data; + +namespace dsv { namespace view { //when device is logic analyzer mode, to draw logic signal trace @@ -61,9 +66,9 @@ class LogicSignal : public Signal }; public: - LogicSignal(data::LogicSnapshot *data, sr_channel *probe); + LogicSignal(LogicSnapshot *data, sr_channel *probe); - LogicSignal(view::LogicSignal*s, data::LogicSnapshot *data, sr_channel *probe); + LogicSignal(view::LogicSignal*s, LogicSnapshot *data, sr_channel *probe); virtual ~LogicSignal(); @@ -71,11 +76,11 @@ class LogicSignal : public Signal return _probe; } - inline data::LogicSnapshot* data(){ + inline LogicSnapshot* data(){ return _data; } - void set_data(data::LogicSnapshot* data); + void set_data(LogicSnapshot* data); inline LogicSetRegions get_trig(){ return _trig; @@ -121,14 +126,14 @@ class LogicSignal : public Signal void paint_mid_align(QPainter &p, int left, int right, QColor fore, QColor back, uint64_t end_align_sample); private: - pv::data::LogicSnapshot* _data; - std::vector< std::pair > _cur_edges; + LogicSnapshot* _data; + std::vector > _cur_edges; std::vector> _cur_pulses; LogicSetRegions _trig; uint64_t _paint_align_sample_count; }; } // namespace view -} // namespace pv +} // namespace dsv #endif // DSVIEW_PV_LOGICSIGNAL_H diff --git a/DSView/pv/view/mathtrace.cpp b/DSView/src/view/mathtrace.cpp similarity index 98% rename from DSView/pv/view/mathtrace.cpp rename to DSView/src/view/mathtrace.cpp index 5c394ec66..1d8cc5d7f 100644 --- a/DSView/pv/view/mathtrace.cpp +++ b/DSView/src/view/mathtrace.cpp @@ -26,13 +26,13 @@ #include "../data/dsosnapshot.h" #include "../data/mathstack.h" #include "view.h" -#include "../sigsession.h" -#include "../view/dsosignal.h" -#include "../dsvdef.h" +#include "../appcore/sigsession.h" +#include "dsosignal.h" +#include "../basedef.h" using namespace std; -namespace pv { +namespace dsv { namespace view { MathTrace::MathTrace(bool enable,data::MathStack *math_stack, @@ -497,11 +497,11 @@ QString MathTrace::get_time(double t) return str; } -pv::data::MathStack* MathTrace::get_math_stack() +dsv::data::MathStack* MathTrace::get_math_stack() { return _math_stack; } } // namespace view -} // namespace pv +} // namespace dsv diff --git a/DSView/pv/view/mathtrace.h b/DSView/src/view/mathtrace.h similarity index 95% rename from DSView/pv/view/mathtrace.h rename to DSView/src/view/mathtrace.h index 71218975c..ea0b1b775 100644 --- a/DSView/pv/view/mathtrace.h +++ b/DSView/src/view/mathtrace.h @@ -25,7 +25,7 @@ #include "trace.h" -namespace pv { +namespace dsv { namespace data { class DsoSnapshot; @@ -47,7 +47,7 @@ class MathTrace : public Trace }; public: - MathTrace(bool enable, pv::data::MathStack *math_stack, + MathTrace(bool enable, dsv::data::MathStack *math_stack, view::DsoSignal *dsoSig1, view::DsoSignal *dsoSig2); @@ -126,7 +126,7 @@ class MathTrace : public Trace bool mouse_wheel(int right, const QPoint pt, const int shift); - pv::data::MathStack* get_math_stack(); + dsv::data::MathStack* get_math_stack(); protected: void paint_type_options(QPainter &p, int right, const QPoint pt, QColor fore); @@ -143,7 +143,7 @@ class MathTrace : public Trace void paint_hover_measure(QPainter &p, QColor fore, QColor back); private: - pv::data::MathStack *_math_stack; + dsv::data::MathStack *_math_stack; view::DsoSignal *_dsoSig1; view::DsoSignal *_dsoSig2; bool _enable; @@ -164,6 +164,6 @@ class MathTrace : public Trace }; } // namespace view -} // namespace pv +} // namespace dsv #endif // DSVIEW_PV_MATHTRACE_H diff --git a/DSView/pv/view/ruler.cpp b/DSView/src/view/ruler.cpp similarity index 99% rename from DSView/pv/view/ruler.cpp rename to DSView/src/view/ruler.cpp index 3076275bb..0459bc49f 100644 --- a/DSView/pv/view/ruler.cpp +++ b/DSView/src/view/ruler.cpp @@ -21,31 +21,28 @@ */ #include "ruler.h" - #include "cursor.h" #include "view.h" #include "viewport.h" -#include "../sigsession.h" +#include "../appcore/sigsession.h" #include "dsosignal.h" -#include "../dsvdef.h" - +#include "../basedef.h" #include #include #include #include - #include #include #include -#include "../appcontrol.h" +#include "../appcore/appcontrol.h" #include "../config/appconfig.h" #include "../ui/fn.h" - using namespace std; using namespace Qt; +using namespace dsv::config; -namespace pv { +namespace dsv { namespace view { const int Ruler::MinorTickSubdivision = 4; @@ -751,4 +748,4 @@ double Ruler::get_min_period() } } // namespace view -} // namespace pv +} // namespace dsv diff --git a/DSView/pv/view/ruler.h b/DSView/src/view/ruler.h similarity index 98% rename from DSView/pv/view/ruler.h rename to DSView/src/view/ruler.h index 822c7d5fe..bb038e886 100644 --- a/DSView/pv/view/ruler.h +++ b/DSView/src/view/ruler.h @@ -27,7 +27,7 @@ #include #include -namespace pv { +namespace dsv { namespace view { class TimeMarker; @@ -113,6 +113,6 @@ private slots: }; } // namespace view -} // namespace pv +} // namespace dsv #endif // DSVIEW_PV_VIEW_RULER_H diff --git a/DSView/pv/view/signal.cpp b/DSView/src/view/signal.cpp similarity index 92% rename from DSView/pv/view/signal.cpp rename to DSView/src/view/signal.cpp index cbd69482a..f082f8c72 100644 --- a/DSView/pv/view/signal.cpp +++ b/DSView/src/view/signal.cpp @@ -20,15 +20,14 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ - -#include #include "signal.h" +#include #include "view.h" -#include "../dsvdef.h" -#include "../appcontrol.h" -#include "../sigsession.h" +#include "../basedef.h" +#include "../appcore/appcontrol.h" +#include "../appcore/sigsession.h" -namespace pv { +namespace dsv { namespace view { Signal::Signal(sr_channel *probe) : @@ -57,4 +56,4 @@ void Signal::set_name(QString name) _probe->name = g_strdup(name.toUtf8().data()); } } // namespace view -} // namespace pv +} // namespace dsv diff --git a/DSView/pv/view/signal.h b/DSView/src/view/signal.h similarity index 89% rename from DSView/pv/view/signal.h rename to DSView/src/view/signal.h index 464a09339..dd6897a6d 100644 --- a/DSView/pv/view/signal.h +++ b/DSView/src/view/signal.h @@ -24,27 +24,28 @@ #ifndef DSVIEW_PV_SIGNAL_H #define DSVIEW_PV_SIGNAL_H - #include #include #include #include #include - #include #include - #include #include "trace.h" -namespace pv { - -namespace data { -class SignalData; +namespace dsv{ + namespace appcore{ + class SigSession; + } + namespace data { + class SignalData; + } } +using namespace dsv::appcore; +using namespace dsv::data; -class SigSession; - +namespace dsv { namespace view { //draw signal trace base class @@ -81,6 +82,6 @@ class Signal : public Trace }; } // namespace view -} // namespace pv +} // namespace dsv #endif // DSVIEW_PV_SIGNAL_H diff --git a/DSView/pv/view/spectrumtrace.cpp b/DSView/src/view/spectrumtrace.cpp similarity index 97% rename from DSView/pv/view/spectrumtrace.cpp rename to DSView/src/view/spectrumtrace.cpp index 0deb82045..a10bf4556 100644 --- a/DSView/pv/view/spectrumtrace.cpp +++ b/DSView/src/view/spectrumtrace.cpp @@ -19,25 +19,23 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ - +#include "spectrumtrace.h" #include #include #include #include #include - -#include "spectrumtrace.h" -#include "../sigsession.h" +#include "../appcore/sigsession.h" #include "../data/dsosnapshot.h" -#include "../view/dsosignal.h" -#include "../view/viewport.h" +#include "dsosignal.h" +#include "viewport.h" #include "../data/spectrumstack.h" -#include "../dsvdef.h" +#include "../basedef.h" using namespace boost; using namespace std; -namespace pv { +namespace dsv { namespace view { const int SpectrumTrace::UpMargin = 0; @@ -67,8 +65,8 @@ const int SpectrumTrace::DbvRanges[4] = { const int SpectrumTrace::HoverPointSize = 3; const double SpectrumTrace::VerticalRate = 1.0 / 2000.0; -SpectrumTrace::SpectrumTrace(pv::SigSession *session, - pv::data::SpectrumStack *spectrum_stack, int index) : +SpectrumTrace::SpectrumTrace(SigSession *session, + SpectrumStack *spectrum_stack, int index) : Trace("FFT("+QString::number(index)+")", index, SR_CHANNEL_FFT), _session(session), _spectrum_stack(spectrum_stack), @@ -122,11 +120,6 @@ std::vector SpectrumTrace::get_view_modes_support() return modes; } -pv::data::SpectrumStack* SpectrumTrace::get_spectrum_stack() -{ - return _spectrum_stack; -} - void SpectrumTrace::init_zoom() { _scale = 1; @@ -496,4 +489,4 @@ QRect SpectrumTrace::get_view_rect() } } // namespace view -} // namespace pv +} // namespace dsv diff --git a/DSView/pv/view/spectrumtrace.h b/DSView/src/view/spectrumtrace.h similarity index 89% rename from DSView/pv/view/spectrumtrace.h rename to DSView/src/view/spectrumtrace.h index 30e37b3d9..369ca9467 100644 --- a/DSView/pv/view/spectrumtrace.h +++ b/DSView/src/view/spectrumtrace.h @@ -23,21 +23,23 @@ #define DSVIEW_PV_VIEW_SPECTRUMTRACE_H #include "trace.h" - #include #include - struct srd_channel; -namespace pv { - -class SigSession; - -namespace data{ -class SpectrumStack; +namespace dsv{ + namespace appcore{ + class SigSession; + } + namespace data{ + class SpectrumStack; + } } +using namespace dsv::appcore; +using namespace dsv::data; +namespace dsv { namespace view { //when device is oscillcopse mode, to draw signal trace @@ -67,7 +69,7 @@ class SpectrumTrace : public Trace static const double VerticalRate; public: - SpectrumTrace(pv::SigSession *session, pv::data::SpectrumStack *spectrum_stack, int index); + SpectrumTrace(SigSession *session,SpectrumStack *spectrum_stack, int index); ~SpectrumTrace(); bool enabled(); @@ -92,7 +94,9 @@ class SpectrumTrace : public Trace void set_view_mode(unsigned int mode); std::vector get_view_modes_support(); - pv::data::SpectrumStack* get_spectrum_stack(); + inline SpectrumStack* get_spectrum_stack(){ + return _spectrum_stack; + } static QString format_freq(double freq, unsigned precision = Pricision); @@ -127,13 +131,10 @@ class SpectrumTrace : public Trace protected: void paint_type_options(QPainter &p, int right, const QPoint pt, QColor fore); -private: - -private slots: private: - pv::SigSession *_session; - pv::data::SpectrumStack *_spectrum_stack; + SigSession *_session; + SpectrumStack *_spectrum_stack; bool _enable; int _view_mode; @@ -152,6 +153,6 @@ private slots: }; } // namespace view -} // namespace pv +} // namespace dsv #endif // DSVIEW_PV_VIEW_SPECTRUMTRACE_H diff --git a/DSView/pv/view/timemarker.cpp b/DSView/src/view/timemarker.cpp similarity index 98% rename from DSView/pv/view/timemarker.cpp rename to DSView/src/view/timemarker.cpp index ad9693e9a..58ab58b07 100644 --- a/DSView/pv/view/timemarker.cpp +++ b/DSView/src/view/timemarker.cpp @@ -21,13 +21,11 @@ */ #include "timemarker.h" - +#include #include "view.h" #include "ruler.h" -#include - -namespace pv { +namespace dsv { namespace view { TimeMarker::TimeMarker(View &view, QColor &colour, @@ -89,4 +87,4 @@ void TimeMarker::paint(QPainter &p, const QRect &rect, const bool highlight, int } } // namespace view -} // namespace pv +} // namespace dsv diff --git a/DSView/pv/view/timemarker.h b/DSView/src/view/timemarker.h similarity index 98% rename from DSView/pv/view/timemarker.h rename to DSView/src/view/timemarker.h index 84cc0bcbc..afd97b81e 100644 --- a/DSView/pv/view/timemarker.h +++ b/DSView/src/view/timemarker.h @@ -26,13 +26,12 @@ #include #include #include - #include class QPainter; class QRect; -namespace pv { +namespace dsv { namespace view { class View; @@ -120,6 +119,6 @@ class TimeMarker : public QObject }; } // namespace view -} // namespace pv +} // namespace dsv #endif // DSVIEW_PV_VIEW_MARKER_H diff --git a/DSView/pv/view/trace.cpp b/DSView/src/view/trace.cpp similarity index 96% rename from DSView/pv/view/trace.cpp rename to DSView/src/view/trace.cpp index b9bd648c5..c5c4ccf53 100644 --- a/DSView/pv/view/trace.cpp +++ b/DSView/src/view/trace.cpp @@ -20,22 +20,21 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ - +#include "trace.h" #include #include #include #include #include - -#include "trace.h" #include "view.h" -#include "../sigsession.h" -#include "../dsvdef.h" +#include "../appcore/sigsession.h" +#include "../basedef.h" #include "../config/appconfig.h" -#include "../appcontrol.h" +#include "../appcore/appcontrol.h" +using namespace dsv::config; -namespace pv { +namespace dsv { namespace view { const QColor Trace::PROBE_COLORS[8] = { @@ -61,6 +60,7 @@ Trace::Trace(QString name, uint16_t index, int type) : { _index_list.push_back(index); _view_index = -1; + _selected = false; } Trace::Trace(QString name, std::list index_list, int type, int sec_index) : @@ -74,6 +74,7 @@ Trace::Trace(QString name, std::list index_list, int type, int sec_index) : _typeWidth(SquareNum) { _view_index = -1; + _selected = false; } Trace::Trace(const Trace &t) : @@ -90,6 +91,7 @@ Trace::Trace(const Trace &t) : _text_size(t._text_size) { _view_index = -1; + _selected = false; } @@ -135,14 +137,14 @@ void Trace::resize() { } -void Trace::set_view(pv::view::View *view) +void Trace::set_view(dsv::view::View *view) { assert(view); _view = view; connect(_view, SIGNAL(resize()), this, SLOT(resize())); } -void Trace::set_viewport(pv::view::Viewport *viewport) +void Trace::set_viewport(dsv::view::Viewport *viewport) { assert(viewport); _viewport = viewport; @@ -347,18 +349,6 @@ QColor Trace::get_text_colour() return (_colour.lightness() > 64) ? Qt::black : Qt::white; } -void Trace::on_text_changed(const QString &text) -{ - set_name(text); - text_changed(); -} - -void Trace::on_colour_changed(const QColor &colour) -{ - set_colour(colour); - colour_changed(); -} - int Trace::rows_size() { return 1; @@ -394,4 +384,4 @@ QRectF Trace::get_rect(const char *s, int y, int right) } } // namespace view -} // namespace pv +} // namespace dsv diff --git a/DSView/pv/view/trace.h b/DSView/src/view/trace.h similarity index 93% rename from DSView/pv/view/trace.h rename to DSView/src/view/trace.h index 70669f487..2dbaf100e 100644 --- a/DSView/pv/view/trace.h +++ b/DSView/src/view/trace.h @@ -28,22 +28,20 @@ #include #include #include - +#include #include - -#include "selectableitem.h" #include "dsldial.h" class QFormLayout; -namespace pv { +namespace dsv { namespace view { class View; class Viewport; //base class -class Trace : public SelectableItem +class Trace : public QObject { Q_OBJECT @@ -188,15 +186,15 @@ class Trace : public SelectableItem */ virtual bool enabled() = 0; - virtual void set_view(pv::view::View *view); + virtual void set_view(dsv::view::View *view); - inline pv::view::View* get_view(){ + inline dsv::view::View* get_view(){ return _view; } - virtual void set_viewport(pv::view::Viewport *viewport); + virtual void set_viewport(dsv::view::Viewport *viewport); - inline pv::view::Viewport* get_viewport(){ + inline dsv::view::Viewport* get_viewport(){ return _viewport; } @@ -295,6 +293,14 @@ class Trace : public SelectableItem return _view_index; } + inline bool selected(){ + return _selected; + } + + inline void select(bool flag){ + _selected = flag; + } + protected: /** @@ -322,9 +328,7 @@ class Trace : public SelectableItem void compute_text_size(QPainter &p); private slots: - void on_text_changed(const QString &text); - void on_colour_changed(const QColor &colour); - virtual void resize(); + void resize(); signals: void visibility_changed(); @@ -332,8 +336,8 @@ private slots: void colour_changed(); protected: - pv::view::View *_view; - pv::view::Viewport *_viewport; + dsv::view::View *_view; + dsv::view::Viewport *_viewport; QString _name; QColor _colour; @@ -347,9 +351,10 @@ private slots: int _view_index; QSizeF _text_size; + bool _selected; }; } // namespace view -} // namespace pv +} // namespace dsv #endif // DSVIEW_PV_VIEW_TRACE_H diff --git a/DSView/pv/view/view.cpp b/DSView/src/view/view.cpp similarity index 99% rename from DSView/pv/view/view.cpp rename to DSView/src/view/view.cpp index edd320193..a72b1eb09 100644 --- a/DSView/pv/view/view.cpp +++ b/DSView/src/view/view.cpp @@ -20,15 +20,14 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "view.h" #include #include #include - #include #include #include #include - #include "groupsignal.h" #include "decodetrace.h" #include "header.h" @@ -36,25 +35,24 @@ #include "ruler.h" #include "signal.h" #include "dsosignal.h" -#include "view.h" #include "viewport.h" #include "spectrumtrace.h" #include "lissajoustrace.h" #include "analogsignal.h" - -#include "../sigsession.h" +#include "../appcore/sigsession.h" #include "../data/logicsnapshot.h" #include "../dialogs/calibration.h" #include "../dialogs/lissajousoptions.h" -#include "../dsvdef.h" +#include "../basedef.h" #include "../log.h" #include "../config/appconfig.h" -#include "../appcontrol.h" +#include "../appcore/appcontrol.h" using namespace std; +using namespace dsv::config; -namespace pv { +namespace dsv { namespace view { const int View::LabelMarginWidth = 70; @@ -80,7 +78,7 @@ const QColor View::LightBlue = QColor(17, 133, 209, 200); const QColor View::LightRed = QColor(213, 15, 37, 200); -View::View(SigSession *session, pv::toolbars::SamplingBar *sampling_bar, QWidget *parent) : +View::View(SigSession *session, dsv::toolbars::SamplingBar *sampling_bar, QWidget *parent) : QScrollArea(parent), _sampling_bar(sampling_bar), _scale(10), @@ -188,7 +186,7 @@ View::View(SigSession *session, pv::toolbars::SamplingBar *sampling_bar, QWidget _search_pos = 0; _search_cursor = new Cursor(*this, fore, _search_pos); - _cali = new pv::dialogs::Calibration(this); + _cali = new dsv::dialogs::Calibration(this); _cali->hide(); connect(horizontalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(h_scroll_value_changed(int))); @@ -1341,10 +1339,10 @@ int View::get_body_height() _time_viewport->update(); } - void View::update_font() + void View::UpdateFont() { headerWidth(); } } // namespace view -} // namespace pv +} // namespace dsv diff --git a/DSView/pv/view/view.h b/DSView/src/view/view.h similarity index 96% rename from DSView/pv/view/view.h rename to DSView/src/view/view.h index dcf3b0be0..558d6a786 100644 --- a/DSView/pv/view/view.h +++ b/DSView/src/view/view.h @@ -26,27 +26,23 @@ #include #include -#include - +#include #include #include #include -#include - - +#include #include "../toolbars/samplingbar.h" #include "../data/signaldata.h" -#include "../view/viewport.h" +#include "viewport.h" #include "cursor.h" #include "xcursor.h" #include "signal.h" #include "viewstatus.h" -#include "../dsvdef.h" +#include "../basedef.h" #include "../interface/icallbacks.h" - -class DeviceAgent; - -namespace pv { + + +namespace dsv { namespace toolbars { class SamplingBar; @@ -57,7 +53,10 @@ namespace dialogs { class Lissajous; } -class SigSession; +namespace appcore{ + class SigSession; + class DeviceAgent; +} namespace view { @@ -106,7 +105,7 @@ class View : public QScrollArea, public IFontForm{ static const QColor LightRed; public: - explicit View(SigSession *session, pv::toolbars::SamplingBar *sampling_bar, QWidget *parent = 0); + explicit View(SigSession *session, dsv::toolbars::SamplingBar *sampling_bar, QWidget *parent = 0); ~View(); @@ -321,7 +320,7 @@ class View : public QScrollArea, public IFontForm{ } //IFontForm - void update_font() override; + void UpdateFont() override; signals: void hover_point_changed(); @@ -418,7 +417,7 @@ private slots: private: SigSession *_session; - pv::toolbars::SamplingBar *_sampling_bar; + dsv::toolbars::SamplingBar *_sampling_bar; QWidget *_viewcenter; ViewStatus *_viewbottom; @@ -472,6 +471,6 @@ private slots: }; } // namespace view -} // namespace pv +} // namespace dsv #endif // DSVIEW_PV_VIEW_VIEW_H diff --git a/DSView/pv/view/viewport.cpp b/DSView/src/view/viewport.cpp similarity index 99% rename from DSView/pv/view/viewport.cpp rename to DSView/src/view/viewport.cpp index 1d4570b8b..a96ca569f 100644 --- a/DSView/pv/view/viewport.cpp +++ b/DSView/src/view/viewport.cpp @@ -21,35 +21,33 @@ */ #include "viewport.h" +#include +#include +#include +#include +#include #include "ruler.h" - #include "signal.h" #include "dsosignal.h" #include "logicsignal.h" #include "analogsignal.h" #include "spectrumtrace.h" #include "../data/logicsnapshot.h" -#include "../sigsession.h" +#include "../appcore/sigsession.h" #include "../dialogs/dsomeasure.h" #include "decodetrace.h" - -#include -#include -#include -#include -#include - #include "../config/appconfig.h" -#include "../dsvdef.h" -#include "../appcontrol.h" -#include "../log.h" -#include "../ui/langresource.h" +#include "../basedef.h" +#include "../appcore/appcontrol.h" +#include "../log.h" +#include "../uicore/langresource.h" #include "../ui/fn.h" #include "lissajoustrace.h" using namespace std; +using namespace dsv::config; -namespace pv { +namespace dsv { namespace view { const double Viewport::DragDamping = 1.05; @@ -108,7 +106,7 @@ Viewport::Viewport(View &parent, View_type type) : _xAction = xAction; setContextMenuPolicy(Qt::CustomContextMenu); - this->update_font(); + this->UpdateFont(); connect(&_trigger_timer, SIGNAL(timeout()),this, SLOT(on_trigger_timer())); connect(&_drag_timer, SIGNAL(timeout()),this, SLOT(on_drag_timer())); @@ -152,7 +150,7 @@ void Viewport::paintEvent(QPaintEvent *event) void Viewport::doPaint() { - using pv::view::Signal; + using dsv::view::Signal; QStyleOption o; o.initFrom(this); @@ -483,7 +481,7 @@ void Viewport::paintProgress(QPainter &p, QColor fore, QColor back) return; } - using pv::view::Signal; + using dsv::view::Signal; double progress = 0; int progress100 = 0; @@ -2003,7 +2001,7 @@ void Viewport::add_cursor_x() _view.show_xcursors(true); } -void Viewport::update_font() +void Viewport::UpdateFont() { QFont font = this->font(); font.setPointSizeF(AppConfig::Instance().appOptions.fontSize); @@ -2018,4 +2016,4 @@ void Viewport::update_lang() } } // namespace view -} // namespace pv +} // namespace dsv diff --git a/DSView/pv/view/viewport.h b/DSView/src/view/viewport.h similarity index 96% rename from DSView/pv/view/viewport.h rename to DSView/src/view/viewport.h index 14c027224..c75257070 100644 --- a/DSView/pv/view/viewport.h +++ b/DSView/src/view/viewport.h @@ -25,27 +25,31 @@ #define DSVIEW_PV_VIEW_VIEWPORT_H #include - #include #include #include #include #include #include - -#include "../view/view.h" -#include "../dsvdef.h" +#include "view.h" +#include "../basedef.h" #include "../interface/icallbacks.h" class QPainter; class QPaintEvent; -class SigSession; class QAction; using std::chrono::high_resolution_clock; using std::chrono::milliseconds; -namespace pv { +namespace dsv{ + namespace appcore{ + class SigSession; + } +} +using namespace dsv::appcore; + +namespace dsv { namespace view { class Signal; @@ -112,7 +116,7 @@ class Viewport : public QWidget, public IFontForm void update_lang(); //IFontForm - void update_font() override; + void UpdateFont() override; protected: bool event(QEvent *event) override; @@ -230,6 +234,6 @@ private slots: }; } // namespace view -} // namespace pv +} // namespace dsv #endif // DSVIEW_PV_VIEW_VIEWPORT_H diff --git a/DSView/pv/view/viewstatus.cpp b/DSView/src/view/viewstatus.cpp similarity index 94% rename from DSView/pv/view/viewstatus.cpp rename to DSView/src/view/viewstatus.cpp index feff7362f..0013578f5 100644 --- a/DSView/pv/view/viewstatus.cpp +++ b/DSView/src/view/viewstatus.cpp @@ -20,7 +20,6 @@ */ #include "viewstatus.h" - #include #include #include @@ -28,22 +27,21 @@ #include #include #include - -#include "../view/trace.h" -#include "../sigsession.h" -#include "../view/view.h" #include "../view/trace.h" +#include "../appcore/sigsession.h" +#include "view.h" +#include "trace.h" #include "../dialogs/dsomeasure.h" - -#include "../ui/langresource.h" +#include "../uicore/langresource.h" #include "../log.h" #include "../config/appconfig.h" -#include "../appcontrol.h" +#include "../appcore/appcontrol.h" #include "../ui/fn.h" using namespace std; +using namespace dsv::config; -namespace pv { +namespace dsv { namespace view { ViewStatus::ViewStatus(SigSession *session, View &parent) : @@ -114,7 +112,7 @@ void ViewStatus::paintEvent(QPaintEvent *) p.setBrush(active ? dsoSig->get_colour() : fore); p.drawRect(QRect(rect.topLeft(), QSize(10, rect.height()))); - QPixmap msPix(pv::dialogs::DsoMeasure::get_ms_icon(std::get<2>(_mrects[i]))); + QPixmap msPix(dsv::dialogs::DsoMeasure::get_ms_icon(std::get<2>(_mrects[i]))); QBitmap msMask = msPix.createMaskFromColor(QColor("black"), Qt::MaskOutColor); msPix.fill(active ? dsoSig->get_colour() : fore); msPix.setMask(msMask); @@ -129,7 +127,7 @@ void ViewStatus::paintEvent(QPaintEvent *) enum DSO_MEASURE_TYPE mtype = std::get<2>(_mrects[i]); if (active && (mtype != DSO_MS_BEGIN)) { - QString title = pv::dialogs::DsoMeasure::get_ms_text(std::get<2>(_mrects[i])) + ":"; + QString title = dsv::dialogs::DsoMeasure::get_ms_text(std::get<2>(_mrects[i])) + ":"; title += dsoSig->get_measure(mtype); int width = p.boundingRect(rect, title).width(); p.drawText(QRect(rect.left()+10+rect.height(), rect.top(), width, rect.height()), @@ -221,7 +219,7 @@ void ViewStatus::mousePressEvent(QMouseEvent *event) const QRect rect = std::get<0>(_mrects[i]); if (rect.contains(event->pos())) { _hit_rect = (int)i; - pv::dialogs::DsoMeasure dsoMeasureDialog(_session, _view, i, _last_sig_index); + dsv::dialogs::DsoMeasure dsoMeasureDialog(_session, _view, i, _last_sig_index); dsoMeasureDialog.exec(); break; } @@ -298,4 +296,4 @@ void ViewStatus::load_session(QJsonArray measure_array, int version) } } // namespace view -} // namespace pv +} // namespace dsv diff --git a/DSView/pv/view/viewstatus.h b/DSView/src/view/viewstatus.h similarity index 94% rename from DSView/pv/view/viewstatus.h rename to DSView/src/view/viewstatus.h index 87ea2a6f2..70aea1d53 100644 --- a/DSView/pv/view/viewstatus.h +++ b/DSView/src/view/viewstatus.h @@ -29,10 +29,14 @@ #include #include -namespace pv { - -class SigSession; - +namespace dsv{ + namespace appcore{ + class SigSession; + } +} +using namespace dsv::appcore; + +namespace dsv { namespace view { class View; class DsoSignal; @@ -78,6 +82,6 @@ public slots: }; } // namespace view -} // namespace pv +} // namespace dsv #endif // DSVIEW_PV_VIEW_VIEWSTATUS_H diff --git a/DSView/pv/view/xcursor.cpp b/DSView/src/view/xcursor.cpp similarity index 99% rename from DSView/pv/view/xcursor.cpp rename to DSView/src/view/xcursor.cpp index 37adc4f61..0c1d60726 100644 --- a/DSView/pv/view/xcursor.cpp +++ b/DSView/src/view/xcursor.cpp @@ -21,17 +21,16 @@ */ #include "xcursor.h" - +#include #include "view.h" #include "ruler.h" #include "dsosignal.h" #include "../log.h" +#include "../appcore/sigsession.h" -#include - using namespace std; -namespace pv { +namespace dsv { namespace view { XCursor::XCursor(View &view, QColor &colour, @@ -271,4 +270,4 @@ void XCursor::paint_label(QPainter &p, const QRect &rect) } } // namespace view -} // namespace pv +} // namespace dsv diff --git a/DSView/pv/view/xcursor.h b/DSView/src/view/xcursor.h similarity index 98% rename from DSView/pv/view/xcursor.h rename to DSView/src/view/xcursor.h index 96f2b8920..7b0644ccd 100644 --- a/DSView/pv/view/xcursor.h +++ b/DSView/src/view/xcursor.h @@ -25,14 +25,13 @@ #include #include -#include - +#include #include class QPainter; class QRect; -namespace pv { +namespace dsv { namespace view { class View; @@ -145,6 +144,6 @@ private slots: }; } // namespace view -} // namespace pv +} // namespace dsv #endif // DSVIEW_PV_VIEW_XCURSOR_H diff --git a/DSView/pv/widgets/border.cpp b/DSView/src/widgets/border.cpp similarity index 91% rename from DSView/pv/widgets/border.cpp rename to DSView/src/widgets/border.cpp index ec1b19d6c..50aba98e5 100644 --- a/DSView/pv/widgets/border.cpp +++ b/DSView/src/widgets/border.cpp @@ -20,14 +20,16 @@ */ #include "border.h" -#include "../mainframe.h" - +#include "../appcore/mainframe.h" #include #include #include #include "../config/appconfig.h" -namespace pv { +using namespace dsv::config; +using namespace dsv::appcore; + +namespace dsv { namespace widgets { const QColor Border::dark_border0 = QColor(80, 80, 80, 255); @@ -88,46 +90,46 @@ void Border::paintEvent(QPaintEvent *) radialGrad.setColorAt(1, light_border4); } - if (_type == pv::MainFrame::TopLeft) { + if (_type == MainFrame::TopLeft) { QRectF rectangle(0, 0, width()*2, height()*2); radialGrad.setCenter(QPointF(width(), height())); radialGrad.setFocalPoint(QPointF(width(), height())); painter.setBrush(QBrush(radialGrad)); painter.drawPie(rectangle, 90 * 16, 180 * 16); - } else if (_type == pv::MainFrame::TopRight) { + } else if (_type == MainFrame::TopRight) { QRectF rectangle(-width(), 0, width()*2, height()*2); radialGrad.setCenter(QPointF(0, height())); radialGrad.setFocalPoint(QPointF(0, height())); painter.setBrush(QBrush(radialGrad)); painter.drawPie(rectangle, 0 * 16, 90 * 16); - } else if (_type == pv::MainFrame::BottomLeft) { + } else if (_type == MainFrame::BottomLeft) { QRectF rectangle(0, -height(), width()*2, height()*2); radialGrad.setCenter(QPointF(width(), 0)); radialGrad.setFocalPoint(QPointF(width(), 0)); painter.setBrush(QBrush(radialGrad)); painter.drawPie(rectangle, 180 * 16, 270 * 16); - } else if (_type == pv::MainFrame::BottomRight) { + } else if (_type == MainFrame::BottomRight) { QRectF rectangle(-width(), -height(), width()*2, height()*2); radialGrad.setCenter(QPointF(0, 0)); radialGrad.setFocalPoint(QPointF(0, 0)); painter.setBrush(QBrush(radialGrad)); painter.drawPie(rectangle, 270 * 16, 360 * 16); - } else if (_type == pv::MainFrame::Top) { + } else if (_type == MainFrame::Top) { linearGrad.setStart(QPointF(0, height())); linearGrad.setFinalStop(QPointF(0, 0)); painter.setBrush(QBrush(linearGrad)); painter.drawRect(rect()); - } else if (_type == pv::MainFrame::Bottom) { + } else if (_type == MainFrame::Bottom) { linearGrad.setStart(QPointF(0, 0)); linearGrad.setFinalStop(QPointF(0, height())); painter.setBrush(QBrush(linearGrad)); painter.drawRect(rect()); - } else if (_type == pv::MainFrame::Left) { + } else if (_type == MainFrame::Left) { linearGrad.setStart(QPointF(width(), 0)); linearGrad.setFinalStop(QPointF(0, 0)); painter.setBrush(QBrush(linearGrad)); painter.drawRect(rect()); - } else if (_type == pv::MainFrame::Right) { + } else if (_type == MainFrame::Right) { linearGrad.setStart(QPointF(0, 0)); linearGrad.setFinalStop(QPointF(width(), 0)); painter.setBrush(QBrush(linearGrad)); @@ -141,4 +143,4 @@ void Border::leaveEvent(QEvent*) } } // namespace widgets -} // namespace pv +} // namespace dsv diff --git a/DSView/pv/widgets/border.h b/DSView/src/widgets/border.h similarity index 97% rename from DSView/pv/widgets/border.h rename to DSView/src/widgets/border.h index bc78997ed..1160b7379 100644 --- a/DSView/pv/widgets/border.h +++ b/DSView/src/widgets/border.h @@ -24,7 +24,7 @@ #include -namespace pv { +namespace dsv { namespace widgets { class Border : public QWidget @@ -55,6 +55,6 @@ class Border : public QWidget }; } // namespace widgets -} // namespace pv +} // namespace dsv #endif // DSVIEW_PV_WIDGETS_BORDER_H diff --git a/DSView/pv/widgets/decodergroupbox.cpp b/DSView/src/widgets/decodergroupbox.cpp similarity index 95% rename from DSView/pv/widgets/decodergroupbox.cpp rename to DSView/src/widgets/decodergroupbox.cpp index 6bb35e635..227f6a54b 100644 --- a/DSView/pv/widgets/decodergroupbox.cpp +++ b/DSView/src/widgets/decodergroupbox.cpp @@ -20,28 +20,27 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include #include "decodergroupbox.h" -#include "../data/decoderstack.h" -#include "../data/decode/decoder.h" -#include "../data/decode/row.h" - +#include #include #include #include #include #include #include - +#include +#include "../data/decoderstack.h" +#include "../decode/decoder.h" +#include "../decode/row.h" #include "../config/appconfig.h" -#include +using namespace dsv::config; -namespace pv { +namespace dsv { namespace widgets { DecoderGroupBox::DecoderGroupBox(data::DecoderStack *decoder_stack, - data::decode::Decoder *dec, + decode::Decoder *dec, QLayout *dec_layout, QWidget *parent, QFont font): QWidget(parent) @@ -56,7 +55,7 @@ DecoderGroupBox::DecoderGroupBox(data::DecoderStack *decoder_stack, _layout->setContentsMargins(0, 0, 0, 0); _layout->setVerticalSpacing(2); - QString iconPath = GetIconPath(); + QString iconPath = AppConfig::GetIconPath(); _layout->addWidget(new QLabel(QString("

%1

").arg(_dec->decoder()->name), _widget), 0, 0); _layout->setColumnStretch(0, 1); @@ -127,7 +126,7 @@ bool DecoderGroupBox::eventFilter(QObject *o, QEvent *e) void DecoderGroupBox::tog_icon() { - QString iconPath = GetIconPath(); + QString iconPath = AppConfig::GetIconPath(); QPushButton *sc = dynamic_cast(sender()); int index = sc->property("index").toInt(); diff --git a/DSView/pv/widgets/decodergroupbox.h b/DSView/src/widgets/decodergroupbox.h similarity index 85% rename from DSView/pv/widgets/decodergroupbox.h rename to DSView/src/widgets/decodergroupbox.h index 5791a362f..559a3097f 100644 --- a/DSView/pv/widgets/decodergroupbox.h +++ b/DSView/src/widgets/decodergroupbox.h @@ -29,13 +29,14 @@ #include #include -namespace pv { +namespace dsv { namespace data{ -class DecoderStack; -namespace decode{ -class Decoder; + class DecoderStack; } + +namespace decode{ + class Decoder; } namespace widgets { @@ -45,8 +46,8 @@ class DecoderGroupBox : public QWidget Q_OBJECT public: - DecoderGroupBox(pv::data::DecoderStack *decoder_stack, - data::decode::Decoder *dec, QLayout *dec_layout, + DecoderGroupBox(dsv::data::DecoderStack *decoder_stack, + decode::Decoder *dec, QLayout *dec_layout, QWidget *parent, QFont font); ~DecoderGroupBox(); bool eventFilter(QObject *o, QEvent *e); @@ -58,7 +59,7 @@ class DecoderGroupBox : public QWidget signals: void show_hide_decoder(); void show_hide_row(); - void del_stack(data::decode::Decoder *_dec); + void del_stack(decode::Decoder *_dec); private slots: void tog_icon(); @@ -67,8 +68,8 @@ private slots: private: QWidget *_widget; - pv::data::DecoderStack *_decoder_stack; - data::decode::Decoder *_dec; + dsv::data::DecoderStack *_decoder_stack; + decode::Decoder *_dec; int _index; QGridLayout *_layout; diff --git a/DSView/pv/widgets/decodermenu.cpp b/DSView/src/widgets/decodermenu.cpp similarity index 99% rename from DSView/pv/widgets/decodermenu.cpp rename to DSView/src/widgets/decodermenu.cpp index 0072f7882..665d5a347 100644 --- a/DSView/pv/widgets/decodermenu.cpp +++ b/DSView/src/widgets/decodermenu.cpp @@ -19,11 +19,11 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include #include "decodermenu.h" +#include #include -namespace pv { +namespace dsv { namespace widgets { DecoderMenu::DecoderMenu(QWidget *parent, bool first_level_decoder) : diff --git a/DSView/pv/widgets/decodermenu.h b/DSView/src/widgets/decodermenu.h similarity index 98% rename from DSView/pv/widgets/decodermenu.h rename to DSView/src/widgets/decodermenu.h index ca8b532e9..af01f23ec 100644 --- a/DSView/pv/widgets/decodermenu.h +++ b/DSView/src/widgets/decodermenu.h @@ -27,7 +27,7 @@ struct srd_decoder; -namespace pv { +namespace dsv { namespace widgets { class DecoderMenu : public QMenu diff --git a/DSView/pv/widgets/fakelineedit.cpp b/DSView/src/widgets/fakelineedit.cpp similarity index 97% rename from DSView/pv/widgets/fakelineedit.cpp rename to DSView/src/widgets/fakelineedit.cpp index eb698ba65..e9b7f0ff0 100644 --- a/DSView/pv/widgets/fakelineedit.cpp +++ b/DSView/src/widgets/fakelineedit.cpp @@ -22,7 +22,7 @@ #include "fakelineedit.h" #include -namespace pv { +namespace dsv { namespace widgets { FakeLineEdit::FakeLineEdit(QLineEdit *parent) : @@ -38,4 +38,4 @@ void FakeLineEdit::mousePressEvent(QMouseEvent *event) } } // namespace widgets -} // namespace pv +} // namespace dsv diff --git a/DSView/pv/widgets/fakelineedit.h b/DSView/src/widgets/fakelineedit.h similarity index 96% rename from DSView/pv/widgets/fakelineedit.h rename to DSView/src/widgets/fakelineedit.h index 51b1d7e1b..aa3f771e0 100644 --- a/DSView/pv/widgets/fakelineedit.h +++ b/DSView/src/widgets/fakelineedit.h @@ -24,9 +24,7 @@ #include -namespace pv { - -class SigSession; +namespace dsv { namespace widgets { @@ -47,6 +45,6 @@ public slots: }; } // namespace widgets -} // namespace pv +} // namespace dsv #endif // DSVIEW_PV_WIDGETS_FAKELINEEDIT_H diff --git a/DSView/test/CMakeLists.txt b/DSView/test/CMakeLists.txt deleted file mode 100644 index 2b48a7b61..000000000 --- a/DSView/test/CMakeLists.txt +++ /dev/null @@ -1,385 +0,0 @@ -## -## This file is part of the DSView project. -## -## Copyright (C) 2012 Joel Holdsworth -## Copyright (C) 2012-2013 Alexandru Gagniuc -## Copyright (C) 2013-2014 DreamSourceLab -## -## This program is free software: you can redistribute it and/or modify -## it under the terms of the GNU General Public License as published by -## the Free Software Foundation, either version 2 of the License, or -## (at your option) any later version. -## -## This program 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 General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with this program. If not, see . -## - -cmake_minimum_required(VERSION 2.8.6) - -include(FindPkgConfig) -include(GNUInstallDirs) - -set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMake") - -project(DSView) - -#=============================================================================== -#= User Options -#------------------------------------------------------------------------------- - -option(DISABLE_WERROR "Build without -Werror" TRUE) -option(ENABLE_SIGNALS "Build with UNIX signals" TRUE) -option(ENABLE_DECODE "Build with libsigrokdecode" TRUE) -option(ENABLE_COTIRE "Enable cotire" FALSE) -option(ENABLE_TESTS "Enable unit tests" FALSE) -option(STATIC_PKGDEPS_LIBS "Statically link to (pkg-config) libraries" FALSE) -option(FORCE_QT4 "Force use of Qt4 even if Qt5 is available" FALSE) - -if(WIN32) - # On Windows/MinGW we need to statically link to libraries. - # This option is user configurable, but enable it by default on win32. - set(STATIC_PKGDEPS_LIBS TRUE) - - # Windows does not support UNIX signals. - set(ENABLE_SIGNALS FALSE) -endif() - -if(NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING - "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." - FORCE) -endif() - -#=============================================================================== -#= Dependencies -#------------------------------------------------------------------------------- - -list(APPEND PKGDEPS - "libsigrok4DSL >= 0.2.0" - "libusb-1.0 >= 1.0.16" -) -if(ENABLE_DECODE) - list(APPEND PKGDEPS "libsigrokdecode>=0.3.0") -endif() - -find_package(PkgConfig) -pkg_check_modules(PKGDEPS REQUIRED ${PKGDEPS}) - -if(FORCE_QT4) - set(Qt5Core_FOUND FALSE) -else() - find_package(Qt5Core QUIET) -endif() - -if(Qt5Core_FOUND) - message("-- Using Qt5") - find_package(Qt5Widgets REQUIRED) - find_package(Qt5Gui REQUIRED) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}") - set(QT_INCLUDE_DIRS ${Qt5Gui_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS}) - set(QT_LIBRARIES Qt5::Gui Qt5::Widgets) - add_definitions(${Qt5Gui_DEFINITIONS} ${Qt5Widgets_DEFINITIONS}) -else() - find_program(QT_QMAKE_EXECUTABLE NAMES qmake4 qmake-qt4 qmake-mac) - find_package(Qt4 REQUIRED) -endif() - -find_package(Threads) - -find_package(Boost 1.42 COMPONENTS filesystem system thread REQUIRED) -find_package(libusb-1.0 REQUIRED) - -#=============================================================================== -#= Config Header -#------------------------------------------------------------------------------- - -set(DS_TITLE DSView) -set(DS_DESCRIPTION "A GUI for instruments of DreamSourceLab") - -set(DS_VERSION_MAJOR 0) -set(DS_VERSION_MINOR 9) -set(DS_VERSION_MICRO 2) -set(DS_VERSION_STRING - ${DS_VERSION_MAJOR}.${DS_VERSION_MINOR}.${DS_VERSION_MICRO} -) - -configure_file ( - ${PROJECT_SOURCE_DIR}/config.h.in - ${PROJECT_BINARY_DIR}/config.h -) - -#=============================================================================== -#= Sources -#------------------------------------------------------------------------------- - -set(DSView_SOURCES - main.cpp - pv/devicemanager.cpp - pv/mainwindow.cpp - pv/sigsession.cpp - pv/storesession.cpp - pv/data/analog.cpp - pv/data/analogsnapshot.cpp - pv/data/dso.cpp - pv/data/dsosnapshot.cpp - pv/data/group.cpp - pv/data/groupsnapshot.cpp - pv/data/logic.cpp - pv/data/logicsnapshot.cpp - pv/data/signaldata.cpp - pv/data/snapshot.cpp - pv/device/devinst.cpp - pv/device/device.cpp - pv/device/file.cpp - pv/device/inputfile.cpp - pv/device/sessionfile.cpp - pv/dialogs/about.cpp - pv/dialogs/deviceoptions.cpp - pv/dialogs/search.cpp - pv/dialogs/storeprogress.cpp - pv/dialogs/streamoptions.cpp - pv/dialogs/waitingdialog.cpp - pv/dock/dsotriggerdock.cpp - pv/dock/measuredock.cpp - pv/dock/searchdock.cpp - pv/dock/triggerdock.cpp - pv/prop/bool.cpp - pv/prop/double.cpp - pv/prop/enum.cpp - pv/prop/int.cpp - pv/prop/property.cpp - pv/prop/string.cpp - pv/prop/binding/binding.cpp - pv/prop/binding/binding_deviceoptions.cpp - pv/toolbars/filebar.cpp - pv/toolbars/logobar.cpp - pv/toolbars/samplingbar.cpp - pv/toolbars/trigbar.cpp - pv/view/analogsignal.cpp - pv/view/cursor.cpp - pv/view/devmode.cpp - pv/view/dsldial.cpp - pv/view/dsosignal.cpp - pv/view/groupsignal.cpp - pv/view/header.cpp - pv/view/logicsignal.cpp - pv/view/ruler.cpp - pv/view/selectableitem.cpp - pv/view/signal.cpp - pv/view/timemarker.cpp - pv/view/trace.cpp - pv/view/view.cpp - pv/view/viewport.cpp - pv/widgets/fakelineedit.cpp -) - -set(DSView_HEADERS - pv/mainwindow.h - pv/sigsession.h - pv/storesession.h - pv/device/devinst.h - pv/dialogs/about.h - pv/dialogs/deviceoptions.h - pv/dialogs/search.h - pv/dialogs/storeprogress.h - pv/dialogs/streamoptions.h - pv/dialogs/waitingdialog.h - pv/dock/dsotriggerdock.h - pv/dock/measuredock.h - pv/dock/searchdock.h - pv/dock/triggerdock.h - pv/prop/bool.h - pv/prop/double.h - pv/prop/enum.h - pv/prop/int.h - pv/prop/property.h - pv/prop/string.h - pv/toolbars/filebar.h - pv/toolbars/logobar.h - pv/toolbars/samplingbar.h - pv/toolbars/trigbar.h - pv/view/cursor.h - pv/view/devmode.h - pv/view/header.h - pv/view/ruler.h - pv/view/selectableitem.h - pv/view/timemarker.h - pv/view/trace.h - pv/view/view.h - pv/view/viewport.h - pv/widgets/fakelineedit.h -) - -set(DSView_FORMS - pv/dialogs/about.ui -) - -set(DSView_RESOURCES - DSView.qrc -) - - -if(ENABLE_DECODE) - list(APPEND DSView_SOURCES - pv/dock/protocoldock.cpp - pv/data/decoderstack.cpp - pv/data/decode/annotation.cpp - pv/data/decode/decoder.cpp - pv/data/decode/row.cpp - pv/data/decode/rowdata.cpp - pv/prop/binding/decoderoptions.cpp - pv/view/decodetrace.cpp - pv/widgets/decodergroupbox.cpp - pv/widgets/decodermenu.cpp - ) - - list(APPEND DSView_HEADERS - pv/dock/protocoldock.h - pv/data/decoderstack.h - pv/view/decodetrace.h - pv/widgets/decodergroupbox.h - pv/widgets/decodermenu.h - ) -endif() - -if(WIN32) - # Use the DSView icon for the DSView.exe executable. - set(CMAKE_RC_COMPILE_OBJECT "${CMAKE_RC_COMPILER} -O coff -I${CMAKE_CURRENT_SOURCE_DIR} ") - enable_language(RC) - list(APPEND DSView_SOURCES DSView.rc) -endif() - -if(Qt5Core_FOUND) - qt5_wrap_cpp(DSView_HEADERS_MOC ${DSView_HEADERS}) - qt5_wrap_ui(DSView_FORMS_HEADERS ${DSView_FORMS}) - qt5_add_resources(DSView_RESOURCES_RCC ${DSView_RESOURCES}) -else() - qt4_wrap_cpp(DSView_HEADERS_MOC ${DSView_HEADERS}) - qt4_wrap_ui(DSView_FORMS_HEADERS ${DSView_FORMS}) - qt4_add_resources(DSView_RESOURCES_RCC ${DSView_RESOURCES}) - include(${QT_USE_FILE}) -endif() - -#=============================================================================== -#= Global Definitions -#------------------------------------------------------------------------------- - -add_definitions(${QT_DEFINITIONS}) -add_definitions(-Wall -Wextra -Wno-return-type -Wno-ignored-qualifiers) - -if(ENABLE_DECODE) - add_definitions(-DENABLE_DECODE) -endif() - -if(NOT DISABLE_WERROR) - add_definitions(-Werror) -endif() - -#=============================================================================== -#= Global Include Directories -#------------------------------------------------------------------------------- - -include_directories( - ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_CURRENT_SOURCE_DIR} - ${Boost_INCLUDE_DIRS} - ${QT_INCLUDE_DIRS} -) - -if(STATIC_PKGDEPS_LIBS) - include_directories(${PKGDEPS_STATIC_INCLUDE_DIRS}) -else() - include_directories(${PKGDEPS_INCLUDE_DIRS}) -endif() - -#=============================================================================== -#= Linker Configuration -#------------------------------------------------------------------------------- - -link_directories(${Boost_LIBRARY_DIRS}) - -set(DSVIEW_LINK_LIBS - ${Boost_LIBRARIES} - ${CMAKE_THREAD_LIBS_INIT} - ${QT_LIBRARIES} - ${LIBUSB_1_LIBRARIES} -) - -if(STATIC_PKGDEPS_LIBS) - link_directories(${PKGDEPS_STATIC_LIBRARY_DIRS}) - list(APPEND DSVIEW_LINK_LIBS ${PKGDEPS_STATIC_LIBRARIES}) -if(WIN32) - # Workaround for a MinGW linking issue. - list(APPEND PULSEVIEW_LINK_LIBS "-llzma -llcms2") -endif() -else() - link_directories(${PKGDEPS_LIBRARY_DIRS}) - list(APPEND DSVIEW_LINK_LIBS ${PKGDEPS_LIBRARIES}) -endif() - - -add_executable(${PROJECT_NAME} - ${DSView_SOURCES} - ${DSView_HEADERS_MOC} - ${DSView_FORMS_HEADERS} - ${DSView_RESOURCES_RCC} -) - -target_link_libraries(${PROJECT_NAME} ${DSVIEW_LINK_LIBS}) - -if(WIN32) -# Pass -mwindows so that no "DOS box" will open when PulseView is started. -set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "-mwindows") -endif() - - -if(ENABLE_COTIRE) - include(cotire) - cotire(${PROJECT_NAME}) -endif() -set_target_properties(${PROJECT_NAME} PROPERTIES INSTALL_RPATH "/usr/local/lib") - -#=============================================================================== -#= Installation -#------------------------------------------------------------------------------- - -# Install the executable. -install(TARGETS ${PROJECT_NAME} DESTINATION bin/) -install(FILES res/DSLogic.fw DESTINATION bin/res/) -install(FILES res/DSLogic33.bin DESTINATION bin/res/) -install(FILES res/DSLogic50.bin DESTINATION bin/res/) -install(FILES res/DSLogicPro.fw DESTINATION bin/res/) -install(FILES res/DSLogicPro.bin DESTINATION bin/res/) -install(FILES res/DSCope.fw DESTINATION bin/res/) -install(FILES res/DSCope.bin DESTINATION bin/res/) - -#=============================================================================== -#= Packaging (handled by CPack) -#------------------------------------------------------------------------------- - -set(CPACK_PACKAGE_VERSION_MAJOR ${DS_VERSION_MAJOR}) -set(CPACK_PACKAGE_VERSION_MINOR ${DS_VERSION_MINOR}) -set(CPACK_PACKAGE_VERSION_PATCH ${DS_VERSION_MICRO}) -set(CPACK_PACKAGE_DESCRIPTION_FILE ${CMAKE_CURRENT_SOURCE_DIR}/README) -set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/COPYING) -set(CPACK_SOURCE_IGNORE_FILES ${CMAKE_CURRENT_BINARY_DIR} ".gitignore" ".git") -set(CPACK_SOURCE_PACKAGE_FILE_NAME - "${CMAKE_PROJECT_NAME}-${DS_VERSION_MAJOR}.${DS_VERSION_MINOR}.${DS_VERSION_MICRO}") -set(CPACK_SOURCE_GENERATOR "TGZ") - -include(CPack) - -#=============================================================================== -#= Tests -#------------------------------------------------------------------------------- - -if(ENABLE_TESTS) - add_subdirectory(test) - enable_testing() - add_test(test ${CMAKE_CURRENT_BINARY_DIR}/test/DSView-test) -endif(ENABLE_TESTS) diff --git a/DSView/test/data/analogsnapshot.cpp b/DSView/test/data/analogsnapshot.cpp deleted file mode 100644 index 2f46ed51e..000000000 --- a/DSView/test/data/analogsnapshot.cpp +++ /dev/null @@ -1,124 +0,0 @@ -/* - * This file is part of the PulseView project. - * DSView is based on PulseView. - * - * Copyright (C) 2013 Joel Holdsworth - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#define __STDC_LIMIT_MACROS -#include - -#include -#include "../../pv/data/analogsnapshot.h" -#include "../extdef.h" - -using namespace std; - -using pv::data::AnalogSnapshot; - -BOOST_AUTO_TEST_SUITE(AnalogSnapshotTest) - -void push_analog(AnalogSnapshot &s, unsigned int num_samples, - float value) -{ - sr_datafeed_analog analog; - analog.num_samples = num_samples; - - float *data = new float[num_samples]; - analog.data = data; - while(num_samples-- != 0) - *data++ = value; - - s.append_payload(analog); - delete[] (float*)analog.data; -} - -BOOST_AUTO_TEST_CASE(Basic) -{ - // Create an empty AnalogSnapshot object - sr_datafeed_analog analog; - analog.num_samples = 0; - analog.data = NULL; - - AnalogSnapshot s(analog); - - //----- Test AnalogSnapshot::push_analog -----// - - BOOST_CHECK(s.get_sample_count() == 0); - for (unsigned int i = 0; i < AnalogSnapshot::ScaleStepCount; i++) - { - const AnalogSnapshot::Envelope &m = s._envelope_levels[i]; - BOOST_CHECK_EQUAL(m.length, 0); - BOOST_CHECK_EQUAL(m.data_length, 0); - BOOST_CHECK(m.samples == NULL); - } - - // Push 8 samples of all zeros - push_analog(s, 8, 0.0f); - - BOOST_CHECK(s.get_sample_count() == 8); - - // There should not be enough samples to have a single mip map sample - for (unsigned int i = 0; i < AnalogSnapshot::ScaleStepCount; i++) - { - const AnalogSnapshot::Envelope &m = s._envelope_levels[i]; - BOOST_CHECK_EQUAL(m.length, 0); - BOOST_CHECK_EQUAL(m.data_length, 0); - BOOST_CHECK(m.samples == NULL); - } - - // Push 8 samples of 1.0s to bring the total up to 16 - push_analog(s, 8, 1.0f); - - // There should now be enough data for exactly one sample - // in mip map level 0, and that sample should be 0 - const AnalogSnapshot::Envelope &e0 = s._envelope_levels[0]; - BOOST_CHECK_EQUAL(e0.length, 1); - BOOST_CHECK_EQUAL(e0.data_length, AnalogSnapshot::EnvelopeDataUnit); - BOOST_REQUIRE(e0.samples != NULL); - BOOST_CHECK_EQUAL(e0.samples[0].min, 0.0f); - BOOST_CHECK_EQUAL(e0.samples[0].max, 1.0f); - - // The higher levels should still be empty - for (unsigned int i = 1; i < AnalogSnapshot::ScaleStepCount; i++) - { - const AnalogSnapshot::Envelope &m = s._envelope_levels[i]; - BOOST_CHECK_EQUAL(m.length, 0); - BOOST_CHECK_EQUAL(m.data_length, 0); - BOOST_CHECK(m.samples == NULL); - } - - // Push 240 samples of all zeros to bring the total up to 256 - push_analog(s, 240, -1.0f); - - BOOST_CHECK_EQUAL(e0.length, 16); - BOOST_CHECK_EQUAL(e0.data_length, AnalogSnapshot::EnvelopeDataUnit); - - for (unsigned int i = 1; i < e0.length; i++) { - BOOST_CHECK_EQUAL(e0.samples[i].min, -1.0f); - BOOST_CHECK_EQUAL(e0.samples[i].max, -1.0f); - } - - const AnalogSnapshot::Envelope &e1 = s._envelope_levels[1]; - BOOST_CHECK_EQUAL(e1.length, 1); - BOOST_CHECK_EQUAL(e1.data_length, AnalogSnapshot::EnvelopeDataUnit); - BOOST_REQUIRE(e1.samples != NULL); - BOOST_CHECK_EQUAL(e1.samples[0].min, -1.0f); - BOOST_CHECK_EQUAL(e1.samples[0].max, 1.0f); -} - -BOOST_AUTO_TEST_SUITE_END() diff --git a/DSView/test/data/logicsnapshot.cpp b/DSView/test/data/logicsnapshot.cpp deleted file mode 100644 index eb4fb6c56..000000000 --- a/DSView/test/data/logicsnapshot.cpp +++ /dev/null @@ -1,537 +0,0 @@ -/* - * This file is part of the PulseView project. - * DSView is based on PulseView. - * - * Copyright (C) 2012 Joel Holdsworth - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "../extdef.h" - -#define __STDC_LIMIT_MACROS -#include - -#include - -#include "../../pv/data/logicsnapshot.h" - -using namespace std; - -using pv::data::LogicSnapshot; - -BOOST_AUTO_TEST_SUITE(LogicSnapshotTest) - -void push_logic(LogicSnapshot &s, unsigned int length, uint8_t value) -{ - sr_datafeed_logic logic; - logic.unitsize = 1; - logic.length = length; - logic.data = new uint8_t[length]; - memset(logic.data, value, length * logic.unitsize); - s.append_payload(logic); - delete[] (uint8_t*)logic.data; -} - -BOOST_AUTO_TEST_CASE(Pow2) -{ - BOOST_CHECK_EQUAL(LogicSnapshot::pow2_ceil(0, 0), 0); - BOOST_CHECK_EQUAL(LogicSnapshot::pow2_ceil(1, 0), 1); - BOOST_CHECK_EQUAL(LogicSnapshot::pow2_ceil(2, 0), 2); - - BOOST_CHECK_EQUAL( - LogicSnapshot::pow2_ceil(INT64_MIN, 0), INT64_MIN); - BOOST_CHECK_EQUAL( - LogicSnapshot::pow2_ceil(INT64_MAX, 0), INT64_MAX); - - BOOST_CHECK_EQUAL(LogicSnapshot::pow2_ceil(0, 1), 0); - BOOST_CHECK_EQUAL(LogicSnapshot::pow2_ceil(1, 1), 2); - BOOST_CHECK_EQUAL(LogicSnapshot::pow2_ceil(2, 1), 2); - BOOST_CHECK_EQUAL(LogicSnapshot::pow2_ceil(3, 1), 4); -} - -BOOST_AUTO_TEST_CASE(Basic) -{ - // Create an empty LogicSnapshot object - sr_datafeed_logic logic; - logic.length = 0; - logic.unitsize = 1; - logic.data = NULL; - - LogicSnapshot s(logic); - - //----- Test LogicSnapshot::push_logic -----// - - BOOST_CHECK(s.get_sample_count() == 0); - for (unsigned int i = 0; i < LogicSnapshot::ScaleStepCount; i++) - { - const LogicSnapshot::MipMapLevel &m = s._mip_map[i]; - BOOST_CHECK_EQUAL(m.length, 0); - BOOST_CHECK_EQUAL(m.data_length, 0); - BOOST_CHECK(m.data == NULL); - } - - // Push 8 samples of all zeros - push_logic(s, 8, 0); - - BOOST_CHECK(s.get_sample_count() == 8); - - // There should not be enough samples to have a single mip map sample - for (unsigned int i = 0; i < LogicSnapshot::ScaleStepCount; i++) - { - const LogicSnapshot::MipMapLevel &m = s._mip_map[i]; - BOOST_CHECK_EQUAL(m.length, 0); - BOOST_CHECK_EQUAL(m.data_length, 0); - BOOST_CHECK(m.data == NULL); - } - - // Push 8 samples of 0x11s to bring the total up to 16 - push_logic(s, 8, 0x11); - - // There should now be enough data for exactly one sample - // in mip map level 0, and that sample should be 0 - const LogicSnapshot::MipMapLevel &m0 = s._mip_map[0]; - BOOST_CHECK_EQUAL(m0.length, 1); - BOOST_CHECK_EQUAL(m0.data_length, LogicSnapshot::MipMapDataUnit); - BOOST_REQUIRE(m0.data != NULL); - BOOST_CHECK_EQUAL(((uint8_t*)m0.data)[0], 0x11); - - // The higher levels should still be empty - for (unsigned int i = 1; i < LogicSnapshot::ScaleStepCount; i++) - { - const LogicSnapshot::MipMapLevel &m = s._mip_map[i]; - BOOST_CHECK_EQUAL(m.length, 0); - BOOST_CHECK_EQUAL(m.data_length, 0); - BOOST_CHECK(m.data == NULL); - } - - // Push 240 samples of all zeros to bring the total up to 256 - push_logic(s, 240, 0); - - BOOST_CHECK_EQUAL(m0.length, 16); - BOOST_CHECK_EQUAL(m0.data_length, LogicSnapshot::MipMapDataUnit); - - BOOST_CHECK_EQUAL(((uint8_t*)m0.data)[1], 0x11); - for (unsigned int i = 2; i < m0.length; i++) - BOOST_CHECK_EQUAL(((uint8_t*)m0.data)[i], 0); - - const LogicSnapshot::MipMapLevel &m1 = s._mip_map[1]; - BOOST_CHECK_EQUAL(m1.length, 1); - BOOST_CHECK_EQUAL(m1.data_length, LogicSnapshot::MipMapDataUnit); - BOOST_REQUIRE(m1.data != NULL); - BOOST_CHECK_EQUAL(((uint8_t*)m1.data)[0], 0x11); - - //----- Test LogicSnapshot::get_subsampled_edges -----// - - // Test a full view at full zoom. - vector edges; - s.get_subsampled_edges(edges, 0, 255, 1, 0); - BOOST_REQUIRE_EQUAL(edges.size(), 4); - - BOOST_CHECK_EQUAL(edges[0].first, 0); - BOOST_CHECK_EQUAL(edges[1].first, 8); - BOOST_CHECK_EQUAL(edges[2].first, 16); - BOOST_CHECK_EQUAL(edges[3].first, 255); - - // Test a subset at high zoom - edges.clear(); - s.get_subsampled_edges(edges, 6, 17, 0.05f, 0); - BOOST_REQUIRE_EQUAL(edges.size(), 4); - - BOOST_CHECK_EQUAL(edges[0].first, 6); - BOOST_CHECK_EQUAL(edges[1].first, 8); - BOOST_CHECK_EQUAL(edges[2].first, 16); - BOOST_CHECK_EQUAL(edges[3].first, 17); -} - -BOOST_AUTO_TEST_CASE(LargeData) -{ - uint8_t prev_sample; - const unsigned int Length = 1000000; - - sr_datafeed_logic logic; - logic.unitsize = 1; - logic.length = Length; - logic.data = new uint8_t[Length]; - uint8_t *data = (uint8_t*)logic.data; - - for (unsigned int i = 0; i < Length; i++) - *data++ = (uint8_t)(i >> 8); - - LogicSnapshot s(logic); - delete[] (uint8_t*)logic.data; - - BOOST_CHECK(s.get_sample_count() == Length); - - // Check mip map level 0 - BOOST_CHECK_EQUAL(s._mip_map[0].length, 62500); - BOOST_CHECK_EQUAL(s._mip_map[0].data_length, - LogicSnapshot::MipMapDataUnit); - BOOST_REQUIRE(s._mip_map[0].data != NULL); - - prev_sample = 0; - for (unsigned int i = 0; i < s._mip_map[0].length;) - { - BOOST_TEST_MESSAGE("Testing mip_map[0].data[" << i << "]"); - - const uint8_t sample = (uint8_t)((i*16) >> 8); - BOOST_CHECK_EQUAL(s.get_subsample(0, i++) & 0xFF, - prev_sample ^ sample); - prev_sample = sample; - - for (int j = 1; i < s._mip_map[0].length && j < 16; j++) - { - BOOST_TEST_MESSAGE("Testing mip_map[0].data[" << i << "]"); - BOOST_CHECK_EQUAL(s.get_subsample(0, i++) & 0xFF, 0); - } - } - - // Check mip map level 1 - BOOST_CHECK_EQUAL(s._mip_map[1].length, 3906); - BOOST_CHECK_EQUAL(s._mip_map[1].data_length, - LogicSnapshot::MipMapDataUnit); - BOOST_REQUIRE(s._mip_map[1].data != NULL); - - prev_sample = 0; - for (unsigned int i = 0; i < s._mip_map[1].length; i++) - { - BOOST_TEST_MESSAGE("Testing mip_map[1].data[" << i << "]"); - - const uint8_t sample = i; - const uint8_t expected = sample ^ prev_sample; - prev_sample = i; - - BOOST_CHECK_EQUAL(s.get_subsample(1, i) & 0xFF, expected); - } - - // Check mip map level 2 - BOOST_CHECK_EQUAL(s._mip_map[2].length, 244); - BOOST_CHECK_EQUAL(s._mip_map[2].data_length, - LogicSnapshot::MipMapDataUnit); - BOOST_REQUIRE(s._mip_map[2].data != NULL); - - prev_sample = 0; - for (unsigned int i = 0; i < s._mip_map[2].length; i++) - { - BOOST_TEST_MESSAGE("Testing mip_map[2].data[" << i << "]"); - - const uint8_t sample = i << 4; - const uint8_t expected = (sample ^ prev_sample) | 0x0F; - prev_sample = sample; - - BOOST_CHECK_EQUAL(s.get_subsample(2, i) & 0xFF, expected); - } - - // Check mip map level 3 - BOOST_CHECK_EQUAL(s._mip_map[3].length, 15); - BOOST_CHECK_EQUAL(s._mip_map[3].data_length, - LogicSnapshot::MipMapDataUnit); - BOOST_REQUIRE(s._mip_map[3].data != NULL); - - for (unsigned int i = 0; i < s._mip_map[3].length; i++) - BOOST_CHECK_EQUAL(*((uint8_t*)s._mip_map[3].data + i), - 0xFF); - - // Check the higher levels - for (unsigned int i = 4; i < LogicSnapshot::ScaleStepCount; i++) - { - const LogicSnapshot::MipMapLevel &m = s._mip_map[i]; - BOOST_CHECK_EQUAL(m.length, 0); - BOOST_CHECK_EQUAL(m.data_length, 0); - BOOST_CHECK(m.data == NULL); - } - - //----- Test LogicSnapshot::get_subsampled_edges -----// - // Check in normal case - vector edges; - s.get_subsampled_edges(edges, 0, Length-1, 1, 7); - - BOOST_CHECK_EQUAL(edges.size(), 32); - - for (unsigned int i = 0; i < edges.size() - 1; i++) - { - BOOST_CHECK_EQUAL(edges[i].first, i * 32768); - BOOST_CHECK_EQUAL(edges[i].second, i & 1); - } - - BOOST_CHECK_EQUAL(edges[31].first, 999999); - - // Check in very low zoom case - edges.clear(); - s.get_subsampled_edges(edges, 0, Length-1, 50e6f, 7); - - BOOST_CHECK_EQUAL(edges.size(), 2); -} - -BOOST_AUTO_TEST_CASE(Pulses) -{ - const int Cycles = 3; - const int Period = 64; - const int Length = Cycles * Period; - - vector edges; - - //----- Create a LogicSnapshot -----// - sr_datafeed_logic logic; - logic.unitsize = 1; - logic.length = Length; - logic.data = (uint64_t*)new uint8_t[Length]; - uint8_t *p = (uint8_t*)logic.data; - - for (int i = 0; i < Cycles; i++) { - *p++ = 0xFF; - for (int j = 1; j < Period; j++) - *p++ = 0x00; - } - - LogicSnapshot s(logic); - delete[] (uint8_t*)logic.data; - - //----- Check the mip-map -----// - // Check mip map level 0 - BOOST_CHECK_EQUAL(s._mip_map[0].length, 12); - BOOST_CHECK_EQUAL(s._mip_map[0].data_length, - LogicSnapshot::MipMapDataUnit); - BOOST_REQUIRE(s._mip_map[0].data != NULL); - - for (unsigned int i = 0; i < s._mip_map[0].length;) { - BOOST_TEST_MESSAGE("Testing mip_map[0].data[" << i << "]"); - BOOST_CHECK_EQUAL(s.get_subsample(0, i++) & 0xFF, 0xFF); - - for (int j = 1; - i < s._mip_map[0].length && - j < Period/LogicSnapshot::MipMapScaleFactor; j++) { - BOOST_TEST_MESSAGE( - "Testing mip_map[0].data[" << i << "]"); - BOOST_CHECK_EQUAL(s.get_subsample(0, i++) & 0xFF, 0x00); - } - } - - // Check the higher levels are all inactive - for (unsigned int i = 1; i < LogicSnapshot::ScaleStepCount; i++) { - const LogicSnapshot::MipMapLevel &m = s._mip_map[i]; - BOOST_CHECK_EQUAL(m.length, 0); - BOOST_CHECK_EQUAL(m.data_length, 0); - BOOST_CHECK(m.data == NULL); - } - - //----- Test get_subsampled_edges at reduced scale -----// - s.get_subsampled_edges(edges, 0, Length-1, 16.0f, 2); - BOOST_REQUIRE_EQUAL(edges.size(), Cycles + 2); - - BOOST_CHECK_EQUAL(0, false); - for (unsigned int i = 1; i < edges.size(); i++) - BOOST_CHECK_EQUAL(edges[i].second, false); -} - -BOOST_AUTO_TEST_CASE(LongPulses) -{ - const int Cycles = 3; - const int Period = 64; - const int PulseWidth = 16; - const int Length = Cycles * Period; - - int j; - vector edges; - - //----- Create a LogicSnapshot -----// - sr_datafeed_logic logic; - logic.unitsize = 8; - logic.length = Length * 8; - logic.data = (uint64_t*)new uint64_t[Length]; - uint64_t *p = (uint64_t*)logic.data; - - for (int i = 0; i < Cycles; i++) { - for (j = 0; j < PulseWidth; j++) - *p++ = ~0; - for (; j < Period; j++) - *p++ = 0; - } - - LogicSnapshot s(logic); - delete[] (uint64_t*)logic.data; - - //----- Check the mip-map -----// - // Check mip map level 0 - BOOST_CHECK_EQUAL(s._mip_map[0].length, 12); - BOOST_CHECK_EQUAL(s._mip_map[0].data_length, - LogicSnapshot::MipMapDataUnit); - BOOST_REQUIRE(s._mip_map[0].data != NULL); - - for (unsigned int i = 0; i < s._mip_map[0].length;) { - for (j = 0; i < s._mip_map[0].length && j < 2; j++) { - BOOST_TEST_MESSAGE( - "Testing mip_map[0].data[" << i << "]"); - BOOST_CHECK_EQUAL(s.get_subsample(0, i++), ~0); - } - - for (; i < s._mip_map[0].length && - j < Period/LogicSnapshot::MipMapScaleFactor; j++) { - BOOST_TEST_MESSAGE( - "Testing mip_map[0].data[" << i << "]"); - BOOST_CHECK_EQUAL(s.get_subsample(0, i++), 0); - } - } - - // Check the higher levels are all inactive - for (unsigned int i = 1; i < LogicSnapshot::ScaleStepCount; i++) { - const LogicSnapshot::MipMapLevel &m = s._mip_map[i]; - BOOST_CHECK_EQUAL(m.length, 0); - BOOST_CHECK_EQUAL(m.data_length, 0); - BOOST_CHECK(m.data == NULL); - } - - //----- Test get_subsampled_edges at a full scale -----// - s.get_subsampled_edges(edges, 0, Length-1, 16.0f, 2); - BOOST_REQUIRE_EQUAL(edges.size(), Cycles * 2 + 1); - - for (int i = 0; i < Cycles; i++) { - BOOST_CHECK_EQUAL(edges[i*2].first, i * Period); - BOOST_CHECK_EQUAL(edges[i*2].second, true); - BOOST_CHECK_EQUAL(edges[i*2+1].first, i * Period + PulseWidth); - BOOST_CHECK_EQUAL(edges[i*2+1].second, false); - } - - BOOST_CHECK_EQUAL(edges.back().first, Length-1); - BOOST_CHECK_EQUAL(edges.back().second, false); - - //----- Test get_subsampled_edges at a simplified scale -----// - edges.clear(); - s.get_subsampled_edges(edges, 0, Length-1, 17.0f, 2); - - BOOST_CHECK_EQUAL(edges[0].first, 0); - BOOST_CHECK_EQUAL(edges[0].second, true); - BOOST_CHECK_EQUAL(edges[1].first, 16); - BOOST_CHECK_EQUAL(edges[1].second, false); - - for (int i = 1; i < Cycles; i++) { - BOOST_CHECK_EQUAL(edges[i+1].first, i * Period); - BOOST_CHECK_EQUAL(edges[i+1].second, false); - } - - BOOST_CHECK_EQUAL(edges.back().first, Length-1); - BOOST_CHECK_EQUAL(edges.back().second, false); -} - -BOOST_AUTO_TEST_CASE(LisaMUsbHid) -{ - /* This test was created from the beginning of the USB_DM signal in - * sigrok-dumps-usb/lisa_m_usbhid/lisa_m_usbhid.sr - */ - - const int Edges[] = { - 7028, 7033, 7036, 7041, 7044, 7049, 7053, 7066, 7073, 7079, - 7086, 7095, 7103, 7108, 7111, 7116, 7119, 7124, 7136, 7141, - 7148, 7162, 7500 - }; - const int Length = Edges[countof(Edges) - 1]; - - bool state = false; - int lastEdgePos = 0; - - //----- Create a LogicSnapshot -----// - sr_datafeed_logic logic; - logic.unitsize = 1; - logic.length = Length; - logic.data = new uint8_t[Length]; - uint8_t *data = (uint8_t*)logic.data; - - for (unsigned int i = 0; i < countof(Edges); i++) { - const int edgePos = Edges[i]; - memset(&data[lastEdgePos], state ? 0x02 : 0, - edgePos - lastEdgePos - 1); - - lastEdgePos = edgePos; - state = !state; - } - - LogicSnapshot s(logic); - delete[] (uint64_t*)logic.data; - - vector edges; - - - /* The trailing edge of the pulse train is falling in the source data. - * Check this is always true at different scales - */ - - edges.clear(); - s.get_subsampled_edges(edges, 0, Length-1, 33.333332f, 1); - BOOST_CHECK_EQUAL(edges[edges.size() - 2].second, false); -} - -/* - * This test checks the rendering of wide data (more than 8 probes) - * Probe signals are either all-high, or all-low, but are interleaved such that - * they would toggle during every sample if treated like 8 probes. - * The packet contains a large number of samples, so the mipmap generation kicks - * in. - * - * The signals should not toggle (have exactly two edges: the start and end) - */ -BOOST_AUTO_TEST_CASE(WideData) -{ - const int Length = 512<<10; - uint16_t *data = new uint16_t[Length]; - - sr_datafeed_logic logic; - logic.unitsize = sizeof(data[0]); - logic.length = Length * sizeof(data[0]); - logic.data = data; - - for (int i = 0; i < Length; i++) - data[i] = 0x0FF0; - - LogicSnapshot s(logic); - - vector edges; - - edges.clear(); - s.get_subsampled_edges(edges, 0, Length-1, 1, 0); - BOOST_CHECK_EQUAL(edges.size(), 2); - - edges.clear(); - s.get_subsampled_edges(edges, 0, Length-1, 1, 8); - BOOST_CHECK_EQUAL(edges.size(), 2); - - // Cleanup - delete [] data; -} - -/* - * This test is a replica of sixteen.sr attached to Bug #33. - */ -BOOST_AUTO_TEST_CASE(Sixteen) -{ - const int Length = 8; - uint16_t data[Length]; - - sr_datafeed_logic logic; - logic.unitsize = sizeof(data[0]); - logic.length = Length * sizeof(data[0]); - logic.data = data; - - for (int i = 0; i < Length; i++) - data[i] = 0xFFFE; - - LogicSnapshot s(logic); - - vector edges; - s.get_subsampled_edges(edges, 0, 2, 0.0004, 1); - - BOOST_CHECK_EQUAL(edges.size(), 2); -} - -BOOST_AUTO_TEST_SUITE_END() diff --git a/DSView/test/test.cpp b/DSView/test/test.cpp deleted file mode 100644 index b74021a54..000000000 --- a/DSView/test/test.cpp +++ /dev/null @@ -1,23 +0,0 @@ -/* - * This file is part of the PulseView project. - * DSView is based on PulseView. - * - * Copyright (C) 2012 Joel Holdsworth - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#define BOOST_TEST_MAIN -#include diff --git a/libsigrok4DSL/tests/check_core.c b/libsigrok4DSL/tests/check_core.c deleted file mode 100644 index fae7b24a2..000000000 --- a/libsigrok4DSL/tests/check_core.c +++ /dev/null @@ -1,182 +0,0 @@ -/* - * This file is part of the libsigrok project. - * - * Copyright (C) 2013 Uwe Hermann - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include -#include -#include - -/* - * Check various basic init related things. - * - * - Check whether an sr_init() call with a proper sr_ctx works. - * If it returns != SR_OK (or segfaults) this test will fail. - * The sr_init() call (among other things) also runs sanity checks on - * all libsigrok hardware drivers and errors out upon issues. - * - * - Check whether a subsequent sr_exit() with that sr_ctx works. - * If it returns != SR_OK (or segfaults) this test will fail. - */ -START_TEST(test_init_exit) -{ - int ret; - struct sr_context *sr_ctx; - - ret = sr_init(&sr_ctx); - fail_unless(ret == SR_OK, "sr_init() failed: %d.", ret); - ret = sr_exit(sr_ctx); - fail_unless(ret == SR_OK, "sr_exit() failed: %d.", ret); -} -END_TEST - -/* - * Check whether two nested sr_init() and sr_exit() calls work. - * The two functions have two different contexts. - * If any function returns != SR_OK (or segfaults) this test will fail. - */ -START_TEST(test_init_exit_2) -{ - int ret; - struct sr_context *sr_ctx1, *sr_ctx2; - - ret = sr_init(&sr_ctx1); - fail_unless(ret == SR_OK, "sr_init() 1 failed: %d.", ret); - ret = sr_init(&sr_ctx2); - fail_unless(ret == SR_OK, "sr_init() 2 failed: %d.", ret); - ret = sr_exit(sr_ctx2); - fail_unless(ret == SR_OK, "sr_exit() 2 failed: %d.", ret); - ret = sr_exit(sr_ctx1); - fail_unless(ret == SR_OK, "sr_exit() 1 failed: %d.", ret); -} -END_TEST - -/* - * Same as above, but sr_exit() in the "wrong" order. - * This should work fine, it's not a bug to do this. - */ -START_TEST(test_init_exit_2_reverse) -{ - int ret; - struct sr_context *sr_ctx1, *sr_ctx2; - - ret = sr_init(&sr_ctx1); - fail_unless(ret == SR_OK, "sr_init() 1 failed: %d.", ret); - ret = sr_init(&sr_ctx2); - fail_unless(ret == SR_OK, "sr_init() 2 failed: %d.", ret); - ret = sr_exit(sr_ctx1); - fail_unless(ret == SR_OK, "sr_exit() 1 failed: %d.", ret); - ret = sr_exit(sr_ctx2); - fail_unless(ret == SR_OK, "sr_exit() 2 failed: %d.", ret); -} -END_TEST - -/* - * Check whether three nested sr_init() and sr_exit() calls work. - * The three functions have three different contexts. - * If any function returns != SR_OK (or segfaults) this test will fail. - */ -START_TEST(test_init_exit_3) -{ - int ret; - struct sr_context *sr_ctx1, *sr_ctx2, *sr_ctx3; - - ret = sr_init(&sr_ctx1); - fail_unless(ret == SR_OK, "sr_init() 1 failed: %d.", ret); - ret = sr_init(&sr_ctx2); - fail_unless(ret == SR_OK, "sr_init() 2 failed: %d.", ret); - ret = sr_init(&sr_ctx3); - fail_unless(ret == SR_OK, "sr_init() 3 failed: %d.", ret); - ret = sr_exit(sr_ctx3); - fail_unless(ret == SR_OK, "sr_exit() 3 failed: %d.", ret); - ret = sr_exit(sr_ctx2); - fail_unless(ret == SR_OK, "sr_exit() 2 failed: %d.", ret); - ret = sr_exit(sr_ctx1); - fail_unless(ret == SR_OK, "sr_exit() 1 failed: %d.", ret); -} -END_TEST - -/* - * Same as above, but sr_exit() in the "wrong" order. - * This should work fine, it's not a bug to do this. - */ -START_TEST(test_init_exit_3_reverse) -{ - int ret; - struct sr_context *sr_ctx1, *sr_ctx2, *sr_ctx3; - - ret = sr_init(&sr_ctx1); - fail_unless(ret == SR_OK, "sr_init() 1 failed: %d.", ret); - ret = sr_init(&sr_ctx2); - fail_unless(ret == SR_OK, "sr_init() 2 failed: %d.", ret); - ret = sr_init(&sr_ctx3); - fail_unless(ret == SR_OK, "sr_init() 3 failed: %d.", ret); - ret = sr_exit(sr_ctx1); - fail_unless(ret == SR_OK, "sr_exit() 1 failed: %d.", ret); - ret = sr_exit(sr_ctx2); - fail_unless(ret == SR_OK, "sr_exit() 2 failed: %d.", ret); - ret = sr_exit(sr_ctx3); - fail_unless(ret == SR_OK, "sr_exit() 3 failed: %d.", ret); -} -END_TEST - -/* Check whether sr_init(NULL) fails as it should. */ -START_TEST(test_init_null) -{ - int ret; - - ret = sr_log_loglevel_set(SR_LOG_NONE); - fail_unless(ret == SR_OK, "sr_log_loglevel_set() failed: %d.", ret); - - ret = sr_init(NULL); - fail_unless(ret != SR_OK, "sr_init(NULL) should have failed."); -} -END_TEST - -/* Check whether sr_exit(NULL) fails as it should. */ -START_TEST(test_exit_null) -{ - int ret; - - ret = sr_log_loglevel_set(SR_LOG_NONE); - fail_unless(ret == SR_OK, "sr_log_loglevel_set() failed: %d.", ret); - - ret = sr_exit(NULL); - fail_unless(ret != SR_OK, "sr_exit(NULL) should have failed."); -} -END_TEST - -Suite *suite_core(void) -{ - Suite *s; - TCase *tc; - - s = suite_create("core"); - - tc = tcase_create("init_exit"); - tcase_add_test(tc, test_init_exit); - tcase_add_test(tc, test_init_exit_2); - tcase_add_test(tc, test_init_exit_2_reverse); - tcase_add_test(tc, test_init_exit_3); - tcase_add_test(tc, test_init_exit_3_reverse); - tcase_add_test(tc, test_init_null); - tcase_add_test(tc, test_exit_null); - suite_add_tcase(s, tc); - - return s; -} diff --git a/libsigrok4DSL/tests/check_driver_all.c b/libsigrok4DSL/tests/check_driver_all.c deleted file mode 100644 index 099013a97..000000000 --- a/libsigrok4DSL/tests/check_driver_all.c +++ /dev/null @@ -1,96 +0,0 @@ -/* - * This file is part of the libsigrok project. - * - * Copyright (C) 2013 Uwe Hermann - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include -#include -#include -#include "lib.h" - -struct sr_context *sr_ctx; - -static void setup(void) -{ - int ret; - - ret = sr_init(&sr_ctx); - fail_unless(ret == SR_OK, "sr_init() failed: %d.", ret); -} - -static void teardown(void) -{ - int ret; - - ret = sr_exit(sr_ctx); - fail_unless(ret == SR_OK, "sr_exit() failed: %d.", ret); -} - -/* Check whether at least one driver is available. */ -START_TEST(test_driver_available) -{ - struct sr_dev_driver **drivers; - - drivers = sr_driver_list(); - fail_unless(drivers != NULL, "No drivers found."); -} -END_TEST - -/* Check whether initializing all drivers works. */ -START_TEST(test_driver_init_all) -{ - srtest_driver_init_all(sr_ctx); -} -END_TEST - -/* - * Check whether setting a samplerate works. - * - * Additionally, this also checks whether SR_CONF_SAMPLERATE can be both - * set and read back properly. - */ -#if 0 -START_TEST(test_config_get_set_samplerate) -{ - /* - * Note: This currently only works for the demo driver. - * For other drivers, a scan is needed and the respective - * hardware must be attached to the host running the testsuite. - */ - srtest_check_samplerate(sr_ctx, "demo", SR_KHZ(19)); -} -END_TEST -#endif - -Suite *suite_driver_all(void) -{ - Suite *s; - TCase *tc; - - s = suite_create("driver-all"); - - tc = tcase_create("config"); - tcase_add_checked_fixture(tc, setup, teardown); - tcase_add_test(tc, test_driver_available); - tcase_add_test(tc, test_driver_init_all); - // TODO: Currently broken. - // tcase_add_test(tc, test_config_get_set_samplerate); - suite_add_tcase(s, tc); - - return s; -} diff --git a/libsigrok4DSL/tests/check_main.c b/libsigrok4DSL/tests/check_main.c deleted file mode 100644 index 45de83c42..000000000 --- a/libsigrok4DSL/tests/check_main.c +++ /dev/null @@ -1,48 +0,0 @@ -/* - * This file is part of the libsigrok project. - * - * Copyright (C) 2013 Uwe Hermann - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include -#include -#include - -Suite *suite_core(void); -Suite *suite_strutil(void); -Suite *suite_driver_all(void); - -int main(void) -{ - int ret; - Suite *s; - SRunner *srunner; - - s = suite_create("mastersuite"); - srunner = srunner_create(s); - - /* Add all testsuites to the master suite. */ - srunner_add_suite(srunner, suite_core()); - srunner_add_suite(srunner, suite_strutil()); - srunner_add_suite(srunner, suite_driver_all()); - - srunner_run_all(srunner, CK_VERBOSE); - ret = srunner_ntests_failed(srunner); - srunner_free(srunner); - - return (ret == 0) ? EXIT_SUCCESS : EXIT_FAILURE; -} diff --git a/libsigrok4DSL/tests/check_strutil.c b/libsigrok4DSL/tests/check_strutil.c deleted file mode 100644 index 815ceb914..000000000 --- a/libsigrok4DSL/tests/check_strutil.c +++ /dev/null @@ -1,192 +0,0 @@ -/* - * This file is part of the libsigrok project. - * - * Copyright (C) 2013 Uwe Hermann - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include -#include - -struct sr_context *sr_ctx; - -static void setup(void) -{ - int ret; - - ret = sr_init(&sr_ctx); - fail_unless(ret == SR_OK, "sr_init() failed: %d.", ret); -} - -static void teardown(void) -{ - int ret; - - ret = sr_exit(sr_ctx); - fail_unless(ret == SR_OK, "sr_exit() failed: %d.", ret); -} - -static void test_samplerate(uint64_t samplerate, const char *expected) -{ - char *s; - - s = sr_samplerate_string(samplerate); - fail_unless(s != NULL); - fail_unless(!strcmp(s, expected), - "Invalid result for '%s': %s.", expected, s); - g_free(s); -} - -/* - * Check various inputs for sr_samplerate_string(): - * - * - One, two, or three digit results (e.g. 5/55/555 MHz). - * - Results which contain commas (e.g. 1.234 / 12.34 / 123.4 kHz). - * - Results with zeroes right after the comma (e.g. 1.034 Hz). - * See also: http://sigrok.org/bugzilla/show_bug.cgi?id=73 - * - Results with trailing zeroes (e.g. 1.230 kHz). - * (This is currently allowed, but might be changed later) - * - Results with zeroes in the middle (e.g. 1.204 kHz). - * - All of the above, but using SR_MHZ() and friends. - * See also: http://sigrok.org/bugzilla/show_bug.cgi?id=72 - * - * All of the above tests are done for the Hz/kHz/MHz/GHz ranges. - */ - -START_TEST(test_hz) -{ - test_samplerate(0, "0 Hz"); - test_samplerate(1, "1 Hz"); - test_samplerate(23, "23 Hz"); - test_samplerate(644, "644 Hz"); - test_samplerate(604, "604 Hz"); - test_samplerate(550, "550 Hz"); - - /* Again, but now using SR_HZ(). */ - test_samplerate(SR_HZ(0), "0 Hz"); - test_samplerate(SR_HZ(1), "1 Hz"); - test_samplerate(SR_HZ(23), "23 Hz"); - test_samplerate(SR_HZ(644), "644 Hz"); - test_samplerate(SR_HZ(604), "604 Hz"); - test_samplerate(SR_HZ(550), "550 Hz"); -} -END_TEST - -START_TEST(test_khz) -{ - test_samplerate(1000, "1 kHz"); - test_samplerate(99000, "99 kHz"); - test_samplerate(225000, "225 kHz"); - test_samplerate(1234, "1.234 kHz"); - test_samplerate(12345, "12.345 kHz"); - test_samplerate(123456, "123.456 kHz"); - test_samplerate(1034, "1.034 kHz"); - test_samplerate(1004, "1.004 kHz"); - test_samplerate(1230, "1.230 kHz"); - - /* Again, but now using SR_KHZ(). */ - test_samplerate(SR_KHZ(1), "1 kHz"); - test_samplerate(SR_KHZ(99), "99 kHz"); - test_samplerate(SR_KHZ(225), "225 kHz"); - test_samplerate(SR_KHZ(1.234), "1.234 kHz"); - test_samplerate(SR_KHZ(12.345), "12.345 kHz"); - test_samplerate(SR_KHZ(123.456), "123.456 kHz"); - test_samplerate(SR_KHZ(1.204), "1.204 kHz"); - test_samplerate(SR_KHZ(1.034), "1.034 kHz"); - test_samplerate(SR_KHZ(1.004), "1.004 kHz"); - test_samplerate(SR_KHZ(1.230), "1.230 kHz"); -} -END_TEST - -START_TEST(test_mhz) -{ - test_samplerate(1000000, "1 MHz"); - test_samplerate(28000000, "28 MHz"); - test_samplerate(775000000, "775 MHz"); - test_samplerate(1234567, "1.234567 MHz"); - test_samplerate(12345678, "12.345678 MHz"); - test_samplerate(123456789, "123.456789 MHz"); - test_samplerate(1230007, "1.230007 MHz"); - test_samplerate(1034567, "1.034567 MHz"); - test_samplerate(1000007, "1.000007 MHz"); - test_samplerate(1234000, "1.234000 MHz"); - - /* Again, but now using SR_MHZ(). */ - test_samplerate(SR_MHZ(1), "1 MHz"); - test_samplerate(SR_MHZ(28), "28 MHz"); - test_samplerate(SR_MHZ(775), "775 MHz"); - test_samplerate(SR_MHZ(1.234567), "1.234567 MHz"); - test_samplerate(SR_MHZ(12.345678), "12.345678 MHz"); - test_samplerate(SR_MHZ(123.456789), "123.456789 MHz"); - test_samplerate(SR_MHZ(1.230007), "1.230007 MHz"); - test_samplerate(SR_MHZ(1.034567), "1.034567 MHz"); - test_samplerate(SR_MHZ(1.000007), "1.000007 MHz"); - test_samplerate(SR_MHZ(1.234000), "1.234000 MHz"); -} -END_TEST - -START_TEST(test_ghz) -{ - /* Note: Numbers > 2^32 need a ULL suffix. */ - - test_samplerate(1000000000, "1 GHz"); - test_samplerate(5000000000ULL, "5 GHz"); - test_samplerate(72000000000ULL, "72 GHz"); - test_samplerate(388000000000ULL, "388 GHz"); - test_samplerate(4417594444ULL, "4.417594444 GHz"); - test_samplerate(44175944444ULL, "44.175944444 GHz"); - test_samplerate(441759444441ULL, "441.759444441 GHz"); - test_samplerate(441759000001ULL, "441.759000001 GHz"); - test_samplerate(441050000000ULL, "441.05 GHz"); - test_samplerate(441000000005ULL, "441.000000005 GHz"); - test_samplerate(441500000000ULL, "441.500000000 GHz"); - - /* Again, but now using SR_GHZ(). */ - test_samplerate(SR_GHZ(1), "1 GHz"); - test_samplerate(SR_GHZ(5), "5 GHz"); - test_samplerate(SR_GHZ(72), "72 GHz"); - test_samplerate(SR_GHZ(388), "388 GHz"); - test_samplerate(SR_GHZ(4.417594444), "4.417594444 GHz"); - test_samplerate(SR_GHZ(44.175944444), "44.175944444 GHz"); - test_samplerate(SR_GHZ(441.759444441), "441.759444441 GHz"); - test_samplerate(SR_GHZ(441.759000001), "441.759000001 GHz"); - test_samplerate(SR_GHZ(441.050000000), "441.05 GHz"); - test_samplerate(SR_GHZ(441.000000005), "441.000000005 GHz"); - test_samplerate(SR_GHZ(441.500000000), "441.500000000 GHz"); - - /* Now check the biggest-possible samplerate (2^64 Hz). */ - test_samplerate(18446744073709551615ULL, "18446744073.709551615 GHz"); - test_samplerate(SR_GHZ(18446744073ULL), "18446744073 GHz"); -} -END_TEST - -Suite *suite_strutil(void) -{ - Suite *s; - TCase *tc; - - s = suite_create("strutil"); - - tc = tcase_create("sr_samplerate_string"); - tcase_add_checked_fixture(tc, setup, teardown); - tcase_add_test(tc, test_hz); - tcase_add_test(tc, test_khz); - tcase_add_test(tc, test_mhz); - tcase_add_test(tc, test_ghz); - suite_add_tcase(s, tc); - - return s; -} diff --git a/libsigrok4DSL/tests/lib.c b/libsigrok4DSL/tests/lib.c deleted file mode 100644 index a628a1a79..000000000 --- a/libsigrok4DSL/tests/lib.c +++ /dev/null @@ -1,122 +0,0 @@ -/* - * This file is part of the libsigrok project. - * - * Copyright (C) 2013 Uwe Hermann - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include -#include -#include -#include - -/* Get a libsigrok driver by name. */ -struct sr_dev_driver *srtest_driver_get(const char *drivername) -{ - struct sr_dev_driver **drivers, *driver = NULL; - int i; - - drivers = sr_driver_list(); - fail_unless(drivers != NULL, "No drivers found."); - - for (i = 0; drivers[i]; i++) { - if (strcmp(drivers[i]->name, drivername)) - continue; - driver = drivers[i]; - } - fail_unless(driver != NULL, "Driver '%s' not found.", drivername); - - return driver; -} - -/* Initialize a libsigrok driver. */ -void srtest_driver_init(struct sr_context *sr_ctx, struct sr_dev_driver *driver) -{ - int ret; - - ret = sr_driver_init(sr_ctx, driver); - fail_unless(ret == SR_OK, "Failed to init '%s' driver: %d.", - driver->name, ret); -} - -/* Initialize all libsigrok drivers. */ -void srtest_driver_init_all(struct sr_context *sr_ctx) -{ - struct sr_dev_driver **drivers, *driver; - int i, ret; - - drivers = sr_driver_list(); - fail_unless(drivers != NULL, "No drivers found."); - - for (i = 0; drivers[i]; i++) { - driver = drivers[i]; - ret = sr_driver_init(sr_ctx, driver); - fail_unless(ret == SR_OK, "Failed to init '%s' driver: %d.", - driver->name, ret); - } -} - -/* Set the samplerate for the respective driver to the specified value. */ -void srtest_set_samplerate(struct sr_dev_driver *driver, uint64_t samplerate) -{ - int ret; - struct sr_dev_inst *sdi; - GVariant *gvar; - - sdi = g_slist_nth_data(driver->priv, 0); - - gvar = g_variant_new_uint64(samplerate); - ret = driver->config_set(SR_CONF_SAMPLERATE, gvar, sdi); - g_variant_unref(gvar); - - fail_unless(ret == SR_OK, "%s: Failed to set SR_CONF_SAMPLERATE: %d.", - driver->name, ret); -} - -/* Get the respective driver's current samplerate. */ -uint64_t srtest_get_samplerate(struct sr_dev_driver *driver) -{ - int ret; - uint64_t samplerate; - struct sr_dev_inst *sdi; - GVariant *gvar; - - sdi = g_slist_nth_data(driver->priv, 0); - - ret = driver->config_get(SR_CONF_SAMPLERATE, &gvar, sdi); - samplerate = g_variant_get_uint64(gvar); - g_variant_unref(gvar); - - fail_unless(ret == SR_OK, "%s: Failed to get SR_CONF_SAMPLERATE: %d.", - driver->name, ret); - - return samplerate; -} - -/* Check whether the respective driver can set/get the correct samplerate. */ -void srtest_check_samplerate(struct sr_context *sr_ctx, const char *drivername, - uint64_t samplerate) -{ - struct sr_dev_driver *driver; - uint64_t s; - - driver = srtest_driver_get(drivername); - srtest_driver_init(sr_ctx, driver);; - srtest_set_samplerate(driver, samplerate); - s = srtest_get_samplerate(driver); - fail_unless(s == samplerate, "%s: Incorrect samplerate: %llu.", - drivername, (u64_t)s); -} diff --git a/libsigrok4DSL/tests/lib.h b/libsigrok4DSL/tests/lib.h deleted file mode 100644 index c48ce1e8b..000000000 --- a/libsigrok4DSL/tests/lib.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * This file is part of the libsigrok project. - * - * Copyright (C) 2013 Uwe Hermann - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef LIBSIGROK_TESTS_LIB_H -#define LIBSIGROK_TESTS_LIB_H - -#include - -struct sr_dev_driver *srtest_driver_get(const char *drivername); -void srtest_driver_init(struct sr_context *sr_ctx, struct sr_dev_driver *driver); -void srtest_driver_init_all(struct sr_context *sr_ctx); -void srtest_set_samplerate(struct sr_dev_driver *driver, uint64_t samplerate); -uint64_t srtest_get_samplerate(struct sr_dev_driver *driver); -void srtest_check_samplerate(struct sr_context *sr_ctx, const char *drivername, - uint64_t samplerate); - -#endif diff --git a/libsigrok4DSL/tests/test_main.cpp b/libsigrok4DSL/tests/test_main.cpp deleted file mode 100644 index 3ab8d96c1..000000000 --- a/libsigrok4DSL/tests/test_main.cpp +++ /dev/null @@ -1,68 +0,0 @@ - -#include -#include "../log.h" -#include -#include -#include -#include - -#include -#include -#include - -using namespace std; - -#undef LOG_PREFIX -#define LOG_PREFIX "test_main: " - -int b_exit = 0; - -void print_log(const char *data, int len){ - if (len > 0){ - //*(data + len-1) = 0; - QString s(data); - // qDebug()<ann_types = g_slist_append(dec->ann_types, GINT_TO_POINTER(ann_type)); - } else if (PyTuple_Size(py_ann) == 2) { + } + else if (PyTuple_Size(py_ann) == 2) { dec->ann_types = g_slist_append(dec->ann_types, GINT_TO_POINTER(ann_type)); ann_type++; } diff --git a/libsigrokdecode4DSL/libsigrokdecode.h b/libsigrokdecode4DSL/libsigrokdecode.h index 79f1d23ad..306c54e5b 100644 --- a/libsigrokdecode4DSL/libsigrokdecode.h +++ b/libsigrokdecode4DSL/libsigrokdecode.h @@ -347,7 +347,8 @@ struct srd_proto_data { }; struct srd_proto_data_annotation { int ann_class; - int ann_type; + int ann_type; + int ann_row_index; char str_number_hex[DECODE_NUM_HEX_MAX_LEN]; //numerical value hex format string long long numberic_value; char **ann_text; //text string lines diff --git a/libsigrokdecode4DSL/type_decoder.c b/libsigrokdecode4DSL/type_decoder.c index 266858403..fd2d5610f 100644 --- a/libsigrokdecode4DSL/type_decoder.c +++ b/libsigrokdecode4DSL/type_decoder.c @@ -178,17 +178,16 @@ static int py_parse_ann_data(PyObject *list_obj, char ***out_strv, int list_size @obj is the fourth param from python calls put() */ static int convert_annotation(struct srd_decoder_inst *di, PyObject *obj, - struct srd_proto_data *pdata) + struct srd_proto_data_annotation *pda) { - PyObject *py_tmp; - struct srd_proto_data_annotation *pda; + PyObject *py_tmp; int ann_class; char **ann_text; gpointer ann_type_ptr; PyGILState_STATE gstate; - int ann_size; + int ann_size; - pda = pdata->data; + assert(pda); gstate = PyGILState_Ensure(); @@ -256,6 +255,8 @@ static int convert_annotation(struct srd_decoder_inst *di, PyObject *obj, pda->ann_type = GPOINTER_TO_INT(ann_type_ptr); pda->ann_text = ann_text; + //srd_info("class:%d, type:%d", ann_class, pda->ann_type); + PyGILState_Release(gstate); return SRD_OK; @@ -458,9 +459,11 @@ static void release_meta(GVariant *gvar) g_variant_unref(gvar); } +//param list: start_sample, end_sample, output_type, [ann_class,[data]] static PyObject *Decoder_put(PyObject *self, PyObject *args) { GSList *l; + GSList *l2; PyObject *py_data, *py_res; struct srd_decoder_inst *di, *next_di; struct srd_pd_output *pdo; @@ -468,9 +471,13 @@ static PyObject *Decoder_put(PyObject *self, PyObject *args) struct srd_proto_data_annotation pda; struct srd_proto_data_binary pdb; uint64_t start_sample, end_sample; - int output_id; + int output_id; //The output type index. struct srd_pd_callback *cb; PyGILState_STATE gstate; + struct srd_decoder_annotation_row *ann_row = NULL; + gpointer ann_row_index_ptr = 0; + int row_index; + int ann_class_tmp; py_data = NULL; //the fourth param from python @@ -518,10 +525,42 @@ static PyObject *Decoder_put(PyObject *self, PyObject *args) if ((cb = srd_pd_output_callback_find(di->sess, pdo->output_type))) { pdata.data = &pda; /* Convert from PyDict to srd_proto_data_annotation. */ - if (convert_annotation(di, py_data, &pdata) != SRD_OK) { + if (convert_annotation(di, py_data, &pda) != SRD_OK) { /* An error was already logged. */ break; } + + //Get the row index. + pda.ann_row_index = -1; + row_index = 0; + + for (l = di->decoder->annotation_rows; l; l = l->next) + { + ann_row = l->data; + + for (l2 = ann_row->ann_classes; l2; l2 = l2->next) + { + ann_class_tmp = GPOINTER_TO_INT(l2->data); + + if (ann_class_tmp == pda.ann_class){ + pda.ann_row_index = row_index; + break; + } + } + row_index++; + + if (pda.ann_row_index != -1){ + break; + } + } + + if (pda.ann_row_index == -1){ + srd_err("\n\nERROR:The annotation have no row index!decoder:%s,ann-class:%d\n\n", + di->decoder->id, pda.ann_class); + release_annotation(pdata.data); + goto err; + } + Py_BEGIN_ALLOW_THREADS cb->cb(&pdata, cb->cb_data); Py_END_ALLOW_THREADS @@ -601,7 +640,7 @@ static PyObject *Decoder_put(PyObject *self, PyObject *args) } /* - return output info index + Returns the output type index */ static PyObject *Decoder_register(PyObject *self, PyObject *args, PyObject *kwargs)