diff --git a/DSView/pv/mainwindow.cpp b/DSView/pv/mainwindow.cpp index f1ccf7b9..99772fd7 100644 --- a/DSView/pv/mainwindow.cpp +++ b/DSView/pv/mainwindow.cpp @@ -753,7 +753,7 @@ namespace pv StoreSession ss(_session); QJsonArray decodeJson; - ss.json_decoders(decodeJson); + ss.gen_decoders_json(decodeJson); sessionVar["decoder"] = decodeJson; if (_device_agent->get_work_mode() == DSO) @@ -1074,6 +1074,7 @@ namespace pv haveDecoder = true; StoreSession ss(_session); ss.load_decoders(_protocol_widget, deArray); + _view->update_all_trace_postion(); } } @@ -1776,6 +1777,7 @@ namespace pv StoreSession ss(_session); QJsonArray deArray = get_decoder_json_from_file(_device_agent->path()); ss.load_decoders(_protocol_widget, deArray); + _view->update_all_trace_postion(); } _session->start_capture(true); @@ -1797,6 +1799,7 @@ namespace pv StoreSession ss(_session); QJsonArray deArray = get_decoder_json_from_file(_device_agent->path()); ss.load_decoders(_protocol_widget, deArray); + _view->update_all_trace_postion(); } } } @@ -1847,6 +1850,7 @@ namespace pv StoreSession ss(_session); QJsonArray deArray = get_decoder_json_from_file(_device_agent->path()); ss.load_decoders(_protocol_widget, deArray); + _view->update_all_trace_postion(); } } } @@ -1975,6 +1979,7 @@ namespace pv StoreSession ss(_session); QJsonArray deArray = get_decoder_json_from_file(_device_agent->path()); ss.load_decoders(_protocol_widget, deArray); + _view->update_all_trace_postion(); if (msg == DSV_MSG_END_DEVICE_OPTIONS) _session->start_capture(false); // Auto load data. diff --git a/DSView/pv/sigsession.cpp b/DSView/pv/sigsession.cpp index dcb5d25e..1ba454e6 100644 --- a/DSView/pv/sigsession.cpp +++ b/DSView/pv/sigsession.cpp @@ -889,6 +889,7 @@ namespace pv int logic_chan_num = 0; int dso_chan_num = 0; int all_chann_num = 0; + int start_view_dex = -1; set_cur_snap_samplerate(_device_agent.get_sample_rate()); set_cur_samplelimits(_device_agent.get_sample_limit()); @@ -917,6 +918,8 @@ namespace pv if ((*i)->signal_type() == SR_CHANNEL_LOGIC){ view::LogicSignal *logicSig = (view::LogicSignal*)(*i); signal = new view::LogicSignal(logicSig, _view_data->get_logic(), probe); + if (logicSig->get_view_index() < start_view_dex || start_view_dex == -1) + start_view_dex = logicSig->get_view_index(); } break; @@ -971,7 +974,7 @@ namespace pv clear_signals(); std::vector().swap(_signals); _signals = sigs; - make_channels_view_index(); + make_channels_view_index(start_view_dex); if (_device_agent.get_work_mode() == LOGIC){ for (int i=0; iset_view_index(index++); } diff --git a/DSView/pv/sigsession.h b/DSView/pv/sigsession.h index 329ba898..5cb45574 100644 --- a/DSView/pv/sigsession.h +++ b/DSView/pv/sigsession.h @@ -518,7 +518,7 @@ private: } view::Trace* get_channel_by_index(int orgIndex); - void make_channels_view_index(); + void make_channels_view_index(int start_dex = -1); private: mutable std::mutex _sampling_mutex; diff --git a/DSView/pv/storesession.cpp b/DSView/pv/storesession.cpp index be288ab8..193c1953 100644 --- a/DSView/pv/storesession.cpp +++ b/DSView/pv/storesession.cpp @@ -999,7 +999,7 @@ void StoreSession::export_proc(data::Snapshot *snapshot) bool StoreSession::decoders_gen(std::string &str) { QJsonArray dec_array; - if (!json_decoders(dec_array)) + if (!gen_decoders_json(dec_array)) return false; QJsonDocument sessionDoc(dec_array); QString data = QString::fromUtf8(sessionDoc.toJson()); @@ -1007,7 +1007,7 @@ bool StoreSession::decoders_gen(std::string &str) return true; } -bool StoreSession::json_decoders(QJsonArray &array) +bool StoreSession::gen_decoders_json(QJsonArray &array) { for(auto s : _session->get_decode_signals()) { QJsonObject dec_obj; @@ -1074,9 +1074,11 @@ bool StoreSession::json_decoders(QJsonArray &array) } show_obj[d->id] = QJsonValue::fromVariant(dec->shown()); } + dec_obj["version"] = DEOCDER_CONFIG_VERSION; dec_obj["label"] = QString(s->get_name().toUtf8().data()); dec_obj["stacked decoders"] = stack_array; + dec_obj["view_index"] = s->get_view_index(); auto rows = stack->get_rows_gshow(); for (auto i = rows.begin(); i != rows.end(); i++) { @@ -1150,6 +1152,11 @@ bool StoreSession::load_decoders(dock::ProtocolDock *widget, QJsonArray &dec_arr _session->set_decoder_row_label(dec_index, dec_obj["label"].toString()); } + if (dec_obj.contains("view_index")){ + int chan_view_index = dec_obj["view_index"].toInt(); + _session->get_decoder_trace(dec_index)->set_view_index(chan_view_index); + } + std::list bind_indexs; std::vector &aft_dsigs = _session->get_decode_signals(); diff --git a/DSView/pv/storesession.h b/DSView/pv/storesession.h index b95358ec..67974edf 100644 --- a/DSView/pv/storesession.h +++ b/DSView/pv/storesession.h @@ -82,7 +82,7 @@ private: public: - bool json_decoders(QJsonArray &array); + bool gen_decoders_json(QJsonArray &array); bool load_decoders(dock::ProtocolDock *widget, QJsonArray &dec_array); QString MakeSaveFile(bool bDlg); QString MakeExportFile(bool bDlg); diff --git a/DSView/pv/view/decodetrace.cpp b/DSView/pv/view/decodetrace.cpp index e38130fc..bb26dc25 100644 --- a/DSView/pv/view/decodetrace.cpp +++ b/DSView/pv/view/decodetrace.cpp @@ -123,7 +123,6 @@ DecodeTrace::DecodeTrace(pv::SigSession *session, _colour = DecodeColours[index % countof(DecodeColours)]; - _pub_input_layer = NULL; _decode_start = 0; _decode_end = INT64_MAX; _decoder_stack = decoder_stack; diff --git a/DSView/pv/view/decodetrace.h b/DSView/pv/view/decodetrace.h index 0d66a0b0..72d5df51 100644 --- a/DSView/pv/view/decodetrace.h +++ b/DSView/pv/view/decodetrace.h @@ -189,9 +189,7 @@ private: uint64_t _decode_end; uint64_t _decode_cursor1; // the cursor key, sample start index - uint64_t _decode_cursor2; - - QFormLayout *_pub_input_layer; + uint64_t _decode_cursor2; std::vector _cur_row_headings; diff --git a/DSView/pv/view/header.cpp b/DSView/pv/view/header.cpp index d3716e7b..08694f21 100644 --- a/DSView/pv/view/header.cpp +++ b/DSView/pv/view/header.cpp @@ -247,6 +247,10 @@ void Header::mouseReleaseEvent(QMouseEvent *event) { std::vector traces; + for (auto s : _view.session().get_decode_signals()){ + traces.push_back(s); + } + for (auto s : _view.session().get_signals()){ traces.push_back(s); } diff --git a/DSView/pv/view/trace.cpp b/DSView/pv/view/trace.cpp index 285d593e..1584112a 100644 --- a/DSView/pv/view/trace.cpp +++ b/DSView/pv/view/trace.cpp @@ -58,7 +58,7 @@ Trace::Trace(QString name, uint16_t index, int type) : _typeWidth(SquareNum) { _index_list.push_back(index); - _view_index = 0; + _view_index = -1; } Trace::Trace(QString name, std::list index_list, int type, int sec_index) : @@ -71,7 +71,7 @@ Trace::Trace(QString name, std::list index_list, int type, int sec_index) : _totalHeight(30), _typeWidth(SquareNum) { - _view_index = 0; + _view_index = -1; } Trace::Trace(const Trace &t) : @@ -87,7 +87,7 @@ Trace::Trace(const Trace &t) : _typeWidth(t._typeWidth), _text_size(t._text_size) { - _view_index = 0; + _view_index = -1; } diff --git a/DSView/pv/view/view.cpp b/DSView/pv/view/view.cpp index addc1a87..781f734f 100644 --- a/DSView/pv/view/view.cpp +++ b/DSView/pv/view/view.cpp @@ -719,17 +719,27 @@ void View::signals_changed() _spanY = _signalHeight + 2 * actualMargin; int next_v_offset = actualMargin; - //Make list by view index; + //Make list by view-index; if (mode == LOGIC) - { - sort(logic_traces.begin(), logic_traces.end(), compare_trace_view_index); + { time_traces.clear(); - - for(auto t : decoder_traces){ - time_traces.push_back(t); - } + + std::vector all_traces; for(auto t : logic_traces){ + all_traces.push_back(t); + } + + for(auto t : decoder_traces){ + if (t->get_view_index() != -1) + all_traces.push_back(t); + else + time_traces.push_back(t); + } + + sort(all_traces.begin(), all_traces.end(), compare_trace_view_index); + + for(auto t : all_traces){ time_traces.push_back(t); } }