From: Joel Holdsworth Date: Sat, 22 Nov 2014 08:53:27 +0000 (+0000) Subject: Renamed C++ headers to .hpp X-Git-Tag: pulseview-0.3.0~439 X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=commitdiff_plain;h=2acdb232d6bb452cfdfaea3ef5218fb4da592329 Renamed C++ headers to .hpp --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 136880e0..05c6270c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -193,42 +193,42 @@ set(pulseview_SOURCES # This list includes only QObject derived class headers. set(pulseview_HEADERS - pv/mainwindow.h - pv/sigsession.h - pv/storesession.h - pv/dialogs/about.h - pv/dialogs/connect.h - pv/dialogs/storeprogress.h - pv/popups/channels.h - pv/popups/deviceoptions.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/prop/binding/deviceoptions.h - pv/toolbars/samplingbar.h - pv/view/cursor.h - pv/view/cursorheader.h - pv/view/header.h - pv/view/logicsignal.h - pv/view/marginwidget.h - pv/view/rowitem.h - pv/view/ruler.h - pv/view/selectableitem.h - pv/view/signal.h - pv/view/timemarker.h - pv/view/trace.h - pv/view/tracegroup.h - pv/view/view.h - pv/view/viewport.h - pv/widgets/colourbutton.h - pv/widgets/colourpopup.h - pv/widgets/popup.h - pv/widgets/popuptoolbutton.h - pv/widgets/sweeptimingwidget.h - pv/widgets/wellarray.h + pv/mainwindow.hpp + pv/sigsession.hpp + pv/storesession.hpp + pv/dialogs/about.hpp + pv/dialogs/connect.hpp + pv/dialogs/storeprogress.hpp + pv/popups/channels.hpp + pv/popups/deviceoptions.hpp + pv/prop/bool.hpp + pv/prop/double.hpp + pv/prop/enum.hpp + pv/prop/int.hpp + pv/prop/property.hpp + pv/prop/string.hpp + pv/prop/binding/deviceoptions.hpp + pv/toolbars/samplingbar.hpp + pv/view/cursor.hpp + pv/view/cursorheader.hpp + pv/view/header.hpp + pv/view/logicsignal.hpp + pv/view/marginwidget.hpp + pv/view/rowitem.hpp + pv/view/ruler.hpp + pv/view/selectableitem.hpp + pv/view/signal.hpp + pv/view/timemarker.hpp + pv/view/trace.hpp + pv/view/tracegroup.hpp + pv/view/view.hpp + pv/view/viewport.hpp + pv/widgets/colourbutton.hpp + pv/widgets/colourpopup.hpp + pv/widgets/popup.hpp + pv/widgets/popuptoolbutton.hpp + pv/widgets/sweeptimingwidget.hpp + pv/widgets/wellarray.hpp ) set(pulseview_FORMS @@ -241,7 +241,7 @@ set(pulseview_RESOURCES if(ENABLE_SIGNALS) list(APPEND pulseview_SOURCES signalhandler.cpp) - list(APPEND pulseview_HEADERS signalhandler.h) + list(APPEND pulseview_HEADERS signalhandler.hpp) endif() if(ENABLE_DECODE) @@ -258,10 +258,10 @@ if(ENABLE_DECODE) ) list(APPEND pulseview_HEADERS - pv/data/decoderstack.h - pv/view/decodetrace.h - pv/widgets/decodergroupbox.h - pv/widgets/decodermenu.h + pv/data/decoderstack.hpp + pv/view/decodetrace.hpp + pv/widgets/decodergroupbox.hpp + pv/widgets/decodermenu.hpp ) endif() diff --git a/android/loghandler.cpp b/android/loghandler.cpp index 3cd2e3b7..8e7806c8 100644 --- a/android/loghandler.cpp +++ b/android/loghandler.cpp @@ -26,7 +26,7 @@ #include #include -#include "android/loghandler.h" +#include "android/loghandler.hpp" namespace pv { diff --git a/android/loghandler.h b/android/loghandler.h deleted file mode 100644 index e49158ad..00000000 --- a/android/loghandler.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * This file is part of the PulseView project. - * - * Copyright (C) 2014 Marcus Comstedt - * - * 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 3 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 PULSEVIEW_ANDROID_LOGHANDLER_H -#define PULSEVIEW_ANDROID_LOGHANDLER_H - -#include - -namespace pv { - -class AndroidLogHandler -{ -private: - static int sr_callback(void *cb_data, int loglevel, const char *format, va_list args); - static int srd_callback(void *cb_data, int loglevel, const char *format, va_list args); - -public: - static void install_callbacks(); -}; - -} // namespace pv - -#endif // PULSEVIEW_ANDROID_LOGHANDLER_H diff --git a/android/loghandler.hpp b/android/loghandler.hpp new file mode 100644 index 00000000..e49158ad --- /dev/null +++ b/android/loghandler.hpp @@ -0,0 +1,39 @@ +/* + * This file is part of the PulseView project. + * + * Copyright (C) 2014 Marcus Comstedt + * + * 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 3 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 PULSEVIEW_ANDROID_LOGHANDLER_H +#define PULSEVIEW_ANDROID_LOGHANDLER_H + +#include + +namespace pv { + +class AndroidLogHandler +{ +private: + static int sr_callback(void *cb_data, int loglevel, const char *format, va_list args); + static int srd_callback(void *cb_data, int loglevel, const char *format, va_list args); + +public: + static void install_callbacks(); +}; + +} // namespace pv + +#endif // PULSEVIEW_ANDROID_LOGHANDLER_H diff --git a/main.cpp b/main.cpp index c0ac04b4..8fac9234 100644 --- a/main.cpp +++ b/main.cpp @@ -30,15 +30,15 @@ #include #ifdef ENABLE_SIGNALS -#include "signalhandler.h" +#include "signalhandler.hpp" #endif -#include "pv/application.h" -#include "pv/devicemanager.h" -#include "pv/mainwindow.h" +#include "pv/application.hpp" +#include "pv/devicemanager.hpp" +#include "pv/mainwindow.hpp" #ifdef ANDROID #include -#include "android/loghandler.h" +#include "android/loghandler.hpp" #endif #include "config.h" diff --git a/pv/application.cpp b/pv/application.cpp index 66991dd9..41f00f8c 100644 --- a/pv/application.cpp +++ b/pv/application.cpp @@ -18,7 +18,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "application.h" +#include "application.hpp" #include "config.h" #include diff --git a/pv/application.h b/pv/application.h deleted file mode 100644 index 5a80ec86..00000000 --- a/pv/application.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * This file is part of the PulseView project. - * - * Copyright (C) 2014 Martin Ling - * - * 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 PULSEVIEW_PV_APPLICATION_H -#define PULSEVIEW_PV_APPLICATION_H - -#include - -class Application : public QApplication -{ -public: - Application(int &argc, char* argv[]); -private: - bool notify(QObject *receiver, QEvent *event); -}; - -#endif // PULSEVIEW_PV_APPLICATION_H diff --git a/pv/application.hpp b/pv/application.hpp new file mode 100644 index 00000000..5a80ec86 --- /dev/null +++ b/pv/application.hpp @@ -0,0 +1,34 @@ +/* + * This file is part of the PulseView project. + * + * Copyright (C) 2014 Martin Ling + * + * 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 PULSEVIEW_PV_APPLICATION_H +#define PULSEVIEW_PV_APPLICATION_H + +#include + +class Application : public QApplication +{ +public: + Application(int &argc, char* argv[]); +private: + bool notify(QObject *receiver, QEvent *event); +}; + +#endif // PULSEVIEW_PV_APPLICATION_H diff --git a/pv/data/analog.cpp b/pv/data/analog.cpp index eb25629f..30cf5013 100644 --- a/pv/data/analog.cpp +++ b/pv/data/analog.cpp @@ -20,8 +20,8 @@ #include -#include "analog.h" -#include "analogsnapshot.h" +#include "analog.hpp" +#include "analogsnapshot.hpp" using std::deque; using std::max; diff --git a/pv/data/analog.h b/pv/data/analog.h deleted file mode 100644 index b89dd22f..00000000 --- a/pv/data/analog.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * This file is part of the PulseView project. - * - * 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 - */ - -#ifndef PULSEVIEW_PV_DATA_ANALOG_H -#define PULSEVIEW_PV_DATA_ANALOG_H - -#include "signaldata.h" - -#include -#include - -namespace pv { -namespace data { - -class AnalogSnapshot; - -class Analog : public SignalData -{ -public: - Analog(); - - void push_snapshot( - std::shared_ptr &snapshot); - - std::deque< std::shared_ptr >& - get_snapshots(); - - void clear(); - - uint64_t get_max_sample_count() const; - -private: - std::deque< std::shared_ptr > snapshots_; -}; - -} // namespace data -} // namespace pv - -#endif // PULSEVIEW_PV_DATA_ANALOG_H diff --git a/pv/data/analog.hpp b/pv/data/analog.hpp new file mode 100644 index 00000000..cfc964e1 --- /dev/null +++ b/pv/data/analog.hpp @@ -0,0 +1,56 @@ +/* + * This file is part of the PulseView project. + * + * 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 + */ + +#ifndef PULSEVIEW_PV_DATA_ANALOG_H +#define PULSEVIEW_PV_DATA_ANALOG_H + +#include "signaldata.hpp" + +#include +#include + +namespace pv { +namespace data { + +class AnalogSnapshot; + +class Analog : public SignalData +{ +public: + Analog(); + + void push_snapshot( + std::shared_ptr &snapshot); + + std::deque< std::shared_ptr >& + get_snapshots(); + + void clear(); + + uint64_t get_max_sample_count() const; + +private: + std::deque< std::shared_ptr > snapshots_; +}; + +} // namespace data +} // namespace pv + +#endif // PULSEVIEW_PV_DATA_ANALOG_H diff --git a/pv/data/analogsnapshot.cpp b/pv/data/analogsnapshot.cpp index df3cb42d..589b1aa4 100644 --- a/pv/data/analogsnapshot.cpp +++ b/pv/data/analogsnapshot.cpp @@ -27,7 +27,7 @@ #include -#include "analogsnapshot.h" +#include "analogsnapshot.hpp" using std::lock_guard; using std::recursive_mutex; diff --git a/pv/data/analogsnapshot.h b/pv/data/analogsnapshot.h deleted file mode 100644 index 9e2e782a..00000000 --- a/pv/data/analogsnapshot.h +++ /dev/null @@ -1,96 +0,0 @@ -/* - * This file is part of the PulseView project. - * - * 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 - */ - -#ifndef PULSEVIEW_PV_DATA_ANALOGSNAPSHOT_H -#define PULSEVIEW_PV_DATA_ANALOGSNAPSHOT_H - -#include "snapshot.h" - -#include -#include - -namespace AnalogSnapshotTest { -struct Basic; -} - -namespace pv { -namespace data { - -class AnalogSnapshot : public Snapshot -{ -public: - struct EnvelopeSample - { - float min; - float max; - }; - - struct EnvelopeSection - { - uint64_t start; - unsigned int scale; - uint64_t length; - EnvelopeSample *samples; - }; - -private: - struct Envelope - { - uint64_t length; - uint64_t data_length; - EnvelopeSample *samples; - }; - -private: - static const unsigned int ScaleStepCount = 10; - static const int EnvelopeScalePower; - static const int EnvelopeScaleFactor; - static const float LogEnvelopeScaleFactor; - static const uint64_t EnvelopeDataUnit; - -public: - AnalogSnapshot(uint64_t expected_num_samples = 0); - - virtual ~AnalogSnapshot(); - - void append_interleaved_samples(const float *data, - size_t sample_count, size_t stride); - - const float* get_samples(int64_t start_sample, - int64_t end_sample) const; - - void get_envelope_section(EnvelopeSection &s, - uint64_t start, uint64_t end, float min_length) const; - -private: - void reallocate_envelope(Envelope &l); - - void append_payload_to_envelope_levels(); - -private: - struct Envelope envelope_levels_[ScaleStepCount]; - - friend struct AnalogSnapshotTest::Basic; -}; - -} // namespace data -} // namespace pv - -#endif // PULSEVIEW_PV_DATA_ANALOGSNAPSHOT_H diff --git a/pv/data/analogsnapshot.hpp b/pv/data/analogsnapshot.hpp new file mode 100644 index 00000000..3c6f99c2 --- /dev/null +++ b/pv/data/analogsnapshot.hpp @@ -0,0 +1,96 @@ +/* + * This file is part of the PulseView project. + * + * 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 + */ + +#ifndef PULSEVIEW_PV_DATA_ANALOGSNAPSHOT_H +#define PULSEVIEW_PV_DATA_ANALOGSNAPSHOT_H + +#include "snapshot.hpp" + +#include +#include + +namespace AnalogSnapshotTest { +struct Basic; +} + +namespace pv { +namespace data { + +class AnalogSnapshot : public Snapshot +{ +public: + struct EnvelopeSample + { + float min; + float max; + }; + + struct EnvelopeSection + { + uint64_t start; + unsigned int scale; + uint64_t length; + EnvelopeSample *samples; + }; + +private: + struct Envelope + { + uint64_t length; + uint64_t data_length; + EnvelopeSample *samples; + }; + +private: + static const unsigned int ScaleStepCount = 10; + static const int EnvelopeScalePower; + static const int EnvelopeScaleFactor; + static const float LogEnvelopeScaleFactor; + static const uint64_t EnvelopeDataUnit; + +public: + AnalogSnapshot(uint64_t expected_num_samples = 0); + + virtual ~AnalogSnapshot(); + + void append_interleaved_samples(const float *data, + size_t sample_count, size_t stride); + + const float* get_samples(int64_t start_sample, + int64_t end_sample) const; + + void get_envelope_section(EnvelopeSection &s, + uint64_t start, uint64_t end, float min_length) const; + +private: + void reallocate_envelope(Envelope &l); + + void append_payload_to_envelope_levels(); + +private: + struct Envelope envelope_levels_[ScaleStepCount]; + + friend struct AnalogSnapshotTest::Basic; +}; + +} // namespace data +} // namespace pv + +#endif // PULSEVIEW_PV_DATA_ANALOGSNAPSHOT_H diff --git a/pv/data/decode/annotation.cpp b/pv/data/decode/annotation.cpp index 9b07efbc..6287edce 100644 --- a/pv/data/decode/annotation.cpp +++ b/pv/data/decode/annotation.cpp @@ -25,7 +25,7 @@ extern "C" { #include #include -#include "annotation.h" +#include "annotation.hpp" namespace pv { namespace data { diff --git a/pv/data/decode/annotation.h b/pv/data/decode/annotation.h deleted file mode 100644 index f1e2ef35..00000000 --- a/pv/data/decode/annotation.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * This file is part of the PulseView project. - * - * 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 - */ - -#ifndef PULSEVIEW_PV_VIEW_DECODE_ANNOTATION_H -#define PULSEVIEW_PV_VIEW_DECODE_ANNOTATION_H - -#include - -#include - -struct srd_proto_data; - -namespace pv { -namespace data { -namespace decode { - -class Annotation -{ -public: - Annotation(const srd_proto_data *const pdata); - - uint64_t start_sample() const; - uint64_t end_sample() const; - int format() const; - const std::vector& annotations() const; - -private: - uint64_t start_sample_; - uint64_t end_sample_; - int format_; - std::vector annotations_; -}; - -} // namespace decode -} // namespace data -} // namespace pv - -#endif // PULSEVIEW_PV_VIEW_DECODE_ANNOTATION_H diff --git a/pv/data/decode/annotation.hpp b/pv/data/decode/annotation.hpp new file mode 100644 index 00000000..f1e2ef35 --- /dev/null +++ b/pv/data/decode/annotation.hpp @@ -0,0 +1,55 @@ +/* + * This file is part of the PulseView project. + * + * 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 + */ + +#ifndef PULSEVIEW_PV_VIEW_DECODE_ANNOTATION_H +#define PULSEVIEW_PV_VIEW_DECODE_ANNOTATION_H + +#include + +#include + +struct srd_proto_data; + +namespace pv { +namespace data { +namespace decode { + +class Annotation +{ +public: + Annotation(const srd_proto_data *const pdata); + + uint64_t start_sample() const; + uint64_t end_sample() const; + int format() const; + const std::vector& annotations() const; + +private: + uint64_t start_sample_; + uint64_t end_sample_; + int format_; + std::vector annotations_; +}; + +} // namespace decode +} // namespace data +} // namespace pv + +#endif // PULSEVIEW_PV_VIEW_DECODE_ANNOTATION_H diff --git a/pv/data/decode/decoder.cpp b/pv/data/decode/decoder.cpp index e2db7742..c5fffa67 100644 --- a/pv/data/decode/decoder.cpp +++ b/pv/data/decode/decoder.cpp @@ -23,9 +23,9 @@ #include #include -#include "decoder.h" +#include "decoder.hpp" -#include +#include using std::set; using std::map; diff --git a/pv/data/decode/decoder.h b/pv/data/decode/decoder.h deleted file mode 100644 index fbe59059..00000000 --- a/pv/data/decode/decoder.h +++ /dev/null @@ -1,89 +0,0 @@ -/* - * This file is part of the PulseView project. - * - * 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 - */ - -#ifndef PULSEVIEW_PV_DATA_DECODE_DECODER_H -#define PULSEVIEW_PV_DATA_DECODE_DECODER_H - -#include -#include -#include - -#include - -struct srd_decoder; -struct srd_decoder_inst; -struct srd_channel; -struct srd_session; - -namespace pv { - -namespace view { -class LogicSignal; -} - -namespace data { - -class Logic; - -namespace decode { - -class Decoder -{ -public: - Decoder(const srd_decoder *const decoder); - - virtual ~Decoder(); - - const srd_decoder* decoder() const; - - bool shown() const; - void show(bool show = true); - - const std::map >& channels() const; - void set_channels(std::map > channels); - - const std::map& options() const; - - void set_option(const char *id, GVariant *value); - - bool have_required_channels() const; - - srd_decoder_inst* create_decoder_inst( - srd_session *session, int unit_size) const; - - std::set< std::shared_ptr > get_data(); - -private: - const srd_decoder *const decoder_; - - bool shown_; - - std::map > - channels_; - std::map options_; -}; - -} // namespace decode -} // namespace data -} // namespace pv - -#endif // PULSEVIEW_PV_DATA_DECODE_DECODER_H diff --git a/pv/data/decode/decoder.hpp b/pv/data/decode/decoder.hpp new file mode 100644 index 00000000..fbe59059 --- /dev/null +++ b/pv/data/decode/decoder.hpp @@ -0,0 +1,89 @@ +/* + * This file is part of the PulseView project. + * + * 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 + */ + +#ifndef PULSEVIEW_PV_DATA_DECODE_DECODER_H +#define PULSEVIEW_PV_DATA_DECODE_DECODER_H + +#include +#include +#include + +#include + +struct srd_decoder; +struct srd_decoder_inst; +struct srd_channel; +struct srd_session; + +namespace pv { + +namespace view { +class LogicSignal; +} + +namespace data { + +class Logic; + +namespace decode { + +class Decoder +{ +public: + Decoder(const srd_decoder *const decoder); + + virtual ~Decoder(); + + const srd_decoder* decoder() const; + + bool shown() const; + void show(bool show = true); + + const std::map >& channels() const; + void set_channels(std::map > channels); + + const std::map& options() const; + + void set_option(const char *id, GVariant *value); + + bool have_required_channels() const; + + srd_decoder_inst* create_decoder_inst( + srd_session *session, int unit_size) const; + + std::set< std::shared_ptr > get_data(); + +private: + const srd_decoder *const decoder_; + + bool shown_; + + std::map > + channels_; + std::map options_; +}; + +} // namespace decode +} // namespace data +} // namespace pv + +#endif // PULSEVIEW_PV_DATA_DECODE_DECODER_H diff --git a/pv/data/decode/row.cpp b/pv/data/decode/row.cpp index 8e3a6512..e36051c3 100644 --- a/pv/data/decode/row.cpp +++ b/pv/data/decode/row.cpp @@ -18,7 +18,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "row.h" +#include "row.hpp" #include diff --git a/pv/data/decode/row.h b/pv/data/decode/row.h deleted file mode 100644 index 221d9c9b..00000000 --- a/pv/data/decode/row.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * This file is part of the PulseView project. - * - * Copyright (C) 2014 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 - */ - -#ifndef PULSEVIEW_PV_DATA_DECODE_ROW_H -#define PULSEVIEW_PV_DATA_DECODE_ROW_H - -#include - -#include "annotation.h" - -struct srd_decoder; -struct srd_decoder_annotation_row; - -namespace pv { -namespace data { -namespace decode { - -class Row -{ -public: - Row(); - - Row(const srd_decoder *decoder, - const srd_decoder_annotation_row *row = NULL); - - const srd_decoder* decoder() const; - const srd_decoder_annotation_row* row() const; - - const QString title() const; - - bool operator<(const Row &other) const; - -private: - const srd_decoder *decoder_; - const srd_decoder_annotation_row *row_; -}; - -} // decode -} // data -} // pv - -#endif // PULSEVIEW_PV_DATA_DECODE_ROW_H diff --git a/pv/data/decode/row.hpp b/pv/data/decode/row.hpp new file mode 100644 index 00000000..3a163fb3 --- /dev/null +++ b/pv/data/decode/row.hpp @@ -0,0 +1,59 @@ +/* + * This file is part of the PulseView project. + * + * Copyright (C) 2014 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 + */ + +#ifndef PULSEVIEW_PV_DATA_DECODE_ROW_H +#define PULSEVIEW_PV_DATA_DECODE_ROW_H + +#include + +#include "annotation.hpp" + +struct srd_decoder; +struct srd_decoder_annotation_row; + +namespace pv { +namespace data { +namespace decode { + +class Row +{ +public: + Row(); + + Row(const srd_decoder *decoder, + const srd_decoder_annotation_row *row = NULL); + + const srd_decoder* decoder() const; + const srd_decoder_annotation_row* row() const; + + const QString title() const; + + bool operator<(const Row &other) const; + +private: + const srd_decoder *decoder_; + const srd_decoder_annotation_row *row_; +}; + +} // decode +} // data +} // pv + +#endif // PULSEVIEW_PV_DATA_DECODE_ROW_H diff --git a/pv/data/decode/rowdata.cpp b/pv/data/decode/rowdata.cpp index b4ccd64d..9402e707 100644 --- a/pv/data/decode/rowdata.cpp +++ b/pv/data/decode/rowdata.cpp @@ -18,7 +18,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "rowdata.h" +#include "rowdata.hpp" using std::vector; diff --git a/pv/data/decode/rowdata.h b/pv/data/decode/rowdata.h deleted file mode 100644 index 265c4e37..00000000 --- a/pv/data/decode/rowdata.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * This file is part of the PulseView project. - * - * Copyright (C) 2014 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 - */ - -#ifndef PULSEVIEW_PV_DATA_DECODE_ROWDATA_H -#define PULSEVIEW_PV_DATA_DECODE_ROWDATA_H - -#include - -#include "annotation.h" - -namespace pv { -namespace data { -namespace decode { - -class RowData -{ -public: - RowData(); - -public: - uint64_t get_max_sample() const; - - /** - * Extracts sorted annotations between two period into a vector. - */ - void get_annotation_subset( - std::vector &dest, - uint64_t start_sample, uint64_t end_sample) const; - - void push_annotation(const Annotation &a); - -private: - std::vector annotations_; -}; - -} -} // data -} // pv - -#endif // PULSEVIEW_PV_DATA_DECODE_ROWDATA_H diff --git a/pv/data/decode/rowdata.hpp b/pv/data/decode/rowdata.hpp new file mode 100644 index 00000000..568b1bb0 --- /dev/null +++ b/pv/data/decode/rowdata.hpp @@ -0,0 +1,57 @@ +/* + * This file is part of the PulseView project. + * + * Copyright (C) 2014 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 + */ + +#ifndef PULSEVIEW_PV_DATA_DECODE_ROWDATA_H +#define PULSEVIEW_PV_DATA_DECODE_ROWDATA_H + +#include + +#include "annotation.hpp" + +namespace pv { +namespace data { +namespace decode { + +class RowData +{ +public: + RowData(); + +public: + uint64_t get_max_sample() const; + + /** + * Extracts sorted annotations between two period into a vector. + */ + void get_annotation_subset( + std::vector &dest, + uint64_t start_sample, uint64_t end_sample) const; + + void push_annotation(const Annotation &a); + +private: + std::vector annotations_; +}; + +} +} // data +} // pv + +#endif // PULSEVIEW_PV_DATA_DECODE_ROWDATA_H diff --git a/pv/data/decoderstack.cpp b/pv/data/decoderstack.cpp index 3d734126..5e30faa7 100644 --- a/pv/data/decoderstack.cpp +++ b/pv/data/decoderstack.cpp @@ -24,14 +24,14 @@ #include -#include "decoderstack.h" - -#include -#include -#include -#include -#include -#include +#include "decoderstack.hpp" + +#include +#include +#include +#include +#include +#include using std::lock_guard; using std::mutex; diff --git a/pv/data/decoderstack.h b/pv/data/decoderstack.h deleted file mode 100644 index c50f3859..00000000 --- a/pv/data/decoderstack.h +++ /dev/null @@ -1,169 +0,0 @@ -/* - * This file is part of the PulseView project. - * - * 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 - */ - -#ifndef PULSEVIEW_PV_DATA_DECODERSTACK_H -#define PULSEVIEW_PV_DATA_DECODERSTACK_H - -#include "signaldata.h" - -#include -#include -#include -#include -#include -#include - -#include - -#include -#include - -#include -#include - -struct srd_decoder; -struct srd_decoder_annotation_row; -struct srd_channel; -struct srd_proto_data; -struct srd_session; - -namespace DecoderStackTest { -struct TwoDecoderStack; -} - -namespace pv { - -class SigSession; - -namespace view { -class LogicSignal; -} - -namespace data { - -class LogicSnapshot; - -namespace decode { -class Annotation; -class Decoder; -} - -class Logic; - -class DecoderStack : public QObject, public SignalData -{ - Q_OBJECT - -private: - static const double DecodeMargin; - static const double DecodeThreshold; - static const int64_t DecodeChunkLength; - static const unsigned int DecodeNotifyPeriod; - -public: - DecoderStack(pv::SigSession &session_, - const srd_decoder *const decoder); - - virtual ~DecoderStack(); - - const std::list< std::shared_ptr >& stack() const; - void push(std::shared_ptr decoder); - void remove(int index); - - int64_t samples_decoded() const; - - std::vector get_visible_rows() const; - - /** - * Extracts sorted annotations between two period into a vector. - */ - void get_annotation_subset( - std::vector &dest, - const decode::Row &row, uint64_t start_sample, - uint64_t end_sample) const; - - QString error_message(); - - void clear(); - - uint64_t get_max_sample_count() const; - - void begin_decode(); - -private: - boost::optional wait_for_data() const; - - void decode_data(const int64_t sample_count, - const unsigned int unit_size, srd_session *const session); - - void decode_proc(); - - static void annotation_callback(srd_proto_data *pdata, - void *decoder); - -private Q_SLOTS: - void on_new_frame(); - - void on_data_received(); - - void on_frame_ended(); - -Q_SIGNALS: - void new_decode_data(); - -private: - pv::SigSession &session_; - - /** - * This mutex prevents more than one decode operation occuring - * concurrently. - * @todo A proper solution should be implemented to allow multiple - * decode operations. - */ - static std::mutex global_decode_mutex_; - - std::list< std::shared_ptr > stack_; - - std::shared_ptr snapshot_; - - mutable std::mutex input_mutex_; - mutable std::condition_variable input_cond_; - int64_t sample_count_; - bool frame_complete_; - - mutable std::mutex output_mutex_; - int64_t samples_decoded_; - - std::map rows_; - - std::map, decode::Row> class_rows_; - - QString error_message_; - - std::thread decode_thread_; - std::atomic interrupt_; - - friend struct DecoderStackTest::TwoDecoderStack; -}; - -} // namespace data -} // namespace pv - -#endif // PULSEVIEW_PV_DATA_DECODERSTACK_H diff --git a/pv/data/decoderstack.hpp b/pv/data/decoderstack.hpp new file mode 100644 index 00000000..979a56fa --- /dev/null +++ b/pv/data/decoderstack.hpp @@ -0,0 +1,169 @@ +/* + * This file is part of the PulseView project. + * + * 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 + */ + +#ifndef PULSEVIEW_PV_DATA_DECODERSTACK_H +#define PULSEVIEW_PV_DATA_DECODERSTACK_H + +#include "signaldata.hpp" + +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +#include +#include + +struct srd_decoder; +struct srd_decoder_annotation_row; +struct srd_channel; +struct srd_proto_data; +struct srd_session; + +namespace DecoderStackTest { +struct TwoDecoderStack; +} + +namespace pv { + +class SigSession; + +namespace view { +class LogicSignal; +} + +namespace data { + +class LogicSnapshot; + +namespace decode { +class Annotation; +class Decoder; +} + +class Logic; + +class DecoderStack : public QObject, public SignalData +{ + Q_OBJECT + +private: + static const double DecodeMargin; + static const double DecodeThreshold; + static const int64_t DecodeChunkLength; + static const unsigned int DecodeNotifyPeriod; + +public: + DecoderStack(pv::SigSession &session_, + const srd_decoder *const decoder); + + virtual ~DecoderStack(); + + const std::list< std::shared_ptr >& stack() const; + void push(std::shared_ptr decoder); + void remove(int index); + + int64_t samples_decoded() const; + + std::vector get_visible_rows() const; + + /** + * Extracts sorted annotations between two period into a vector. + */ + void get_annotation_subset( + std::vector &dest, + const decode::Row &row, uint64_t start_sample, + uint64_t end_sample) const; + + QString error_message(); + + void clear(); + + uint64_t get_max_sample_count() const; + + void begin_decode(); + +private: + boost::optional wait_for_data() const; + + void decode_data(const int64_t sample_count, + const unsigned int unit_size, srd_session *const session); + + void decode_proc(); + + static void annotation_callback(srd_proto_data *pdata, + void *decoder); + +private Q_SLOTS: + void on_new_frame(); + + void on_data_received(); + + void on_frame_ended(); + +Q_SIGNALS: + void new_decode_data(); + +private: + pv::SigSession &session_; + + /** + * This mutex prevents more than one decode operation occuring + * concurrently. + * @todo A proper solution should be implemented to allow multiple + * decode operations. + */ + static std::mutex global_decode_mutex_; + + std::list< std::shared_ptr > stack_; + + std::shared_ptr snapshot_; + + mutable std::mutex input_mutex_; + mutable std::condition_variable input_cond_; + int64_t sample_count_; + bool frame_complete_; + + mutable std::mutex output_mutex_; + int64_t samples_decoded_; + + std::map rows_; + + std::map, decode::Row> class_rows_; + + QString error_message_; + + std::thread decode_thread_; + std::atomic interrupt_; + + friend struct DecoderStackTest::TwoDecoderStack; +}; + +} // namespace data +} // namespace pv + +#endif // PULSEVIEW_PV_DATA_DECODERSTACK_H diff --git a/pv/data/logic.cpp b/pv/data/logic.cpp index b7b6cace..8f1d294d 100644 --- a/pv/data/logic.cpp +++ b/pv/data/logic.cpp @@ -20,8 +20,8 @@ #include -#include "logic.h" -#include "logicsnapshot.h" +#include "logic.hpp" +#include "logicsnapshot.hpp" using std::deque; using std::max; diff --git a/pv/data/logic.h b/pv/data/logic.h deleted file mode 100644 index d8ee5305..00000000 --- a/pv/data/logic.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * This file is part of the PulseView project. - * - * 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 - */ - -#ifndef PULSEVIEW_PV_DATA_LOGIC_H -#define PULSEVIEW_PV_DATA_LOGIC_H - -#include "signaldata.h" - -#include -#include - -namespace pv { -namespace data { - -class LogicSnapshot; - -class Logic : public SignalData -{ -public: - Logic(unsigned int num_channels); - - int get_num_channels() const; - - void push_snapshot( - std::shared_ptr &snapshot); - - std::deque< std::shared_ptr >& - get_snapshots(); - - void clear(); - - uint64_t get_max_sample_count() const; - -private: - const unsigned int num_channels_; - std::deque< std::shared_ptr > snapshots_; -}; - -} // namespace data -} // namespace pv - -#endif // PULSEVIEW_PV_DATA_LOGIC_H diff --git a/pv/data/logic.hpp b/pv/data/logic.hpp new file mode 100644 index 00000000..51e12cb9 --- /dev/null +++ b/pv/data/logic.hpp @@ -0,0 +1,59 @@ +/* + * This file is part of the PulseView project. + * + * 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 + */ + +#ifndef PULSEVIEW_PV_DATA_LOGIC_H +#define PULSEVIEW_PV_DATA_LOGIC_H + +#include "signaldata.hpp" + +#include +#include + +namespace pv { +namespace data { + +class LogicSnapshot; + +class Logic : public SignalData +{ +public: + Logic(unsigned int num_channels); + + int get_num_channels() const; + + void push_snapshot( + std::shared_ptr &snapshot); + + std::deque< std::shared_ptr >& + get_snapshots(); + + void clear(); + + uint64_t get_max_sample_count() const; + +private: + const unsigned int num_channels_; + std::deque< std::shared_ptr > snapshots_; +}; + +} // namespace data +} // namespace pv + +#endif // PULSEVIEW_PV_DATA_LOGIC_H diff --git a/pv/data/logicsnapshot.cpp b/pv/data/logicsnapshot.cpp index 31093c27..82d90074 100644 --- a/pv/data/logicsnapshot.cpp +++ b/pv/data/logicsnapshot.cpp @@ -25,8 +25,7 @@ #include #include -#include "config.h" -#include "logicsnapshot.h" +#include "logicsnapshot.hpp" #include diff --git a/pv/data/logicsnapshot.h b/pv/data/logicsnapshot.h deleted file mode 100644 index db4d97b3..00000000 --- a/pv/data/logicsnapshot.h +++ /dev/null @@ -1,119 +0,0 @@ -/* - * This file is part of the PulseView project. - * - * 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 - */ - -#ifndef PULSEVIEW_PV_DATA_LOGICSNAPSHOT_H -#define PULSEVIEW_PV_DATA_LOGICSNAPSHOT_H - -#include "snapshot.h" - -#include -#include - -namespace sigrok { - class Logic; -} - -namespace LogicSnapshotTest { -struct Pow2; -struct Basic; -struct LargeData; -struct Pulses; -struct LongPulses; -} - -namespace pv { -namespace data { - -class LogicSnapshot : public Snapshot -{ -private: - struct MipMapLevel - { - uint64_t length; - uint64_t data_length; - void *data; - }; - -private: - static const unsigned int ScaleStepCount = 10; - static const int MipMapScalePower; - static const int MipMapScaleFactor; - static const float LogMipMapScaleFactor; - static const uint64_t MipMapDataUnit; - -public: - typedef std::pair EdgePair; - -public: - LogicSnapshot(std::shared_ptr logic, - uint64_t expected_num_samples = 0); - - virtual ~LogicSnapshot(); - - void append_payload(std::shared_ptr logic); - - void get_samples(uint8_t *const data, - int64_t start_sample, int64_t end_sample) const; - -private: - uint64_t unpack_sample(const uint8_t *ptr) const; - void pack_sample(uint8_t *ptr, uint64_t value); - - void reallocate_mipmap_level(MipMapLevel &m); - - void append_payload_to_mipmap(); - - uint64_t get_sample(uint64_t index) const; - -public: - /** - * Parses a logic data snapshot to generate a list of transitions - * in a time interval to a given level of detail. - * @param[out] edges The vector to place the edges into. - * @param[in] start The start sample index. - * @param[in] end The end sample index. - * @param[in] min_length The minimum number of samples that - * can be resolved at this level of detail. - * @param[in] sig_index The index of the signal. - **/ - void get_subsampled_edges(std::vector &edges, - uint64_t start, uint64_t end, - float min_length, int sig_index); - -private: - uint64_t get_subsample(int level, uint64_t offset) const; - - static uint64_t pow2_ceil(uint64_t x, unsigned int power); - -private: - struct MipMapLevel mip_map_[ScaleStepCount]; - uint64_t last_append_sample_; - - friend struct LogicSnapshotTest::Pow2; - friend struct LogicSnapshotTest::Basic; - friend struct LogicSnapshotTest::LargeData; - friend struct LogicSnapshotTest::Pulses; - friend struct LogicSnapshotTest::LongPulses; -}; - -} // namespace data -} // namespace pv - -#endif // PULSEVIEW_PV_DATA_LOGICSNAPSHOT_H diff --git a/pv/data/logicsnapshot.hpp b/pv/data/logicsnapshot.hpp new file mode 100644 index 00000000..619048d8 --- /dev/null +++ b/pv/data/logicsnapshot.hpp @@ -0,0 +1,119 @@ +/* + * This file is part of the PulseView project. + * + * 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 + */ + +#ifndef PULSEVIEW_PV_DATA_LOGICSNAPSHOT_H +#define PULSEVIEW_PV_DATA_LOGICSNAPSHOT_H + +#include "snapshot.hpp" + +#include +#include + +namespace sigrok { + class Logic; +} + +namespace LogicSnapshotTest { +struct Pow2; +struct Basic; +struct LargeData; +struct Pulses; +struct LongPulses; +} + +namespace pv { +namespace data { + +class LogicSnapshot : public Snapshot +{ +private: + struct MipMapLevel + { + uint64_t length; + uint64_t data_length; + void *data; + }; + +private: + static const unsigned int ScaleStepCount = 10; + static const int MipMapScalePower; + static const int MipMapScaleFactor; + static const float LogMipMapScaleFactor; + static const uint64_t MipMapDataUnit; + +public: + typedef std::pair EdgePair; + +public: + LogicSnapshot(std::shared_ptr logic, + uint64_t expected_num_samples = 0); + + virtual ~LogicSnapshot(); + + void append_payload(std::shared_ptr logic); + + void get_samples(uint8_t *const data, + int64_t start_sample, int64_t end_sample) const; + +private: + uint64_t unpack_sample(const uint8_t *ptr) const; + void pack_sample(uint8_t *ptr, uint64_t value); + + void reallocate_mipmap_level(MipMapLevel &m); + + void append_payload_to_mipmap(); + + uint64_t get_sample(uint64_t index) const; + +public: + /** + * Parses a logic data snapshot to generate a list of transitions + * in a time interval to a given level of detail. + * @param[out] edges The vector to place the edges into. + * @param[in] start The start sample index. + * @param[in] end The end sample index. + * @param[in] min_length The minimum number of samples that + * can be resolved at this level of detail. + * @param[in] sig_index The index of the signal. + **/ + void get_subsampled_edges(std::vector &edges, + uint64_t start, uint64_t end, + float min_length, int sig_index); + +private: + uint64_t get_subsample(int level, uint64_t offset) const; + + static uint64_t pow2_ceil(uint64_t x, unsigned int power); + +private: + struct MipMapLevel mip_map_[ScaleStepCount]; + uint64_t last_append_sample_; + + friend struct LogicSnapshotTest::Pow2; + friend struct LogicSnapshotTest::Basic; + friend struct LogicSnapshotTest::LargeData; + friend struct LogicSnapshotTest::Pulses; + friend struct LogicSnapshotTest::LongPulses; +}; + +} // namespace data +} // namespace pv + +#endif // PULSEVIEW_PV_DATA_LOGICSNAPSHOT_H diff --git a/pv/data/signaldata.cpp b/pv/data/signaldata.cpp index 456edf14..42409b82 100644 --- a/pv/data/signaldata.cpp +++ b/pv/data/signaldata.cpp @@ -18,7 +18,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "signaldata.h" +#include "signaldata.hpp" namespace pv { namespace data { diff --git a/pv/data/signaldata.h b/pv/data/signaldata.h deleted file mode 100644 index 885f8435..00000000 --- a/pv/data/signaldata.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * This file is part of the PulseView project. - * - * 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 - */ - -#ifndef PULSEVIEW_PV_DATA_SIGNALDATA_H -#define PULSEVIEW_PV_DATA_SIGNALDATA_H - -#include - -namespace pv { -namespace data { - -class SignalData -{ -public: - SignalData(); - virtual ~SignalData() {} - -public: - double samplerate() const; - void set_samplerate(double samplerate); - - double get_start_time() const; - - virtual void clear() = 0; - - virtual uint64_t get_max_sample_count() const = 0; - -protected: - double start_time_; - double samplerate_; -}; - -} // namespace data -} // namespace pv - -#endif // PULSEVIEW_PV_DATA_SIGNALDATA_H diff --git a/pv/data/signaldata.hpp b/pv/data/signaldata.hpp new file mode 100644 index 00000000..885f8435 --- /dev/null +++ b/pv/data/signaldata.hpp @@ -0,0 +1,53 @@ +/* + * This file is part of the PulseView project. + * + * 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 + */ + +#ifndef PULSEVIEW_PV_DATA_SIGNALDATA_H +#define PULSEVIEW_PV_DATA_SIGNALDATA_H + +#include + +namespace pv { +namespace data { + +class SignalData +{ +public: + SignalData(); + virtual ~SignalData() {} + +public: + double samplerate() const; + void set_samplerate(double samplerate); + + double get_start_time() const; + + virtual void clear() = 0; + + virtual uint64_t get_max_sample_count() const = 0; + +protected: + double start_time_; + double samplerate_; +}; + +} // namespace data +} // namespace pv + +#endif // PULSEVIEW_PV_DATA_SIGNALDATA_H diff --git a/pv/data/snapshot.cpp b/pv/data/snapshot.cpp index 80b9fb37..58da4dbd 100644 --- a/pv/data/snapshot.cpp +++ b/pv/data/snapshot.cpp @@ -18,7 +18,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "snapshot.h" +#include "snapshot.hpp" #include #include diff --git a/pv/data/snapshot.h b/pv/data/snapshot.h deleted file mode 100644 index 29d0eed4..00000000 --- a/pv/data/snapshot.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * This file is part of the PulseView project. - * - * 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 - */ - -#ifndef PULSEVIEW_PV_DATA_SNAPSHOT_H -#define PULSEVIEW_PV_DATA_SNAPSHOT_H - -#include -#include -#include - -namespace pv { -namespace data { - -class Snapshot -{ -public: - Snapshot(unsigned int unit_size); - - virtual ~Snapshot(); - - uint64_t get_sample_count() const; - - unsigned int unit_size() const; - - /** - * @brief Increase the capacity of the snapshot. - * - * Increasing the capacity allows samples to be appended without needing - * to reallocate memory. - * - * For the best efficiency @c set_capacity() should be called once before - * @c append_data() is called to set up the snapshot with the expected number - * of samples that will be appended in total. - * - * @note The capacity will automatically be increased when @c append_data() - * is called if there is not enough capacity in the buffer to store the samples. - * - * @param[in] new_capacity The new capacity of the snapshot. If this value is - * smaller or equal than the current capacity then the method has no effect. - */ - void set_capacity(uint64_t new_capacity); - - /** - * @brief Get the current capacity of the snapshot. - * - * The capacity can be increased by calling @c set_capacity(). - * - * @return The current capacity of the snapshot. - */ - uint64_t capacity() const; - -protected: - void append_data(void *data, uint64_t samples); - -protected: - mutable std::recursive_mutex mutex_; - std::vector data_; - uint64_t sample_count_; - uint64_t capacity_; - unsigned int unit_size_; -}; - -} // namespace data -} // namespace pv - -#endif // PULSEVIEW_PV_DATA_SNAPSHOT_H diff --git a/pv/data/snapshot.hpp b/pv/data/snapshot.hpp new file mode 100644 index 00000000..29d0eed4 --- /dev/null +++ b/pv/data/snapshot.hpp @@ -0,0 +1,83 @@ +/* + * This file is part of the PulseView project. + * + * 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 + */ + +#ifndef PULSEVIEW_PV_DATA_SNAPSHOT_H +#define PULSEVIEW_PV_DATA_SNAPSHOT_H + +#include +#include +#include + +namespace pv { +namespace data { + +class Snapshot +{ +public: + Snapshot(unsigned int unit_size); + + virtual ~Snapshot(); + + uint64_t get_sample_count() const; + + unsigned int unit_size() const; + + /** + * @brief Increase the capacity of the snapshot. + * + * Increasing the capacity allows samples to be appended without needing + * to reallocate memory. + * + * For the best efficiency @c set_capacity() should be called once before + * @c append_data() is called to set up the snapshot with the expected number + * of samples that will be appended in total. + * + * @note The capacity will automatically be increased when @c append_data() + * is called if there is not enough capacity in the buffer to store the samples. + * + * @param[in] new_capacity The new capacity of the snapshot. If this value is + * smaller or equal than the current capacity then the method has no effect. + */ + void set_capacity(uint64_t new_capacity); + + /** + * @brief Get the current capacity of the snapshot. + * + * The capacity can be increased by calling @c set_capacity(). + * + * @return The current capacity of the snapshot. + */ + uint64_t capacity() const; + +protected: + void append_data(void *data, uint64_t samples); + +protected: + mutable std::recursive_mutex mutex_; + std::vector data_; + uint64_t sample_count_; + uint64_t capacity_; + unsigned int unit_size_; +}; + +} // namespace data +} // namespace pv + +#endif // PULSEVIEW_PV_DATA_SNAPSHOT_H diff --git a/pv/devicemanager.cpp b/pv/devicemanager.cpp index 2f446c45..7a016d1b 100644 --- a/pv/devicemanager.cpp +++ b/pv/devicemanager.cpp @@ -18,8 +18,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "devicemanager.h" -#include "sigsession.h" +#include "devicemanager.hpp" +#include "sigsession.hpp" #include #include diff --git a/pv/devicemanager.h b/pv/devicemanager.h deleted file mode 100644 index 823cb2bc..00000000 --- a/pv/devicemanager.h +++ /dev/null @@ -1,85 +0,0 @@ -/* - * This file is part of the PulseView project. - * - * 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 - */ - -#ifndef PULSEVIEW_PV_DEVICEMANAGER_H -#define PULSEVIEW_PV_DEVICEMANAGER_H - -#include -#include -#include -#include - -namespace Glib { - class VariantBase; -} - -namespace sigrok { - class ConfigKey; - class Context; - class Driver; - class Device; - class HardwareDevice; -} - -namespace pv { - -class SigSession; - -class DeviceManager -{ -public: - DeviceManager(std::shared_ptr context); - - ~DeviceManager(); - - std::shared_ptr context(); - - const std::list< std::shared_ptr >& - devices() const; - - std::list< std::shared_ptr > driver_scan( - std::shared_ptr driver, - std::map drvopts); - - const std::map get_device_info( - const std::shared_ptr device); - - const std::shared_ptr find_device_from_info( - const std::map search_info); - - const std::string build_display_name(std::shared_ptr device); - - const std::string get_display_name(std::shared_ptr dev); - - void update_display_name(std::shared_ptr dev); - -private: - bool compare_devices(std::shared_ptr a, - std::shared_ptr b); - -protected: - std::shared_ptr context_; - std::list< std::shared_ptr > devices_; - std::map< std::shared_ptr, std::string > display_names_; -}; - -} // namespace pv - -#endif // PULSEVIEW_PV_DEVICEMANAGER_H diff --git a/pv/devicemanager.hpp b/pv/devicemanager.hpp new file mode 100644 index 00000000..823cb2bc --- /dev/null +++ b/pv/devicemanager.hpp @@ -0,0 +1,85 @@ +/* + * This file is part of the PulseView project. + * + * 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 + */ + +#ifndef PULSEVIEW_PV_DEVICEMANAGER_H +#define PULSEVIEW_PV_DEVICEMANAGER_H + +#include +#include +#include +#include + +namespace Glib { + class VariantBase; +} + +namespace sigrok { + class ConfigKey; + class Context; + class Driver; + class Device; + class HardwareDevice; +} + +namespace pv { + +class SigSession; + +class DeviceManager +{ +public: + DeviceManager(std::shared_ptr context); + + ~DeviceManager(); + + std::shared_ptr context(); + + const std::list< std::shared_ptr >& + devices() const; + + std::list< std::shared_ptr > driver_scan( + std::shared_ptr driver, + std::map drvopts); + + const std::map get_device_info( + const std::shared_ptr device); + + const std::shared_ptr find_device_from_info( + const std::map search_info); + + const std::string build_display_name(std::shared_ptr device); + + const std::string get_display_name(std::shared_ptr dev); + + void update_display_name(std::shared_ptr dev); + +private: + bool compare_devices(std::shared_ptr a, + std::shared_ptr b); + +protected: + std::shared_ptr context_; + std::list< std::shared_ptr > devices_; + std::map< std::shared_ptr, std::string > display_names_; +}; + +} // namespace pv + +#endif // PULSEVIEW_PV_DEVICEMANAGER_H diff --git a/pv/dialogs/about.cpp b/pv/dialogs/about.cpp index 05daff8a..5517beb3 100644 --- a/pv/dialogs/about.cpp +++ b/pv/dialogs/about.cpp @@ -24,7 +24,7 @@ #include -#include "about.h" +#include "about.hpp" #include #include diff --git a/pv/dialogs/about.h b/pv/dialogs/about.h deleted file mode 100644 index 6656f9c0..00000000 --- a/pv/dialogs/about.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * This file is part of the PulseView project. - * - * 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 - */ - -#ifndef PULSEVIEW_PV_ABOUT_H -#define PULSEVIEW_PV_ABOUT_H - -#include - -#include - -class QTextDocument; - -namespace sigrok { - class Context; -} - -namespace Ui { -class About; -} - -namespace pv { -namespace dialogs { - -class About : public QDialog -{ - Q_OBJECT - -public: - explicit About(std::shared_ptr context, QWidget *parent = 0); - ~About(); - -private: - Ui::About *ui; - std::auto_ptr supportedDoc; -}; - -} // namespace dialogs -} // namespace pv - -#endif // PULSEVIEW_PV_ABOUT_H diff --git a/pv/dialogs/about.hpp b/pv/dialogs/about.hpp new file mode 100644 index 00000000..6656f9c0 --- /dev/null +++ b/pv/dialogs/about.hpp @@ -0,0 +1,57 @@ +/* + * This file is part of the PulseView project. + * + * 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 + */ + +#ifndef PULSEVIEW_PV_ABOUT_H +#define PULSEVIEW_PV_ABOUT_H + +#include + +#include + +class QTextDocument; + +namespace sigrok { + class Context; +} + +namespace Ui { +class About; +} + +namespace pv { +namespace dialogs { + +class About : public QDialog +{ + Q_OBJECT + +public: + explicit About(std::shared_ptr context, QWidget *parent = 0); + ~About(); + +private: + Ui::About *ui; + std::auto_ptr supportedDoc; +}; + +} // namespace dialogs +} // namespace pv + +#endif // PULSEVIEW_PV_ABOUT_H diff --git a/pv/dialogs/connect.cpp b/pv/dialogs/connect.cpp index 5535f46d..2700672a 100644 --- a/pv/dialogs/connect.cpp +++ b/pv/dialogs/connect.cpp @@ -22,9 +22,9 @@ #include -#include "connect.h" +#include "connect.hpp" -#include "pv/devicemanager.h" +#include "pv/devicemanager.hpp" using std::list; using std::map; diff --git a/pv/dialogs/connect.h b/pv/dialogs/connect.h deleted file mode 100644 index b46da06f..00000000 --- a/pv/dialogs/connect.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - * This file is part of the PulseView project. - * - * Copyright (C) 2012-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 - */ - -#ifndef PULSEVIEW_PV_CONNECT_H -#define PULSEVIEW_PV_CONNECT_H - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -namespace sigrok { - class Driver; - class HardwareDevice; -} - -Q_DECLARE_METATYPE(std::shared_ptr); -Q_DECLARE_METATYPE(std::shared_ptr); - -namespace pv { - -class DeviceManager; - -namespace dialogs { - -class Connect : public QDialog -{ - Q_OBJECT - -public: - Connect(QWidget *parent, pv::DeviceManager &device_manager); - - std::shared_ptr get_selected_device() const; - -private: - void populate_drivers(); - - void unset_connection(); - - void set_serial_connection(); - -private Q_SLOTS: - void device_selected(int index); - - void scan_pressed(); - -private: - pv::DeviceManager &device_manager_; - - QVBoxLayout layout_; - - QWidget form_; - QFormLayout form_layout_; - - QComboBox drivers_; - - QLineEdit serial_device_; - - QPushButton scan_button_; - QListWidget device_list_; - - QDialogButtonBox button_box_; -}; - -} // namespace dialogs -} // namespace pv - -#endif // PULSEVIEW_PV_CONNECT_H diff --git a/pv/dialogs/connect.hpp b/pv/dialogs/connect.hpp new file mode 100644 index 00000000..b46da06f --- /dev/null +++ b/pv/dialogs/connect.hpp @@ -0,0 +1,91 @@ +/* + * This file is part of the PulseView project. + * + * Copyright (C) 2012-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 + */ + +#ifndef PULSEVIEW_PV_CONNECT_H +#define PULSEVIEW_PV_CONNECT_H + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace sigrok { + class Driver; + class HardwareDevice; +} + +Q_DECLARE_METATYPE(std::shared_ptr); +Q_DECLARE_METATYPE(std::shared_ptr); + +namespace pv { + +class DeviceManager; + +namespace dialogs { + +class Connect : public QDialog +{ + Q_OBJECT + +public: + Connect(QWidget *parent, pv::DeviceManager &device_manager); + + std::shared_ptr get_selected_device() const; + +private: + void populate_drivers(); + + void unset_connection(); + + void set_serial_connection(); + +private Q_SLOTS: + void device_selected(int index); + + void scan_pressed(); + +private: + pv::DeviceManager &device_manager_; + + QVBoxLayout layout_; + + QWidget form_; + QFormLayout form_layout_; + + QComboBox drivers_; + + QLineEdit serial_device_; + + QPushButton scan_button_; + QListWidget device_list_; + + QDialogButtonBox button_box_; +}; + +} // namespace dialogs +} // namespace pv + +#endif // PULSEVIEW_PV_CONNECT_H diff --git a/pv/dialogs/storeprogress.cpp b/pv/dialogs/storeprogress.cpp index 6c264096..7cc40a75 100644 --- a/pv/dialogs/storeprogress.cpp +++ b/pv/dialogs/storeprogress.cpp @@ -22,7 +22,7 @@ #include -#include "storeprogress.h" +#include "storeprogress.hpp" namespace pv { namespace dialogs { diff --git a/pv/dialogs/storeprogress.h b/pv/dialogs/storeprogress.h deleted file mode 100644 index 497099e9..00000000 --- a/pv/dialogs/storeprogress.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * This file is part of the PulseView project. - * - * Copyright (C) 2014 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 - */ - -#ifndef PULSEVIEW_PV_DIALOGS_SAVEPROGRESS_H -#define PULSEVIEW_PV_DIALOGS_SAVEPROGRESS_H - -#include -#include - -#include - -#include - -namespace pv { - -class SigSession; - -namespace dialogs { - -class StoreProgress : public QProgressDialog -{ - Q_OBJECT - -public: - StoreProgress(const QString &file_name, const SigSession &session, - QWidget *parent = 0); - - virtual ~StoreProgress(); - - void run(); - -private: - void show_error(); - - void closeEvent(QCloseEvent*); - -private Q_SLOTS: - void on_progress_updated(); - -private: - pv::StoreSession session_; -}; - -} // dialogs -} // pv - -#endif // PULSEVIEW_PV_DIALOGS_SAVEPROGRESS_H diff --git a/pv/dialogs/storeprogress.hpp b/pv/dialogs/storeprogress.hpp new file mode 100644 index 00000000..ca14dfb2 --- /dev/null +++ b/pv/dialogs/storeprogress.hpp @@ -0,0 +1,64 @@ +/* + * This file is part of the PulseView project. + * + * Copyright (C) 2014 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 + */ + +#ifndef PULSEVIEW_PV_DIALOGS_SAVEPROGRESS_H +#define PULSEVIEW_PV_DIALOGS_SAVEPROGRESS_H + +#include +#include + +#include + +#include + +namespace pv { + +class SigSession; + +namespace dialogs { + +class StoreProgress : public QProgressDialog +{ + Q_OBJECT + +public: + StoreProgress(const QString &file_name, const SigSession &session, + QWidget *parent = 0); + + virtual ~StoreProgress(); + + void run(); + +private: + void show_error(); + + void closeEvent(QCloseEvent*); + +private Q_SLOTS: + void on_progress_updated(); + +private: + pv::StoreSession session_; +}; + +} // dialogs +} // pv + +#endif // PULSEVIEW_PV_DIALOGS_SAVEPROGRESS_H diff --git a/pv/mainwindow.cpp b/pv/mainwindow.cpp index d1418b59..a43b575a 100644 --- a/pv/mainwindow.cpp +++ b/pv/mainwindow.cpp @@ -40,17 +40,17 @@ #include #include -#include "mainwindow.h" - -#include "devicemanager.h" -#include "dialogs/about.h" -#include "dialogs/connect.h" -#include "dialogs/storeprogress.h" -#include "toolbars/samplingbar.h" -#include "view/logicsignal.h" -#include "view/view.h" +#include "mainwindow.hpp" + +#include "devicemanager.hpp" +#include "dialogs/about.hpp" +#include "dialogs/connect.hpp" +#include "dialogs/storeprogress.hpp" +#include "toolbars/samplingbar.hpp" +#include "view/logicsignal.hpp" +#include "view/view.hpp" #ifdef ENABLE_DECODE -#include "widgets/decodermenu.h" +#include "widgets/decodermenu.hpp" #endif #include diff --git a/pv/mainwindow.h b/pv/mainwindow.h deleted file mode 100644 index 94a6c42e..00000000 --- a/pv/mainwindow.h +++ /dev/null @@ -1,134 +0,0 @@ -/* - * This file is part of the PulseView project. - * - * 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 - */ - -#ifndef PULSEVIEW_PV_MAINWINDOW_H -#define PULSEVIEW_PV_MAINWINDOW_H - -#include -#include - -#include - -#include "sigsession.h" - -struct srd_decoder; - -class QVBoxLayout; - -namespace pv { - -class DeviceManager; - -namespace toolbars { -class ContextBar; -class SamplingBar; -} - -namespace view { -class View; -} - -namespace widgets { -class DecoderMenu; -} - -class MainWindow : public QMainWindow -{ - Q_OBJECT - -public: - explicit MainWindow(DeviceManager &device_manager, - const char *open_file_name = NULL, - QWidget *parent = 0); - -private: - void setup_ui(); - - void save_ui_settings(); - - void restore_ui_settings(); - - void session_error(const QString text, const QString info_text); - - /** - * Updates the device list in the sampling bar - */ - void update_device_list(); - - void closeEvent(QCloseEvent *event); - -private Q_SLOTS: - void load_file(QString file_name); - - void show_session_error( - const QString text, const QString info_text); - - void on_actionOpen_triggered(); - void on_actionSaveAs_triggered(); - void on_actionQuit_triggered(); - - void on_actionConnect_triggered(); - - void on_actionViewZoomIn_triggered(); - - void on_actionViewZoomOut_triggered(); - - void on_actionViewZoomFit_triggered(); - - void on_actionViewZoomOneToOne_triggered(); - - void on_actionViewShowCursors_triggered(); - - void on_actionAbout_triggered(); - - void add_decoder(srd_decoder *decoder); - - void run_stop(); - - void capture_state_changed(int state); - -private: - /** - * Name of the setting used to remember the directory - * containing the last file that was opened. - */ - static const char *SettingOpenDirectory; - - /** - * Name of the setting used to remember the directory - * containing the last file that was saved. - */ - static const char *SettingSaveDirectory; - - DeviceManager &device_manager_; - - SigSession session_; - - pv::view::View *view_; - - QWidget *central_widget_; - QVBoxLayout *vertical_layout_; - - toolbars::SamplingBar *sampling_bar_; -}; - -} // namespace pv - -#endif // PULSEVIEW_PV_MAINWINDOW_H diff --git a/pv/mainwindow.hpp b/pv/mainwindow.hpp new file mode 100644 index 00000000..9a000c2a --- /dev/null +++ b/pv/mainwindow.hpp @@ -0,0 +1,134 @@ +/* + * This file is part of the PulseView project. + * + * 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 + */ + +#ifndef PULSEVIEW_PV_MAINWINDOW_H +#define PULSEVIEW_PV_MAINWINDOW_H + +#include +#include + +#include + +#include "sigsession.hpp" + +struct srd_decoder; + +class QVBoxLayout; + +namespace pv { + +class DeviceManager; + +namespace toolbars { +class ContextBar; +class SamplingBar; +} + +namespace view { +class View; +} + +namespace widgets { +class DecoderMenu; +} + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + explicit MainWindow(DeviceManager &device_manager, + const char *open_file_name = NULL, + QWidget *parent = 0); + +private: + void setup_ui(); + + void save_ui_settings(); + + void restore_ui_settings(); + + void session_error(const QString text, const QString info_text); + + /** + * Updates the device list in the sampling bar + */ + void update_device_list(); + + void closeEvent(QCloseEvent *event); + +private Q_SLOTS: + void load_file(QString file_name); + + void show_session_error( + const QString text, const QString info_text); + + void on_actionOpen_triggered(); + void on_actionSaveAs_triggered(); + void on_actionQuit_triggered(); + + void on_actionConnect_triggered(); + + void on_actionViewZoomIn_triggered(); + + void on_actionViewZoomOut_triggered(); + + void on_actionViewZoomFit_triggered(); + + void on_actionViewZoomOneToOne_triggered(); + + void on_actionViewShowCursors_triggered(); + + void on_actionAbout_triggered(); + + void add_decoder(srd_decoder *decoder); + + void run_stop(); + + void capture_state_changed(int state); + +private: + /** + * Name of the setting used to remember the directory + * containing the last file that was opened. + */ + static const char *SettingOpenDirectory; + + /** + * Name of the setting used to remember the directory + * containing the last file that was saved. + */ + static const char *SettingSaveDirectory; + + DeviceManager &device_manager_; + + SigSession session_; + + pv::view::View *view_; + + QWidget *central_widget_; + QVBoxLayout *vertical_layout_; + + toolbars::SamplingBar *sampling_bar_; +}; + +} // namespace pv + +#endif // PULSEVIEW_PV_MAINWINDOW_H diff --git a/pv/popups/channels.cpp b/pv/popups/channels.cpp index beacfb43..4598f123 100644 --- a/pv/popups/channels.cpp +++ b/pv/popups/channels.cpp @@ -25,11 +25,11 @@ #include #include -#include "channels.h" +#include "channels.hpp" -#include -#include -#include +#include +#include +#include #include diff --git a/pv/popups/channels.h b/pv/popups/channels.h deleted file mode 100644 index 667db937..00000000 --- a/pv/popups/channels.h +++ /dev/null @@ -1,105 +0,0 @@ -/* - * This file is part of the PulseView project. - * - * 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 - */ - -#ifndef PULSEVIEW_PV_POPUPS_CHANNELS_H -#define PULSEVIEW_PV_POPUPS_CHANNELS_H - -#include -#include -#include - -#include -#include -#include -#include - -#include - -class QCheckBox; -class QGridLayout; - -namespace sigrok { - class ChannelGroup; -} - -namespace pv { - -class SigSession; - -namespace prop { -namespace binding { -class DeviceOptions; -} -} - -namespace view { -class Signal; -} - -namespace popups { - -class Channels : public pv::widgets::Popup -{ - Q_OBJECT - -public: - Channels(SigSession &session_, QWidget *parent); - -private: - void set_all_channels(bool set); - - void populate_group(std::shared_ptr group, - const std::vector< std::shared_ptr > sigs); - - QGridLayout* create_channel_group_grid( - const std::vector< std::shared_ptr > sigs); - -private: - void showEvent(QShowEvent *e); - -private Q_SLOTS: - void on_channel_checked(QWidget *widget); - - void enable_all_channels(); - void disable_all_channels(); - -private: - pv::SigSession &session_; - - QFormLayout layout_; - - bool updating_channels_; - - std::vector< std::shared_ptr > - group_bindings_; - std::map< QCheckBox*, std::shared_ptr > - check_box_signal_map_; - - QHBoxLayout buttons_bar_; - QPushButton enable_all_channels_; - QPushButton disable_all_channels_; - - QSignalMapper check_box_mapper_; -}; - -} // popups -} // pv - -#endif // PULSEVIEW_PV_POPUPS_CHANNELS_H diff --git a/pv/popups/channels.hpp b/pv/popups/channels.hpp new file mode 100644 index 00000000..e472fdff --- /dev/null +++ b/pv/popups/channels.hpp @@ -0,0 +1,105 @@ +/* + * This file is part of the PulseView project. + * + * 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 + */ + +#ifndef PULSEVIEW_PV_POPUPS_CHANNELS_H +#define PULSEVIEW_PV_POPUPS_CHANNELS_H + +#include +#include +#include + +#include +#include +#include +#include + +#include + +class QCheckBox; +class QGridLayout; + +namespace sigrok { + class ChannelGroup; +} + +namespace pv { + +class SigSession; + +namespace prop { +namespace binding { +class DeviceOptions; +} +} + +namespace view { +class Signal; +} + +namespace popups { + +class Channels : public pv::widgets::Popup +{ + Q_OBJECT + +public: + Channels(SigSession &session_, QWidget *parent); + +private: + void set_all_channels(bool set); + + void populate_group(std::shared_ptr group, + const std::vector< std::shared_ptr > sigs); + + QGridLayout* create_channel_group_grid( + const std::vector< std::shared_ptr > sigs); + +private: + void showEvent(QShowEvent *e); + +private Q_SLOTS: + void on_channel_checked(QWidget *widget); + + void enable_all_channels(); + void disable_all_channels(); + +private: + pv::SigSession &session_; + + QFormLayout layout_; + + bool updating_channels_; + + std::vector< std::shared_ptr > + group_bindings_; + std::map< QCheckBox*, std::shared_ptr > + check_box_signal_map_; + + QHBoxLayout buttons_bar_; + QPushButton enable_all_channels_; + QPushButton disable_all_channels_; + + QSignalMapper check_box_mapper_; +}; + +} // popups +} // pv + +#endif // PULSEVIEW_PV_POPUPS_CHANNELS_H diff --git a/pv/popups/deviceoptions.cpp b/pv/popups/deviceoptions.cpp index bdc0ab23..a92b0aea 100644 --- a/pv/popups/deviceoptions.cpp +++ b/pv/popups/deviceoptions.cpp @@ -18,12 +18,12 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "deviceoptions.h" +#include "deviceoptions.hpp" #include #include -#include +#include #include diff --git a/pv/popups/deviceoptions.h b/pv/popups/deviceoptions.h deleted file mode 100644 index 5fb60fc7..00000000 --- a/pv/popups/deviceoptions.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * This file is part of the PulseView project. - * - * 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 - */ - -#ifndef PULSEVIEW_PV_POPUPS_DEVICEOPTIONS_H -#define PULSEVIEW_PV_POPUPS_DEVICEOPTIONS_H - -#include -#include - -#include -#include - -namespace sigrok { - class Device; -} - -namespace pv { -namespace popups { - -class DeviceOptions : public pv::widgets::Popup -{ - Q_OBJECT - -public: - DeviceOptions(std::shared_ptr device, - QWidget *parent); - - pv::prop::binding::DeviceOptions& binding(); - -private: - std::shared_ptr device_; - - QVBoxLayout layout_; - - pv::prop::binding::DeviceOptions binding_; -}; - -} // namespace popups -} // namespace pv - -#endif // PULSEVIEW_PV_POPUPS_DEVICEOPTIONS_H diff --git a/pv/popups/deviceoptions.hpp b/pv/popups/deviceoptions.hpp new file mode 100644 index 00000000..d43ab607 --- /dev/null +++ b/pv/popups/deviceoptions.hpp @@ -0,0 +1,58 @@ +/* + * This file is part of the PulseView project. + * + * 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 + */ + +#ifndef PULSEVIEW_PV_POPUPS_DEVICEOPTIONS_H +#define PULSEVIEW_PV_POPUPS_DEVICEOPTIONS_H + +#include +#include + +#include +#include + +namespace sigrok { + class Device; +} + +namespace pv { +namespace popups { + +class DeviceOptions : public pv::widgets::Popup +{ + Q_OBJECT + +public: + DeviceOptions(std::shared_ptr device, + QWidget *parent); + + pv::prop::binding::DeviceOptions& binding(); + +private: + std::shared_ptr device_; + + QVBoxLayout layout_; + + pv::prop::binding::DeviceOptions binding_; +}; + +} // namespace popups +} // namespace pv + +#endif // PULSEVIEW_PV_POPUPS_DEVICEOPTIONS_H diff --git a/pv/prop/binding/binding.cpp b/pv/prop/binding/binding.cpp index 0bc9854c..062ce667 100644 --- a/pv/prop/binding/binding.cpp +++ b/pv/prop/binding/binding.cpp @@ -22,9 +22,9 @@ #include -#include +#include -#include "binding.h" +#include "binding.hpp" using std::shared_ptr; diff --git a/pv/prop/binding/binding.h b/pv/prop/binding/binding.h deleted file mode 100644 index 7d216e2d..00000000 --- a/pv/prop/binding/binding.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * This file is part of the PulseView project. - * - * 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 - */ - -#ifndef PULSEVIEW_PV_PROP_BINDING_BINDING_H -#define PULSEVIEW_PV_PROP_BINDING_BINDING_H - -#include - -#include -#include - -#include - -class QFormLayout; -class QWidget; - -namespace pv { -namespace prop { - -class Property; - -namespace binding { - -class Binding -{ -public: - const std::vector< std::shared_ptr >& properties(); - - void commit(); - - void add_properties_to_form(QFormLayout *layout, - bool auto_commit = false) const; - - QWidget* get_property_form(QWidget *parent, - bool auto_commit = false) const; - - static QString print_gvariant(Glib::VariantBase gvar); - -protected: - std::vector< std::shared_ptr > properties_; -}; - -} // binding -} // prop -} // pv - -#endif // PULSEVIEW_PV_PROP_BINDING_BINDING_H diff --git a/pv/prop/binding/binding.hpp b/pv/prop/binding/binding.hpp new file mode 100644 index 00000000..7d216e2d --- /dev/null +++ b/pv/prop/binding/binding.hpp @@ -0,0 +1,64 @@ +/* + * This file is part of the PulseView project. + * + * 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 + */ + +#ifndef PULSEVIEW_PV_PROP_BINDING_BINDING_H +#define PULSEVIEW_PV_PROP_BINDING_BINDING_H + +#include + +#include +#include + +#include + +class QFormLayout; +class QWidget; + +namespace pv { +namespace prop { + +class Property; + +namespace binding { + +class Binding +{ +public: + const std::vector< std::shared_ptr >& properties(); + + void commit(); + + void add_properties_to_form(QFormLayout *layout, + bool auto_commit = false) const; + + QWidget* get_property_form(QWidget *parent, + bool auto_commit = false) const; + + static QString print_gvariant(Glib::VariantBase gvar); + +protected: + std::vector< std::shared_ptr > properties_; +}; + +} // binding +} // prop +} // pv + +#endif // PULSEVIEW_PV_PROP_BINDING_BINDING_H diff --git a/pv/prop/binding/decoderoptions.cpp b/pv/prop/binding/decoderoptions.cpp index a46f0df1..d9b4b88d 100644 --- a/pv/prop/binding/decoderoptions.cpp +++ b/pv/prop/binding/decoderoptions.cpp @@ -20,16 +20,16 @@ #include -#include "decoderoptions.h" +#include "decoderoptions.hpp" #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include using boost::none; using std::make_pair; diff --git a/pv/prop/binding/decoderoptions.h b/pv/prop/binding/decoderoptions.h deleted file mode 100644 index 7f14d0fd..00000000 --- a/pv/prop/binding/decoderoptions.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * This file is part of the PulseView project. - * - * 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 - */ - -#ifndef PULSEVIEW_PV_PROP_BINDING_DECODEROPTIONS_H -#define PULSEVIEW_PV_PROP_BINDING_DECODEROPTIONS_H - -#include "binding.h" - -#include - -struct srd_decoder_option; - -namespace pv { - -namespace data { -class DecoderStack; -namespace decode { -class Decoder; -} -} - -namespace prop { -namespace binding { - -class DecoderOptions : public Binding -{ -public: - DecoderOptions(std::shared_ptr decoder_stack, - std::shared_ptr decoder); - -private: - static std::shared_ptr bind_enum(const QString &name, - const srd_decoder_option *option, - Property::Getter getter, Property::Setter setter); - - Glib::VariantBase getter(const char *id); - - void setter(const char *id, Glib::VariantBase value); - -private: - std::shared_ptr decoder_stack_; - std::shared_ptr decoder_; -}; - -} // binding -} // prop -} // pv - -#endif // PULSEVIEW_PV_PROP_BINDING_DECODEROPTIONS_H diff --git a/pv/prop/binding/decoderoptions.hpp b/pv/prop/binding/decoderoptions.hpp new file mode 100644 index 00000000..680bc42f --- /dev/null +++ b/pv/prop/binding/decoderoptions.hpp @@ -0,0 +1,66 @@ +/* + * This file is part of the PulseView project. + * + * 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 + */ + +#ifndef PULSEVIEW_PV_PROP_BINDING_DECODEROPTIONS_H +#define PULSEVIEW_PV_PROP_BINDING_DECODEROPTIONS_H + +#include "binding.hpp" + +#include + +struct srd_decoder_option; + +namespace pv { + +namespace data { +class DecoderStack; +namespace decode { +class Decoder; +} +} + +namespace prop { +namespace binding { + +class DecoderOptions : public Binding +{ +public: + DecoderOptions(std::shared_ptr decoder_stack, + std::shared_ptr decoder); + +private: + static std::shared_ptr bind_enum(const QString &name, + const srd_decoder_option *option, + Property::Getter getter, Property::Setter setter); + + Glib::VariantBase getter(const char *id); + + void setter(const char *id, Glib::VariantBase value); + +private: + std::shared_ptr decoder_stack_; + std::shared_ptr decoder_; +}; + +} // binding +} // prop +} // pv + +#endif // PULSEVIEW_PV_PROP_BINDING_DECODEROPTIONS_H diff --git a/pv/prop/binding/deviceoptions.cpp b/pv/prop/binding/deviceoptions.cpp index e112bb12..68e3237f 100644 --- a/pv/prop/binding/deviceoptions.cpp +++ b/pv/prop/binding/deviceoptions.cpp @@ -22,12 +22,12 @@ #include -#include "deviceoptions.h" +#include "deviceoptions.hpp" -#include -#include -#include -#include +#include +#include +#include +#include #include diff --git a/pv/prop/binding/deviceoptions.h b/pv/prop/binding/deviceoptions.h deleted file mode 100644 index 0ca55e0e..00000000 --- a/pv/prop/binding/deviceoptions.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * This file is part of the PulseView project. - * - * 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 - */ - -#ifndef PULSEVIEW_PV_PROP_BINDING_DEVICEOPTIONS_H -#define PULSEVIEW_PV_PROP_BINDING_DEVICEOPTIONS_H - -#include - -#include -#include - -#include "binding.h" - -#include - -namespace sigrok { - class Configurable; -} - -namespace pv { - -namespace prop { -namespace binding { - -class DeviceOptions : public QObject, public Binding -{ - Q_OBJECT - -public: - DeviceOptions(std::shared_ptr configurable); - -Q_SIGNALS: - void config_changed(); - -private: - void bind_bool(const QString &name, - Property::Getter getter, Property::Setter setter); - void bind_enum(const QString &name, Glib::VariantContainerBase gvar_list, - Property::Getter getter, Property::Setter setter, - std::function printer = print_gvariant); - void bind_int(const QString &name, QString suffix, - boost::optional< std::pair > range, - Property::Getter getter, Property::Setter setter); - - static QString print_timebase(Glib::VariantBase gvar); - static QString print_vdiv(Glib::VariantBase gvar); - static QString print_voltage_threshold(Glib::VariantBase gvar); - -protected: - std::shared_ptr configurable_; -}; - -} // binding -} // prop -} // pv - -#endif // PULSEVIEW_PV_PROP_BINDING_DEVICEOPTIONS_H diff --git a/pv/prop/binding/deviceoptions.hpp b/pv/prop/binding/deviceoptions.hpp new file mode 100644 index 00000000..d027cccb --- /dev/null +++ b/pv/prop/binding/deviceoptions.hpp @@ -0,0 +1,74 @@ +/* + * This file is part of the PulseView project. + * + * 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 + */ + +#ifndef PULSEVIEW_PV_PROP_BINDING_DEVICEOPTIONS_H +#define PULSEVIEW_PV_PROP_BINDING_DEVICEOPTIONS_H + +#include + +#include +#include + +#include "binding.hpp" + +#include + +namespace sigrok { + class Configurable; +} + +namespace pv { + +namespace prop { +namespace binding { + +class DeviceOptions : public QObject, public Binding +{ + Q_OBJECT + +public: + DeviceOptions(std::shared_ptr configurable); + +Q_SIGNALS: + void config_changed(); + +private: + void bind_bool(const QString &name, + Property::Getter getter, Property::Setter setter); + void bind_enum(const QString &name, Glib::VariantContainerBase gvar_list, + Property::Getter getter, Property::Setter setter, + std::function printer = print_gvariant); + void bind_int(const QString &name, QString suffix, + boost::optional< std::pair > range, + Property::Getter getter, Property::Setter setter); + + static QString print_timebase(Glib::VariantBase gvar); + static QString print_vdiv(Glib::VariantBase gvar); + static QString print_voltage_threshold(Glib::VariantBase gvar); + +protected: + std::shared_ptr configurable_; +}; + +} // binding +} // prop +} // pv + +#endif // PULSEVIEW_PV_PROP_BINDING_DEVICEOPTIONS_H diff --git a/pv/prop/bool.cpp b/pv/prop/bool.cpp index c057d61e..e3e0ebd5 100644 --- a/pv/prop/bool.cpp +++ b/pv/prop/bool.cpp @@ -22,7 +22,7 @@ #include -#include "bool.h" +#include "bool.hpp" namespace pv { namespace prop { diff --git a/pv/prop/bool.h b/pv/prop/bool.h deleted file mode 100644 index d7f8877b..00000000 --- a/pv/prop/bool.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * This file is part of the PulseView project. - * - * 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 - */ - -#ifndef PULSEVIEW_PV_PROP_BOOL_H -#define PULSEVIEW_PV_PROP_BOOL_H - -#include "property.h" - -class QCheckBox; - -namespace pv { -namespace prop { - -class Bool : public Property -{ - Q_OBJECT; - -public: - Bool(QString name, Getter getter, Setter setter); - - virtual ~Bool(); - - QWidget* get_widget(QWidget *parent, bool auto_commit); - bool labeled_widget() const; - - void commit(); - -private Q_SLOTS: - void on_state_changed(int); - -private: - QCheckBox *check_box_; -}; - -} // prop -} // pv - -#endif // PULSEVIEW_PV_PROP_BOOL_H diff --git a/pv/prop/bool.hpp b/pv/prop/bool.hpp new file mode 100644 index 00000000..965efc19 --- /dev/null +++ b/pv/prop/bool.hpp @@ -0,0 +1,55 @@ +/* + * This file is part of the PulseView project. + * + * 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 + */ + +#ifndef PULSEVIEW_PV_PROP_BOOL_H +#define PULSEVIEW_PV_PROP_BOOL_H + +#include "property.hpp" + +class QCheckBox; + +namespace pv { +namespace prop { + +class Bool : public Property +{ + Q_OBJECT; + +public: + Bool(QString name, Getter getter, Setter setter); + + virtual ~Bool(); + + QWidget* get_widget(QWidget *parent, bool auto_commit); + bool labeled_widget() const; + + void commit(); + +private Q_SLOTS: + void on_state_changed(int); + +private: + QCheckBox *check_box_; +}; + +} // prop +} // pv + +#endif // PULSEVIEW_PV_PROP_BOOL_H diff --git a/pv/prop/double.cpp b/pv/prop/double.cpp index d8a7a292..d0597558 100644 --- a/pv/prop/double.cpp +++ b/pv/prop/double.cpp @@ -22,7 +22,7 @@ #include -#include "double.h" +#include "double.hpp" using boost::optional; using std::pair; diff --git a/pv/prop/double.h b/pv/prop/double.h deleted file mode 100644 index dc4c6ec9..00000000 --- a/pv/prop/double.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * This file is part of the PulseView project. - * - * 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 - */ - -#ifndef PULSEVIEW_PV_PROP_DOUBLE_H -#define PULSEVIEW_PV_PROP_DOUBLE_H - -#include - -#include - -#include "property.h" - -class QDoubleSpinBox; - -namespace pv { -namespace prop { - -class Double : public Property -{ - Q_OBJECT - -public: - Double(QString name, int decimals, QString suffix, - boost::optional< std::pair > range, - boost::optional step, - Getter getter, - Setter setter); - - virtual ~Double(); - - QWidget* get_widget(QWidget *parent, bool auto_commit); - - void commit(); - -private Q_SLOTS: - void on_value_changed(double); - -private: - const int decimals_; - const QString suffix_; - const boost::optional< std::pair > range_; - const boost::optional step_; - - QDoubleSpinBox *spin_box_; -}; - -} // prop -} // pv - -#endif // PULSEVIEW_PV_PROP_DOUBLE_H diff --git a/pv/prop/double.hpp b/pv/prop/double.hpp new file mode 100644 index 00000000..89b74cca --- /dev/null +++ b/pv/prop/double.hpp @@ -0,0 +1,67 @@ +/* + * This file is part of the PulseView project. + * + * 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 + */ + +#ifndef PULSEVIEW_PV_PROP_DOUBLE_H +#define PULSEVIEW_PV_PROP_DOUBLE_H + +#include + +#include + +#include "property.hpp" + +class QDoubleSpinBox; + +namespace pv { +namespace prop { + +class Double : public Property +{ + Q_OBJECT + +public: + Double(QString name, int decimals, QString suffix, + boost::optional< std::pair > range, + boost::optional step, + Getter getter, + Setter setter); + + virtual ~Double(); + + QWidget* get_widget(QWidget *parent, bool auto_commit); + + void commit(); + +private Q_SLOTS: + void on_value_changed(double); + +private: + const int decimals_; + const QString suffix_; + const boost::optional< std::pair > range_; + const boost::optional step_; + + QDoubleSpinBox *spin_box_; +}; + +} // prop +} // pv + +#endif // PULSEVIEW_PV_PROP_DOUBLE_H diff --git a/pv/prop/enum.cpp b/pv/prop/enum.cpp index 473e3d5f..6717101b 100644 --- a/pv/prop/enum.cpp +++ b/pv/prop/enum.cpp @@ -22,7 +22,7 @@ #include -#include "enum.h" +#include "enum.hpp" using std::pair; using std::vector; diff --git a/pv/prop/enum.h b/pv/prop/enum.h deleted file mode 100644 index 45454fde..00000000 --- a/pv/prop/enum.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * This file is part of the PulseView project. - * - * 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 - */ - -#ifndef PULSEVIEW_PV_PROP_ENUM_H -#define PULSEVIEW_PV_PROP_ENUM_H - -#include -#include - -#include "property.h" - -#include - -Q_DECLARE_METATYPE(Glib::VariantBase); - -class QComboBox; - -namespace pv { -namespace prop { - -class Enum : public Property -{ - Q_OBJECT; - -public: - Enum(QString name, std::vector > values, - Getter getter, Setter setter); - - virtual ~Enum(); - - QWidget* get_widget(QWidget *parent, bool auto_commit); - - void commit(); - -private Q_SLOTS: - void on_current_item_changed(int); - -private: - const std::vector< std::pair > values_; - - QComboBox *selector_; -}; - -} // prop -} // pv - -#endif // PULSEVIEW_PV_PROP_ENUM_H diff --git a/pv/prop/enum.hpp b/pv/prop/enum.hpp new file mode 100644 index 00000000..7b7fcc5d --- /dev/null +++ b/pv/prop/enum.hpp @@ -0,0 +1,64 @@ +/* + * This file is part of the PulseView project. + * + * 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 + */ + +#ifndef PULSEVIEW_PV_PROP_ENUM_H +#define PULSEVIEW_PV_PROP_ENUM_H + +#include +#include + +#include "property.hpp" + +#include + +Q_DECLARE_METATYPE(Glib::VariantBase); + +class QComboBox; + +namespace pv { +namespace prop { + +class Enum : public Property +{ + Q_OBJECT; + +public: + Enum(QString name, std::vector > values, + Getter getter, Setter setter); + + virtual ~Enum(); + + QWidget* get_widget(QWidget *parent, bool auto_commit); + + void commit(); + +private Q_SLOTS: + void on_current_item_changed(int); + +private: + const std::vector< std::pair > values_; + + QComboBox *selector_; +}; + +} // prop +} // pv + +#endif // PULSEVIEW_PV_PROP_ENUM_H diff --git a/pv/prop/int.cpp b/pv/prop/int.cpp index ef962e5a..0edba420 100644 --- a/pv/prop/int.cpp +++ b/pv/prop/int.cpp @@ -23,7 +23,7 @@ #include -#include "int.h" +#include "int.hpp" using boost::optional; using std::max; diff --git a/pv/prop/int.h b/pv/prop/int.h deleted file mode 100644 index 5779b37b..00000000 --- a/pv/prop/int.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * This file is part of the PulseView project. - * - * 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 - */ - -#ifndef PULSEVIEW_PV_PROP_INT_H -#define PULSEVIEW_PV_PROP_INT_H - -#include - -#include - -#include "property.h" - -class QSpinBox; - -namespace pv { -namespace prop { - -class Int : public Property -{ - Q_OBJECT; - -public: - Int(QString name, QString suffix, - boost::optional< std::pair > range, - Getter getter, Setter setter); - - virtual ~Int(); - - QWidget* get_widget(QWidget *parent, bool auto_commit); - - void commit(); - -private Q_SLOTS: - void on_value_changed(int); - -private: - const QString suffix_; - const boost::optional< std::pair > range_; - - Glib::VariantBase value_; - QSpinBox *spin_box_; -}; - -} // prop -} // pv - -#endif // PULSEVIEW_PV_PROP_INT_H diff --git a/pv/prop/int.hpp b/pv/prop/int.hpp new file mode 100644 index 00000000..a1c529fd --- /dev/null +++ b/pv/prop/int.hpp @@ -0,0 +1,64 @@ +/* + * This file is part of the PulseView project. + * + * 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 + */ + +#ifndef PULSEVIEW_PV_PROP_INT_H +#define PULSEVIEW_PV_PROP_INT_H + +#include + +#include + +#include "property.hpp" + +class QSpinBox; + +namespace pv { +namespace prop { + +class Int : public Property +{ + Q_OBJECT; + +public: + Int(QString name, QString suffix, + boost::optional< std::pair > range, + Getter getter, Setter setter); + + virtual ~Int(); + + QWidget* get_widget(QWidget *parent, bool auto_commit); + + void commit(); + +private Q_SLOTS: + void on_value_changed(int); + +private: + const QString suffix_; + const boost::optional< std::pair > range_; + + Glib::VariantBase value_; + QSpinBox *spin_box_; +}; + +} // prop +} // pv + +#endif // PULSEVIEW_PV_PROP_INT_H diff --git a/pv/prop/property.cpp b/pv/prop/property.cpp index 26740ba0..c513d51e 100644 --- a/pv/prop/property.cpp +++ b/pv/prop/property.cpp @@ -18,7 +18,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "property.h" +#include "property.hpp" namespace pv { namespace prop { diff --git a/pv/prop/property.h b/pv/prop/property.h deleted file mode 100644 index dd6d25ba..00000000 --- a/pv/prop/property.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * This file is part of the PulseView project. - * - * 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 - */ - -#ifndef PULSEVIEW_PV_PROP_PROPERTY_H -#define PULSEVIEW_PV_PROP_PROPERTY_H - -#include - -#include -#include -#include - -class QWidget; - -namespace pv { -namespace prop { - -class Property : public QObject -{ - Q_OBJECT; - -public: - typedef std::function Getter; - typedef std::function Setter; - -protected: - Property(QString name, Getter getter, Setter setter); - -public: - const QString& name() const; - - virtual QWidget* get_widget(QWidget *parent, - bool auto_commit = false) = 0; - virtual bool labeled_widget() const; - - virtual void commit() = 0; - -protected: - const Getter getter_; - const Setter setter_; - -private: - QString name_; -}; - -} // prop -} // pv - -#endif // PULSEVIEW_PV_PROP_PROPERTY_H diff --git a/pv/prop/property.hpp b/pv/prop/property.hpp new file mode 100644 index 00000000..dd6d25ba --- /dev/null +++ b/pv/prop/property.hpp @@ -0,0 +1,66 @@ +/* + * This file is part of the PulseView project. + * + * 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 + */ + +#ifndef PULSEVIEW_PV_PROP_PROPERTY_H +#define PULSEVIEW_PV_PROP_PROPERTY_H + +#include + +#include +#include +#include + +class QWidget; + +namespace pv { +namespace prop { + +class Property : public QObject +{ + Q_OBJECT; + +public: + typedef std::function Getter; + typedef std::function Setter; + +protected: + Property(QString name, Getter getter, Setter setter); + +public: + const QString& name() const; + + virtual QWidget* get_widget(QWidget *parent, + bool auto_commit = false) = 0; + virtual bool labeled_widget() const; + + virtual void commit() = 0; + +protected: + const Getter getter_; + const Setter setter_; + +private: + QString name_; +}; + +} // prop +} // pv + +#endif // PULSEVIEW_PV_PROP_PROPERTY_H diff --git a/pv/prop/string.cpp b/pv/prop/string.cpp index ebad62ba..b8ecf738 100644 --- a/pv/prop/string.cpp +++ b/pv/prop/string.cpp @@ -23,7 +23,7 @@ #include #include -#include "string.h" +#include "string.hpp" using std::string; diff --git a/pv/prop/string.h b/pv/prop/string.h deleted file mode 100644 index 793a23cb..00000000 --- a/pv/prop/string.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * This file is part of the PulseView project. - * - * 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 - */ - -#ifndef PULSEVIEW_PV_PROP_STRING_H -#define PULSEVIEW_PV_PROP_STRING_H - -#include "property.h" - -class QLineEdit; - -namespace pv { -namespace prop { - -class String : public Property -{ - Q_OBJECT; - -public: - String(QString name, Getter getter, Setter setter); - - QWidget* get_widget(QWidget *parent, bool auto_commit); - - void commit(); - -private Q_SLOTS: - void on_text_edited(const QString&); - -private: - QLineEdit *line_edit_; -}; - -} // prop -} // pv - -#endif // PULSEVIEW_PV_PROP_STRING_H diff --git a/pv/prop/string.hpp b/pv/prop/string.hpp new file mode 100644 index 00000000..db57f7cd --- /dev/null +++ b/pv/prop/string.hpp @@ -0,0 +1,52 @@ +/* + * This file is part of the PulseView project. + * + * 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 + */ + +#ifndef PULSEVIEW_PV_PROP_STRING_H +#define PULSEVIEW_PV_PROP_STRING_H + +#include "property.hpp" + +class QLineEdit; + +namespace pv { +namespace prop { + +class String : public Property +{ + Q_OBJECT; + +public: + String(QString name, Getter getter, Setter setter); + + QWidget* get_widget(QWidget *parent, bool auto_commit); + + void commit(); + +private Q_SLOTS: + void on_text_edited(const QString&); + +private: + QLineEdit *line_edit_; +}; + +} // prop +} // pv + +#endif // PULSEVIEW_PV_PROP_STRING_H diff --git a/pv/sigsession.cpp b/pv/sigsession.cpp index a2eba967..f3eb1946 100644 --- a/pv/sigsession.cpp +++ b/pv/sigsession.cpp @@ -22,20 +22,20 @@ #include #endif -#include "sigsession.h" +#include "sigsession.hpp" -#include "devicemanager.h" +#include "devicemanager.hpp" -#include "data/analog.h" -#include "data/analogsnapshot.h" -#include "data/decoderstack.h" -#include "data/logic.h" -#include "data/logicsnapshot.h" -#include "data/decode/decoder.h" +#include "data/analog.hpp" +#include "data/analogsnapshot.hpp" +#include "data/decoderstack.hpp" +#include "data/logic.hpp" +#include "data/logicsnapshot.hpp" +#include "data/decode/decoder.hpp" -#include "view/analogsignal.h" -#include "view/decodetrace.h" -#include "view/logicsignal.h" +#include "view/analogsignal.hpp" +#include "view/decodetrace.hpp" +#include "view/logicsignal.hpp" #include #include diff --git a/pv/sigsession.h b/pv/sigsession.h deleted file mode 100644 index 513177be..00000000 --- a/pv/sigsession.h +++ /dev/null @@ -1,189 +0,0 @@ -/* - * This file is part of the PulseView project. - * - * Copyright (C) 2012-14 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 - */ - -#ifndef PULSEVIEW_PV_SIGSESSION_H -#define PULSEVIEW_PV_SIGSESSION_H - -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include - -struct srd_decoder; -struct srd_channel; - -namespace sigrok { - class Analog; - class Channel; - class Device; - class Logic; - class Meta; - class Packet; - class Session; -} - -namespace pv { - -class DeviceManager; - -namespace data { -class Analog; -class AnalogSnapshot; -class Logic; -class LogicSnapshot; -class SignalData; -} - -namespace view { -class DecodeTrace; -class LogicSignal; -class Signal; -} - -class SigSession : public QObject -{ - Q_OBJECT - -public: - enum capture_state { - Stopped, - AwaitingTrigger, - Running - }; - -public: - SigSession(DeviceManager &device_manager); - - ~SigSession(); - - DeviceManager& device_manager(); - - const DeviceManager& device_manager() const; - - const std::shared_ptr& session() const; - - std::shared_ptr device() const; - - /** - * Sets device instance that will be used in the next capture session. - */ - void set_device(std::shared_ptr device); - - void set_file(const std::string &name); - - void set_default_device(); - - capture_state get_capture_state() const; - - void start_capture(std::function error_handler); - - void stop_capture(); - - std::set< std::shared_ptr > get_data() const; - - boost::shared_mutex& signals_mutex() const; - - const std::vector< std::shared_ptr >& signals() const; - -#ifdef ENABLE_DECODE - bool add_decoder(srd_decoder *const dec); - - std::vector< std::shared_ptr > - get_decode_signals() const; - - void remove_decode_signal(view::DecodeTrace *signal); -#endif - -private: - void set_capture_state(capture_state state); - - void update_signals(std::shared_ptr device); - - std::shared_ptr signal_from_channel( - std::shared_ptr channel) const; - - void read_sample_rate(std::shared_ptr); - -private: - void sample_thread_proc(std::shared_ptr device, - std::function error_handler); - - void feed_in_header(std::shared_ptr device); - - void feed_in_meta(std::shared_ptr device, - std::shared_ptr meta); - - void feed_in_frame_begin(); - - void feed_in_logic(std::shared_ptr logic); - - void feed_in_analog(std::shared_ptr analog); - - void data_feed_in(std::shared_ptr device, - std::shared_ptr packet); - -private: - DeviceManager &device_manager_; - std::shared_ptr session_; - - /** - * The device instance that will be used in the next capture session. - */ - std::shared_ptr device_; - - std::vector< std::shared_ptr > decode_traces_; - - mutable std::mutex sampling_mutex_; - capture_state capture_state_; - - mutable boost::shared_mutex signals_mutex_; - std::vector< std::shared_ptr > signals_; - - mutable std::mutex data_mutex_; - std::shared_ptr logic_data_; - std::shared_ptr cur_logic_snapshot_; - std::map< std::shared_ptr, std::shared_ptr > - cur_analog_snapshots_; - - std::thread sampling_thread_; - -Q_SIGNALS: - void capture_state_changed(int state); - - void signals_changed(); - - void frame_began(); - - void data_received(); - - void frame_ended(); -}; - -} // namespace pv - -#endif // PULSEVIEW_PV_SIGSESSION_H diff --git a/pv/sigsession.hpp b/pv/sigsession.hpp new file mode 100644 index 00000000..513177be --- /dev/null +++ b/pv/sigsession.hpp @@ -0,0 +1,189 @@ +/* + * This file is part of the PulseView project. + * + * Copyright (C) 2012-14 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 + */ + +#ifndef PULSEVIEW_PV_SIGSESSION_H +#define PULSEVIEW_PV_SIGSESSION_H + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +struct srd_decoder; +struct srd_channel; + +namespace sigrok { + class Analog; + class Channel; + class Device; + class Logic; + class Meta; + class Packet; + class Session; +} + +namespace pv { + +class DeviceManager; + +namespace data { +class Analog; +class AnalogSnapshot; +class Logic; +class LogicSnapshot; +class SignalData; +} + +namespace view { +class DecodeTrace; +class LogicSignal; +class Signal; +} + +class SigSession : public QObject +{ + Q_OBJECT + +public: + enum capture_state { + Stopped, + AwaitingTrigger, + Running + }; + +public: + SigSession(DeviceManager &device_manager); + + ~SigSession(); + + DeviceManager& device_manager(); + + const DeviceManager& device_manager() const; + + const std::shared_ptr& session() const; + + std::shared_ptr device() const; + + /** + * Sets device instance that will be used in the next capture session. + */ + void set_device(std::shared_ptr device); + + void set_file(const std::string &name); + + void set_default_device(); + + capture_state get_capture_state() const; + + void start_capture(std::function error_handler); + + void stop_capture(); + + std::set< std::shared_ptr > get_data() const; + + boost::shared_mutex& signals_mutex() const; + + const std::vector< std::shared_ptr >& signals() const; + +#ifdef ENABLE_DECODE + bool add_decoder(srd_decoder *const dec); + + std::vector< std::shared_ptr > + get_decode_signals() const; + + void remove_decode_signal(view::DecodeTrace *signal); +#endif + +private: + void set_capture_state(capture_state state); + + void update_signals(std::shared_ptr device); + + std::shared_ptr signal_from_channel( + std::shared_ptr channel) const; + + void read_sample_rate(std::shared_ptr); + +private: + void sample_thread_proc(std::shared_ptr device, + std::function error_handler); + + void feed_in_header(std::shared_ptr device); + + void feed_in_meta(std::shared_ptr device, + std::shared_ptr meta); + + void feed_in_frame_begin(); + + void feed_in_logic(std::shared_ptr logic); + + void feed_in_analog(std::shared_ptr analog); + + void data_feed_in(std::shared_ptr device, + std::shared_ptr packet); + +private: + DeviceManager &device_manager_; + std::shared_ptr session_; + + /** + * The device instance that will be used in the next capture session. + */ + std::shared_ptr device_; + + std::vector< std::shared_ptr > decode_traces_; + + mutable std::mutex sampling_mutex_; + capture_state capture_state_; + + mutable boost::shared_mutex signals_mutex_; + std::vector< std::shared_ptr > signals_; + + mutable std::mutex data_mutex_; + std::shared_ptr logic_data_; + std::shared_ptr cur_logic_snapshot_; + std::map< std::shared_ptr, std::shared_ptr > + cur_analog_snapshots_; + + std::thread sampling_thread_; + +Q_SIGNALS: + void capture_state_changed(int state); + + void signals_changed(); + + void frame_began(); + + void data_received(); + + void frame_ended(); +}; + +} // namespace pv + +#endif // PULSEVIEW_PV_SIGSESSION_H diff --git a/pv/storesession.cpp b/pv/storesession.cpp index dbe04b2c..058b46a9 100644 --- a/pv/storesession.cpp +++ b/pv/storesession.cpp @@ -20,12 +20,12 @@ #include -#include "storesession.h" +#include "storesession.hpp" -#include -#include -#include -#include +#include +#include +#include +#include #include diff --git a/pv/storesession.h b/pv/storesession.h deleted file mode 100644 index 8eaddaa6..00000000 --- a/pv/storesession.h +++ /dev/null @@ -1,92 +0,0 @@ -/* - * This file is part of the PulseView project. - * - * Copyright (C) 2014 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 - */ - -#ifndef PULSEVIEW_PV_STORESESSION_H -#define PULSEVIEW_PV_STORESESSION_H - -#include - -#include -#include -#include -#include - -#include - -namespace sigrok { -class Output; -} - -namespace pv { - -class SigSession; - -namespace data { -class LogicSnapshot; -} - -class StoreSession : public QObject -{ - Q_OBJECT - -private: - static const size_t BlockSize; - -public: - StoreSession(const std::string &file_name, - const SigSession &session); - - ~StoreSession(); - - std::pair progress() const; - - const QString& error() const; - - bool start(); - - void wait(); - - void cancel(); - -private: - void store_proc(std::shared_ptr snapshot); - -Q_SIGNALS: - void progress_updated(); - -private: - const std::string file_name_; - const SigSession &session_; - - std::shared_ptr output_; - - std::thread thread_; - - std::atomic interrupt_; - - std::atomic units_stored_, unit_count_; - - mutable std::mutex mutex_; - QString error_; -}; - -} // pv - -#endif // PULSEVIEW_PV_STORESESSION_H diff --git a/pv/storesession.hpp b/pv/storesession.hpp new file mode 100644 index 00000000..8eaddaa6 --- /dev/null +++ b/pv/storesession.hpp @@ -0,0 +1,92 @@ +/* + * This file is part of the PulseView project. + * + * Copyright (C) 2014 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 + */ + +#ifndef PULSEVIEW_PV_STORESESSION_H +#define PULSEVIEW_PV_STORESESSION_H + +#include + +#include +#include +#include +#include + +#include + +namespace sigrok { +class Output; +} + +namespace pv { + +class SigSession; + +namespace data { +class LogicSnapshot; +} + +class StoreSession : public QObject +{ + Q_OBJECT + +private: + static const size_t BlockSize; + +public: + StoreSession(const std::string &file_name, + const SigSession &session); + + ~StoreSession(); + + std::pair progress() const; + + const QString& error() const; + + bool start(); + + void wait(); + + void cancel(); + +private: + void store_proc(std::shared_ptr snapshot); + +Q_SIGNALS: + void progress_updated(); + +private: + const std::string file_name_; + const SigSession &session_; + + std::shared_ptr output_; + + std::thread thread_; + + std::atomic interrupt_; + + std::atomic units_stored_, unit_count_; + + mutable std::mutex mutex_; + QString error_; +}; + +} // pv + +#endif // PULSEVIEW_PV_STORESESSION_H diff --git a/pv/toolbars/samplingbar.cpp b/pv/toolbars/samplingbar.cpp index 13c57d6c..2749e0ee 100644 --- a/pv/toolbars/samplingbar.cpp +++ b/pv/toolbars/samplingbar.cpp @@ -27,12 +27,12 @@ #include #include -#include "samplingbar.h" +#include "samplingbar.hpp" -#include -#include -#include -#include +#include +#include +#include +#include #include diff --git a/pv/toolbars/samplingbar.h b/pv/toolbars/samplingbar.h deleted file mode 100644 index 2397e2aa..00000000 --- a/pv/toolbars/samplingbar.h +++ /dev/null @@ -1,121 +0,0 @@ -/* - * This file is part of the PulseView project. - * - * 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 - */ - -#ifndef PULSEVIEW_PV_TOOLBARS_SAMPLINGBAR_H -#define PULSEVIEW_PV_TOOLBARS_SAMPLINGBAR_H - -#include - -#include -#include - -#include -#include -#include -#include - -#include -#include -#include - -namespace sigrok { - class Device; -} - -Q_DECLARE_METATYPE(std::shared_ptr) - -class QAction; - -namespace pv { - -class SigSession; - -namespace toolbars { - -class SamplingBar : public QToolBar -{ - Q_OBJECT - -private: - static const uint64_t MinSampleCount; - static const uint64_t MaxSampleCount; - static const uint64_t DefaultSampleCount; - -public: - SamplingBar(SigSession &session, QWidget *parent); - - void set_device_list( - const std::list< std::pair, std::string> > &devices, - std::shared_ptr selected); - - std::shared_ptr get_selected_device() const; - - void set_capture_state(pv::SigSession::capture_state state); - -Q_SIGNALS: - void run_stop(); - -private: - void update_sample_rate_selector(); - void update_sample_rate_selector_value(); - void update_sample_count_selector(); - void update_device_config_widgets(); - void commit_sample_rate(); - void commit_sample_count(); - -private Q_SLOTS: - void on_device_selected(); - void on_sample_count_changed(); - void on_sample_rate_changed(); - void on_run_stop(); - - void on_config_changed(); - -protected: - bool eventFilter(QObject *watched, QEvent *event); - -private: - SigSession &session_; - - QComboBox device_selector_; - bool updating_device_selector_; - - pv::widgets::PopupToolButton configure_button_; - QAction *configure_button_action_; - - pv::widgets::PopupToolButton channels_button_; - - pv::widgets::SweepTimingWidget sample_count_; - pv::widgets::SweepTimingWidget sample_rate_; - bool updating_sample_rate_; - bool updating_sample_count_; - - bool sample_count_supported_; - - QIcon icon_red_; - QIcon icon_green_; - QIcon icon_grey_; - QToolButton run_stop_button_; -}; - -} // namespace toolbars -} // namespace pv - -#endif // PULSEVIEW_PV_TOOLBARS_SAMPLINGBAR_H diff --git a/pv/toolbars/samplingbar.hpp b/pv/toolbars/samplingbar.hpp new file mode 100644 index 00000000..d027d60e --- /dev/null +++ b/pv/toolbars/samplingbar.hpp @@ -0,0 +1,121 @@ +/* + * This file is part of the PulseView project. + * + * 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 + */ + +#ifndef PULSEVIEW_PV_TOOLBARS_SAMPLINGBAR_H +#define PULSEVIEW_PV_TOOLBARS_SAMPLINGBAR_H + +#include + +#include +#include + +#include +#include +#include +#include + +#include +#include +#include + +namespace sigrok { + class Device; +} + +Q_DECLARE_METATYPE(std::shared_ptr) + +class QAction; + +namespace pv { + +class SigSession; + +namespace toolbars { + +class SamplingBar : public QToolBar +{ + Q_OBJECT + +private: + static const uint64_t MinSampleCount; + static const uint64_t MaxSampleCount; + static const uint64_t DefaultSampleCount; + +public: + SamplingBar(SigSession &session, QWidget *parent); + + void set_device_list( + const std::list< std::pair, std::string> > &devices, + std::shared_ptr selected); + + std::shared_ptr get_selected_device() const; + + void set_capture_state(pv::SigSession::capture_state state); + +Q_SIGNALS: + void run_stop(); + +private: + void update_sample_rate_selector(); + void update_sample_rate_selector_value(); + void update_sample_count_selector(); + void update_device_config_widgets(); + void commit_sample_rate(); + void commit_sample_count(); + +private Q_SLOTS: + void on_device_selected(); + void on_sample_count_changed(); + void on_sample_rate_changed(); + void on_run_stop(); + + void on_config_changed(); + +protected: + bool eventFilter(QObject *watched, QEvent *event); + +private: + SigSession &session_; + + QComboBox device_selector_; + bool updating_device_selector_; + + pv::widgets::PopupToolButton configure_button_; + QAction *configure_button_action_; + + pv::widgets::PopupToolButton channels_button_; + + pv::widgets::SweepTimingWidget sample_count_; + pv::widgets::SweepTimingWidget sample_rate_; + bool updating_sample_rate_; + bool updating_sample_count_; + + bool sample_count_supported_; + + QIcon icon_red_; + QIcon icon_green_; + QIcon icon_grey_; + QToolButton run_stop_button_; +}; + +} // namespace toolbars +} // namespace pv + +#endif // PULSEVIEW_PV_TOOLBARS_SAMPLINGBAR_H diff --git a/pv/util.cpp b/pv/util.cpp index a54bdcaf..62f0ee1f 100644 --- a/pv/util.cpp +++ b/pv/util.cpp @@ -18,7 +18,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "util.h" +#include "util.hpp" #include diff --git a/pv/util.h b/pv/util.h deleted file mode 100644 index 572bed31..00000000 --- a/pv/util.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * This file is part of the PulseView project. - * - * 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 - */ - -#ifndef PULSEVIEW_UTIL_H -#define PULSEVIEW_UTIL_H - -#include - -#include - -namespace pv { -namespace util { - -extern const int FirstSIPrefixPower; - -/** - * Formats a given time value with the specified SI prefix. - * @param t The time value in seconds to format. - * @param prefix The number of the prefix, from 0 for 'femto' up to - * 8 for 'giga'. - * @parma precision The number of digits after the decimal separator. - * @param sign Whether or not to add a sign also for positive numbers. - * - * @return The formated value. - */ -QString format_time( - double t, unsigned int prefix, - unsigned precision = 0, bool sign = true); - -/** - * Formats a given time value with a SI prefix so that the - * value is between 1 and 999. - * @param second The time value in seconds to format. - * - * @return The formated value. - */ -QString format_second(double second); - -} // namespace util -} // namespace pv - -#endif // PULSEVIEW_UTIL_H diff --git a/pv/util.hpp b/pv/util.hpp new file mode 100644 index 00000000..572bed31 --- /dev/null +++ b/pv/util.hpp @@ -0,0 +1,59 @@ +/* + * This file is part of the PulseView project. + * + * 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 + */ + +#ifndef PULSEVIEW_UTIL_H +#define PULSEVIEW_UTIL_H + +#include + +#include + +namespace pv { +namespace util { + +extern const int FirstSIPrefixPower; + +/** + * Formats a given time value with the specified SI prefix. + * @param t The time value in seconds to format. + * @param prefix The number of the prefix, from 0 for 'femto' up to + * 8 for 'giga'. + * @parma precision The number of digits after the decimal separator. + * @param sign Whether or not to add a sign also for positive numbers. + * + * @return The formated value. + */ +QString format_time( + double t, unsigned int prefix, + unsigned precision = 0, bool sign = true); + +/** + * Formats a given time value with a SI prefix so that the + * value is between 1 and 999. + * @param second The time value in seconds to format. + * + * @return The formated value. + */ +QString format_second(double second); + +} // namespace util +} // namespace pv + +#endif // PULSEVIEW_UTIL_H diff --git a/pv/view/analogsignal.cpp b/pv/view/analogsignal.cpp index 3509a040..abbb94c5 100644 --- a/pv/view/analogsignal.cpp +++ b/pv/view/analogsignal.cpp @@ -23,10 +23,10 @@ #include #include -#include "analogsignal.h" -#include "pv/data/analog.h" -#include "pv/data/analogsnapshot.h" -#include "pv/view/view.h" +#include "analogsignal.hpp" +#include "pv/data/analog.hpp" +#include "pv/data/analogsnapshot.hpp" +#include "pv/view/view.hpp" #include diff --git a/pv/view/analogsignal.h b/pv/view/analogsignal.h deleted file mode 100644 index 326e6fbc..00000000 --- a/pv/view/analogsignal.h +++ /dev/null @@ -1,99 +0,0 @@ -/* - * This file is part of the PulseView project. - * - * 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 - */ - -#ifndef PULSEVIEW_PV_VIEW_ANALOGSIGNAL_H -#define PULSEVIEW_PV_VIEW_ANALOGSIGNAL_H - -#include "signal.h" - -#include - -namespace pv { - -namespace data { -class Analog; -class AnalogSnapshot; -} - -namespace view { - -class AnalogSignal : public Signal -{ -private: - static const int NominalHeight; - static const QColor SignalColours[4]; - - static const float EnvelopeThreshold; - -public: - AnalogSignal(pv::SigSession &session, - std::shared_ptr channel, - std::shared_ptr data); - - virtual ~AnalogSignal(); - - std::shared_ptr data() const; - - std::shared_ptr analog_data() const; - - void set_scale(float scale); - - /** - * Computes the vertical extents of the contents of this row item. - * @return A pair containing the minimum and maximum y-values. - */ - std::pair v_extents() const; - - /** - * Paints the background layer of the signal with a QPainter - * @param p the QPainter to paint into. - * @param left the x-coordinate of the left edge of the signal. - * @param right the x-coordinate of the right edge of the signal. - **/ - void paint_back(QPainter &p, int left, int right); - - /** - * Paints the mid-layer of the signal with a QPainter - * @param p the QPainter to paint into. - * @param left the x-coordinate of the left edge of the signal. - * @param right the x-coordinate of the right edge of the signal. - **/ - void paint_mid(QPainter &p, int left, int right); - -private: - void paint_trace(QPainter &p, - const std::shared_ptr &snapshot, - int y, int left, const int64_t start, const int64_t end, - const double pixels_offset, const double samples_per_pixel); - - void paint_envelope(QPainter &p, - const std::shared_ptr &snapshot, - int y, int left, const int64_t start, const int64_t end, - const double pixels_offset, const double samples_per_pixel); - -private: - std::shared_ptr data_; - float scale_; -}; - -} // namespace view -} // namespace pv - -#endif // PULSEVIEW_PV_VIEW_ANALOGSIGNAL_H diff --git a/pv/view/analogsignal.hpp b/pv/view/analogsignal.hpp new file mode 100644 index 00000000..91a8e5c2 --- /dev/null +++ b/pv/view/analogsignal.hpp @@ -0,0 +1,99 @@ +/* + * This file is part of the PulseView project. + * + * 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 + */ + +#ifndef PULSEVIEW_PV_VIEW_ANALOGSIGNAL_H +#define PULSEVIEW_PV_VIEW_ANALOGSIGNAL_H + +#include "signal.hpp" + +#include + +namespace pv { + +namespace data { +class Analog; +class AnalogSnapshot; +} + +namespace view { + +class AnalogSignal : public Signal +{ +private: + static const int NominalHeight; + static const QColor SignalColours[4]; + + static const float EnvelopeThreshold; + +public: + AnalogSignal(pv::SigSession &session, + std::shared_ptr channel, + std::shared_ptr data); + + virtual ~AnalogSignal(); + + std::shared_ptr data() const; + + std::shared_ptr analog_data() const; + + void set_scale(float scale); + + /** + * Computes the vertical extents of the contents of this row item. + * @return A pair containing the minimum and maximum y-values. + */ + std::pair v_extents() const; + + /** + * Paints the background layer of the signal with a QPainter + * @param p the QPainter to paint into. + * @param left the x-coordinate of the left edge of the signal. + * @param right the x-coordinate of the right edge of the signal. + **/ + void paint_back(QPainter &p, int left, int right); + + /** + * Paints the mid-layer of the signal with a QPainter + * @param p the QPainter to paint into. + * @param left the x-coordinate of the left edge of the signal. + * @param right the x-coordinate of the right edge of the signal. + **/ + void paint_mid(QPainter &p, int left, int right); + +private: + void paint_trace(QPainter &p, + const std::shared_ptr &snapshot, + int y, int left, const int64_t start, const int64_t end, + const double pixels_offset, const double samples_per_pixel); + + void paint_envelope(QPainter &p, + const std::shared_ptr &snapshot, + int y, int left, const int64_t start, const int64_t end, + const double pixels_offset, const double samples_per_pixel); + +private: + std::shared_ptr data_; + float scale_; +}; + +} // namespace view +} // namespace pv + +#endif // PULSEVIEW_PV_VIEW_ANALOGSIGNAL_H diff --git a/pv/view/cursor.cpp b/pv/view/cursor.cpp index 0cc63142..03df0543 100644 --- a/pv/view/cursor.cpp +++ b/pv/view/cursor.cpp @@ -18,10 +18,10 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "cursor.h" +#include "cursor.hpp" -#include "view.h" -#include "pv/util.h" +#include "view.hpp" +#include "pv/util.hpp" #include #include diff --git a/pv/view/cursor.h b/pv/view/cursor.h deleted file mode 100644 index 649230ce..00000000 --- a/pv/view/cursor.h +++ /dev/null @@ -1,86 +0,0 @@ -/* - * This file is part of the PulseView project. - * - * 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 - */ - -#ifndef PULSEVIEW_PV_VIEW_CURSOR_H -#define PULSEVIEW_PV_VIEW_CURSOR_H - -#include "timemarker.h" - -#include - -#include - -class QPainter; - -namespace pv { -namespace view { - -class Cursor : public TimeMarker -{ - Q_OBJECT - -public: - static const QColor LineColour; - static const QColor FillColour; - static const QColor HighlightColour; - static const QColor TextColour; - - static const int Offset; - - static const int ArrowSize; - -public: - /** - * Constructor. - * @param view A reference to the view that owns this cursor pair. - * @param time The time to set the flag to. - */ - Cursor(View &view, double time); - -public: - /** - * Gets the marker label rectangle. - * @param rect The rectangle of the ruler client area. - * @return Returns the label rectangle. - */ - QRectF get_label_rect(const QRect &rect) const; - - /** - * Paints the cursor's label to the ruler. - * @param p The painter to draw with. - * @param rect The rectangle of the ruler client area. - * @param prefix The index of the SI prefix to use. - */ - void paint_label(QPainter &p, const QRect &rect, - unsigned int prefix); - -private: - void compute_text_size(QPainter &p, unsigned int prefix); - - std::shared_ptr get_other_cursor() const; - -private: - QSizeF text_size_; -}; - -} // namespace view -} // namespace pv - -#endif // PULSEVIEW_PV_VIEW_CURSOR_H diff --git a/pv/view/cursor.hpp b/pv/view/cursor.hpp new file mode 100644 index 00000000..8679a286 --- /dev/null +++ b/pv/view/cursor.hpp @@ -0,0 +1,86 @@ +/* + * This file is part of the PulseView project. + * + * 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 + */ + +#ifndef PULSEVIEW_PV_VIEW_CURSOR_H +#define PULSEVIEW_PV_VIEW_CURSOR_H + +#include "timemarker.hpp" + +#include + +#include + +class QPainter; + +namespace pv { +namespace view { + +class Cursor : public TimeMarker +{ + Q_OBJECT + +public: + static const QColor LineColour; + static const QColor FillColour; + static const QColor HighlightColour; + static const QColor TextColour; + + static const int Offset; + + static const int ArrowSize; + +public: + /** + * Constructor. + * @param view A reference to the view that owns this cursor pair. + * @param time The time to set the flag to. + */ + Cursor(View &view, double time); + +public: + /** + * Gets the marker label rectangle. + * @param rect The rectangle of the ruler client area. + * @return Returns the label rectangle. + */ + QRectF get_label_rect(const QRect &rect) const; + + /** + * Paints the cursor's label to the ruler. + * @param p The painter to draw with. + * @param rect The rectangle of the ruler client area. + * @param prefix The index of the SI prefix to use. + */ + void paint_label(QPainter &p, const QRect &rect, + unsigned int prefix); + +private: + void compute_text_size(QPainter &p, unsigned int prefix); + + std::shared_ptr get_other_cursor() const; + +private: + QSizeF text_size_; +}; + +} // namespace view +} // namespace pv + +#endif // PULSEVIEW_PV_VIEW_CURSOR_H diff --git a/pv/view/cursorheader.cpp b/pv/view/cursorheader.cpp index 3f25e212..3fa0b0c5 100644 --- a/pv/view/cursorheader.cpp +++ b/pv/view/cursorheader.cpp @@ -18,16 +18,16 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "cursorheader.h" +#include "cursorheader.hpp" -#include "ruler.h" -#include "view.h" +#include "ruler.hpp" +#include "view.hpp" #include #include #include -#include +#include using std::shared_ptr; diff --git a/pv/view/cursorheader.h b/pv/view/cursorheader.h deleted file mode 100644 index e6552265..00000000 --- a/pv/view/cursorheader.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * This file is part of the PulseView project. - * - * 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 - */ - -#ifndef PULSEVIEW_PV_VIEW_CURSORHEADER_H -#define PULSEVIEW_PV_VIEW_CURSORHEADER_H - -#include - -#include "marginwidget.h" - -namespace pv { -namespace view { - -class TimeMarker; - -/** - * Widget to hold the labels over the cursors. - */ -class CursorHeader : public MarginWidget -{ - Q_OBJECT - - static const int Padding; - - /** - * The vertical offset, relative to the bottom line of the widget, - * where the arrows of the cursor labels end. - */ - static const int BaselineOffset; - -public: - CursorHeader(View &parent); - - QSize sizeHint() const; - - void clear_selection(); - -private: - void paintEvent(QPaintEvent *event); - - void mouseMoveEvent(QMouseEvent *e); - void mousePressEvent(QMouseEvent *e); - void mouseReleaseEvent(QMouseEvent *); - - int calculateTextHeight(); - - std::weak_ptr grabbed_marker_; - QPoint mouse_down_point_; - bool dragging_; - const int textHeight_; -}; - -} // namespace view -} // namespace pv - -#endif // PULSEVIEW_PV_VIEW_CURSORHEADER_H diff --git a/pv/view/cursorheader.hpp b/pv/view/cursorheader.hpp new file mode 100644 index 00000000..90a000f1 --- /dev/null +++ b/pv/view/cursorheader.hpp @@ -0,0 +1,73 @@ +/* + * This file is part of the PulseView project. + * + * 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 + */ + +#ifndef PULSEVIEW_PV_VIEW_CURSORHEADER_H +#define PULSEVIEW_PV_VIEW_CURSORHEADER_H + +#include + +#include "marginwidget.hpp" + +namespace pv { +namespace view { + +class TimeMarker; + +/** + * Widget to hold the labels over the cursors. + */ +class CursorHeader : public MarginWidget +{ + Q_OBJECT + + static const int Padding; + + /** + * The vertical offset, relative to the bottom line of the widget, + * where the arrows of the cursor labels end. + */ + static const int BaselineOffset; + +public: + CursorHeader(View &parent); + + QSize sizeHint() const; + + void clear_selection(); + +private: + void paintEvent(QPaintEvent *event); + + void mouseMoveEvent(QMouseEvent *e); + void mousePressEvent(QMouseEvent *e); + void mouseReleaseEvent(QMouseEvent *); + + int calculateTextHeight(); + + std::weak_ptr grabbed_marker_; + QPoint mouse_down_point_; + bool dragging_; + const int textHeight_; +}; + +} // namespace view +} // namespace pv + +#endif // PULSEVIEW_PV_VIEW_CURSORHEADER_H diff --git a/pv/view/cursorpair.cpp b/pv/view/cursorpair.cpp index 0b5363f1..0fb0d8d1 100644 --- a/pv/view/cursorpair.cpp +++ b/pv/view/cursorpair.cpp @@ -18,10 +18,10 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "cursorpair.h" +#include "cursorpair.hpp" -#include "view.h" -#include "pv/util.h" +#include "view.hpp" +#include "pv/util.hpp" #include #include diff --git a/pv/view/cursorpair.h b/pv/view/cursorpair.h deleted file mode 100644 index f7eb51ca..00000000 --- a/pv/view/cursorpair.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - * This file is part of the PulseView project. - * - * 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 - */ - -#ifndef PULSEVIEW_PV_VIEW_CURSORPAIR_H -#define PULSEVIEW_PV_VIEW_CURSORPAIR_H - -#include "cursor.h" - -#include - -#include - -class QPainter; - -namespace pv { -namespace view { - -class CursorPair -{ -private: - static const int DeltaPadding; - -public: - /** - * Constructor. - * @param view A reference to the view that owns this cursor pair. - */ - CursorPair(View &view); - - /** - * Returns a pointer to the first cursor. - */ - std::shared_ptr first() const; - - /** - * Returns a pointer to the second cursor. - */ - std::shared_ptr second() const; - -public: - QRectF get_label_rect(const QRect &rect) const; - - void draw_markers(QPainter &p, - const QRect &rect, unsigned int prefix); - - void draw_viewport_background(QPainter &p, const QRect &rect); - - void draw_viewport_foreground(QPainter &p, const QRect &rect); - - void compute_text_size(QPainter &p, unsigned int prefix); - - std::pair get_cursor_offsets() const; - -private: - std::shared_ptr first_, second_; - const View &view_; - - QSizeF text_size_; -}; - -} // namespace view -} // namespace pv - -#endif // PULSEVIEW_PV_VIEW_CURSORPAIR_H diff --git a/pv/view/cursorpair.hpp b/pv/view/cursorpair.hpp new file mode 100644 index 00000000..dd37b0ed --- /dev/null +++ b/pv/view/cursorpair.hpp @@ -0,0 +1,81 @@ +/* + * This file is part of the PulseView project. + * + * 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 + */ + +#ifndef PULSEVIEW_PV_VIEW_CURSORPAIR_H +#define PULSEVIEW_PV_VIEW_CURSORPAIR_H + +#include "cursor.hpp" + +#include + +#include + +class QPainter; + +namespace pv { +namespace view { + +class CursorPair +{ +private: + static const int DeltaPadding; + +public: + /** + * Constructor. + * @param view A reference to the view that owns this cursor pair. + */ + CursorPair(View &view); + + /** + * Returns a pointer to the first cursor. + */ + std::shared_ptr first() const; + + /** + * Returns a pointer to the second cursor. + */ + std::shared_ptr second() const; + +public: + QRectF get_label_rect(const QRect &rect) const; + + void draw_markers(QPainter &p, + const QRect &rect, unsigned int prefix); + + void draw_viewport_background(QPainter &p, const QRect &rect); + + void draw_viewport_foreground(QPainter &p, const QRect &rect); + + void compute_text_size(QPainter &p, unsigned int prefix); + + std::pair get_cursor_offsets() const; + +private: + std::shared_ptr first_, second_; + const View &view_; + + QSizeF text_size_; +}; + +} // namespace view +} // namespace pv + +#endif // PULSEVIEW_PV_VIEW_CURSORPAIR_H diff --git a/pv/view/decodetrace.cpp b/pv/view/decodetrace.cpp index 005d98b8..01bf934c 100644 --- a/pv/view/decodetrace.cpp +++ b/pv/view/decodetrace.cpp @@ -39,19 +39,19 @@ extern "C" { #include #include -#include "decodetrace.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "decodetrace.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include using boost::shared_lock; using boost::shared_mutex; diff --git a/pv/view/decodetrace.h b/pv/view/decodetrace.h deleted file mode 100644 index 9704f69a..00000000 --- a/pv/view/decodetrace.h +++ /dev/null @@ -1,215 +0,0 @@ -/* - * This file is part of the PulseView project. - * - * 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 - */ - -#ifndef PULSEVIEW_PV_VIEW_DECODETRACE_H -#define PULSEVIEW_PV_VIEW_DECODETRACE_H - -#include "trace.h" - -#include -#include -#include - -#include - -#include -#include - -struct srd_channel; -struct srd_decoder; - -class QComboBox; - -namespace pv { - -class SigSession; - -namespace data { -class DecoderStack; - -namespace decode { -class Annotation; -class Decoder; -class Row; -} -} - -namespace widgets { -class DecoderGroupBox; -} - -namespace view { - -class DecodeTrace : public Trace -{ - Q_OBJECT - -private: - struct ChannelSelector - { - const QComboBox *combo_; - const std::shared_ptr decoder_; - const srd_channel *pdch_; - }; - -private: - static const QColor DecodeColours[4]; - static const QColor ErrorBgColour; - static const QColor NoDecodeColour; - - static const int ArrowSize; - static const double EndCapWidth; - static const int DrawPadding; - - static const QColor Colours[16]; - static const QColor OutlineColours[16]; - -public: - DecodeTrace(pv::SigSession &session, - std::shared_ptr decoder_stack, - int index); - - bool enabled() const; - - const std::shared_ptr& decoder() const; - - /** - * Computes the vertical extents of the contents of this row item. - * @return A pair containing the minimum and maximum y-values. - */ - std::pair v_extents() const; - - /** - * Paints the background layer of the trace with a QPainter - * @param p the QPainter to paint into. - * @param left the x-coordinate of the left edge of the signal. - * @param right the x-coordinate of the right edge of the signal. - **/ - void paint_back(QPainter &p, int left, int right); - - /** - * Paints the mid-layer of the trace with a QPainter - * @param p the QPainter to paint into. - * @param left the x-coordinate of the left edge of the signal - * @param right the x-coordinate of the right edge of the signal - **/ - void paint_mid(QPainter &p, int left, int right); - - /** - * Paints the foreground layer of the trace with a QPainter - * @param p the QPainter to paint into. - * @param left the x-coordinate of the left edge of the signal - * @param right the x-coordinate of the right edge of the signal - **/ - void paint_fore(QPainter &p, int left, int right); - - void populate_popup_form(QWidget *parent, QFormLayout *form); - - QMenu* create_context_menu(QWidget *parent); - - void delete_pressed(); - -private: - void draw_annotation(const pv::data::decode::Annotation &a, QPainter &p, - QColor text_colour, int text_height, int left, int right, int y, - size_t base_colour) const; - - void draw_instant(const pv::data::decode::Annotation &a, QPainter &p, - QColor fill, QColor outline, QColor text_color, int h, double x, - int y) const; - - void draw_range(const pv::data::decode::Annotation &a, QPainter &p, - QColor fill, QColor outline, QColor text_color, int h, double start, - double end, int y) const; - - void draw_error(QPainter &p, const QString &message, - int left, int right); - - void draw_unresolved_period(QPainter &p, int h, int left, - int right) const; - - std::pair get_pixels_offset_samples_per_pixel() const; - - /** - * Determines the start and end sample for a given pixel range. - * @param x_start the X coordinate of the start sample in the view - * @param x_end the X coordinate of the end sample in the view - * @return Returns a pair containing the start sample and the end - * sample that correspond to the start and end coordinates. - */ - std::pair get_sample_range(int x_start, int x_end) const; - - int get_row_at_point(const QPoint &point); - - const QString get_annotation_at_point(const QPoint &point); - - void hide_hover_annotation(); - - void create_decoder_form(int index, - std::shared_ptr &dec, - QWidget *parent, QFormLayout *form); - - QComboBox* create_channel_selector(QWidget *parent, - const std::shared_ptr &dec, - const srd_channel *const pdch); - - void commit_decoder_channels( - std::shared_ptr &dec); - - void commit_channels(); - -public: - void hover_point_changed(); - -private Q_SLOTS: - void on_new_decode_data(); - - void on_delete(); - - void on_channel_selected(int); - - void on_stack_decoder(srd_decoder *decoder); - - void on_delete_decoder(int index); - - void on_show_hide_decoder(int index); - -private: - pv::SigSession &session_; - std::shared_ptr decoder_stack_; - - uint64_t decode_start_, decode_end_; - - std::list< std::shared_ptr > - bindings_; - - std::list channel_selectors_; - std::vector decoder_forms_; - - std::vector visible_rows_; - int text_height_, row_height_; - - QSignalMapper delete_mapper_, show_hide_mapper_; -}; - -} // namespace view -} // namespace pv - -#endif // PULSEVIEW_PV_VIEW_DECODETRACE_H diff --git a/pv/view/decodetrace.hpp b/pv/view/decodetrace.hpp new file mode 100644 index 00000000..0e2ce146 --- /dev/null +++ b/pv/view/decodetrace.hpp @@ -0,0 +1,215 @@ +/* + * This file is part of the PulseView project. + * + * 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 + */ + +#ifndef PULSEVIEW_PV_VIEW_DECODETRACE_H +#define PULSEVIEW_PV_VIEW_DECODETRACE_H + +#include "trace.hpp" + +#include +#include +#include + +#include + +#include +#include + +struct srd_channel; +struct srd_decoder; + +class QComboBox; + +namespace pv { + +class SigSession; + +namespace data { +class DecoderStack; + +namespace decode { +class Annotation; +class Decoder; +class Row; +} +} + +namespace widgets { +class DecoderGroupBox; +} + +namespace view { + +class DecodeTrace : public Trace +{ + Q_OBJECT + +private: + struct ChannelSelector + { + const QComboBox *combo_; + const std::shared_ptr decoder_; + const srd_channel *pdch_; + }; + +private: + static const QColor DecodeColours[4]; + static const QColor ErrorBgColour; + static const QColor NoDecodeColour; + + static const int ArrowSize; + static const double EndCapWidth; + static const int DrawPadding; + + static const QColor Colours[16]; + static const QColor OutlineColours[16]; + +public: + DecodeTrace(pv::SigSession &session, + std::shared_ptr decoder_stack, + int index); + + bool enabled() const; + + const std::shared_ptr& decoder() const; + + /** + * Computes the vertical extents of the contents of this row item. + * @return A pair containing the minimum and maximum y-values. + */ + std::pair v_extents() const; + + /** + * Paints the background layer of the trace with a QPainter + * @param p the QPainter to paint into. + * @param left the x-coordinate of the left edge of the signal. + * @param right the x-coordinate of the right edge of the signal. + **/ + void paint_back(QPainter &p, int left, int right); + + /** + * Paints the mid-layer of the trace with a QPainter + * @param p the QPainter to paint into. + * @param left the x-coordinate of the left edge of the signal + * @param right the x-coordinate of the right edge of the signal + **/ + void paint_mid(QPainter &p, int left, int right); + + /** + * Paints the foreground layer of the trace with a QPainter + * @param p the QPainter to paint into. + * @param left the x-coordinate of the left edge of the signal + * @param right the x-coordinate of the right edge of the signal + **/ + void paint_fore(QPainter &p, int left, int right); + + void populate_popup_form(QWidget *parent, QFormLayout *form); + + QMenu* create_context_menu(QWidget *parent); + + void delete_pressed(); + +private: + void draw_annotation(const pv::data::decode::Annotation &a, QPainter &p, + QColor text_colour, int text_height, int left, int right, int y, + size_t base_colour) const; + + void draw_instant(const pv::data::decode::Annotation &a, QPainter &p, + QColor fill, QColor outline, QColor text_color, int h, double x, + int y) const; + + void draw_range(const pv::data::decode::Annotation &a, QPainter &p, + QColor fill, QColor outline, QColor text_color, int h, double start, + double end, int y) const; + + void draw_error(QPainter &p, const QString &message, + int left, int right); + + void draw_unresolved_period(QPainter &p, int h, int left, + int right) const; + + std::pair get_pixels_offset_samples_per_pixel() const; + + /** + * Determines the start and end sample for a given pixel range. + * @param x_start the X coordinate of the start sample in the view + * @param x_end the X coordinate of the end sample in the view + * @return Returns a pair containing the start sample and the end + * sample that correspond to the start and end coordinates. + */ + std::pair get_sample_range(int x_start, int x_end) const; + + int get_row_at_point(const QPoint &point); + + const QString get_annotation_at_point(const QPoint &point); + + void hide_hover_annotation(); + + void create_decoder_form(int index, + std::shared_ptr &dec, + QWidget *parent, QFormLayout *form); + + QComboBox* create_channel_selector(QWidget *parent, + const std::shared_ptr &dec, + const srd_channel *const pdch); + + void commit_decoder_channels( + std::shared_ptr &dec); + + void commit_channels(); + +public: + void hover_point_changed(); + +private Q_SLOTS: + void on_new_decode_data(); + + void on_delete(); + + void on_channel_selected(int); + + void on_stack_decoder(srd_decoder *decoder); + + void on_delete_decoder(int index); + + void on_show_hide_decoder(int index); + +private: + pv::SigSession &session_; + std::shared_ptr decoder_stack_; + + uint64_t decode_start_, decode_end_; + + std::list< std::shared_ptr > + bindings_; + + std::list channel_selectors_; + std::vector decoder_forms_; + + std::vector visible_rows_; + int text_height_, row_height_; + + QSignalMapper delete_mapper_, show_hide_mapper_; +}; + +} // namespace view +} // namespace pv + +#endif // PULSEVIEW_PV_VIEW_DECODETRACE_H diff --git a/pv/view/header.cpp b/pv/view/header.cpp index 1dee05f4..08b3fdd2 100644 --- a/pv/view/header.cpp +++ b/pv/view/header.cpp @@ -18,12 +18,11 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "header.h" -#include "view.h" +#include "header.hpp" +#include "view.hpp" -#include "signal.h" -#include "tracegroup.h" -#include "../sigsession.h" +#include "signal.hpp" +#include "tracegroup.hpp" #include #include @@ -36,7 +35,8 @@ #include #include -#include +#include +#include using boost::make_filter_iterator; using std::dynamic_pointer_cast; diff --git a/pv/view/header.h b/pv/view/header.h deleted file mode 100644 index 49a95bb7..00000000 --- a/pv/view/header.h +++ /dev/null @@ -1,100 +0,0 @@ -/* - * This file is part of the PulseView project. - * - * 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 - */ - -#ifndef PULSEVIEW_PV_VIEW_HEADER_H -#define PULSEVIEW_PV_VIEW_HEADER_H - -#include -#include -#include - -#include "marginwidget.h" - -namespace pv { -namespace view { - -class RowItem; -class View; - -class Header : public MarginWidget -{ - Q_OBJECT - -private: - static const int Padding; - -public: - Header(View &parent); - - QSize sizeHint() const; - - /** - * The horizontal offset, relative to the left edge of the widget, - * where the arrows of the trace labels end. - */ - static const int BaselineOffset; - -private: - std::shared_ptr get_mouse_over_row_item( - const QPoint &pt); - - void clear_selection(); - - void show_popup(const std::shared_ptr &item); - -private: - void paintEvent(QPaintEvent *event); - -private: - void mouseLeftPressEvent(QMouseEvent *event); - void mousePressEvent(QMouseEvent * event); - - void mouseLeftReleaseEvent(QMouseEvent *event); - void mouseReleaseEvent(QMouseEvent *event); - - void mouseMoveEvent(QMouseEvent *event); - - void leaveEvent(QEvent *event); - - void contextMenuEvent(QContextMenuEvent *event); - - void keyPressEvent(QKeyEvent *e); - -private Q_SLOTS: - void on_signals_moved(); - - void on_group(); - - void on_ungroup(); - -Q_SIGNALS: - void signals_moved(); - -private: - QPoint mouse_point_; - QPoint mouse_down_point_; - std::shared_ptr mouse_down_item_; - bool dragging_; -}; - -} // namespace view -} // namespace pv - -#endif // PULSEVIEW_PV_VIEW_HEADER_H diff --git a/pv/view/header.hpp b/pv/view/header.hpp new file mode 100644 index 00000000..662e19f2 --- /dev/null +++ b/pv/view/header.hpp @@ -0,0 +1,100 @@ +/* + * This file is part of the PulseView project. + * + * 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 + */ + +#ifndef PULSEVIEW_PV_VIEW_HEADER_H +#define PULSEVIEW_PV_VIEW_HEADER_H + +#include +#include +#include + +#include "marginwidget.hpp" + +namespace pv { +namespace view { + +class RowItem; +class View; + +class Header : public MarginWidget +{ + Q_OBJECT + +private: + static const int Padding; + +public: + Header(View &parent); + + QSize sizeHint() const; + + /** + * The horizontal offset, relative to the left edge of the widget, + * where the arrows of the trace labels end. + */ + static const int BaselineOffset; + +private: + std::shared_ptr get_mouse_over_row_item( + const QPoint &pt); + + void clear_selection(); + + void show_popup(const std::shared_ptr &item); + +private: + void paintEvent(QPaintEvent *event); + +private: + void mouseLeftPressEvent(QMouseEvent *event); + void mousePressEvent(QMouseEvent * event); + + void mouseLeftReleaseEvent(QMouseEvent *event); + void mouseReleaseEvent(QMouseEvent *event); + + void mouseMoveEvent(QMouseEvent *event); + + void leaveEvent(QEvent *event); + + void contextMenuEvent(QContextMenuEvent *event); + + void keyPressEvent(QKeyEvent *e); + +private Q_SLOTS: + void on_signals_moved(); + + void on_group(); + + void on_ungroup(); + +Q_SIGNALS: + void signals_moved(); + +private: + QPoint mouse_point_; + QPoint mouse_down_point_; + std::shared_ptr mouse_down_item_; + bool dragging_; +}; + +} // namespace view +} // namespace pv + +#endif // PULSEVIEW_PV_VIEW_HEADER_H diff --git a/pv/view/logicsignal.cpp b/pv/view/logicsignal.cpp index 1b873e24..5beb39df 100644 --- a/pv/view/logicsignal.cpp +++ b/pv/view/logicsignal.cpp @@ -28,14 +28,14 @@ #include #include -#include "logicsignal.h" -#include "view.h" - -#include -#include -#include -#include -#include +#include "logicsignal.hpp" +#include "view.hpp" + +#include +#include +#include +#include +#include #include diff --git a/pv/view/logicsignal.h b/pv/view/logicsignal.h deleted file mode 100644 index 79bbe396..00000000 --- a/pv/view/logicsignal.h +++ /dev/null @@ -1,126 +0,0 @@ -/* - * This file is part of the PulseView project. - * - * 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 - */ - -#ifndef PULSEVIEW_PV_VIEW_LOGICSIGNAL_H -#define PULSEVIEW_PV_VIEW_LOGICSIGNAL_H - -#include "signal.h" - -#include - -class QToolBar; - -namespace sigrok { - class Device; - class TriggerMatchType; -} - -namespace pv { - -namespace data { -class Logic; -} - -namespace view { - -class LogicSignal : public Signal -{ - Q_OBJECT - -private: - static const int SignalHeight; - static const int SignalMargin; - - static const float Oversampling; - - static const QColor EdgeColour; - static const QColor HighColour; - static const QColor LowColour; - - static const QColor SignalColours[10]; - -public: - LogicSignal(pv::SigSession &session, - std::shared_ptr device, - std::shared_ptr channel, - std::shared_ptr data); - - virtual ~LogicSignal(); - - std::shared_ptr data() const; - - std::shared_ptr logic_data() const; - - /** - * Computes the vertical extents of the contents of this row item. - * @return A pair containing the minimum and maximum y-values. - */ - std::pair v_extents() const; - - /** - * Paints the background layer of the signal with a QPainter - * @param p the QPainter to paint into. - * @param left the x-coordinate of the left edge of the signal. - * @param right the x-coordinate of the right edge of the signal. - **/ - void paint_back(QPainter &p, int left, int right); - - /** - * Paints the mid-layer of the signal with a QPainter - * @param p the QPainter to paint into. - * @param left the x-coordinate of the left edge of the signal. - * @param right the x-coordinate of the right edge of the signal. - **/ - void paint_mid(QPainter &p, int left, int right); - -private: - void paint_caps(QPainter &p, QLineF *const lines, - std::vector< std::pair > &edges, - bool level, double samples_per_pixel, double pixels_offset, - float x_offset, float y_offset); - - void init_trigger_actions(QWidget *parent); - - QAction* match_action(const sigrok::TriggerMatchType *match); - const sigrok::TriggerMatchType *action_match(QAction *action); - void populate_popup_form(QWidget *parent, QFormLayout *form); - void modify_trigger(); - -private Q_SLOTS: - void on_trigger(); - -private: - std::shared_ptr device_; - std::shared_ptr data_; - - const sigrok::TriggerMatchType *trigger_match_; - QToolBar *trigger_bar_; - QAction *trigger_none_; - QAction *trigger_rising_; - QAction *trigger_high_; - QAction *trigger_falling_; - QAction *trigger_low_; - QAction *trigger_change_; -}; - -} // namespace view -} // namespace pv - -#endif // PULSEVIEW_PV_VIEW_LOGICSIGNAL_H diff --git a/pv/view/logicsignal.hpp b/pv/view/logicsignal.hpp new file mode 100644 index 00000000..a4f64e6b --- /dev/null +++ b/pv/view/logicsignal.hpp @@ -0,0 +1,126 @@ +/* + * This file is part of the PulseView project. + * + * 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 + */ + +#ifndef PULSEVIEW_PV_VIEW_LOGICSIGNAL_H +#define PULSEVIEW_PV_VIEW_LOGICSIGNAL_H + +#include "signal.hpp" + +#include + +class QToolBar; + +namespace sigrok { + class Device; + class TriggerMatchType; +} + +namespace pv { + +namespace data { +class Logic; +} + +namespace view { + +class LogicSignal : public Signal +{ + Q_OBJECT + +private: + static const int SignalHeight; + static const int SignalMargin; + + static const float Oversampling; + + static const QColor EdgeColour; + static const QColor HighColour; + static const QColor LowColour; + + static const QColor SignalColours[10]; + +public: + LogicSignal(pv::SigSession &session, + std::shared_ptr device, + std::shared_ptr channel, + std::shared_ptr data); + + virtual ~LogicSignal(); + + std::shared_ptr data() const; + + std::shared_ptr logic_data() const; + + /** + * Computes the vertical extents of the contents of this row item. + * @return A pair containing the minimum and maximum y-values. + */ + std::pair v_extents() const; + + /** + * Paints the background layer of the signal with a QPainter + * @param p the QPainter to paint into. + * @param left the x-coordinate of the left edge of the signal. + * @param right the x-coordinate of the right edge of the signal. + **/ + void paint_back(QPainter &p, int left, int right); + + /** + * Paints the mid-layer of the signal with a QPainter + * @param p the QPainter to paint into. + * @param left the x-coordinate of the left edge of the signal. + * @param right the x-coordinate of the right edge of the signal. + **/ + void paint_mid(QPainter &p, int left, int right); + +private: + void paint_caps(QPainter &p, QLineF *const lines, + std::vector< std::pair > &edges, + bool level, double samples_per_pixel, double pixels_offset, + float x_offset, float y_offset); + + void init_trigger_actions(QWidget *parent); + + QAction* match_action(const sigrok::TriggerMatchType *match); + const sigrok::TriggerMatchType *action_match(QAction *action); + void populate_popup_form(QWidget *parent, QFormLayout *form); + void modify_trigger(); + +private Q_SLOTS: + void on_trigger(); + +private: + std::shared_ptr device_; + std::shared_ptr data_; + + const sigrok::TriggerMatchType *trigger_match_; + QToolBar *trigger_bar_; + QAction *trigger_none_; + QAction *trigger_rising_; + QAction *trigger_high_; + QAction *trigger_falling_; + QAction *trigger_low_; + QAction *trigger_change_; +}; + +} // namespace view +} // namespace pv + +#endif // PULSEVIEW_PV_VIEW_LOGICSIGNAL_H diff --git a/pv/view/marginwidget.cpp b/pv/view/marginwidget.cpp index 179e82b9..f3abe361 100644 --- a/pv/view/marginwidget.cpp +++ b/pv/view/marginwidget.cpp @@ -18,9 +18,9 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "view.h" +#include "view.hpp" -#include "marginwidget.h" +#include "marginwidget.hpp" namespace pv { namespace view { diff --git a/pv/view/marginwidget.h b/pv/view/marginwidget.h deleted file mode 100644 index 9ff4276b..00000000 --- a/pv/view/marginwidget.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * This file is part of the PulseView project. - * - * 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 - */ - -#ifndef PULSEVIEW_PV_MARGINWIDGET_H -#define PULSEVIEW_PV_MARGINWIDGET_H - -#include - -namespace pv { -namespace view { - -class View; - -class MarginWidget : public QWidget -{ - Q_OBJECT - -public: - MarginWidget(pv::view::View &parent); - -public Q_SLOTS: - virtual void clear_selection(); - -Q_SIGNALS: - void selection_changed(); - -protected: - pv::view::View &view_; -}; - -} // namespace view -} // namespace pv - -#endif // PULSEVIEW_PV_MARGINWIDGET_H diff --git a/pv/view/marginwidget.hpp b/pv/view/marginwidget.hpp new file mode 100644 index 00000000..9ff4276b --- /dev/null +++ b/pv/view/marginwidget.hpp @@ -0,0 +1,51 @@ +/* + * This file is part of the PulseView project. + * + * 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 + */ + +#ifndef PULSEVIEW_PV_MARGINWIDGET_H +#define PULSEVIEW_PV_MARGINWIDGET_H + +#include + +namespace pv { +namespace view { + +class View; + +class MarginWidget : public QWidget +{ + Q_OBJECT + +public: + MarginWidget(pv::view::View &parent); + +public Q_SLOTS: + virtual void clear_selection(); + +Q_SIGNALS: + void selection_changed(); + +protected: + pv::view::View &view_; +}; + +} // namespace view +} // namespace pv + +#endif // PULSEVIEW_PV_MARGINWIDGET_H diff --git a/pv/view/rowitem.cpp b/pv/view/rowitem.cpp index 29346023..6e87de10 100644 --- a/pv/view/rowitem.cpp +++ b/pv/view/rowitem.cpp @@ -20,9 +20,9 @@ #include -#include "view.h" +#include "view.hpp" -#include "rowitem.h" +#include "rowitem.hpp" namespace pv { namespace view { diff --git a/pv/view/rowitem.h b/pv/view/rowitem.h deleted file mode 100644 index db6e580d..00000000 --- a/pv/view/rowitem.h +++ /dev/null @@ -1,169 +0,0 @@ -/* - * This file is part of the PulseView project. - * - * 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 - */ - -#ifndef PULSEVIEW_PV_VIEW_HEADERITEM_H -#define PULSEVIEW_PV_VIEW_HEADERITEM_H - -#include - -#include - -#include "selectableitem.h" - -namespace pv { -namespace view { - -class RowItemOwner; - -class RowItem : public SelectableItem, - public std::enable_shared_from_this -{ - Q_OBJECT - Q_PROPERTY(int visual_v_offset - READ visual_v_offset - WRITE set_visual_v_offset) - -public: - /** - * Constructor. - */ - RowItem(); - - /** - * Returns true if the item is visible and enabled. - */ - virtual bool enabled() const = 0; - - /** - * Gets the vertical layout offset of this signal. - */ - int layout_v_offset() const; - - /** - * Sets the vertical layout offset of this signal. - */ - void set_layout_v_offset(int v_offset); - - /** - * Gets the vertical visual offset of this signal. - */ - int visual_v_offset() const; - - /** - * Sets the vertical visual offset of this signal. - */ - void set_visual_v_offset(int v_offset); - - /** - * Sets the visual and layout offset of this signal. - */ - void force_to_v_offset(int v_offset); - - /** - * Begins an animation that will animate the visual offset toward - * the layout offset. - */ - void animate_to_layout_v_offset(); - - /** - * Gets the owner this trace in the view trace hierachy. - */ - pv::view::RowItemOwner* owner() const; - - /** - * Sets the owner this trace in the view trace hierachy. - * @param The new owner of the trace. - */ - void set_owner(pv::view::RowItemOwner *owner); - - /** - * Gets the visual y-offset of the axis. - */ - int get_visual_y() const; - - /** - * Gets the drag point of the row item. - */ - QPoint point() const; - - /** - * Computes the vertical extents of the contents of this row item. - * @return A pair containing the minimum and maximum y-values. - */ - virtual std::pair v_extents() const = 0; - - /** - * Paints the background layer of the trace with a QPainter - * @param p the QPainter to paint into. - * @param left the x-coordinate of the left edge of the signal - * @param right the x-coordinate of the right edge of the signal - **/ - virtual void paint_back(QPainter &p, int left, int right); - - /** - * Paints the mid-layer of the trace with a QPainter - * @param p the QPainter to paint into. - * @param left the x-coordinate of the left edge of the signal - * @param right the x-coordinate of the right edge of the signal - **/ - virtual void paint_mid(QPainter &p, int left, int right); - - /** - * Paints the foreground layer of the trace with a QPainter - * @param p the QPainter to paint into. - * @param left the x-coordinate of the left edge of the signal - * @param right the x-coordinate of the right edge of the signal - **/ - virtual void paint_fore(QPainter &p, int left, int right); - - /** - * Paints the signal label. - * @param p the QPainter to paint into. - * @param right the x-coordinate of the right edge of the header - * area. - * @param hover true if the label is being hovered over by the mouse. - */ - virtual void paint_label(QPainter &p, int right, bool hover) = 0; - - /** - * Computes the outline rectangle of a label. - * @param right the x-coordinate of the right edge of the header - * area. - * @return Returns the rectangle of the signal label. - */ - virtual QRectF label_rect(int right) const = 0; - -public: - virtual void hover_point_changed(); - -protected: - pv::view::RowItemOwner *owner_; - - int layout_v_offset_; - int visual_v_offset_; - -private: - QPropertyAnimation v_offset_animation_; -}; - -} // namespace view -} // namespace pv - -#endif // PULSEVIEW_PV_VIEW_HEADERITEM_H diff --git a/pv/view/rowitem.hpp b/pv/view/rowitem.hpp new file mode 100644 index 00000000..d6233e8c --- /dev/null +++ b/pv/view/rowitem.hpp @@ -0,0 +1,169 @@ +/* + * This file is part of the PulseView project. + * + * 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 + */ + +#ifndef PULSEVIEW_PV_VIEW_HEADERITEM_H +#define PULSEVIEW_PV_VIEW_HEADERITEM_H + +#include + +#include + +#include "selectableitem.hpp" + +namespace pv { +namespace view { + +class RowItemOwner; + +class RowItem : public SelectableItem, + public std::enable_shared_from_this +{ + Q_OBJECT + Q_PROPERTY(int visual_v_offset + READ visual_v_offset + WRITE set_visual_v_offset) + +public: + /** + * Constructor. + */ + RowItem(); + + /** + * Returns true if the item is visible and enabled. + */ + virtual bool enabled() const = 0; + + /** + * Gets the vertical layout offset of this signal. + */ + int layout_v_offset() const; + + /** + * Sets the vertical layout offset of this signal. + */ + void set_layout_v_offset(int v_offset); + + /** + * Gets the vertical visual offset of this signal. + */ + int visual_v_offset() const; + + /** + * Sets the vertical visual offset of this signal. + */ + void set_visual_v_offset(int v_offset); + + /** + * Sets the visual and layout offset of this signal. + */ + void force_to_v_offset(int v_offset); + + /** + * Begins an animation that will animate the visual offset toward + * the layout offset. + */ + void animate_to_layout_v_offset(); + + /** + * Gets the owner this trace in the view trace hierachy. + */ + pv::view::RowItemOwner* owner() const; + + /** + * Sets the owner this trace in the view trace hierachy. + * @param The new owner of the trace. + */ + void set_owner(pv::view::RowItemOwner *owner); + + /** + * Gets the visual y-offset of the axis. + */ + int get_visual_y() const; + + /** + * Gets the drag point of the row item. + */ + QPoint point() const; + + /** + * Computes the vertical extents of the contents of this row item. + * @return A pair containing the minimum and maximum y-values. + */ + virtual std::pair v_extents() const = 0; + + /** + * Paints the background layer of the trace with a QPainter + * @param p the QPainter to paint into. + * @param left the x-coordinate of the left edge of the signal + * @param right the x-coordinate of the right edge of the signal + **/ + virtual void paint_back(QPainter &p, int left, int right); + + /** + * Paints the mid-layer of the trace with a QPainter + * @param p the QPainter to paint into. + * @param left the x-coordinate of the left edge of the signal + * @param right the x-coordinate of the right edge of the signal + **/ + virtual void paint_mid(QPainter &p, int left, int right); + + /** + * Paints the foreground layer of the trace with a QPainter + * @param p the QPainter to paint into. + * @param left the x-coordinate of the left edge of the signal + * @param right the x-coordinate of the right edge of the signal + **/ + virtual void paint_fore(QPainter &p, int left, int right); + + /** + * Paints the signal label. + * @param p the QPainter to paint into. + * @param right the x-coordinate of the right edge of the header + * area. + * @param hover true if the label is being hovered over by the mouse. + */ + virtual void paint_label(QPainter &p, int right, bool hover) = 0; + + /** + * Computes the outline rectangle of a label. + * @param right the x-coordinate of the right edge of the header + * area. + * @return Returns the rectangle of the signal label. + */ + virtual QRectF label_rect(int right) const = 0; + +public: + virtual void hover_point_changed(); + +protected: + pv::view::RowItemOwner *owner_; + + int layout_v_offset_; + int visual_v_offset_; + +private: + QPropertyAnimation v_offset_animation_; +}; + +} // namespace view +} // namespace pv + +#endif // PULSEVIEW_PV_VIEW_HEADERITEM_H diff --git a/pv/view/rowitemiterator.h b/pv/view/rowitemiterator.h deleted file mode 100644 index 178677a2..00000000 --- a/pv/view/rowitemiterator.h +++ /dev/null @@ -1,143 +0,0 @@ -/* - * This file is part of the PulseView project. - * - * Copyright (C) 2014 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 - */ - -#ifndef PULSEVIEW_PV_VIEW_ROWITEMITERATOR_H -#define PULSEVIEW_PV_VIEW_ROWITEMITERATOR_H - -#include -#include -#include -#include -#include -#include -#include - -#include - -#include - -namespace pv { -namespace view { - -template class RowItemIterator -{ -public: - typedef typename std::conditional::value, - typename Owner::item_list::const_iterator, - typename Owner::item_list::iterator>::type child_iterator; - - typedef std::shared_ptr value_type; - typedef ptrdiff_t difference_type; - typedef value_type pointer; - typedef value_type& reference; - typedef std::forward_iterator_tag iterator_category; - -public: - RowItemIterator(Owner *owner) : - owner_(owner), - lock_(owner->session().signals_mutex()) {} - - RowItemIterator(Owner *owner, child_iterator iter) : - owner_(owner), - lock_(owner->session().signals_mutex()) { - assert(owner); - if (iter != owner->child_items().end()) - iter_stack_.push(iter); - } - - RowItemIterator(const RowItemIterator &o) : - owner_(o.owner_), - lock_(*o.lock_.mutex()), - iter_stack_(o.iter_stack_) {} - - reference operator*() const { - return *iter_stack_.top(); - } - - reference operator->() const { - return *this; - } - - RowItemIterator& operator++() { - using std::dynamic_pointer_cast; - using std::shared_ptr; - - assert(owner_); - assert(!iter_stack_.empty()); - - shared_ptr owner(dynamic_pointer_cast( - *iter_stack_.top())); - if (owner && !owner->child_items().empty()) { - owner_ = owner.get(); - iter_stack_.push(owner->child_items().begin()); - } else { - ++iter_stack_.top(); - while (owner_ && iter_stack_.top() == - owner_->child_items().end()) { - iter_stack_.pop(); - owner_ = iter_stack_.empty() ? nullptr : - (*iter_stack_.top()++)->owner(); - } - } - - return *this; - } - - RowItemIterator operator++(int) { - RowItemIterator pre = *this; - ++*this; - return pre; - } - - bool operator==(const RowItemIterator &o) const { - return (iter_stack_.empty() && o.iter_stack_.empty()) || - (owner_ == o.owner_ && - iter_stack_.size() == o.iter_stack_.size() && - std::equal( - owner_->child_items().cbegin(), - owner_->child_items().cend(), - o.owner_->child_items().cbegin())); - } - - bool operator!=(const RowItemIterator &o) const { - return !((const RowItemIterator&)*this == o); - } - - void swap(RowItemIterator& other) { - swap(owner_, other.owner_); - swap(iter_stack_, other.iter_stack_); - } - -private: - Owner *owner_; - boost::shared_lock lock_; - std::stack iter_stack_; -}; - -template -void swap(RowItemIterator& a, RowItemIterator& b) -{ - a.swap(b); -} - -} // namespace view -} // namespace pv - -#endif // PULSEVIEW_PV_VIEW_ROWITEMITERATOR_H diff --git a/pv/view/rowitemiterator.hpp b/pv/view/rowitemiterator.hpp new file mode 100644 index 00000000..110dc574 --- /dev/null +++ b/pv/view/rowitemiterator.hpp @@ -0,0 +1,143 @@ +/* + * This file is part of the PulseView project. + * + * Copyright (C) 2014 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 + */ + +#ifndef PULSEVIEW_PV_VIEW_ROWITEMITERATOR_H +#define PULSEVIEW_PV_VIEW_ROWITEMITERATOR_H + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +namespace pv { +namespace view { + +template class RowItemIterator +{ +public: + typedef typename std::conditional::value, + typename Owner::item_list::const_iterator, + typename Owner::item_list::iterator>::type child_iterator; + + typedef std::shared_ptr value_type; + typedef ptrdiff_t difference_type; + typedef value_type pointer; + typedef value_type& reference; + typedef std::forward_iterator_tag iterator_category; + +public: + RowItemIterator(Owner *owner) : + owner_(owner), + lock_(owner->session().signals_mutex()) {} + + RowItemIterator(Owner *owner, child_iterator iter) : + owner_(owner), + lock_(owner->session().signals_mutex()) { + assert(owner); + if (iter != owner->child_items().end()) + iter_stack_.push(iter); + } + + RowItemIterator(const RowItemIterator &o) : + owner_(o.owner_), + lock_(*o.lock_.mutex()), + iter_stack_(o.iter_stack_) {} + + reference operator*() const { + return *iter_stack_.top(); + } + + reference operator->() const { + return *this; + } + + RowItemIterator& operator++() { + using std::dynamic_pointer_cast; + using std::shared_ptr; + + assert(owner_); + assert(!iter_stack_.empty()); + + shared_ptr owner(dynamic_pointer_cast( + *iter_stack_.top())); + if (owner && !owner->child_items().empty()) { + owner_ = owner.get(); + iter_stack_.push(owner->child_items().begin()); + } else { + ++iter_stack_.top(); + while (owner_ && iter_stack_.top() == + owner_->child_items().end()) { + iter_stack_.pop(); + owner_ = iter_stack_.empty() ? nullptr : + (*iter_stack_.top()++)->owner(); + } + } + + return *this; + } + + RowItemIterator operator++(int) { + RowItemIterator pre = *this; + ++*this; + return pre; + } + + bool operator==(const RowItemIterator &o) const { + return (iter_stack_.empty() && o.iter_stack_.empty()) || + (owner_ == o.owner_ && + iter_stack_.size() == o.iter_stack_.size() && + std::equal( + owner_->child_items().cbegin(), + owner_->child_items().cend(), + o.owner_->child_items().cbegin())); + } + + bool operator!=(const RowItemIterator &o) const { + return !((const RowItemIterator&)*this == o); + } + + void swap(RowItemIterator& other) { + swap(owner_, other.owner_); + swap(iter_stack_, other.iter_stack_); + } + +private: + Owner *owner_; + boost::shared_lock lock_; + std::stack iter_stack_; +}; + +template +void swap(RowItemIterator& a, RowItemIterator& b) +{ + a.swap(b); +} + +} // namespace view +} // namespace pv + +#endif // PULSEVIEW_PV_VIEW_ROWITEMITERATOR_H diff --git a/pv/view/rowitemowner.cpp b/pv/view/rowitemowner.cpp index 6f7cbb26..625620ed 100644 --- a/pv/view/rowitemowner.cpp +++ b/pv/view/rowitemowner.cpp @@ -20,8 +20,8 @@ #include -#include "rowitem.h" -#include "rowitemowner.h" +#include "rowitem.hpp" +#include "rowitemowner.hpp" using std::max; using std::make_pair; diff --git a/pv/view/rowitemowner.h b/pv/view/rowitemowner.h deleted file mode 100644 index 3c568da4..00000000 --- a/pv/view/rowitemowner.h +++ /dev/null @@ -1,141 +0,0 @@ -/* - * This file is part of the PulseView project. - * - * Copyright (C) 2014 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 - */ - -#ifndef PULSEVIEW_PV_VIEW_ROWITEMOWNER_H -#define PULSEVIEW_PV_VIEW_ROWITEMOWNER_H - -#include -#include - -#include "rowitemiterator.h" - -namespace pv { - -class SigSession; - -namespace view { - -class RowItem; -class View; - -class RowItemOwner -{ -public: - typedef std::vector< std::shared_ptr > item_list; - typedef RowItemIterator iterator; - typedef RowItemIterator const_iterator; - -public: - /** - * Returns the session of the onwer. - */ - virtual pv::SigSession& session() = 0; - - /** - * Returns the session of the owner. - */ - virtual const pv::SigSession& session() const = 0; - - /** - * Returns the view of the owner. - */ - virtual pv::view::View* view() = 0; - - /** - * Returns the view of the owner. - */ - virtual const pv::view::View* view() const = 0; - - virtual int owner_visual_v_offset() const = 0; - - /** - * Returns the number of nested parents that this row item owner has. - */ - virtual unsigned int depth() const = 0; - - /** - * Returns a list of row items owned by this object. - */ - virtual item_list& child_items(); - - /** - * Returns a list of row items owned by this object. - */ - virtual const item_list& child_items() const; - - /** - * Clears the list of child items. - */ - void clear_child_items(); - - /** - * Adds a child item to this object. - */ - void add_child_item(std::shared_ptr item); - - /** - * Removes a child item from this object. - */ - void remove_child_item(std::shared_ptr item); - - /** - * Returns a depth-first iterator at the beginning of the child RowItem - * tree. - */ - iterator begin(); - - /** - * Returns a depth-first iterator at the end of the child RowItem tree. - */ - iterator end(); - - /** - * Returns a constant depth-first iterator at the beginning of the - * child RowItem tree. - */ - const_iterator begin() const; - - /** - * Returns a constant depth-first iterator at the end of the child - * RowItem tree. - */ - const_iterator end() const; - - /** - * Computes the vertical extents of the contents of this row item owner. - * @return A pair containing the minimum and maximum y-values. - */ - std::pair v_extents() const; - - virtual void restack_items(); - -public: - virtual void appearance_changed(bool label, bool content) = 0; - - virtual void extents_changed(bool horz, bool vert) = 0; - -private: - item_list items_; -}; - -} // view -} // pv - -#endif // PULSEVIEW_PV_VIEW_ROWITEMOWNER_H diff --git a/pv/view/rowitemowner.hpp b/pv/view/rowitemowner.hpp new file mode 100644 index 00000000..8c63aa56 --- /dev/null +++ b/pv/view/rowitemowner.hpp @@ -0,0 +1,141 @@ +/* + * This file is part of the PulseView project. + * + * Copyright (C) 2014 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 + */ + +#ifndef PULSEVIEW_PV_VIEW_ROWITEMOWNER_H +#define PULSEVIEW_PV_VIEW_ROWITEMOWNER_H + +#include +#include + +#include "rowitemiterator.hpp" + +namespace pv { + +class SigSession; + +namespace view { + +class RowItem; +class View; + +class RowItemOwner +{ +public: + typedef std::vector< std::shared_ptr > item_list; + typedef RowItemIterator iterator; + typedef RowItemIterator const_iterator; + +public: + /** + * Returns the session of the onwer. + */ + virtual pv::SigSession& session() = 0; + + /** + * Returns the session of the owner. + */ + virtual const pv::SigSession& session() const = 0; + + /** + * Returns the view of the owner. + */ + virtual pv::view::View* view() = 0; + + /** + * Returns the view of the owner. + */ + virtual const pv::view::View* view() const = 0; + + virtual int owner_visual_v_offset() const = 0; + + /** + * Returns the number of nested parents that this row item owner has. + */ + virtual unsigned int depth() const = 0; + + /** + * Returns a list of row items owned by this object. + */ + virtual item_list& child_items(); + + /** + * Returns a list of row items owned by this object. + */ + virtual const item_list& child_items() const; + + /** + * Clears the list of child items. + */ + void clear_child_items(); + + /** + * Adds a child item to this object. + */ + void add_child_item(std::shared_ptr item); + + /** + * Removes a child item from this object. + */ + void remove_child_item(std::shared_ptr item); + + /** + * Returns a depth-first iterator at the beginning of the child RowItem + * tree. + */ + iterator begin(); + + /** + * Returns a depth-first iterator at the end of the child RowItem tree. + */ + iterator end(); + + /** + * Returns a constant depth-first iterator at the beginning of the + * child RowItem tree. + */ + const_iterator begin() const; + + /** + * Returns a constant depth-first iterator at the end of the child + * RowItem tree. + */ + const_iterator end() const; + + /** + * Computes the vertical extents of the contents of this row item owner. + * @return A pair containing the minimum and maximum y-values. + */ + std::pair v_extents() const; + + virtual void restack_items(); + +public: + virtual void appearance_changed(bool label, bool content) = 0; + + virtual void extents_changed(bool horz, bool vert) = 0; + +private: + item_list items_; +}; + +} // view +} // pv + +#endif // PULSEVIEW_PV_VIEW_ROWITEMOWNER_H diff --git a/pv/view/ruler.cpp b/pv/view/ruler.cpp index d3e42df6..56651169 100644 --- a/pv/view/ruler.cpp +++ b/pv/view/ruler.cpp @@ -18,10 +18,10 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "ruler.h" +#include "ruler.hpp" -#include "view.h" -#include "pv/util.h" +#include "view.hpp" +#include "pv/util.hpp" #include diff --git a/pv/view/ruler.h b/pv/view/ruler.h deleted file mode 100644 index 00fac244..00000000 --- a/pv/view/ruler.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - * This file is part of the PulseView project. - * - * 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 - */ - -#ifndef PULSEVIEW_PV_VIEW_RULER_H -#define PULSEVIEW_PV_VIEW_RULER_H - -#include - -#include "marginwidget.h" - -namespace pv { -namespace view { - -class Ruler : public MarginWidget -{ - Q_OBJECT - -private: - static const int RulerHeight; - static const int MinorTickSubdivision; - static const int ScaleUnits[3]; - - static const int HoverArrowSize; - -public: - Ruler(View &parent); - - /** - * Find a tick spacing and number formatting that does not cause - * the values to collide. - * @param p A QPainter used to determine the needed space for the values. - * @param scale A pv::view::View's scale. - * @param offset A pv::view::View's offset. - * - * @return The tick period to use in 'first' and the prefix in 'second'. - */ - static std::pair calculate_tick_spacing( - QPainter& p, double scale, double offset); - -public: - QSize sizeHint() const; - -private: - void paintEvent(QPaintEvent *event); - -private: - /** - * Draw a hover arrow under the cursor position. - */ - void draw_hover_mark(QPainter &p); - -private Q_SLOTS: - void hover_point_changed(); -}; - -} // namespace view -} // namespace pv - -#endif // PULSEVIEW_PV_VIEW_RULER_H diff --git a/pv/view/ruler.hpp b/pv/view/ruler.hpp new file mode 100644 index 00000000..438b862c --- /dev/null +++ b/pv/view/ruler.hpp @@ -0,0 +1,76 @@ +/* + * This file is part of the PulseView project. + * + * 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 + */ + +#ifndef PULSEVIEW_PV_VIEW_RULER_H +#define PULSEVIEW_PV_VIEW_RULER_H + +#include + +#include "marginwidget.hpp" + +namespace pv { +namespace view { + +class Ruler : public MarginWidget +{ + Q_OBJECT + +private: + static const int RulerHeight; + static const int MinorTickSubdivision; + static const int ScaleUnits[3]; + + static const int HoverArrowSize; + +public: + Ruler(View &parent); + + /** + * Find a tick spacing and number formatting that does not cause + * the values to collide. + * @param p A QPainter used to determine the needed space for the values. + * @param scale A pv::view::View's scale. + * @param offset A pv::view::View's offset. + * + * @return The tick period to use in 'first' and the prefix in 'second'. + */ + static std::pair calculate_tick_spacing( + QPainter& p, double scale, double offset); + +public: + QSize sizeHint() const; + +private: + void paintEvent(QPaintEvent *event); + +private: + /** + * Draw a hover arrow under the cursor position. + */ + void draw_hover_mark(QPainter &p); + +private Q_SLOTS: + void hover_point_changed(); +}; + +} // namespace view +} // namespace pv + +#endif // PULSEVIEW_PV_VIEW_RULER_H diff --git a/pv/view/selectableitem.cpp b/pv/view/selectableitem.cpp index 5987b3ec..b699005f 100644 --- a/pv/view/selectableitem.cpp +++ b/pv/view/selectableitem.cpp @@ -18,7 +18,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "selectableitem.h" +#include "selectableitem.hpp" #include diff --git a/pv/view/selectableitem.h b/pv/view/selectableitem.h deleted file mode 100644 index 36ff0dbc..00000000 --- a/pv/view/selectableitem.h +++ /dev/null @@ -1,107 +0,0 @@ -/* - * This file is part of the PulseView project. - * - * 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 - */ - -#ifndef PULSEVIEW_PV_SELECTABLEITEM_H -#define PULSEVIEW_PV_SELECTABLEITEM_H - -#include - -#include - -class QAction; -class QMenu; -class QWidget; - -namespace pv { - -namespace widgets { -class Popup; -} - -namespace view { - -class SelectableItem : public QObject -{ - Q_OBJECT - -private: - static const int HighlightRadius; - -public: - SelectableItem(); - -public: - /** - * Returns true if the item has been selected by the user. - */ - bool selected() const; - - /** - * Selects or deselects the signal. - */ - void select(bool select = true); - - /** - * Returns true if the item is being dragged. - */ - bool dragging() const; - - /** - * Retunrns the current drag point. - */ - QPoint drag_point() const; - - /** - * Sets this item into the dragged state. - */ - void drag(); - - /** - * Sets this item into the un-dragged state. - */ - void drag_release(); - - /** - * Get the drag point. - */ - virtual QPoint point() const = 0; - -public: - virtual QMenu* create_context_menu(QWidget *parent); - - virtual pv::widgets::Popup* create_popup(QWidget *parent) = 0; - - virtual void delete_pressed(); - -protected: - static QPen highlight_pen(); - -protected: - QWidget *context_parent_; - -private: - bool selected_; - QPoint drag_point_; -}; - -} // namespace view -} // namespace pv - -#endif // PULSEVIEW_PV_SELECTABLEITEM_H diff --git a/pv/view/selectableitem.hpp b/pv/view/selectableitem.hpp new file mode 100644 index 00000000..36ff0dbc --- /dev/null +++ b/pv/view/selectableitem.hpp @@ -0,0 +1,107 @@ +/* + * This file is part of the PulseView project. + * + * 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 + */ + +#ifndef PULSEVIEW_PV_SELECTABLEITEM_H +#define PULSEVIEW_PV_SELECTABLEITEM_H + +#include + +#include + +class QAction; +class QMenu; +class QWidget; + +namespace pv { + +namespace widgets { +class Popup; +} + +namespace view { + +class SelectableItem : public QObject +{ + Q_OBJECT + +private: + static const int HighlightRadius; + +public: + SelectableItem(); + +public: + /** + * Returns true if the item has been selected by the user. + */ + bool selected() const; + + /** + * Selects or deselects the signal. + */ + void select(bool select = true); + + /** + * Returns true if the item is being dragged. + */ + bool dragging() const; + + /** + * Retunrns the current drag point. + */ + QPoint drag_point() const; + + /** + * Sets this item into the dragged state. + */ + void drag(); + + /** + * Sets this item into the un-dragged state. + */ + void drag_release(); + + /** + * Get the drag point. + */ + virtual QPoint point() const = 0; + +public: + virtual QMenu* create_context_menu(QWidget *parent); + + virtual pv::widgets::Popup* create_popup(QWidget *parent) = 0; + + virtual void delete_pressed(); + +protected: + static QPen highlight_pen(); + +protected: + QWidget *context_parent_; + +private: + bool selected_; + QPoint drag_point_; +}; + +} // namespace view +} // namespace pv + +#endif // PULSEVIEW_PV_SELECTABLEITEM_H diff --git a/pv/view/signal.cpp b/pv/view/signal.cpp index 916801c9..35e1cdbf 100644 --- a/pv/view/signal.cpp +++ b/pv/view/signal.cpp @@ -31,8 +31,8 @@ #include -#include "signal.h" -#include "view.h" +#include "signal.hpp" +#include "view.hpp" using std::shared_ptr; diff --git a/pv/view/signal.h b/pv/view/signal.h deleted file mode 100644 index b3b591b2..00000000 --- a/pv/view/signal.h +++ /dev/null @@ -1,92 +0,0 @@ -/* - * This file is part of the PulseView project. - * - * 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 - */ - -#ifndef PULSEVIEW_PV_VIEW_SIGNAL_H -#define PULSEVIEW_PV_VIEW_SIGNAL_H - -#include - -#include -#include - -#include - -#include "trace.h" - -namespace sigrok { - class Channel; -} - -namespace pv { - -class SigSession; - -namespace data { -class SignalData; -} - -namespace view { - -class Signal : public Trace -{ - Q_OBJECT - -protected: - Signal(pv::SigSession &session, - std::shared_ptr channel); - -public: - /** - * Sets the name of the signal. - */ - void set_name(QString name); - - virtual std::shared_ptr data() const = 0; - - /** - * Returns true if the trace is visible and enabled. - */ - bool enabled() const; - - void enable(bool enable = true); - - std::shared_ptr channel() const; - - virtual void populate_popup_form(QWidget *parent, QFormLayout *form); - - QMenu* create_context_menu(QWidget *parent); - - void delete_pressed(); - -private Q_SLOTS: - void on_disable(); - -protected: - pv::SigSession &session_; - std::shared_ptr channel_; - - QComboBox *name_widget_; - bool updating_name_widget_; -}; - -} // namespace view -} // namespace pv - -#endif // PULSEVIEW_PV_VIEW_SIGNAL_H diff --git a/pv/view/signal.hpp b/pv/view/signal.hpp new file mode 100644 index 00000000..dd3af0b3 --- /dev/null +++ b/pv/view/signal.hpp @@ -0,0 +1,92 @@ +/* + * This file is part of the PulseView project. + * + * 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 + */ + +#ifndef PULSEVIEW_PV_VIEW_SIGNAL_H +#define PULSEVIEW_PV_VIEW_SIGNAL_H + +#include + +#include +#include + +#include + +#include "trace.hpp" + +namespace sigrok { + class Channel; +} + +namespace pv { + +class SigSession; + +namespace data { +class SignalData; +} + +namespace view { + +class Signal : public Trace +{ + Q_OBJECT + +protected: + Signal(pv::SigSession &session, + std::shared_ptr channel); + +public: + /** + * Sets the name of the signal. + */ + void set_name(QString name); + + virtual std::shared_ptr data() const = 0; + + /** + * Returns true if the trace is visible and enabled. + */ + bool enabled() const; + + void enable(bool enable = true); + + std::shared_ptr channel() const; + + virtual void populate_popup_form(QWidget *parent, QFormLayout *form); + + QMenu* create_context_menu(QWidget *parent); + + void delete_pressed(); + +private Q_SLOTS: + void on_disable(); + +protected: + pv::SigSession &session_; + std::shared_ptr channel_; + + QComboBox *name_widget_; + bool updating_name_widget_; +}; + +} // namespace view +} // namespace pv + +#endif // PULSEVIEW_PV_VIEW_SIGNAL_H diff --git a/pv/view/timemarker.cpp b/pv/view/timemarker.cpp index 105bbc14..5196613b 100644 --- a/pv/view/timemarker.cpp +++ b/pv/view/timemarker.cpp @@ -18,14 +18,14 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "timemarker.h" +#include "timemarker.hpp" -#include "view.h" +#include "view.hpp" #include #include -#include +#include namespace pv { namespace view { diff --git a/pv/view/timemarker.h b/pv/view/timemarker.h deleted file mode 100644 index d57b4dd1..00000000 --- a/pv/view/timemarker.h +++ /dev/null @@ -1,118 +0,0 @@ -/* - * This file is part of the PulseView project. - * - * 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 - */ - -#ifndef PULSEVIEW_PV_VIEW_MARKER_H -#define PULSEVIEW_PV_VIEW_MARKER_H - -#include -#include -#include -#include -#include - -#include "selectableitem.h" - -class QPainter; -class QRect; - -namespace pv { -namespace view { - -class View; - -class TimeMarker : public SelectableItem -{ - Q_OBJECT - -protected: - /** - * Constructor. - * @param view A reference to the view that owns this marker. - * @param colour A reference to the colour of this cursor. - * @param time The time to set the flag to. - */ - TimeMarker(View &view, const QColor &colour, double time); - -public: - /** - * Gets the time of the marker. - */ - double time() const; - - /** - * Sets the time of the marker. - */ - void set_time(double time); - - float get_x() const; - - /** - * Gets the drag point of the row item. - */ - QPoint point() const; - - /** - * Paints the marker to the viewport. - * @param p The painter to draw with. - * @param rect The rectangle of the viewport client area. - */ - virtual void paint(QPainter &p, const QRect &rect); - - /** - * Gets the marker label rectangle. - * @param rect The rectangle of the ruler client area. - * @return Returns the label rectangle. - */ - virtual QRectF get_label_rect(const QRect &rect) const = 0; - - /** - * Paints the marker's label to the ruler. - * @param p The painter to draw with. - * @param rect The rectangle of the ruler client area. - * @param prefix The SI prefix to paint time value with. - */ - virtual void paint_label(QPainter &p, const QRect &rect, - unsigned int prefix) = 0; - - pv::widgets::Popup* create_popup(QWidget *parent); - -private Q_SLOTS: - void on_value_changed(double value); - -Q_SIGNALS: - void time_changed(); - -protected: - View &view_; - const QColor &colour_; - - double time_; - - QSizeF text_size_; - - QWidgetAction *value_action_; - QDoubleSpinBox *value_widget_; - bool updating_value_widget_; -}; - -} // namespace view -} // namespace pv - -#endif // PULSEVIEW_PV_VIEW_MARKER_H diff --git a/pv/view/timemarker.hpp b/pv/view/timemarker.hpp new file mode 100644 index 00000000..0103fb04 --- /dev/null +++ b/pv/view/timemarker.hpp @@ -0,0 +1,118 @@ +/* + * This file is part of the PulseView project. + * + * 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 + */ + +#ifndef PULSEVIEW_PV_VIEW_MARKER_H +#define PULSEVIEW_PV_VIEW_MARKER_H + +#include +#include +#include +#include +#include + +#include "selectableitem.hpp" + +class QPainter; +class QRect; + +namespace pv { +namespace view { + +class View; + +class TimeMarker : public SelectableItem +{ + Q_OBJECT + +protected: + /** + * Constructor. + * @param view A reference to the view that owns this marker. + * @param colour A reference to the colour of this cursor. + * @param time The time to set the flag to. + */ + TimeMarker(View &view, const QColor &colour, double time); + +public: + /** + * Gets the time of the marker. + */ + double time() const; + + /** + * Sets the time of the marker. + */ + void set_time(double time); + + float get_x() const; + + /** + * Gets the drag point of the row item. + */ + QPoint point() const; + + /** + * Paints the marker to the viewport. + * @param p The painter to draw with. + * @param rect The rectangle of the viewport client area. + */ + virtual void paint(QPainter &p, const QRect &rect); + + /** + * Gets the marker label rectangle. + * @param rect The rectangle of the ruler client area. + * @return Returns the label rectangle. + */ + virtual QRectF get_label_rect(const QRect &rect) const = 0; + + /** + * Paints the marker's label to the ruler. + * @param p The painter to draw with. + * @param rect The rectangle of the ruler client area. + * @param prefix The SI prefix to paint time value with. + */ + virtual void paint_label(QPainter &p, const QRect &rect, + unsigned int prefix) = 0; + + pv::widgets::Popup* create_popup(QWidget *parent); + +private Q_SLOTS: + void on_value_changed(double value); + +Q_SIGNALS: + void time_changed(); + +protected: + View &view_; + const QColor &colour_; + + double time_; + + QSizeF text_size_; + + QWidgetAction *value_action_; + QDoubleSpinBox *value_widget_; + bool updating_value_widget_; +}; + +} // namespace view +} // namespace pv + +#endif // PULSEVIEW_PV_VIEW_MARKER_H diff --git a/pv/view/trace.cpp b/pv/view/trace.cpp index ebd3dc36..1734921a 100644 --- a/pv/view/trace.cpp +++ b/pv/view/trace.cpp @@ -28,12 +28,12 @@ #include #include -#include "trace.h" -#include "tracepalette.h" -#include "view.h" +#include "trace.hpp" +#include "tracepalette.hpp" +#include "view.hpp" -#include -#include +#include +#include namespace pv { namespace view { diff --git a/pv/view/trace.h b/pv/view/trace.h deleted file mode 100644 index f99e01aa..00000000 --- a/pv/view/trace.h +++ /dev/null @@ -1,141 +0,0 @@ -/* - * This file is part of the PulseView project. - * - * 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 - */ - -#ifndef PULSEVIEW_PV_VIEW_TRACE_H -#define PULSEVIEW_PV_VIEW_TRACE_H - -#include -#include -#include -#include -#include - -#include - -#include "rowitem.h" - -class QFormLayout; - -namespace pv { - -namespace widgets { -class Popup; -} - -namespace view { - -class Trace : public RowItem -{ - Q_OBJECT - -private: - static const QPen AxisPen; - static const int LabelHitPadding; - -protected: - Trace(QString name); - -public: - /** - * Gets the name of this signal. - */ - QString name() const; - - /** - * Sets the name of the signal. - */ - virtual void set_name(QString name); - - /** - * Get the colour of the signal. - */ - QColor colour() const; - - /** - * Set the colour of the signal. - */ - void set_colour(QColor colour); - - /** - * Paints the signal label. - * @param p the QPainter to paint into. - * @param right the x-coordinate of the right edge of the header - * area. - * @param hover true if the label is being hovered over by the mouse. - */ - virtual void paint_label(QPainter &p, int right, bool hover); - - virtual QMenu* create_context_menu(QWidget *parent); - - pv::widgets::Popup* create_popup(QWidget *parent); - - /** - * Computes the outline rectangle of a label. - * @param right the x-coordinate of the right edge of the header - * area. - * @return Returns the rectangle of the signal label. - */ - QRectF label_rect(int right) const; - -protected: - - /** - * Gets the text colour. - * @remarks This colour is computed by comparing the lightness - * of the trace colour against a threshold to determine whether - * white or black would be more visible. - */ - QColor get_text_colour() const; - - /** - * Paints a zero axis across the viewport. - * @param p the QPainter to paint into. - * @param y the y-offset of the axis. - * @param left the x-coordinate of the left edge of the view. - * @param right the x-coordinate of the right edge of the view. - */ - void paint_axis(QPainter &p, int y, int left, int right); - - void add_colour_option(QWidget *parent, QFormLayout *form); - - void create_popup_form(); - - virtual void populate_popup_form(QWidget *parent, QFormLayout *form); - -private Q_SLOTS: - void on_text_changed(const QString &text); - - void on_colour_changed(const QColor &colour); - - void on_popup_closed(); - -protected: - QString name_; - QColor colour_; - -private: - pv::widgets::Popup *popup_; - QFormLayout *popup_form_; -}; - -} // namespace view -} // namespace pv - -#endif // PULSEVIEW_PV_VIEW_TRACE_H diff --git a/pv/view/trace.hpp b/pv/view/trace.hpp new file mode 100644 index 00000000..88df33ea --- /dev/null +++ b/pv/view/trace.hpp @@ -0,0 +1,141 @@ +/* + * This file is part of the PulseView project. + * + * 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 + */ + +#ifndef PULSEVIEW_PV_VIEW_TRACE_H +#define PULSEVIEW_PV_VIEW_TRACE_H + +#include +#include +#include +#include +#include + +#include + +#include "rowitem.hpp" + +class QFormLayout; + +namespace pv { + +namespace widgets { +class Popup; +} + +namespace view { + +class Trace : public RowItem +{ + Q_OBJECT + +private: + static const QPen AxisPen; + static const int LabelHitPadding; + +protected: + Trace(QString name); + +public: + /** + * Gets the name of this signal. + */ + QString name() const; + + /** + * Sets the name of the signal. + */ + virtual void set_name(QString name); + + /** + * Get the colour of the signal. + */ + QColor colour() const; + + /** + * Set the colour of the signal. + */ + void set_colour(QColor colour); + + /** + * Paints the signal label. + * @param p the QPainter to paint into. + * @param right the x-coordinate of the right edge of the header + * area. + * @param hover true if the label is being hovered over by the mouse. + */ + virtual void paint_label(QPainter &p, int right, bool hover); + + virtual QMenu* create_context_menu(QWidget *parent); + + pv::widgets::Popup* create_popup(QWidget *parent); + + /** + * Computes the outline rectangle of a label. + * @param right the x-coordinate of the right edge of the header + * area. + * @return Returns the rectangle of the signal label. + */ + QRectF label_rect(int right) const; + +protected: + + /** + * Gets the text colour. + * @remarks This colour is computed by comparing the lightness + * of the trace colour against a threshold to determine whether + * white or black would be more visible. + */ + QColor get_text_colour() const; + + /** + * Paints a zero axis across the viewport. + * @param p the QPainter to paint into. + * @param y the y-offset of the axis. + * @param left the x-coordinate of the left edge of the view. + * @param right the x-coordinate of the right edge of the view. + */ + void paint_axis(QPainter &p, int y, int left, int right); + + void add_colour_option(QWidget *parent, QFormLayout *form); + + void create_popup_form(); + + virtual void populate_popup_form(QWidget *parent, QFormLayout *form); + +private Q_SLOTS: + void on_text_changed(const QString &text); + + void on_colour_changed(const QColor &colour); + + void on_popup_closed(); + +protected: + QString name_; + QColor colour_; + +private: + pv::widgets::Popup *popup_; + QFormLayout *popup_form_; +}; + +} // namespace view +} // namespace pv + +#endif // PULSEVIEW_PV_VIEW_TRACE_H diff --git a/pv/view/tracegroup.cpp b/pv/view/tracegroup.cpp index 16b9d0cc..665b4ad1 100644 --- a/pv/view/tracegroup.cpp +++ b/pv/view/tracegroup.cpp @@ -26,7 +26,7 @@ #include #include -#include "tracegroup.h" +#include "tracegroup.hpp" using std::pair; using std::shared_ptr; diff --git a/pv/view/tracegroup.h b/pv/view/tracegroup.h deleted file mode 100644 index d2464764..00000000 --- a/pv/view/tracegroup.h +++ /dev/null @@ -1,134 +0,0 @@ -/* - * This file is part of the PulseView project. - * - * 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 - */ - -#ifndef PULSEVIEW_PV_VIEW_TRACEGROUP_H -#define PULSEVIEW_PV_VIEW_TRACEGROUP_H - -#include "rowitem.h" -#include "rowitemowner.h" - -namespace pv { -namespace view { - -class TraceGroup : public RowItem, public RowItemOwner -{ - Q_OBJECT - -private: - static const int Padding; - static const int Width; - static const int LineThickness; - static const QColor LineColour; - -public: - /** - * Virtual destructor - */ - virtual ~TraceGroup(); - - /** - * Returns true if the item is visible and enabled. - */ - bool enabled() const; - - /** - * Returns the session of the onwer. - */ - pv::SigSession& session(); - - /** - * Returns the session of the onwer. - */ - const pv::SigSession& session() const; - - /** - * Returns the view of the owner. - */ - virtual pv::view::View* view(); - - /** - * Returns the view of the owner. - */ - virtual const pv::view::View* view() const; - - /** - * Computes the vertical extents of the contents of this row item. - * @return A pair containing the minimum and maximum y-values. - */ - std::pair v_extents() const; - - /** - * Paints the signal label. - * @param p the QPainter to paint into. - * @param right the x-coordinate of the right edge of the header - * area. - * @param hover true if the label is being hovered over by the mouse. - */ - void paint_label(QPainter &p, int right, bool hover); - - /** - * Computes the outline rectangle of a label. - * @param right the x-coordinate of the right edge of the header - * area. - * @return Returns the rectangle of the signal label. - */ - QRectF label_rect(int right) const; - - /** - * Determines if a point is in the header label rect. - * @param left the x-coordinate of the left edge of the header - * area. - * @param right the x-coordinate of the right edge of the header - * area. - * @param point the point to test. - */ - bool pt_in_label_rect(int left, int right, const QPoint &point); - - QMenu* create_context_menu(QWidget *parent); - - pv::widgets::Popup* create_popup(QWidget *parent); - - /** - * Returns the total vertical offset of this trace and all it's owners - */ - int owner_visual_v_offset() const; - - void restack_items(); - - /** - * Returns the number of nested parents that this row item owner has. - */ - unsigned int depth() const; - - void ungroup(); - -public: - void appearance_changed(bool label, bool content); - - void extents_changed(bool horz, bool vert); - -private Q_SLOTS: - void on_ungroup(); -}; - -} // view -} // pv - -#endif // PULSEVIEW_PV_VIEW_TRACEGROUP_H diff --git a/pv/view/tracegroup.hpp b/pv/view/tracegroup.hpp new file mode 100644 index 00000000..960a15d9 --- /dev/null +++ b/pv/view/tracegroup.hpp @@ -0,0 +1,134 @@ +/* + * This file is part of the PulseView project. + * + * 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 + */ + +#ifndef PULSEVIEW_PV_VIEW_TRACEGROUP_H +#define PULSEVIEW_PV_VIEW_TRACEGROUP_H + +#include "rowitem.hpp" +#include "rowitemowner.hpp" + +namespace pv { +namespace view { + +class TraceGroup : public RowItem, public RowItemOwner +{ + Q_OBJECT + +private: + static const int Padding; + static const int Width; + static const int LineThickness; + static const QColor LineColour; + +public: + /** + * Virtual destructor + */ + virtual ~TraceGroup(); + + /** + * Returns true if the item is visible and enabled. + */ + bool enabled() const; + + /** + * Returns the session of the onwer. + */ + pv::SigSession& session(); + + /** + * Returns the session of the onwer. + */ + const pv::SigSession& session() const; + + /** + * Returns the view of the owner. + */ + virtual pv::view::View* view(); + + /** + * Returns the view of the owner. + */ + virtual const pv::view::View* view() const; + + /** + * Computes the vertical extents of the contents of this row item. + * @return A pair containing the minimum and maximum y-values. + */ + std::pair v_extents() const; + + /** + * Paints the signal label. + * @param p the QPainter to paint into. + * @param right the x-coordinate of the right edge of the header + * area. + * @param hover true if the label is being hovered over by the mouse. + */ + void paint_label(QPainter &p, int right, bool hover); + + /** + * Computes the outline rectangle of a label. + * @param right the x-coordinate of the right edge of the header + * area. + * @return Returns the rectangle of the signal label. + */ + QRectF label_rect(int right) const; + + /** + * Determines if a point is in the header label rect. + * @param left the x-coordinate of the left edge of the header + * area. + * @param right the x-coordinate of the right edge of the header + * area. + * @param point the point to test. + */ + bool pt_in_label_rect(int left, int right, const QPoint &point); + + QMenu* create_context_menu(QWidget *parent); + + pv::widgets::Popup* create_popup(QWidget *parent); + + /** + * Returns the total vertical offset of this trace and all it's owners + */ + int owner_visual_v_offset() const; + + void restack_items(); + + /** + * Returns the number of nested parents that this row item owner has. + */ + unsigned int depth() const; + + void ungroup(); + +public: + void appearance_changed(bool label, bool content); + + void extents_changed(bool horz, bool vert); + +private Q_SLOTS: + void on_ungroup(); +}; + +} // view +} // pv + +#endif // PULSEVIEW_PV_VIEW_TRACEGROUP_H diff --git a/pv/view/tracepalette.cpp b/pv/view/tracepalette.cpp index cefb952d..3dcb63d1 100644 --- a/pv/view/tracepalette.cpp +++ b/pv/view/tracepalette.cpp @@ -18,7 +18,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "tracepalette.h" +#include "tracepalette.hpp" namespace pv { namespace view { diff --git a/pv/view/tracepalette.h b/pv/view/tracepalette.h deleted file mode 100644 index ae3c69ad..00000000 --- a/pv/view/tracepalette.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * This file is part of the PulseView project. - * - * 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 - */ - -#ifndef PULSEVIEW_PV_TRACEPALETTE_H -#define PULSEVIEW_PV_TRACEPALETTE_H - -#include - -namespace pv { -namespace view { - -class TracePalette -{ -public: - static const unsigned int Cols = 8; - static const unsigned int Rows = 4; - static const QColor Colours[Cols * Rows]; -}; - - -} // view -} // pv - -#endif // PULSEVIEW_PV_VIEW_TRACEPALETTE_H diff --git a/pv/view/tracepalette.hpp b/pv/view/tracepalette.hpp new file mode 100644 index 00000000..ae3c69ad --- /dev/null +++ b/pv/view/tracepalette.hpp @@ -0,0 +1,41 @@ +/* + * This file is part of the PulseView project. + * + * 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 + */ + +#ifndef PULSEVIEW_PV_TRACEPALETTE_H +#define PULSEVIEW_PV_TRACEPALETTE_H + +#include + +namespace pv { +namespace view { + +class TracePalette +{ +public: + static const unsigned int Cols = 8; + static const unsigned int Rows = 4; + static const QColor Colours[Cols * Rows]; +}; + + +} // view +} // pv + +#endif // PULSEVIEW_PV_VIEW_TRACEPALETTE_H diff --git a/pv/view/view.cpp b/pv/view/view.cpp index 5af8d28c..d621e714 100644 --- a/pv/view/view.cpp +++ b/pv/view/view.cpp @@ -34,19 +34,19 @@ #include -#include "cursorheader.h" -#include "decodetrace.h" -#include "header.h" -#include "logicsignal.h" -#include "ruler.h" -#include "signal.h" -#include "tracegroup.h" -#include "view.h" -#include "viewport.h" - -#include "pv/sigsession.h" -#include "pv/data/logic.h" -#include "pv/data/logicsnapshot.h" +#include "cursorheader.hpp" +#include "decodetrace.hpp" +#include "header.hpp" +#include "logicsignal.hpp" +#include "ruler.hpp" +#include "signal.hpp" +#include "tracegroup.hpp" +#include "view.hpp" +#include "viewport.hpp" + +#include "pv/sigsession.hpp" +#include "pv/data/logic.hpp" +#include "pv/data/logicsnapshot.hpp" using boost::shared_lock; using boost::shared_mutex; diff --git a/pv/view/view.h b/pv/view/view.h deleted file mode 100644 index dec317cc..00000000 --- a/pv/view/view.h +++ /dev/null @@ -1,267 +0,0 @@ -/* - * This file is part of the PulseView project. - * - * 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 - */ - -#ifndef PULSEVIEW_PV_VIEW_VIEW_H -#define PULSEVIEW_PV_VIEW_VIEW_H - -#include - -#include -#include -#include -#include - -#include -#include -#include - -#include - -#include "cursorpair.h" -#include "rowitemowner.h" - -namespace pv { - -class SigSession; - -namespace view { - -class CursorHeader; -class Header; -class Ruler; -class Viewport; - -class View : public QAbstractScrollArea, public RowItemOwner { - Q_OBJECT - -private: - enum StickyEvents { - SelectableItemHExtentsChanged = 1, - SelectableItemVExtentsChanged = 2 - }; - -private: - static const double MaxScale; - static const double MinScale; - - static const int MaxScrollValue; - -public: - static const QColor CursorAreaColour; - - static const QSizeF LabelPadding; - -public: - explicit View(SigSession &session, QWidget *parent = 0); - - SigSession& session(); - const SigSession& session() const; - - /** - * Returns the view of the owner. - */ - virtual pv::view::View* view(); - - /** - * Returns the view of the owner. - */ - virtual const pv::view::View* view() const; - - Viewport* viewport(); - - const Viewport* viewport() const; - - /** - * Returns the view time scale in seconds per pixel. - */ - double scale() const; - - /** - * Returns the time offset of the left edge of the view in - * seconds. - */ - double offset() const; - int owner_visual_v_offset() const; - - /** - * Returns the number of nested parents that this row item owner has. - */ - unsigned int depth() const; - - void zoom(double steps); - void zoom(double steps, int offset); - - void zoom_fit(); - - void zoom_one_to_one(); - - /** - * Sets the scale and offset. - * @param scale The new view scale in seconds per pixel. - * @param offset The view time offset in seconds. - */ - void set_scale_offset(double scale, double offset); - - std::set< std::shared_ptr > - get_visible_data() const; - - std::pair get_time_extents() const; - - /** - * Returns true if cursors are displayed. false otherwise. - */ - bool cursors_shown() const; - - /** - * Shows or hides the cursors. - */ - void show_cursors(bool show = true); - - /** - * Moves the cursors to a convenient position in the view. - */ - void centre_cursors(); - - /** - * Returns a reference to the pair of cursors. - */ - CursorPair& cursors(); - - /** - * Returns a reference to the pair of cursors. - */ - const CursorPair& cursors() const; - - const QPoint& hover_point() const; - - void update_viewport(); - - void restack_all_row_items(); - -Q_SIGNALS: - void hover_point_changed(); - - void signals_moved(); - - void selection_changed(); - - void scale_offset_changed(); - -private: - void get_scroll_layout(double &length, double &offset) const; - - /** - * Simultaneously sets the zoom and offset. - * @param scale The scale to set the view to in seconds per pixel. This - * value is clamped between MinScale and MaxScale. - * @param offset The offset of the left edge of the view in seconds. - */ - void set_zoom(double scale, int offset); - - void update_scroll(); - - void update_layout(); - - /** - * Satisifies RowItem functionality. - * @param p the QPainter to paint into. - * @param right the x-coordinate of the right edge of the header - * area. - * @param hover true if the label is being hovered over by the mouse. - */ - void paint_label(QPainter &p, int right, bool hover); - - /** - * Computes the outline rectangle of a label. - * @param right the x-coordinate of the right edge of the header - * area. - * @return Returns the rectangle of the signal label. - */ - QRectF label_rect(int right); - - static bool add_channels_to_owner( - const std::vector< std::shared_ptr > &channels, - RowItemOwner *owner, int &offset, - std::unordered_map, - std::shared_ptr > &signal_map, - std::function)> filter_func = - std::function)>()); - - static void apply_offset( - std::shared_ptr row_item, int &offset); - -private: - bool eventFilter(QObject *object, QEvent *event); - - bool viewportEvent(QEvent *e); - - void resizeEvent(QResizeEvent *e); - -public: - void appearance_changed(bool label, bool content); - - void extents_changed(bool horz, bool vert); - -private Q_SLOTS: - - void h_scroll_value_changed(int value); - void v_scroll_value_changed(int value); - - void signals_changed(); - void data_updated(); - - void marker_time_changed(); - - void on_signals_moved(); - - void process_sticky_events(); - - void on_hover_point_changed(); - -private: - SigSession &session_; - - Viewport *viewport_; - Ruler *ruler_; - CursorHeader *cursorheader_; - Header *header_; - - /// The view time scale in seconds per pixel. - double scale_; - - /// The view time offset in seconds. - double offset_; - - int v_offset_; - bool updating_scroll_; - - bool show_cursors_; - CursorPair cursors_; - - QPoint hover_point_; - - unsigned int sticky_events_; - QTimer lazy_event_handler_; -}; - -} // namespace view -} // namespace pv - -#endif // PULSEVIEW_PV_VIEW_VIEW_H diff --git a/pv/view/view.hpp b/pv/view/view.hpp new file mode 100644 index 00000000..c6e585b7 --- /dev/null +++ b/pv/view/view.hpp @@ -0,0 +1,267 @@ +/* + * This file is part of the PulseView project. + * + * 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 + */ + +#ifndef PULSEVIEW_PV_VIEW_VIEW_H +#define PULSEVIEW_PV_VIEW_VIEW_H + +#include + +#include +#include +#include +#include + +#include +#include +#include + +#include + +#include "cursorpair.hpp" +#include "rowitemowner.hpp" + +namespace pv { + +class SigSession; + +namespace view { + +class CursorHeader; +class Header; +class Ruler; +class Viewport; + +class View : public QAbstractScrollArea, public RowItemOwner { + Q_OBJECT + +private: + enum StickyEvents { + SelectableItemHExtentsChanged = 1, + SelectableItemVExtentsChanged = 2 + }; + +private: + static const double MaxScale; + static const double MinScale; + + static const int MaxScrollValue; + +public: + static const QColor CursorAreaColour; + + static const QSizeF LabelPadding; + +public: + explicit View(SigSession &session, QWidget *parent = 0); + + SigSession& session(); + const SigSession& session() const; + + /** + * Returns the view of the owner. + */ + virtual pv::view::View* view(); + + /** + * Returns the view of the owner. + */ + virtual const pv::view::View* view() const; + + Viewport* viewport(); + + const Viewport* viewport() const; + + /** + * Returns the view time scale in seconds per pixel. + */ + double scale() const; + + /** + * Returns the time offset of the left edge of the view in + * seconds. + */ + double offset() const; + int owner_visual_v_offset() const; + + /** + * Returns the number of nested parents that this row item owner has. + */ + unsigned int depth() const; + + void zoom(double steps); + void zoom(double steps, int offset); + + void zoom_fit(); + + void zoom_one_to_one(); + + /** + * Sets the scale and offset. + * @param scale The new view scale in seconds per pixel. + * @param offset The view time offset in seconds. + */ + void set_scale_offset(double scale, double offset); + + std::set< std::shared_ptr > + get_visible_data() const; + + std::pair get_time_extents() const; + + /** + * Returns true if cursors are displayed. false otherwise. + */ + bool cursors_shown() const; + + /** + * Shows or hides the cursors. + */ + void show_cursors(bool show = true); + + /** + * Moves the cursors to a convenient position in the view. + */ + void centre_cursors(); + + /** + * Returns a reference to the pair of cursors. + */ + CursorPair& cursors(); + + /** + * Returns a reference to the pair of cursors. + */ + const CursorPair& cursors() const; + + const QPoint& hover_point() const; + + void update_viewport(); + + void restack_all_row_items(); + +Q_SIGNALS: + void hover_point_changed(); + + void signals_moved(); + + void selection_changed(); + + void scale_offset_changed(); + +private: + void get_scroll_layout(double &length, double &offset) const; + + /** + * Simultaneously sets the zoom and offset. + * @param scale The scale to set the view to in seconds per pixel. This + * value is clamped between MinScale and MaxScale. + * @param offset The offset of the left edge of the view in seconds. + */ + void set_zoom(double scale, int offset); + + void update_scroll(); + + void update_layout(); + + /** + * Satisifies RowItem functionality. + * @param p the QPainter to paint into. + * @param right the x-coordinate of the right edge of the header + * area. + * @param hover true if the label is being hovered over by the mouse. + */ + void paint_label(QPainter &p, int right, bool hover); + + /** + * Computes the outline rectangle of a label. + * @param right the x-coordinate of the right edge of the header + * area. + * @return Returns the rectangle of the signal label. + */ + QRectF label_rect(int right); + + static bool add_channels_to_owner( + const std::vector< std::shared_ptr > &channels, + RowItemOwner *owner, int &offset, + std::unordered_map, + std::shared_ptr > &signal_map, + std::function)> filter_func = + std::function)>()); + + static void apply_offset( + std::shared_ptr row_item, int &offset); + +private: + bool eventFilter(QObject *object, QEvent *event); + + bool viewportEvent(QEvent *e); + + void resizeEvent(QResizeEvent *e); + +public: + void appearance_changed(bool label, bool content); + + void extents_changed(bool horz, bool vert); + +private Q_SLOTS: + + void h_scroll_value_changed(int value); + void v_scroll_value_changed(int value); + + void signals_changed(); + void data_updated(); + + void marker_time_changed(); + + void on_signals_moved(); + + void process_sticky_events(); + + void on_hover_point_changed(); + +private: + SigSession &session_; + + Viewport *viewport_; + Ruler *ruler_; + CursorHeader *cursorheader_; + Header *header_; + + /// The view time scale in seconds per pixel. + double scale_; + + /// The view time offset in seconds. + double offset_; + + int v_offset_; + bool updating_scroll_; + + bool show_cursors_; + CursorPair cursors_; + + QPoint hover_point_; + + unsigned int sticky_events_; + QTimer lazy_event_handler_; +}; + +} // namespace view +} // namespace pv + +#endif // PULSEVIEW_PV_VIEW_VIEW_H diff --git a/pv/view/viewport.cpp b/pv/view/viewport.cpp index 220a10aa..fbbb52bf 100644 --- a/pv/view/viewport.cpp +++ b/pv/view/viewport.cpp @@ -22,11 +22,11 @@ #include #include -#include "view.h" -#include "viewport.h" +#include "signal.hpp" +#include "view.hpp" +#include "viewport.hpp" -#include "signal.h" -#include "../sigsession.h" +#include #include diff --git a/pv/view/viewport.h b/pv/view/viewport.h deleted file mode 100644 index 1171a707..00000000 --- a/pv/view/viewport.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * This file is part of the PulseView project. - * - * 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 - */ - -#ifndef PULSEVIEW_PV_VIEW_VIEWPORT_H -#define PULSEVIEW_PV_VIEW_VIEWPORT_H - -#include -#include -#include - -class QPainter; -class QPaintEvent; -class SigSession; - -namespace pv { -namespace view { - -class View; - -class Viewport : public QWidget -{ - Q_OBJECT - -public: - explicit Viewport(View &parent); - -protected: - void paintEvent(QPaintEvent *event); - -private: - bool event(QEvent *event); - void mousePressEvent(QMouseEvent *event); - void mouseReleaseEvent(QMouseEvent *event); - void mouseMoveEvent(QMouseEvent *event); - void mouseDoubleClickEvent(QMouseEvent * event); - void wheelEvent(QWheelEvent *event); - bool touchEvent(QTouchEvent *e); - -private Q_SLOTS: - void on_signals_moved(); - -private: - View &view_; - - QPoint mouse_down_point_; - double mouse_down_offset_; - bool mouse_down_valid_; - - double pinch_offset0_; - double pinch_offset1_; - bool pinch_zoom_active_; -}; - -} // namespace view -} // namespace pv - -#endif // PULSEVIEW_PV_VIEW_VIEWPORT_H diff --git a/pv/view/viewport.hpp b/pv/view/viewport.hpp new file mode 100644 index 00000000..1171a707 --- /dev/null +++ b/pv/view/viewport.hpp @@ -0,0 +1,74 @@ +/* + * This file is part of the PulseView project. + * + * 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 + */ + +#ifndef PULSEVIEW_PV_VIEW_VIEWPORT_H +#define PULSEVIEW_PV_VIEW_VIEWPORT_H + +#include +#include +#include + +class QPainter; +class QPaintEvent; +class SigSession; + +namespace pv { +namespace view { + +class View; + +class Viewport : public QWidget +{ + Q_OBJECT + +public: + explicit Viewport(View &parent); + +protected: + void paintEvent(QPaintEvent *event); + +private: + bool event(QEvent *event); + void mousePressEvent(QMouseEvent *event); + void mouseReleaseEvent(QMouseEvent *event); + void mouseMoveEvent(QMouseEvent *event); + void mouseDoubleClickEvent(QMouseEvent * event); + void wheelEvent(QWheelEvent *event); + bool touchEvent(QTouchEvent *e); + +private Q_SLOTS: + void on_signals_moved(); + +private: + View &view_; + + QPoint mouse_down_point_; + double mouse_down_offset_; + bool mouse_down_valid_; + + double pinch_offset0_; + double pinch_offset1_; + bool pinch_zoom_active_; +}; + +} // namespace view +} // namespace pv + +#endif // PULSEVIEW_PV_VIEW_VIEWPORT_H diff --git a/pv/widgets/colourbutton.cpp b/pv/widgets/colourbutton.cpp index cf930f65..1f503462 100644 --- a/pv/widgets/colourbutton.cpp +++ b/pv/widgets/colourbutton.cpp @@ -18,7 +18,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "colourbutton.h" +#include "colourbutton.hpp" #include diff --git a/pv/widgets/colourbutton.h b/pv/widgets/colourbutton.h deleted file mode 100644 index a3551486..00000000 --- a/pv/widgets/colourbutton.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * This file is part of the PulseView project. - * - * 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 - */ - -#ifndef PULSEVIEW_PV_WIDGETS_COLOURBUTTON_H -#define PULSEVIEW_PV_WIDGETS_COLOURBUTTON_H - -#include - -#include "colourpopup.h" - -namespace pv { -namespace widgets { - -class ColourButton : public QPushButton -{ - Q_OBJECT; - -private: - static const int SwatchMargin; - -public: - ColourButton(int rows, int cols, QWidget *parent); - - ColourPopup& popup(); - - const QColor& colour() const; - - void set_colour(QColor colour); - - void set_palette(const QColor *const palette); - -private: - void paintEvent(QPaintEvent *e); - -private Q_SLOTS: - void on_clicked(bool); - - void on_selected(int row, int col); - -Q_SIGNALS: - void selected(const QColor &colour); - -private: - ColourPopup popup_; - QColor cur_colour_; -}; - -} // widgets -} // pv - -#endif // PULSEVIEW_PV_WIDGETS_COLOURBUTTON_H diff --git a/pv/widgets/colourbutton.hpp b/pv/widgets/colourbutton.hpp new file mode 100644 index 00000000..d7f019a6 --- /dev/null +++ b/pv/widgets/colourbutton.hpp @@ -0,0 +1,68 @@ +/* + * This file is part of the PulseView project. + * + * 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 + */ + +#ifndef PULSEVIEW_PV_WIDGETS_COLOURBUTTON_H +#define PULSEVIEW_PV_WIDGETS_COLOURBUTTON_H + +#include + +#include "colourpopup.hpp" + +namespace pv { +namespace widgets { + +class ColourButton : public QPushButton +{ + Q_OBJECT; + +private: + static const int SwatchMargin; + +public: + ColourButton(int rows, int cols, QWidget *parent); + + ColourPopup& popup(); + + const QColor& colour() const; + + void set_colour(QColor colour); + + void set_palette(const QColor *const palette); + +private: + void paintEvent(QPaintEvent *e); + +private Q_SLOTS: + void on_clicked(bool); + + void on_selected(int row, int col); + +Q_SIGNALS: + void selected(const QColor &colour); + +private: + ColourPopup popup_; + QColor cur_colour_; +}; + +} // widgets +} // pv + +#endif // PULSEVIEW_PV_WIDGETS_COLOURBUTTON_H diff --git a/pv/widgets/colourpopup.cpp b/pv/widgets/colourpopup.cpp index 285e9a05..bd87c888 100644 --- a/pv/widgets/colourpopup.cpp +++ b/pv/widgets/colourpopup.cpp @@ -18,7 +18,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "colourpopup.h" +#include "colourpopup.hpp" namespace pv { namespace widgets { diff --git a/pv/widgets/colourpopup.h b/pv/widgets/colourpopup.h deleted file mode 100644 index d0441d3c..00000000 --- a/pv/widgets/colourpopup.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * This file is part of the PulseView project. - * - * 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 - */ - -#ifndef PULSEVIEW_PV_WIDGETS_COLOURPOPUP_H -#define PULSEVIEW_PV_WIDGETS_COLOURPOPUP_H - -#include "popup.h" -#include "wellarray.h" - -#include - -namespace pv { -namespace widgets { - -class ColourPopup : public Popup -{ - Q_OBJECT - -public: - ColourPopup(int rows, int cols, QWidget *partent); - - QWellArray& well_array(); - -Q_SIGNALS: - void selected(int row, int col); - -private Q_SLOTS: - void colour_selected(int, int); - -private: - QWellArray well_array_; - QVBoxLayout layout_; -}; - -} // widgets -} // pv - -#endif // PULSEVIEW_PV_WIDGETS_COLOURPOPUP_H diff --git a/pv/widgets/colourpopup.hpp b/pv/widgets/colourpopup.hpp new file mode 100644 index 00000000..a1ee251c --- /dev/null +++ b/pv/widgets/colourpopup.hpp @@ -0,0 +1,55 @@ +/* + * This file is part of the PulseView project. + * + * 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 + */ + +#ifndef PULSEVIEW_PV_WIDGETS_COLOURPOPUP_H +#define PULSEVIEW_PV_WIDGETS_COLOURPOPUP_H + +#include "popup.hpp" +#include "wellarray.hpp" + +#include + +namespace pv { +namespace widgets { + +class ColourPopup : public Popup +{ + Q_OBJECT + +public: + ColourPopup(int rows, int cols, QWidget *partent); + + QWellArray& well_array(); + +Q_SIGNALS: + void selected(int row, int col); + +private Q_SLOTS: + void colour_selected(int, int); + +private: + QWellArray well_array_; + QVBoxLayout layout_; +}; + +} // widgets +} // pv + +#endif // PULSEVIEW_PV_WIDGETS_COLOURPOPUP_H diff --git a/pv/widgets/decodergroupbox.cpp b/pv/widgets/decodergroupbox.cpp index e8723e43..7127ba13 100644 --- a/pv/widgets/decodergroupbox.cpp +++ b/pv/widgets/decodergroupbox.cpp @@ -18,7 +18,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "decodergroupbox.h" +#include "decodergroupbox.hpp" #include #include diff --git a/pv/widgets/decodergroupbox.h b/pv/widgets/decodergroupbox.h deleted file mode 100644 index 2c820762..00000000 --- a/pv/widgets/decodergroupbox.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * This file is part of the PulseView project. - * - * 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 - */ - -#ifndef PULSEVIEW_PV_WIDGETS_DECODERGROUPBOX_H -#define PULSEVIEW_PV_WIDGETS_DECODERGROUPBOX_H - -#include - -class QGridLayout; -class QToolBar; - -namespace pv { -namespace widgets { - -class DecoderGroupBox : public QWidget -{ - Q_OBJECT - -public: - DecoderGroupBox(QString title, QWidget *parent = NULL); - - void add_layout(QLayout *layout); - - void set_decoder_visible(bool visible); - -Q_SIGNALS: - void delete_decoder(); - - void show_hide_decoder(); - -private: - QGridLayout *const layout_; - QPushButton show_hide_button_; -}; - -} // widgets -} // pv - -#endif // PULSEVIEW_PV_WIDGETS_DECODERGROUPBOX_H diff --git a/pv/widgets/decodergroupbox.hpp b/pv/widgets/decodergroupbox.hpp new file mode 100644 index 00000000..2c820762 --- /dev/null +++ b/pv/widgets/decodergroupbox.hpp @@ -0,0 +1,56 @@ +/* + * This file is part of the PulseView project. + * + * 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 + */ + +#ifndef PULSEVIEW_PV_WIDGETS_DECODERGROUPBOX_H +#define PULSEVIEW_PV_WIDGETS_DECODERGROUPBOX_H + +#include + +class QGridLayout; +class QToolBar; + +namespace pv { +namespace widgets { + +class DecoderGroupBox : public QWidget +{ + Q_OBJECT + +public: + DecoderGroupBox(QString title, QWidget *parent = NULL); + + void add_layout(QLayout *layout); + + void set_decoder_visible(bool visible); + +Q_SIGNALS: + void delete_decoder(); + + void show_hide_decoder(); + +private: + QGridLayout *const layout_; + QPushButton show_hide_button_; +}; + +} // widgets +} // pv + +#endif // PULSEVIEW_PV_WIDGETS_DECODERGROUPBOX_H diff --git a/pv/widgets/decodermenu.cpp b/pv/widgets/decodermenu.cpp index 2a1e8395..f3c4e06a 100644 --- a/pv/widgets/decodermenu.cpp +++ b/pv/widgets/decodermenu.cpp @@ -22,7 +22,7 @@ #include -#include "decodermenu.h" +#include "decodermenu.hpp" namespace pv { namespace widgets { diff --git a/pv/widgets/decodermenu.h b/pv/widgets/decodermenu.h deleted file mode 100644 index 92c3a821..00000000 --- a/pv/widgets/decodermenu.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * This file is part of the PulseView project. - * - * 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 - */ - -#ifndef PULSEVIEW_PV_WIDGETS_DECODERMENU_H -#define PULSEVIEW_PV_WIDGETS_DECODERMENU_H - -#include -#include - -struct srd_decoder; - -namespace pv { -namespace widgets { - -class DecoderMenu : public QMenu -{ - Q_OBJECT; - -public: - DecoderMenu(QWidget *parent, bool first_level_decoder = false); - -private: - static int decoder_name_cmp(const void *a, const void *b); - - -private Q_SLOTS: - void on_action(QObject *action); - -Q_SIGNALS: - void decoder_selected(srd_decoder *decoder); - -private: - QSignalMapper mapper_; -}; - -} // widgets -} // pv - -#endif // PULSEVIEW_PV_WIDGETS_DECODERMENU_H diff --git a/pv/widgets/decodermenu.hpp b/pv/widgets/decodermenu.hpp new file mode 100644 index 00000000..92c3a821 --- /dev/null +++ b/pv/widgets/decodermenu.hpp @@ -0,0 +1,56 @@ +/* + * This file is part of the PulseView project. + * + * 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 + */ + +#ifndef PULSEVIEW_PV_WIDGETS_DECODERMENU_H +#define PULSEVIEW_PV_WIDGETS_DECODERMENU_H + +#include +#include + +struct srd_decoder; + +namespace pv { +namespace widgets { + +class DecoderMenu : public QMenu +{ + Q_OBJECT; + +public: + DecoderMenu(QWidget *parent, bool first_level_decoder = false); + +private: + static int decoder_name_cmp(const void *a, const void *b); + + +private Q_SLOTS: + void on_action(QObject *action); + +Q_SIGNALS: + void decoder_selected(srd_decoder *decoder); + +private: + QSignalMapper mapper_; +}; + +} // widgets +} // pv + +#endif // PULSEVIEW_PV_WIDGETS_DECODERMENU_H diff --git a/pv/widgets/popup.cpp b/pv/widgets/popup.cpp index 47280d1f..7143c24a 100644 --- a/pv/widgets/popup.cpp +++ b/pv/widgets/popup.cpp @@ -27,7 +27,7 @@ #include #include -#include "popup.h" +#include "popup.hpp" using std::max; using std::min; diff --git a/pv/widgets/popup.h b/pv/widgets/popup.h deleted file mode 100644 index 83ad7ee0..00000000 --- a/pv/widgets/popup.h +++ /dev/null @@ -1,97 +0,0 @@ -/* - * This file is part of the PulseView project. - * - * 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 - */ - -#ifndef PULSEVIEW_PV_WIDGETS_POPUP_H -#define PULSEVIEW_PV_WIDGETS_POPUP_H - -#include - -namespace pv { -namespace widgets { - -class Popup : public QWidget -{ - Q_OBJECT - -public: - enum Position - { - Right, - Top, - Left, - Bottom - }; - -private: - static const unsigned int ArrowLength; - static const unsigned int ArrowOverlap; - static const unsigned int MarginWidth; - -public: - Popup(QWidget *parent); - - const QPoint& point() const; - Position position() const; - - void set_position(const QPoint point, Position pos); - - bool eventFilter(QObject *obj, QEvent *evt); - - void show(); - -private: - bool space_for_arrow() const; - - QPolygon arrow_polygon() const; - - QRegion arrow_region() const; - - QRect bubble_rect() const; - - QRegion bubble_region() const; - - QRegion popup_region() const; - - void reposition_widget(); - -private: - void closeEvent(QCloseEvent*); - - void paintEvent(QPaintEvent*); - - void resizeEvent(QResizeEvent*); - - void mouseReleaseEvent(QMouseEvent *e); - -protected: - void showEvent(QShowEvent *e); - -Q_SIGNALS: - void closed(); - -private: - QPoint point_; - Position pos_; -}; - -} // namespace widgets -} // namespace pv - -#endif // PULSEVIEW_PV_WIDGETS_POPUP_H diff --git a/pv/widgets/popup.hpp b/pv/widgets/popup.hpp new file mode 100644 index 00000000..83ad7ee0 --- /dev/null +++ b/pv/widgets/popup.hpp @@ -0,0 +1,97 @@ +/* + * This file is part of the PulseView project. + * + * 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 + */ + +#ifndef PULSEVIEW_PV_WIDGETS_POPUP_H +#define PULSEVIEW_PV_WIDGETS_POPUP_H + +#include + +namespace pv { +namespace widgets { + +class Popup : public QWidget +{ + Q_OBJECT + +public: + enum Position + { + Right, + Top, + Left, + Bottom + }; + +private: + static const unsigned int ArrowLength; + static const unsigned int ArrowOverlap; + static const unsigned int MarginWidth; + +public: + Popup(QWidget *parent); + + const QPoint& point() const; + Position position() const; + + void set_position(const QPoint point, Position pos); + + bool eventFilter(QObject *obj, QEvent *evt); + + void show(); + +private: + bool space_for_arrow() const; + + QPolygon arrow_polygon() const; + + QRegion arrow_region() const; + + QRect bubble_rect() const; + + QRegion bubble_region() const; + + QRegion popup_region() const; + + void reposition_widget(); + +private: + void closeEvent(QCloseEvent*); + + void paintEvent(QPaintEvent*); + + void resizeEvent(QResizeEvent*); + + void mouseReleaseEvent(QMouseEvent *e); + +protected: + void showEvent(QShowEvent *e); + +Q_SIGNALS: + void closed(); + +private: + QPoint point_; + Position pos_; +}; + +} // namespace widgets +} // namespace pv + +#endif // PULSEVIEW_PV_WIDGETS_POPUP_H diff --git a/pv/widgets/popuptoolbutton.cpp b/pv/widgets/popuptoolbutton.cpp index a5886aaf..75aa76a5 100644 --- a/pv/widgets/popuptoolbutton.cpp +++ b/pv/widgets/popuptoolbutton.cpp @@ -20,7 +20,7 @@ #include -#include "popuptoolbutton.h" +#include "popuptoolbutton.hpp" namespace pv { namespace widgets { diff --git a/pv/widgets/popuptoolbutton.h b/pv/widgets/popuptoolbutton.h deleted file mode 100644 index 3a3fc63b..00000000 --- a/pv/widgets/popuptoolbutton.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * This file is part of the PulseView project. - * - * 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 - */ - -#ifndef PULSEVIEW_PV_WIDGETS_POPUPTOOLBUTTON_H -#define PULSEVIEW_PV_WIDGETS_POPUPTOOLBUTTON_H - -#include "popup.h" - -#include - -namespace pv { -namespace widgets { - -class PopupToolButton : public QToolButton -{ - Q_OBJECT; - -public: - PopupToolButton(QWidget *parent); - - Popup* popup() const; - - void set_popup(Popup *popup); - -private Q_SLOTS: - void on_clicked(bool); - -private: - Popup *popup_; -}; - -} // widgets -} // pv - -#endif // PULSEVIEW_PV_WIDGETS_POPUPTOOLBUTTON_H diff --git a/pv/widgets/popuptoolbutton.hpp b/pv/widgets/popuptoolbutton.hpp new file mode 100644 index 00000000..6f6111d5 --- /dev/null +++ b/pv/widgets/popuptoolbutton.hpp @@ -0,0 +1,52 @@ +/* + * This file is part of the PulseView project. + * + * 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 + */ + +#ifndef PULSEVIEW_PV_WIDGETS_POPUPTOOLBUTTON_H +#define PULSEVIEW_PV_WIDGETS_POPUPTOOLBUTTON_H + +#include "popup.hpp" + +#include + +namespace pv { +namespace widgets { + +class PopupToolButton : public QToolButton +{ + Q_OBJECT; + +public: + PopupToolButton(QWidget *parent); + + Popup* popup() const; + + void set_popup(Popup *popup); + +private Q_SLOTS: + void on_clicked(bool); + +private: + Popup *popup_; +}; + +} // widgets +} // pv + +#endif // PULSEVIEW_PV_WIDGETS_POPUPTOOLBUTTON_H diff --git a/pv/widgets/sweeptimingwidget.cpp b/pv/widgets/sweeptimingwidget.cpp index 1c1581bb..b2c0e637 100644 --- a/pv/widgets/sweeptimingwidget.cpp +++ b/pv/widgets/sweeptimingwidget.cpp @@ -18,7 +18,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "sweeptimingwidget.h" +#include "sweeptimingwidget.hpp" #include diff --git a/pv/widgets/sweeptimingwidget.h b/pv/widgets/sweeptimingwidget.h deleted file mode 100644 index 5510865e..00000000 --- a/pv/widgets/sweeptimingwidget.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * This file is part of the PulseView project. - * - * 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 - */ - -#ifndef PULSEVIEW_PV_WIDGETS_SWEEPTIMINGWIDGET_H -#define PULSEVIEW_PV_WIDGETS_SWEEPTIMINGWIDGET_H - -#include - -#include -#include -#include -#include -#include - -namespace pv { -namespace widgets { - -class SweepTimingWidget : public QWidget -{ - Q_OBJECT - -private: - enum ValueType - { - None, - MinMaxStep, - List - }; - -public: - SweepTimingWidget(const char *suffix, QWidget *parent = NULL); - - void show_none(); - void show_min_max_step(uint64_t min, uint64_t max, uint64_t step); - void show_list(const uint64_t *vals, size_t count); - void show_125_list(uint64_t min, uint64_t max); - - uint64_t value() const; - void set_value(uint64_t value); - -Q_SIGNALS: - void value_changed(); - -private: - const char *const suffix_; - - QHBoxLayout layout_; - - QDoubleSpinBox value_; - QComboBox list_; - - ValueType value_type_; -}; - -} // widgets -} // pv - -#endif // PULSEVIEW_PV_WIDGETS_SWEEPTIMINGWIDGET_H diff --git a/pv/widgets/sweeptimingwidget.hpp b/pv/widgets/sweeptimingwidget.hpp new file mode 100644 index 00000000..5510865e --- /dev/null +++ b/pv/widgets/sweeptimingwidget.hpp @@ -0,0 +1,75 @@ +/* + * This file is part of the PulseView project. + * + * 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 + */ + +#ifndef PULSEVIEW_PV_WIDGETS_SWEEPTIMINGWIDGET_H +#define PULSEVIEW_PV_WIDGETS_SWEEPTIMINGWIDGET_H + +#include + +#include +#include +#include +#include +#include + +namespace pv { +namespace widgets { + +class SweepTimingWidget : public QWidget +{ + Q_OBJECT + +private: + enum ValueType + { + None, + MinMaxStep, + List + }; + +public: + SweepTimingWidget(const char *suffix, QWidget *parent = NULL); + + void show_none(); + void show_min_max_step(uint64_t min, uint64_t max, uint64_t step); + void show_list(const uint64_t *vals, size_t count); + void show_125_list(uint64_t min, uint64_t max); + + uint64_t value() const; + void set_value(uint64_t value); + +Q_SIGNALS: + void value_changed(); + +private: + const char *const suffix_; + + QHBoxLayout layout_; + + QDoubleSpinBox value_; + QComboBox list_; + + ValueType value_type_; +}; + +} // widgets +} // pv + +#endif // PULSEVIEW_PV_WIDGETS_SWEEPTIMINGWIDGET_H diff --git a/pv/widgets/wellarray.cpp b/pv/widgets/wellarray.cpp index fb674431..26c257ac 100644 --- a/pv/widgets/wellarray.cpp +++ b/pv/widgets/wellarray.cpp @@ -44,7 +44,7 @@ #include #include -#include "wellarray.h" +#include "wellarray.hpp" void QWellArray::paintEvent(QPaintEvent *e) { diff --git a/pv/widgets/wellarray.h b/pv/widgets/wellarray.h deleted file mode 100644 index ebe3c000..00000000 --- a/pv/widgets/wellarray.h +++ /dev/null @@ -1,133 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include - -struct QWellArrayData; - -class QWellArray : public QWidget -{ - Q_OBJECT - Q_PROPERTY(int selectedColumn READ selectedColumn) - Q_PROPERTY(int selectedRow READ selectedRow) - -public: - QWellArray(int rows, int cols, QWidget* parent=0); - QString cellContent(int row, int col) const; - - int selectedColumn() const { return selCol; } - int selectedRow() const { return selRow; } - - virtual void setCurrent(int row, int col); - virtual void setSelected(int row, int col); - - QSize sizeHint() const; - - virtual void setCellBrush(int row, int col, const QBrush &); - QBrush cellBrush(int row, int col); - - inline int cellWidth() const - { return cellw; } - - inline int cellHeight() const - { return cellh; } - - inline int rowAt(int y) const - { return y / cellh; } - - inline int columnAt(int x) const - { if (isRightToLeft()) return ncols - (x / cellw) - 1; return x / cellw; } - - inline int rowY(int row) const - { return cellh * row; } - - inline int columnX(int column) const - { if (isRightToLeft()) return cellw * (ncols - column - 1); return cellw * column; } - - inline int numRows() const - { return nrows; } - - inline int numCols() const - {return ncols; } - - inline QRect cellRect() const - { return QRect(0, 0, cellw, cellh); } - - inline QSize gridSize() const - { return QSize(ncols * cellw, nrows * cellh); } - - QRect cellGeometry(int row, int column) - { - QRect r; - if (row >= 0 && row < nrows && column >= 0 && column < ncols) - r.setRect(columnX(column), rowY(row), cellw, cellh); - return r; - } - - inline void updateCell(int row, int column) { update(cellGeometry(row, column)); } - -Q_SIGNALS: - void selected(int row, int col); - -protected: - virtual void paintCell(QPainter *, int row, int col, const QRect&); - virtual void paintCellContents(QPainter *, int row, int col, const QRect&); - - void mousePressEvent(QMouseEvent*); - void mouseReleaseEvent(QMouseEvent*); - void keyPressEvent(QKeyEvent*); - void focusInEvent(QFocusEvent*); - void focusOutEvent(QFocusEvent*); - void paintEvent(QPaintEvent *); - -private: - Q_DISABLE_COPY(QWellArray) - - int nrows; - int ncols; - int cellw; - int cellh; - int curRow; - int curCol; - int selRow; - int selCol; - QWellArrayData *d; -}; diff --git a/pv/widgets/wellarray.hpp b/pv/widgets/wellarray.hpp new file mode 100644 index 00000000..ebe3c000 --- /dev/null +++ b/pv/widgets/wellarray.hpp @@ -0,0 +1,133 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +struct QWellArrayData; + +class QWellArray : public QWidget +{ + Q_OBJECT + Q_PROPERTY(int selectedColumn READ selectedColumn) + Q_PROPERTY(int selectedRow READ selectedRow) + +public: + QWellArray(int rows, int cols, QWidget* parent=0); + QString cellContent(int row, int col) const; + + int selectedColumn() const { return selCol; } + int selectedRow() const { return selRow; } + + virtual void setCurrent(int row, int col); + virtual void setSelected(int row, int col); + + QSize sizeHint() const; + + virtual void setCellBrush(int row, int col, const QBrush &); + QBrush cellBrush(int row, int col); + + inline int cellWidth() const + { return cellw; } + + inline int cellHeight() const + { return cellh; } + + inline int rowAt(int y) const + { return y / cellh; } + + inline int columnAt(int x) const + { if (isRightToLeft()) return ncols - (x / cellw) - 1; return x / cellw; } + + inline int rowY(int row) const + { return cellh * row; } + + inline int columnX(int column) const + { if (isRightToLeft()) return cellw * (ncols - column - 1); return cellw * column; } + + inline int numRows() const + { return nrows; } + + inline int numCols() const + {return ncols; } + + inline QRect cellRect() const + { return QRect(0, 0, cellw, cellh); } + + inline QSize gridSize() const + { return QSize(ncols * cellw, nrows * cellh); } + + QRect cellGeometry(int row, int column) + { + QRect r; + if (row >= 0 && row < nrows && column >= 0 && column < ncols) + r.setRect(columnX(column), rowY(row), cellw, cellh); + return r; + } + + inline void updateCell(int row, int column) { update(cellGeometry(row, column)); } + +Q_SIGNALS: + void selected(int row, int col); + +protected: + virtual void paintCell(QPainter *, int row, int col, const QRect&); + virtual void paintCellContents(QPainter *, int row, int col, const QRect&); + + void mousePressEvent(QMouseEvent*); + void mouseReleaseEvent(QMouseEvent*); + void keyPressEvent(QKeyEvent*); + void focusInEvent(QFocusEvent*); + void focusOutEvent(QFocusEvent*); + void paintEvent(QPaintEvent *); + +private: + Q_DISABLE_COPY(QWellArray) + + int nrows; + int ncols; + int cellw; + int cellh; + int curRow; + int curCol; + int selRow; + int selCol; + QWellArrayData *d; +}; diff --git a/signalhandler.cpp b/signalhandler.cpp index 475f49b0..66acc1fd 100644 --- a/signalhandler.cpp +++ b/signalhandler.cpp @@ -18,7 +18,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "signalhandler.h" +#include "signalhandler.hpp" #include #include diff --git a/signalhandler.h b/signalhandler.h deleted file mode 100644 index fe54ff2a..00000000 --- a/signalhandler.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * This file is part of the PulseView project. - * - * Copyright (C) 2013 Adam Reichold - * - * 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 SIGNALHANDLER_H -#define SIGNALHANDLER_H - -#include - -class QSocketNotifier; - -class SignalHandler : public QObject -{ - Q_OBJECT - -public: - static bool prepare_signals(); - -public: - explicit SignalHandler(QObject* parent = NULL); - -Q_SIGNALS: - void int_received(); - void term_received(); - -private Q_SLOTS: - void on_socket_notifier_activated(); - -private: - static void handle_signals(int sig_number); - -private: - QSocketNotifier* socket_notifier_; - -private: - static int sockets_[2]; -}; - -#endif // SIGNALHANDLER_H diff --git a/signalhandler.hpp b/signalhandler.hpp new file mode 100644 index 00000000..fe54ff2a --- /dev/null +++ b/signalhandler.hpp @@ -0,0 +1,55 @@ +/* + * This file is part of the PulseView project. + * + * Copyright (C) 2013 Adam Reichold + * + * 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 SIGNALHANDLER_H +#define SIGNALHANDLER_H + +#include + +class QSocketNotifier; + +class SignalHandler : public QObject +{ + Q_OBJECT + +public: + static bool prepare_signals(); + +public: + explicit SignalHandler(QObject* parent = NULL); + +Q_SIGNALS: + void int_received(); + void term_received(); + +private Q_SLOTS: + void on_socket_notifier_activated(); + +private: + static void handle_signals(int sig_number); + +private: + QSocketNotifier* socket_notifier_; + +private: + static int sockets_[2]; +}; + +#endif // SIGNALHANDLER_H diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 4bac48bb..7c454c02 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -87,29 +87,29 @@ set(pulseview_TEST_SOURCES # This list includes only QObject derived class headers. set(pulseview_TEST_HEADERS - ${PROJECT_SOURCE_DIR}/pv/sigsession.h - ${PROJECT_SOURCE_DIR}/pv/prop/double.h - ${PROJECT_SOURCE_DIR}/pv/prop/enum.h - ${PROJECT_SOURCE_DIR}/pv/prop/int.h - ${PROJECT_SOURCE_DIR}/pv/prop/property.h - ${PROJECT_SOURCE_DIR}/pv/prop/string.h - ${PROJECT_SOURCE_DIR}/pv/prop/binding/deviceoptions.h - ${PROJECT_SOURCE_DIR}/pv/view/cursor.h - ${PROJECT_SOURCE_DIR}/pv/view/cursorheader.h - ${PROJECT_SOURCE_DIR}/pv/view/header.h - ${PROJECT_SOURCE_DIR}/pv/view/logicsignal.h - ${PROJECT_SOURCE_DIR}/pv/view/marginwidget.h - ${PROJECT_SOURCE_DIR}/pv/view/ruler.h - ${PROJECT_SOURCE_DIR}/pv/view/selectableitem.h - ${PROJECT_SOURCE_DIR}/pv/view/signal.h - ${PROJECT_SOURCE_DIR}/pv/view/timemarker.h - ${PROJECT_SOURCE_DIR}/pv/view/trace.h - ${PROJECT_SOURCE_DIR}/pv/view/view.h - ${PROJECT_SOURCE_DIR}/pv/view/viewport.h - ${PROJECT_SOURCE_DIR}/pv/widgets/colourbutton.h - ${PROJECT_SOURCE_DIR}/pv/widgets/colourpopup.h - ${PROJECT_SOURCE_DIR}/pv/widgets/popup.h - ${PROJECT_SOURCE_DIR}/pv/widgets/wellarray.h + ${PROJECT_SOURCE_DIR}/pv/sigsession.hpp + ${PROJECT_SOURCE_DIR}/pv/prop/double.hpp + ${PROJECT_SOURCE_DIR}/pv/prop/enum.hpp + ${PROJECT_SOURCE_DIR}/pv/prop/int.hpp + ${PROJECT_SOURCE_DIR}/pv/prop/property.hpp + ${PROJECT_SOURCE_DIR}/pv/prop/string.hpp + ${PROJECT_SOURCE_DIR}/pv/prop/binding/deviceoptions.hpp + ${PROJECT_SOURCE_DIR}/pv/view/cursor.hpp + ${PROJECT_SOURCE_DIR}/pv/view/cursorheader.hpp + ${PROJECT_SOURCE_DIR}/pv/view/header.hpp + ${PROJECT_SOURCE_DIR}/pv/view/logicsignal.hpp + ${PROJECT_SOURCE_DIR}/pv/view/marginwidget.hpp + ${PROJECT_SOURCE_DIR}/pv/view/ruler.hpp + ${PROJECT_SOURCE_DIR}/pv/view/selectableitem.hpp + ${PROJECT_SOURCE_DIR}/pv/view/signal.hpp + ${PROJECT_SOURCE_DIR}/pv/view/timemarker.hpp + ${PROJECT_SOURCE_DIR}/pv/view/trace.hpp + ${PROJECT_SOURCE_DIR}/pv/view/view.hpp + ${PROJECT_SOURCE_DIR}/pv/view/viewport.hpp + ${PROJECT_SOURCE_DIR}/pv/widgets/colourbutton.hpp + ${PROJECT_SOURCE_DIR}/pv/widgets/colourpopup.hpp + ${PROJECT_SOURCE_DIR}/pv/widgets/popup.hpp + ${PROJECT_SOURCE_DIR}/pv/widgets/wellarray.hpp ) if(ENABLE_DECODE) @@ -127,10 +127,10 @@ if(ENABLE_DECODE) ) list(APPEND pulseview_TEST_HEADERS - ${PROJECT_SOURCE_DIR}/pv/data/decoderstack.h - ${PROJECT_SOURCE_DIR}/pv/view/decodetrace.h - ${PROJECT_SOURCE_DIR}/pv/widgets/decodergroupbox.h - ${PROJECT_SOURCE_DIR}/pv/widgets/decodermenu.h + ${PROJECT_SOURCE_DIR}/pv/data/decoderstack.hpp + ${PROJECT_SOURCE_DIR}/pv/view/decodetrace.hpp + ${PROJECT_SOURCE_DIR}/pv/widgets/decodergroupbox.hpp + ${PROJECT_SOURCE_DIR}/pv/widgets/decodermenu.hpp ) endif() diff --git a/test/data/analogsnapshot.cpp b/test/data/analogsnapshot.cpp index 159050aa..3dd04ed6 100644 --- a/test/data/analogsnapshot.cpp +++ b/test/data/analogsnapshot.cpp @@ -24,7 +24,7 @@ #include -#include "../../pv/data/analogsnapshot.h" +#include using pv::data::AnalogSnapshot; diff --git a/test/data/logicsnapshot.cpp b/test/data/logicsnapshot.cpp index 1b5eb24a..4ad23aa4 100644 --- a/test/data/logicsnapshot.cpp +++ b/test/data/logicsnapshot.cpp @@ -24,7 +24,7 @@ #include -#include "../../pv/data/logicsnapshot.h" +#include using pv::data::LogicSnapshot; using std::vector;