From 67092541df6d56c0376e5122617dcd82b8cc5668 Mon Sep 17 00:00:00 2001 From: lsv Date: Fri, 25 Oct 2024 10:27:27 +0500 Subject: [PATCH] Optimization MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Оптимизация TopActivity. --- ctl/wxTopActivity.cpp | 6 ++++-- include/ctl/wxTopActivity.h | 25 +++++++++++++++++++++++-- utils/FormatterSQL.cpp | 31 ++++++++++++++++++++++++++----- 3 files changed, 53 insertions(+), 9 deletions(-) diff --git a/ctl/wxTopActivity.cpp b/ctl/wxTopActivity.cpp index 571163a..56d9a2f 100644 --- a/ctl/wxTopActivity.cpp +++ b/ctl/wxTopActivity.cpp @@ -766,6 +766,8 @@ void wxTopActivity::render(wxDC& dc) std::vector map_sum_all = sort_vec_map(sum_all, itog); int period = ws->getPeriod(); int total = itog; + float limit = 0.1; + if (m_agg_int >= 10 * 60000) limit = 1.0; if (total != 0) { { wxDCFontChanger nfont(dc, dc.GetFont()); @@ -828,7 +830,7 @@ void wxTopActivity::render(wxDC& dc) if (bt >= 0) txt = ws->GetBackendTypeNameShort(bt); w_sum = v; float f = (float)w_sum / 1000; - if (f < 0.1) continue; + if (f < limit) continue; if (!bgproc.IsEmpty()) bgproc += ','; bgproc += wxString::Format("%s(%.1fs)", txt, (float)f); //title_sz = dc.GetTextExtent(txt + pr); @@ -876,7 +878,7 @@ void wxTopActivity::render(wxDC& dc) wxString txt; w_sum = v; float fsek = (float)w_sum / 1000; - if (fsek < 0.1) continue; + if (fsek < limit) continue; unsigned long long ull = k.qid; int h = ull >> 32; int l = ull & 0xFFFFFFFF; diff --git a/include/ctl/wxTopActivity.h b/include/ctl/wxTopActivity.h index 7369703..e9755cc 100644 --- a/include/ctl/wxTopActivity.h +++ b/include/ctl/wxTopActivity.h @@ -627,10 +627,31 @@ public: } } - else { + else + { GetMainWindow()->UnsetToolTip(); lastcol = -1; } } + else if (column && column->GetModelColumn() == 1) { + //qid + MyIndexListModel* m = static_cast(GetModel()); + key3 k = m->GetRowValue(row); + if (k.qid != 0) { + if (((lastcol != ncol) || (lastrow != row))) { + wxString s = w->GetQueryByQid(k.qid); + if (s.IsEmpty()) s = "not found sql text"; + GetMainWindow()->SetToolTip(s); + lastrow = row; + lastcol = ncol; + + } + } + else + { + GetMainWindow()->UnsetToolTip(); lastcol = -1; lastrow = -1; + } + + } else { GetMainWindow()->UnsetToolTip(); @@ -641,7 +662,7 @@ public: else { GetMainWindow()->UnsetToolTip(); - lastcol = -1; + lastcol = -1; ; lastrow = -1; } }); diff --git a/utils/FormatterSQL.cpp b/utils/FormatterSQL.cpp index d75849f..91415cf 100644 --- a/utils/FormatterSQL.cpp +++ b/utils/FormatterSQL.cpp @@ -888,11 +888,13 @@ wxSize FormatterSQL::best_sizeAndDraw(wxDC& dc, wxPoint& pos, view_item& vi, int bool draw = true; if (mode == 2) { draw = false; - pos.x = vi.x; - pos.y = vi.y; + if (pos.x == -1) { + pos.x = vi.x; + pos.y = vi.y; + } } dc.SetTextForeground(*wxBLACK); - dc.SetFont(f.GetBaseFont()); + // dc.SetFont(f.GetBaseFont()); if (vi.type == keyword) { wxDCFontChanger nfont(dc, f.Bold()); @@ -1259,7 +1261,7 @@ void FormatterSQL::Formating(wxDC& dc, wxRect re, bool isTest) { max_exp_bracet_width = 200; pad = 16; casepad = 8; - wxPoint p(0, 0); + wxPoint p(rect.x + 1, 0); // calc size items for (auto& vv : items) { wxSize sz = best_sizeAndDraw(dc, p, vv, 0); @@ -1269,10 +1271,29 @@ void FormatterSQL::Formating(wxDC& dc, wxRect re, bool isTest) { align_level(0, 0, rect.x, rect.y, 0); dc.SetBrush(*wxWHITE_BRUSH); dc.DrawRectangle(re); + wxSize sz; + int xmax = rect.x + rect.width; + int deltax = 0,deltay=0; for (auto& vv : items) { p.x = -1; if (vv.type == unknown) continue; - wxSize sz = best_sizeAndDraw(dc, p, vv, 2); + if (vv.x + vv.width > xmax) { + if (deltax == 0 || (rect.x + vv.width + deltax > xmax)) { deltax = 1; deltay += vv.height; } + } + else + deltax = 0; + if (deltay != 0) { + p.y = vv.y+deltay; + if (deltax == 0) + p.x = vv.x; + else + p.x = rect.x + deltax; + } + sz = best_sizeAndDraw(dc, p, vv, 2); + if (vv.x + vv.width > xmax && deltax>0) { + deltax += vv.width; + + } } } // re - (0,0,width simbol max,height max)