diff --git a/DSView/main.cpp b/DSView/main.cpp index cb3d83ae..fa87b03c 100755 --- a/DSView/main.cpp +++ b/DSView/main.cpp @@ -161,16 +161,17 @@ int main(int argc, char *argv[]) dir.cd("share") && dir.cd(QApplication::applicationName()) && dir.cd("res")) { + // the path command like: cd ../share/DSView/res QString res_dir = dir.absolutePath() + "/"; strcpy(DS_RES_PATH, res_dir.toUtf8().data()); } else { - qDebug() << "ERROR: config files don't exist."; + qDebug() << "DSView run ERROR: config files don't exist."; return 1; } // Initialise libsigrok if (sr_init(&sr_ctx) != SR_OK) { - qDebug() << "ERROR: libsigrok init failed."; + qDebug() << "DSView run ERROR: libsigrok init failed."; return 1; } @@ -194,7 +195,7 @@ int main(int argc, char *argv[]) pv::MainFrame w(device_manager, open_file); w.show(); w.readSettings(); - w.show_doc(); + w.show_doc(); // to show the dailog for open help document // Run the application ret = a.exec(); diff --git a/DSView/pv/devicemanager.cpp b/DSView/pv/devicemanager.cpp index d7778be5..aacfd7d1 100755 --- a/DSView/pv/devicemanager.cpp +++ b/DSView/pv/devicemanager.cpp @@ -105,7 +105,7 @@ std::list > DeviceManager::driver_scan( } else { i++; } - } + } // Clear all the old device instances from this driver sr_dev_clear(driver); diff --git a/DSView/pv/dialogs/storeprogress.cpp b/DSView/pv/dialogs/storeprogress.cpp index 2bb91a18..b74daaa4 100755 --- a/DSView/pv/dialogs/storeprogress.cpp +++ b/DSView/pv/dialogs/storeprogress.cpp @@ -69,7 +69,7 @@ void StoreProgress::timeout() if (_done) { _store_session.session().set_saving(false); save_done(); - close(); + close(); } else { QTimer::singleShot(100, this, SLOT(timeout())); } diff --git a/DSView/pv/mainframe.cpp b/DSView/pv/mainframe.cpp index 4ed79087..714de50b 100755 --- a/DSView/pv/mainframe.cpp +++ b/DSView/pv/mainframe.cpp @@ -77,11 +77,10 @@ MainFrame::MainFrame(DeviceManager &device_manager, // Title _titleBar = new toolbars::TitleBar(true, this); _titleBar->installEventFilter(this); - + // MainWindow _mainWindow = new MainWindow(device_manager, open_file_name, this); _mainWindow->setWindowFlags(Qt::Widget); - _titleBar->setTitle(_mainWindow->windowTitle()); QVBoxLayout *vbox = new QVBoxLayout(); @@ -185,7 +184,7 @@ void MainFrame::hide_border() } void MainFrame::show_border() -{ +{ _top_left->setVisible(true); _top_right->setVisible(true); _top->setVisible(true); diff --git a/DSView/pv/mainwindow.cpp b/DSView/pv/mainwindow.cpp index 2fea92dd..746f34f2 100755 --- a/DSView/pv/mainwindow.cpp +++ b/DSView/pv/mainwindow.cpp @@ -870,6 +870,7 @@ void MainWindow::on_screenShot() } } +//save file void MainWindow::on_save() { using pv::dialogs::StoreProgress; @@ -1227,7 +1228,7 @@ bool MainWindow::store_session(QString name) QJsonDocument sessionDoc(sessionVar); //sessionFile.write(QString::fromUtf8(sessionDoc.toJson())); outStream << QString::fromUtf8(sessionDoc.toJson()); - sessionFile.close(); + sessionFile.close(); return true; } diff --git a/DSView/pv/mainwindow.h b/DSView/pv/mainwindow.h index 0af21189..0069b1e5 100755 --- a/DSView/pv/mainwindow.h +++ b/DSView/pv/mainwindow.h @@ -63,6 +63,8 @@ namespace view { class View; } +//The mainwindow,referenced by MainFrame +//TODO: create graph view,toolbar,and show device list class MainWindow : public QMainWindow { Q_OBJECT @@ -186,7 +188,7 @@ private: toolbars::SamplingBar *_sampling_bar; toolbars::TrigBar *_trig_bar; toolbars::FileBar *_file_bar; - toolbars::LogoBar *_logo_bar; + toolbars::LogoBar *_logo_bar; //help button, on top right #ifdef ENABLE_DECODE QDockWidget *_protocol_dock; diff --git a/DSView/pv/sigsession.cpp b/DSView/pv/sigsession.cpp index f55f1058..df1afdc0 100755 --- a/DSView/pv/sigsession.cpp +++ b/DSView/pv/sigsession.cpp @@ -156,6 +156,9 @@ boost::shared_ptr SigSession::get_device() const return _dev_inst; } +/* + when be called, it will call 4DSL lib sr_session_new, and create a session struct in the lib +*/ void SigSession::set_device(boost::shared_ptr dev_inst) { using pv::device::Device; @@ -746,8 +749,8 @@ void SigSession::init_signals() switch(probe->type) { case SR_CHANNEL_LOGIC: if (probe->enabled) - signal = boost::shared_ptr( - new view::LogicSignal(_dev_inst, _logic_data, probe)); + signal = boost::shared_ptr( + new view::LogicSignal(_dev_inst, _logic_data, probe)); break; case SR_CHANNEL_DSO: @@ -803,7 +806,7 @@ void SigSession::reload() boost::shared_ptr logicSig; if ((logicSig = dynamic_pointer_cast(*i))) signal = boost::shared_ptr( - new view::LogicSignal(logicSig, _logic_data, probe)); + new view::LogicSignal(logicSig, _logic_data, probe)); break; } i++; diff --git a/DSView/pv/sigsession.h b/DSView/pv/sigsession.h index 96fd0649..0f9d46ca 100755 --- a/DSView/pv/sigsession.h +++ b/DSView/pv/sigsession.h @@ -92,6 +92,7 @@ class Decoder; class DecoderFactory; } +//created by MainWindow class SigSession : public QObject { Q_OBJECT @@ -291,8 +292,10 @@ private: void feed_in_logic(const sr_datafeed_logic &logic); void feed_in_dso(const sr_datafeed_dso &dso); void feed_in_analog(const sr_datafeed_analog &analog); + void data_feed_in(const struct sr_dev_inst *sdi, const struct sr_datafeed_packet *packet); + static void data_feed_in_proc(const struct sr_dev_inst *sdi, const struct sr_datafeed_packet *packet, void *cb_data); diff --git a/DSView/pv/storesession.cpp b/DSView/pv/storesession.cpp index d41881ac..18ad1bd5 100755 --- a/DSView/pv/storesession.cpp +++ b/DSView/pv/storesession.cpp @@ -60,6 +60,20 @@ using std::vector; namespace pv { + char chunk_name[30] = {0}; + + void MakeChunkName(int chunk_num, int index, int type, int version){ + if (version == 2) { + const char *type_name = NULL; + type_name = (type == SR_CHANNEL_LOGIC) ? "L" : + (type == SR_CHANNEL_DSO) ? "O" : + (type == SR_CHANNEL_ANALOG) ? "A" : "U"; + snprintf(chunk_name, 15, "%s-%d/%d", type_name, index, chunk_num); + } else { + snprintf(chunk_name, 15, "data"); + } + } + StoreSession::StoreSession(SigSession &session) : _session(session), _outModule(NULL), @@ -179,6 +193,8 @@ bool StoreSession::save_start(QString session_file) #else QString decoders_file = NULL; #endif + + /* if (meta_file == NULL) { _error = tr("Generate temp file failed."); } else { @@ -193,6 +209,23 @@ bool StoreSession::save_start(QString session_file) return !_has_error; } } + */ + + //make zip file + if (meta_file != NULL && m_zipDoc.CreateNew()) + { + if ( !m_zipDoc.AddFromFile(meta_file.toUtf8().data(), "header") + || !m_zipDoc.AddFromFile(decoders_file.toUtf8().data(), "decoders") + || !m_zipDoc.AddFromFile(session_file.toUtf8().data(), "session")) + { + _has_error = true; + _error = m_zipDoc.GetError(); + } + else{ + _thread = boost::thread(&StoreSession::save_proc, this, snapshot); + return !_has_error; + } + } } QFile::remove(_file_name); @@ -239,8 +272,13 @@ void StoreSession::save_proc(shared_ptr snapshot) memset(buf, sample ? 0xff : 0x0, size); } } - ret = sr_session_append(_file_name.toUtf8().data(), buf, size, - i, ch_index, ch_type, File_Version); + + // ret = sr_session_append(_file_name.toUtf8().data(), buf, size, + // i, ch_index, ch_type, File_Version); + + MakeChunkName(i, ch_index, ch_type, File_Version); + ret = m_zipDoc.AddFromBuffer(chunk_name, (const char*)buf, size) ? SR_OK : -1; + if (ret != SR_OK) { if (!_has_error) { _has_error = true; @@ -285,19 +323,30 @@ void StoreSession::save_proc(shared_ptr snapshot) memcpy(tmp, buf, buf_end-buf); memcpy(tmp+(buf_end-buf), buf_start, buf+size-buf_end); } - ret = sr_session_append(_file_name.toUtf8().data(), tmp, size, - i, 0, ch_type, File_Version); + + ret = sr_session_append(_file_name.toUtf8().data(), tmp, size, + i, 0, ch_type, File_Version); + + MakeChunkName(i, 0, ch_type, File_Version); + ret = m_zipDoc.AddFromBuffer(chunk_name, (const char*)tmp, size) ? SR_OK : -1; + buf += (size - _unit_count); if (tmp) free(tmp); } else { - ret = sr_session_append(_file_name.toUtf8().data(), buf, size, - i, 0, ch_type, File_Version); + + // ret = sr_session_append(_file_name.toUtf8().data(), buf, size, + // i, 0, ch_type, File_Version); + + MakeChunkName(i, 0, ch_type, File_Version); + ret = m_zipDoc.AddFromBuffer(chunk_name, (const char*)buf, size) ? SR_OK : -1; + buf += size; } if (ret != SR_OK) { if (!_has_error) { _has_error = true; + auto err = m_zipDoc.GetError(); _error = tr("Failed to create zip file. Please check write permission of this path."); } progress_updated(); @@ -314,6 +363,15 @@ void StoreSession::save_proc(shared_ptr snapshot) if (_canceled || num == 0) QFile::remove(_file_name); + else { + bool bret = m_zipDoc.SaveToFile(_file_name.toUtf8().data()); + m_zipDoc.Release(); + + if (!bret){ + _has_error = true; + _error = m_zipDoc.GetError(); + } + } } QString StoreSession::meta_gen(boost::shared_ptr snapshot) diff --git a/DSView/pv/storesession.h b/DSView/pv/storesession.h index 2f369385..09dc4e3a 100755 --- a/DSView/pv/storesession.h +++ b/DSView/pv/storesession.h @@ -31,6 +31,7 @@ #include #include +#include "ZipMaker.h" namespace pv { @@ -106,6 +107,7 @@ private: bool _has_error; QString _error; bool _canceled; + ZipMaker m_zipDoc; }; } // pv diff --git a/DSView/pv/toolbars/filebar.h b/DSView/pv/toolbars/filebar.h index 3696fab5..0f55c3db 100755 --- a/DSView/pv/toolbars/filebar.h +++ b/DSView/pv/toolbars/filebar.h @@ -33,6 +33,8 @@ namespace pv { namespace toolbars { +//toolbar button,referenced by MainWindow +//TODO: load session file, sorte session, load log data file, sorte data, export data class FileBar : public QToolBar { Q_OBJECT @@ -55,12 +57,12 @@ private: const QString text, const QString info_text); signals: - void load_file(QString); + void load_file(QString); void on_save(); void on_export(); - void on_screenShot(); - void load_session(QString); - void store_session(QString); + void on_screenShot(); //post screen capture event message + void load_session(QString); //post load session event message + void store_session(QString); //post store session event message private slots: void on_actionLoad_triggered(); @@ -77,7 +79,7 @@ private: QMenu *_menu; - QMenu *_menu_session; + QMenu *_menu_session; //when the hardware device is connected,it will be enable QAction *_action_load; QAction *_action_store; QAction *_action_default; diff --git a/DSView/pv/toolbars/logobar.h b/DSView/pv/toolbars/logobar.h index caf686c5..691793a7 100755 --- a/DSView/pv/toolbars/logobar.h +++ b/DSView/pv/toolbars/logobar.h @@ -35,6 +35,8 @@ namespace pv { namespace toolbars { +//The tool button for help,is a ui class,referenced by MainWindow +//TODO: switch language,submit bug descript, class LogoBar : public QToolBar { Q_OBJECT @@ -44,6 +46,7 @@ public: void enable_toggle(bool enable); + //show the hardware device conneted status with logo picture void dsl_connected(bool conn); private: @@ -57,8 +60,11 @@ private: const QString text, const QString info_text); signals: - void setLanguage(int language); - void openDoc(); + //post event message to set language, MainWindow class receive it + void setLanguage(int language); + + //post event message to open user help document, MainWindow class receive it + void openDoc(); private slots: void on_actionEn_triggered(); diff --git a/DSView/pv/toolbars/samplingbar.h b/DSView/pv/toolbars/samplingbar.h index 567eff1f..a19298b9 100755 --- a/DSView/pv/toolbars/samplingbar.h +++ b/DSView/pv/toolbars/samplingbar.h @@ -19,7 +19,6 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ - #ifndef DSVIEW_PV_TOOLBARS_SAMPLINGBAR_H #define DSVIEW_PV_TOOLBARS_SAMPLINGBAR_H @@ -40,134 +39,137 @@ struct st_dev_inst; class QAction; -namespace pv { +namespace pv +{ + class SigSession; -class SigSession; + namespace device + { + // class DevInst; + } -namespace device { -class DevInst; -} + namespace dialogs + { + class deviceoptions; + class Calibration; + } -namespace dialogs { -class deviceoptions; -class Calibration; -} + namespace toolbars + { -namespace toolbars { + class SamplingBar : public QToolBar + { + Q_OBJECT -class SamplingBar : public QToolBar -{ - Q_OBJECT + private: + static const int ComboBoxMaxWidth = 200; + static const int RefreshShort = 500; + static const uint64_t LogicMaxSWDepth64 = SR_GB(16); + static const uint64_t LogicMaxSWDepth32 = SR_GB(8); + static const uint64_t AnalogMaxSWDepth = SR_Mn(100); + static const QString RLEString; + static const QString DIVString; + static const uint64_t ZeroTimeBase = SR_US(2); -private: - static const int ComboBoxMaxWidth = 200; - static const int RefreshShort = 500; - static const uint64_t LogicMaxSWDepth64 = SR_GB(16); - static const uint64_t LogicMaxSWDepth32 = SR_GB(8); - static const uint64_t AnalogMaxSWDepth = SR_Mn(100); - static const QString RLEString; - static const QString DIVString; - static const uint64_t ZeroTimeBase = SR_US(2); + public: + SamplingBar(SigSession &session, QWidget *parent); -public: - SamplingBar(SigSession &session, QWidget *parent); + void set_device_list(const std::list> &devices, + boost::shared_ptr selected); - void set_device_list(const std::list< boost::shared_ptr > &devices, - boost::shared_ptr selected); + boost::shared_ptr get_selected_device() const; - boost::shared_ptr get_selected_device() const; + void update_sample_rate_selector(); - void update_sample_rate_selector(); + void set_sampling(bool sampling); + bool get_sampling() const; + bool get_instant() const; - void set_sampling(bool sampling); - bool get_sampling() const; - bool get_instant() const; + void enable_toggle(bool enable); - void enable_toggle(bool enable); + void enable_run_stop(bool enable); - void enable_run_stop(bool enable); + void enable_instant(bool enable); - void enable_instant(bool enable); + double hori_knob(int dir); + double commit_hori_res(); + double get_hori_res(); - double hori_knob(int dir); - double commit_hori_res(); - double get_hori_res(); + public slots: + void set_sample_rate(uint64_t sample_rate); -public slots: - void set_sample_rate(uint64_t sample_rate); + signals: + void run_stop(); + void instant_stop(); + void device_selected(); + void device_updated(); + void duration_changed(); + void show_calibration(); + void hide_calibration(); -signals: - void run_stop(); - void instant_stop(); - void device_selected(); - void device_updated(); - void duration_changed(); - void show_calibration(); - void hide_calibration(); + private: + void changeEvent(QEvent *event); + void retranslateUi(); + void reStyle(); -private: - void changeEvent(QEvent *event); - void retranslateUi(); - void reStyle(); + void update_sample_rate_selector_value(); + void update_sample_count_selector(); + void update_sample_count_selector_value(); + void commit_settings(); + void setting_adj(); - void update_sample_rate_selector_value(); - void update_sample_count_selector(); - void update_sample_count_selector_value(); - void commit_settings(); - void setting_adj(); + private slots: + void on_mode(); + void on_run_stop(); + void on_instant_stop(); + void on_device_selected(); + void on_samplerate_sel(int index); + void on_samplecount_sel(int index); -private slots: - void on_mode(); - void on_run_stop(); - void on_instant_stop(); - void on_device_selected(); - void on_samplerate_sel(int index); - void on_samplecount_sel(int index); + void show_session_error( + const QString text, const QString info_text); - void show_session_error( - const QString text, const QString info_text); + public slots: + void on_configure(); + void zero_adj(); + void reload(); -public slots: - void on_configure(); - void zero_adj(); - void reload(); + private: + SigSession &_session; -private: - SigSession &_session; + mutable boost::recursive_mutex _sampling_mutex; + bool _enable; + bool _sampling; - mutable boost::recursive_mutex _sampling_mutex; - bool _enable; - bool _sampling; + QToolButton _device_type; - QToolButton _device_type; + QComboBox _device_selector; + std::map> + _device_selector_map; + bool _updating_device_selector; - QComboBox _device_selector; - std::map > - _device_selector_map; - bool _updating_device_selector; + QToolButton _configure_button; - QToolButton _configure_button; + QComboBox _sample_count; + QComboBox _sample_rate; + bool _updating_sample_rate; + bool _updating_sample_count; - QComboBox _sample_count; - QComboBox _sample_rate; - bool _updating_sample_rate; - bool _updating_sample_count; + QToolButton _run_stop_button; + QToolButton _instant_button; + QAction *_run_stop_action; + QAction *_instant_action; - QToolButton _run_stop_button; - QToolButton _instant_button; - QAction* _run_stop_action; - QAction* _instant_action; + QAction *_mode_action; + QToolButton _mode_button; + QMenu *_mode_menu; + QAction *_action_repeat; + QAction *_action_single; - QAction* _mode_action; - QToolButton _mode_button; - QMenu *_mode_menu; - QAction *_action_repeat; - QAction *_action_single; + bool _instant; + }; - bool _instant; -}; - -} // namespace toolbars + } // namespace toolbars } // namespace pv #endif // DSVIEW_PV_TOOLBARS_SAMPLINGBAR_H diff --git a/DSView/pv/toolbars/titlebar.cpp b/DSView/pv/toolbars/titlebar.cpp index ed595925..dffb4bc4 100755 --- a/DSView/pv/toolbars/titlebar.cpp +++ b/DSView/pv/toolbars/titlebar.cpp @@ -101,7 +101,7 @@ void TitleBar::reStyle() } void TitleBar::paintEvent(QPaintEvent *event) -{ +{ QStyleOption o; o.initFrom(this); QPainter p(this); @@ -109,6 +109,7 @@ void TitleBar::paintEvent(QPaintEvent *event) p.setRenderHint(QPainter::Antialiasing, true); + //To draw product logo const int xgap = 2; const int xstart = 10; p.setPen(QPen(QColor(213, 15, 37, 255), 2, Qt::SolidLine)); diff --git a/DSView/pv/toolbars/titlebar.h b/DSView/pv/toolbars/titlebar.h index d48878b1..5463af2f 100755 --- a/DSView/pv/toolbars/titlebar.h +++ b/DSView/pv/toolbars/titlebar.h @@ -26,50 +26,55 @@ class QLabel; class QToolButton; -namespace pv { -namespace toolbars { - -class TitleBar : public QWidget +namespace pv { - Q_OBJECT + namespace toolbars + { -public: - TitleBar(bool top, QWidget *parent, bool hasClose = false); - void setTitle(QString title); - QPoint get_startPos() const; - QString title() const; +//Window's titlebar, referenced by MainFrame, +//The title area above the main screen, +//Display logo and maximize \ minimize button + class TitleBar : public QWidget + { + Q_OBJECT -private: - void changeEvent(QEvent *event); - void reStyle(); + public: + TitleBar(bool top, QWidget *parent, bool hasClose = false); + void setTitle(QString title); + QPoint get_startPos() const; + QString title() const; -signals: - void normalShow(); - void maximizedShow(); + private: + void changeEvent(QEvent *event); + void reStyle(); -public slots: - void showMaxRestore(); - void setRestoreButton(bool max); + signals: + void normalShow(); + void maximizedShow(); -protected: - void paintEvent(QPaintEvent *event); - void mousePressEvent(QMouseEvent *event); - void mouseMoveEvent(QMouseEvent *event); - void mouseReleaseEvent(QMouseEvent *event); - void mouseDoubleClickEvent(QMouseEvent *event); + public slots: + void showMaxRestore(); + void setRestoreButton(bool max); - QLabel *_title; - QToolButton *_minimizeButton; - QToolButton *_maximizeButton; - QToolButton *_closeButton; + protected: + void paintEvent(QPaintEvent *event); + void mousePressEvent(QMouseEvent *event); + void mouseMoveEvent(QMouseEvent *event); + void mouseReleaseEvent(QMouseEvent *event); + void mouseDoubleClickEvent(QMouseEvent *event); - bool _moving; - bool _isTop; - bool _hasClose; - QPoint _startPos; -}; + QLabel *_title; + QToolButton *_minimizeButton; + QToolButton *_maximizeButton; + QToolButton *_closeButton; -} // namespace toolbars + bool _moving; + bool _isTop; + bool _hasClose; + QPoint _startPos; + }; + + } // namespace toolbars } // namespace pv #endif // DSVIEW_PV_TOOLBARS_TITLEBAR_H diff --git a/DSView/pv/toolbars/trigbar.h b/DSView/pv/toolbars/trigbar.h index 6a86218f..fbddf0e0 100755 --- a/DSView/pv/toolbars/trigbar.h +++ b/DSView/pv/toolbars/trigbar.h @@ -34,6 +34,8 @@ class SigSession; namespace toolbars { +//boolbar, referenced by MainWindow +//TODO:show the property panel about protocol\trigger class TrigBar : public QToolBar { Q_OBJECT @@ -57,9 +59,9 @@ private: signals: void setTheme(QString style); - void on_protocol(bool visible); - void on_trigger(bool visible); - void on_measure(bool visible); + void on_protocol(bool visible); //post decode button click event,to show or hide protocol property panel + void on_trigger(bool visible); //post decode button click event,to show or hide trigger property panel + void on_measure(bool visible);//post decode button click event,to show or hide measure property panel void on_search(bool visible); void show_lissajous(bool visible); diff --git a/DSView/pv/view/analogsignal.h b/DSView/pv/view/analogsignal.h index ac7ff67a..0555175d 100755 --- a/DSView/pv/view/analogsignal.h +++ b/DSView/pv/view/analogsignal.h @@ -37,6 +37,8 @@ class AnalogSnapshot; namespace view { +//when device is data acquisition model, to draw trace +//created by SigSession class AnalogSignal : public Signal { Q_OBJECT diff --git a/DSView/pv/view/cursor.h b/DSView/pv/view/cursor.h index 0248c9ce..2a33a8f2 100755 --- a/DSView/pv/view/cursor.h +++ b/DSView/pv/view/cursor.h @@ -33,6 +33,7 @@ class QPainter; namespace pv { namespace view { +//created by View class Cursor : public TimeMarker { Q_OBJECT diff --git a/DSView/pv/view/dsldial.cpp b/DSView/pv/view/dsldial.cpp index f20c872c..618817b1 100755 --- a/DSView/pv/view/dsldial.cpp +++ b/DSView/pv/view/dsldial.cpp @@ -48,7 +48,7 @@ dslDial::~dslDial() } void dslDial::paint(QPainter &p, QRectF dialRect, QColor dialColor, const QPoint pt, QString &pText) -{ +{ p.setPen(dialColor); p.setBrush(dialColor); @@ -108,6 +108,8 @@ void dslDial::paint(QPainter &p, QRectF dialRect, QColor dialColor, const QPoint inc ? 10 : -10, hoverRect.width()/2 + 4); p.restore(); } + + (void*)0; } void dslDial::set_sel(uint64_t sel) diff --git a/DSView/pv/view/dsldial.h b/DSView/pv/view/dsldial.h index 973e0e6e..120b491c 100755 --- a/DSView/pv/view/dsldial.h +++ b/DSView/pv/view/dsldial.h @@ -28,6 +28,8 @@ namespace pv { namespace view { +//when device is oscilloscope model, to draw the dail on the left +//created by DsoSignal class dslDial : public QObject { //Q_OBJECT diff --git a/DSView/pv/view/dsosignal.h b/DSView/pv/view/dsosignal.h index a1b040c4..a6f28ec2 100755 --- a/DSView/pv/view/dsosignal.h +++ b/DSView/pv/view/dsosignal.h @@ -38,6 +38,8 @@ class DsoSnapshot; namespace view { +//when device is oscilloscope model,to draw trace +//created by SigSession class DsoSignal : public Signal { Q_OBJECT diff --git a/DSView/pv/view/groupsignal.h b/DSView/pv/view/groupsignal.h index 358c300f..76f1a20f 100755 --- a/DSView/pv/view/groupsignal.h +++ b/DSView/pv/view/groupsignal.h @@ -40,6 +40,7 @@ class GroupSnapshot; namespace view { +//created by SigSession class GroupSignal : public Trace { private: diff --git a/DSView/pv/view/header.cpp b/DSView/pv/view/header.cpp index 40bcaa43..9d794020 100755 --- a/DSView/pv/view/header.cpp +++ b/DSView/pv/view/header.cpp @@ -131,12 +131,15 @@ void Header::paintEvent(QPaintEvent*) const vector< boost::shared_ptr > traces( _view.get_traces(ALL_VIEW)); + // auto num = traces.size(); + const bool dragging = !_drag_traces.empty(); QColor fore(QWidget::palette().color(QWidget::foregroundRole())); fore.setAlpha(View::ForeAlpha); BOOST_FOREACH(const boost::shared_ptr t, traces) { assert(t); + // auto ptr = t.get(); t->paint_label(painter, w, dragging ? QPoint(-1, -1) : _mouse_point, fore); } diff --git a/DSView/pv/view/header.h b/DSView/pv/view/header.h index 7362973a..1dc83c01 100755 --- a/DSView/pv/view/header.h +++ b/DSView/pv/view/header.h @@ -39,6 +39,8 @@ namespace view { class Trace; class View; +//the left panel of main graph +//created by View class Header : public QWidget { Q_OBJECT diff --git a/DSView/pv/view/lissajoustrace.h b/DSView/pv/view/lissajoustrace.h index 1b5dd2f3..f5245d30 100755 --- a/DSView/pv/view/lissajoustrace.h +++ b/DSView/pv/view/lissajoustrace.h @@ -38,12 +38,14 @@ class DsoSnapshot; namespace view { +//when device is oscilloscope mode, it can use to draw Lissajous graph +//created by SigSession class LissajousTrace : public Trace { Q_OBJECT private: - static const int DIV_NUM = 10; + static const int DIV_NUM = 10; public: LissajousTrace(bool enable, diff --git a/DSView/pv/view/logicsignal.h b/DSView/pv/view/logicsignal.h index 2cb30d4e..c9377c8a 100755 --- a/DSView/pv/view/logicsignal.h +++ b/DSView/pv/view/logicsignal.h @@ -39,6 +39,8 @@ class Analog; namespace view { +//when device is logic analyzer mode, to draw logic signal trace +//created by SigSession class LogicSignal : public Signal { Q_OBJECT diff --git a/DSView/pv/view/ruler.cpp b/DSView/pv/view/ruler.cpp index 86448b42..1108087b 100755 --- a/DSView/pv/view/ruler.cpp +++ b/DSView/pv/view/ruler.cpp @@ -168,7 +168,7 @@ void Ruler::rel_grabbed_cursor() } void Ruler::paintEvent(QPaintEvent*) -{ +{ QStyleOption o; o.initFrom(this); QPainter p(this); diff --git a/DSView/pv/view/ruler.h b/DSView/pv/view/ruler.h index f3cf204d..18b310c9 100755 --- a/DSView/pv/view/ruler.h +++ b/DSView/pv/view/ruler.h @@ -33,6 +33,8 @@ namespace view { class TimeMarker; class View; +//the rule panel on the top +//created by View class Ruler : public QWidget { Q_OBJECT diff --git a/DSView/pv/view/selectableitem.h b/DSView/pv/view/selectableitem.h index de9998a9..7859ee4e 100755 --- a/DSView/pv/view/selectableitem.h +++ b/DSView/pv/view/selectableitem.h @@ -35,6 +35,7 @@ namespace pv { namespace view { +//Trace's base class class SelectableItem : public QObject { Q_OBJECT diff --git a/DSView/pv/view/signal.h b/DSView/pv/view/signal.h index 0c37ca9d..ff7eb5b0 100755 --- a/DSView/pv/view/signal.h +++ b/DSView/pv/view/signal.h @@ -50,6 +50,7 @@ class DevInst; namespace view { +//draw signal trace base class class Signal : public Trace { Q_OBJECT diff --git a/DSView/pv/view/spectrumtrace.h b/DSView/pv/view/spectrumtrace.h index e8a08796..ea78082d 100755 --- a/DSView/pv/view/spectrumtrace.h +++ b/DSView/pv/view/spectrumtrace.h @@ -40,6 +40,8 @@ class SpectrumStack; namespace view { +//draw Scope signal trace +//created by SigSession class SpectrumTrace : public Trace { Q_OBJECT diff --git a/DSView/pv/view/timemarker.h b/DSView/pv/view/timemarker.h index 7a5425b8..abcb63d6 100755 --- a/DSView/pv/view/timemarker.h +++ b/DSView/pv/view/timemarker.h @@ -37,6 +37,7 @@ namespace view { class View; +//the Cursor's base class class TimeMarker : public QObject { Q_OBJECT diff --git a/DSView/pv/view/view.h b/DSView/pv/view/view.h index 58893ec8..e059d461 100755 --- a/DSView/pv/view/view.h +++ b/DSView/pv/view/view.h @@ -67,6 +67,7 @@ class Trace; class Viewport; class LissajousFigure; +//created by MainWindow class View : public QScrollArea { Q_OBJECT diff --git a/DSView/pv/view/viewport.cpp b/DSView/pv/view/viewport.cpp index 16cdce97..e5fa036a 100755 --- a/DSView/pv/view/viewport.cpp +++ b/DSView/pv/view/viewport.cpp @@ -138,7 +138,7 @@ bool Viewport::event(QEvent *event) } void Viewport::paintEvent(QPaintEvent *event) -{ +{ (void)event; using pv::view::Signal; @@ -156,12 +156,15 @@ void Viewport::paintEvent(QPaintEvent *event) const vector< boost::shared_ptr > traces(_view.get_traces(_type)); BOOST_FOREACH(const boost::shared_ptr t, traces) { - assert(t); + assert(t); + t->paint_back(p, 0, _view.get_view_width(), fore, back); if (_view.back_ready()) break; } + //auto st = _view.session().get_capture_state(); + if (_view.session().get_device()->dev_inst()->mode == LOGIC || _view.session().get_instant()) { switch(_view.session().get_capture_state()) { @@ -207,6 +210,10 @@ void Viewport::paintSignals(QPainter &p, QColor fore, QColor back) BOOST_FOREACH(const boost::shared_ptr t, traces) { assert(t); + // auto ptr = t.get(); + // ptr->paint_mid(p, 0, t->get_view_rect().right(), fore, back); + // continue; + if (t->enabled()) t->paint_mid(p, 0, t->get_view_rect().right(), fore, back); } @@ -228,7 +235,7 @@ void Viewport::paintSignals(QPainter &p, QColor fore, QColor back) { assert(t); if (t->enabled()) - t->paint_mid(dbp, 0, t->get_view_rect().right(), fore, back); + t->paint_mid(dbp, 0, t->get_view_rect().right(), fore, back); } _need_update = false; } diff --git a/DSView/pv/view/viewport.h b/DSView/pv/view/viewport.h index 9a9689cf..c1d298f1 100755 --- a/DSView/pv/view/viewport.h +++ b/DSView/pv/view/viewport.h @@ -48,6 +48,9 @@ namespace view { class Signal; class View; +//main graph view port, in the middle region +//draw the left and right rule scale +//created by View class Viewport : public QWidget { Q_OBJECT diff --git a/DSView/pv/view/viewstatus.h b/DSView/pv/view/viewstatus.h index 804dfbfa..c4a006eb 100755 --- a/DSView/pv/view/viewstatus.h +++ b/DSView/pv/view/viewstatus.h @@ -41,12 +41,15 @@ namespace view { class View; class DsoSignal; - +//created by View class ViewStatus : public QWidget { Q_OBJECT + public: - ViewStatus(SigSession &session, View &parent); + ViewStatus(SigSession &session, View &parent); + +public: void paintEvent(QPaintEvent *); void mousePressEvent(QMouseEvent *); diff --git a/DSView/pv/view/xcursor.cpp b/DSView/pv/view/xcursor.cpp index 2566505d..a96daf20 100755 --- a/DSView/pv/view/xcursor.cpp +++ b/DSView/pv/view/xcursor.cpp @@ -132,7 +132,7 @@ void XCursor::set_value(XCur_type type, double value) } void XCursor::paint(QPainter &p, const QRect &rect, XCur_type highlight, int order) -{ +{ const int arrow = 3; const int x = rect.left() + _yvalue * rect.width(); const int y0 = rect.top() + _value0 * rect.height(); diff --git a/DSView/pv/view/xcursor.h b/DSView/pv/view/xcursor.h index 7f5901ba..e64d80b8 100755 --- a/DSView/pv/view/xcursor.h +++ b/DSView/pv/view/xcursor.h @@ -41,9 +41,11 @@ namespace view { class View; class DsoSignal; +//created by View class XCursor : public QObject { Q_OBJECT + public: enum XCur_type { XCur_None = -2, diff --git a/libsigrok4DSL/hardware/demo/demo.h b/libsigrok4DSL/hardware/demo/demo.h index 08a6f421..5a474ea0 100755 --- a/libsigrok4DSL/hardware/demo/demo.h +++ b/libsigrok4DSL/hardware/demo/demo.h @@ -168,8 +168,9 @@ static const struct DEMO_profile supported_Demo[] = { (1 << DEMO_LOGIC100x16) | (1 << DEMO_ANALOG10x2) | (1 << DEMO_DSO200x2), - SR_Mn(100), - SR_Kn(20), + SR_Mn(100), + // SR_Gn(16), + SR_Kn(20), 0, vdivs10to2000, 0, diff --git a/libsigrok4DSL/session_file.c b/libsigrok4DSL/session_file.c index 4ae027db..ec76d4a5 100755 --- a/libsigrok4DSL/session_file.c +++ b/libsigrok4DSL/session_file.c @@ -621,6 +621,7 @@ SR_API int sr_session_append(const char *filename, const unsigned char *buf, goto err; } if (zip_file_add(archive, chunk_name, logicsrc, ZIP_FL_OVERWRITE) == -1) { + // if (zip_add(archive, chunk_name, logicsrc) == -1) { goto err; } if ((ret = zip_close(archive)) == -1) {