author | Paul Beltyukov |
Thu, 18 Aug 2016 14:35:03 +0500 | |
changeset 1517 | 30692ab8b5c7 |
parent 1441 | 826730e60407 |
child 1571 | 486f94a8032c |
permissions | -rw-r--r-- |
978 | 1 |
#!/usr/bin/env python |
2 |
# -*- coding: utf-8 -*- |
|
3 |
||
4 |
#This file is part of PLCOpenEditor, a library implementing an IEC 61131-3 editor |
|
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
5 |
#based on the plcopen standard. |
978 | 6 |
# |
7 |
#Copyright (C) 2013: Edouard TISSERANT and Laurent BESSARD |
|
8 |
# |
|
9 |
#See COPYING file for copyrights details. |
|
10 |
# |
|
11 |
#This library is free software; you can redistribute it and/or |
|
12 |
#modify it under the terms of the GNU General Public |
|
13 |
#License as published by the Free Software Foundation; either |
|
14 |
#version 2.1 of the License, or (at your option) any later version. |
|
15 |
# |
|
16 |
#This library is distributed in the hope that it will be useful, |
|
17 |
#but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
18 |
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
19 |
#General Public License for more details. |
|
20 |
# |
|
21 |
#You should have received a copy of the GNU General Public |
|
22 |
#License along with this library; if not, write to the Free Software |
|
23 |
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
24 |
||
25 |
from datetime import datetime |
|
981
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
26 |
from time import time as gettime |
982
e3c264099bd0
Added support in LogViewer for scrolling using relative timestamp
Laurent Bessard
parents:
981
diff
changeset
|
27 |
import numpy |
978 | 28 |
|
29 |
import wx |
|
30 |
||
1169
53e4a2b775a7
Move CustomToolTip from GraphicCommons to controls
Laurent Bessard
parents:
1094
diff
changeset
|
31 |
from controls.CustomToolTip import CustomToolTip, TOOLTIP_WAIT_PERIOD |
1176
f4b434672204
Moved and rewrote DebugViewer and DebusDataConsumer classes
Laurent Bessard
parents:
1170
diff
changeset
|
32 |
from editors.DebugViewer import DebugViewer, REFRESH_PERIOD |
978 | 33 |
from targets.typemapping import LogLevelsCount, LogLevels |
34 |
from util.BitmapLibrary import GetBitmap |
|
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
35 |
from weakref import proxy |
978 | 36 |
|
981
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
37 |
THUMB_SIZE_RATIO = 1. / 8. |
978 | 38 |
|
993 | 39 |
def ArrowPoints(direction, width, height, xoffset, yoffset): |
986 | 40 |
if direction == wx.TOP: |
993 | 41 |
return [wx.Point(xoffset + 1, yoffset + height - 2), |
42 |
wx.Point(xoffset + width / 2, yoffset + 1), |
|
43 |
wx.Point(xoffset + width - 1, yoffset + height - 2)] |
|
986 | 44 |
else: |
993 | 45 |
return [wx.Point(xoffset + 1, yoffset - height + 1), |
46 |
wx.Point(xoffset + width / 2, yoffset - 2), |
|
47 |
wx.Point(xoffset + width - 1, yoffset - height + 1)] |
|
986 | 48 |
|
983
7dd481eef3b5
Replaced left ugly buttons in LogViewer by custom buttons inside MessagePanel
Laurent Bessard
parents:
982
diff
changeset
|
49 |
class LogScrollBar(wx.Panel): |
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
50 |
|
978 | 51 |
def __init__(self, parent, size): |
52 |
wx.Panel.__init__(self, parent, size=size) |
|
53 |
self.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown) |
|
54 |
self.Bind(wx.EVT_LEFT_UP, self.OnLeftUp) |
|
55 |
self.Bind(wx.EVT_MOTION, self.OnMotion) |
|
988
30e7571c10d0
Reduced flicker on LogViewer and DebugGraphPanel on Windows
Laurent Bessard
parents:
987
diff
changeset
|
56 |
self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground) |
978 | 57 |
self.Bind(wx.EVT_PAINT, self.OnPaint) |
58 |
self.Bind(wx.EVT_SIZE, self.OnResize) |
|
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
59 |
|
981
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
60 |
self.ThumbPosition = 0. # -1 <= ThumbPosition <= 1 |
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
61 |
self.ThumbScrollingStartPos = None |
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
62 |
|
978 | 63 |
def GetRangeRect(self): |
64 |
width, height = self.GetClientSize() |
|
65 |
return wx.Rect(0, width, width, height - 2 * width) |
|
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
66 |
|
978 | 67 |
def GetThumbRect(self): |
68 |
width, height = self.GetClientSize() |
|
69 |
range_rect = self.GetRangeRect() |
|
981
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
70 |
thumb_size = range_rect.height * THUMB_SIZE_RATIO |
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
71 |
thumb_range = range_rect.height - thumb_size |
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
72 |
thumb_center_position = (thumb_size + (self.ThumbPosition + 1) * thumb_range) / 2. |
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
73 |
thumb_start = int(thumb_center_position - thumb_size / 2.) |
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
74 |
thumb_end = int(thumb_center_position + thumb_size / 2.) |
987
7ca88194ae89
Improved graphics of LogViewer scrollbar to be anti-aliased
Laurent Bessard
parents:
986
diff
changeset
|
75 |
return wx.Rect(0, range_rect.y + thumb_start, width, thumb_end - thumb_start) |
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
76 |
|
981
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
77 |
def RefreshThumbPosition(self, thumb_position=None): |
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
78 |
if thumb_position is None: |
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
79 |
thumb_position = self.ThumbPosition |
978 | 80 |
if self.Parent.IsMessagePanelTop(): |
981
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
81 |
thumb_position = max(0., thumb_position) |
978 | 82 |
if self.Parent.IsMessagePanelBottom(): |
981
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
83 |
thumb_position = min(0., thumb_position) |
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
84 |
if thumb_position != self.ThumbPosition: |
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
85 |
self.ThumbPosition = thumb_position |
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
86 |
self.Parent.SetScrollSpeed(self.ThumbPosition) |
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
87 |
self.Refresh() |
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
88 |
|
978 | 89 |
def OnLeftDown(self, event): |
90 |
self.CaptureMouse() |
|
91 |
posx, posy = event.GetPosition() |
|
92 |
width, height = self.GetClientSize() |
|
93 |
range_rect = self.GetRangeRect() |
|
94 |
thumb_rect = self.GetThumbRect() |
|
95 |
if range_rect.InsideXY(posx, posy): |
|
96 |
if thumb_rect.InsideXY(posx, posy): |
|
981
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
97 |
self.ThumbScrollingStartPos = wx.Point(posx, posy) |
978 | 98 |
elif posy < thumb_rect.y: |
981
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
99 |
self.Parent.ScrollToLast() |
978 | 100 |
elif posy > thumb_rect.y + thumb_rect.height: |
981
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
101 |
self.Parent.ScrollToFirst() |
978 | 102 |
elif posy < width: |
986 | 103 |
self.Parent.ScrollMessagePanelByPage(1) |
978 | 104 |
elif posy > height - width: |
986 | 105 |
self.Parent.ScrollMessagePanelByPage(-1) |
978 | 106 |
event.Skip() |
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
107 |
|
978 | 108 |
def OnLeftUp(self, event): |
981
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
109 |
self.ThumbScrollingStartPos = None |
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
110 |
self.RefreshThumbPosition(0.) |
978 | 111 |
if self.HasCapture(): |
112 |
self.ReleaseMouse() |
|
113 |
event.Skip() |
|
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
114 |
|
978 | 115 |
def OnMotion(self, event): |
981
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
116 |
if event.Dragging() and self.ThumbScrollingStartPos is not None: |
978 | 117 |
posx, posy = event.GetPosition() |
118 |
width, height = self.GetClientSize() |
|
119 |
range_rect = self.GetRangeRect() |
|
981
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
120 |
thumb_size = range_rect.height * THUMB_SIZE_RATIO |
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
121 |
thumb_range = range_rect.height - thumb_size |
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
122 |
self.RefreshThumbPosition( |
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
123 |
max(-1., min((posy - self.ThumbScrollingStartPos.y) * 2. / thumb_range, 1.))) |
978 | 124 |
event.Skip() |
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
125 |
|
978 | 126 |
def OnResize(self, event): |
127 |
self.Refresh() |
|
128 |
event.Skip() |
|
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
129 |
|
988
30e7571c10d0
Reduced flicker on LogViewer and DebugGraphPanel on Windows
Laurent Bessard
parents:
987
diff
changeset
|
130 |
def OnEraseBackground(self, event): |
30e7571c10d0
Reduced flicker on LogViewer and DebugGraphPanel on Windows
Laurent Bessard
parents:
987
diff
changeset
|
131 |
pass |
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
132 |
|
978 | 133 |
def OnPaint(self, event): |
134 |
dc = wx.BufferedPaintDC(self) |
|
135 |
dc.Clear() |
|
136 |
dc.BeginDrawing() |
|
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
137 |
|
987
7ca88194ae89
Improved graphics of LogViewer scrollbar to be anti-aliased
Laurent Bessard
parents:
986
diff
changeset
|
138 |
gc = wx.GCDC(dc) |
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
139 |
|
981
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
140 |
width, height = self.GetClientSize() |
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
141 |
|
993 | 142 |
gc.SetPen(wx.Pen(wx.NamedColour("GREY"), 3)) |
987
7ca88194ae89
Improved graphics of LogViewer scrollbar to be anti-aliased
Laurent Bessard
parents:
986
diff
changeset
|
143 |
gc.SetBrush(wx.GREY_BRUSH) |
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
144 |
|
993 | 145 |
gc.DrawLines(ArrowPoints(wx.TOP, width * 0.75, width * 0.5, 2, (width + height) / 4 - 3)) |
146 |
gc.DrawLines(ArrowPoints(wx.TOP, width * 0.75, width * 0.5, 2, (width + height) / 4 + 3)) |
|
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
147 |
|
993 | 148 |
gc.DrawLines(ArrowPoints(wx.BOTTOM, width * 0.75, width * 0.5, 2, (height * 3 - width) / 4 + 3)) |
149 |
gc.DrawLines(ArrowPoints(wx.BOTTOM, width * 0.75, width * 0.5, 2, (height * 3 - width) / 4 - 3)) |
|
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
150 |
|
981
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
151 |
thumb_rect = self.GetThumbRect() |
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
152 |
exclusion_rect = wx.Rect(thumb_rect.x, thumb_rect.y, |
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
153 |
thumb_rect.width, thumb_rect.height) |
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
154 |
if self.Parent.IsMessagePanelTop(): |
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
155 |
exclusion_rect.y, exclusion_rect.height = width, exclusion_rect.y + exclusion_rect.height - width |
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
156 |
if self.Parent.IsMessagePanelBottom(): |
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
157 |
exclusion_rect.height = height - width - exclusion_rect.y |
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
158 |
if exclusion_rect != thumb_rect: |
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
159 |
colour = wx.NamedColour("LIGHT GREY") |
987
7ca88194ae89
Improved graphics of LogViewer scrollbar to be anti-aliased
Laurent Bessard
parents:
986
diff
changeset
|
160 |
gc.SetPen(wx.Pen(colour)) |
7ca88194ae89
Improved graphics of LogViewer scrollbar to be anti-aliased
Laurent Bessard
parents:
986
diff
changeset
|
161 |
gc.SetBrush(wx.Brush(colour)) |
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
162 |
|
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
163 |
gc.DrawRectangle(exclusion_rect.x, exclusion_rect.y, |
981
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
164 |
exclusion_rect.width, exclusion_rect.height) |
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
165 |
|
987
7ca88194ae89
Improved graphics of LogViewer scrollbar to be anti-aliased
Laurent Bessard
parents:
986
diff
changeset
|
166 |
gc.SetPen(wx.GREY_PEN) |
7ca88194ae89
Improved graphics of LogViewer scrollbar to be anti-aliased
Laurent Bessard
parents:
986
diff
changeset
|
167 |
gc.SetBrush(wx.GREY_BRUSH) |
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
168 |
|
993 | 169 |
gc.DrawPolygon(ArrowPoints(wx.TOP, width, width, 0, 0)) |
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
170 |
|
993 | 171 |
gc.DrawPolygon(ArrowPoints(wx.BOTTOM, width, width, 0, height)) |
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
172 |
|
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
173 |
gc.DrawRectangle(thumb_rect.x, thumb_rect.y, |
978 | 174 |
thumb_rect.width, thumb_rect.height) |
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
175 |
|
978 | 176 |
dc.EndDrawing() |
177 |
event.Skip() |
|
178 |
||
983
7dd481eef3b5
Replaced left ugly buttons in LogViewer by custom buttons inside MessagePanel
Laurent Bessard
parents:
982
diff
changeset
|
179 |
BUTTON_SIZE = (30, 15) |
7dd481eef3b5
Replaced left ugly buttons in LogViewer by custom buttons inside MessagePanel
Laurent Bessard
parents:
982
diff
changeset
|
180 |
|
7dd481eef3b5
Replaced left ugly buttons in LogViewer by custom buttons inside MessagePanel
Laurent Bessard
parents:
982
diff
changeset
|
181 |
class LogButton(): |
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
182 |
|
983
7dd481eef3b5
Replaced left ugly buttons in LogViewer by custom buttons inside MessagePanel
Laurent Bessard
parents:
982
diff
changeset
|
183 |
def __init__(self, label, callback): |
7dd481eef3b5
Replaced left ugly buttons in LogViewer by custom buttons inside MessagePanel
Laurent Bessard
parents:
982
diff
changeset
|
184 |
self.Position = wx.Point(0, 0) |
7dd481eef3b5
Replaced left ugly buttons in LogViewer by custom buttons inside MessagePanel
Laurent Bessard
parents:
982
diff
changeset
|
185 |
self.Size = wx.Size(*BUTTON_SIZE) |
7dd481eef3b5
Replaced left ugly buttons in LogViewer by custom buttons inside MessagePanel
Laurent Bessard
parents:
982
diff
changeset
|
186 |
self.Label = label |
7dd481eef3b5
Replaced left ugly buttons in LogViewer by custom buttons inside MessagePanel
Laurent Bessard
parents:
982
diff
changeset
|
187 |
self.Shown = True |
7dd481eef3b5
Replaced left ugly buttons in LogViewer by custom buttons inside MessagePanel
Laurent Bessard
parents:
982
diff
changeset
|
188 |
self.Callback = callback |
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
189 |
|
983
7dd481eef3b5
Replaced left ugly buttons in LogViewer by custom buttons inside MessagePanel
Laurent Bessard
parents:
982
diff
changeset
|
190 |
def __del__(self): |
7dd481eef3b5
Replaced left ugly buttons in LogViewer by custom buttons inside MessagePanel
Laurent Bessard
parents:
982
diff
changeset
|
191 |
self.callback = None |
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
192 |
|
983
7dd481eef3b5
Replaced left ugly buttons in LogViewer by custom buttons inside MessagePanel
Laurent Bessard
parents:
982
diff
changeset
|
193 |
def GetSize(self): |
7dd481eef3b5
Replaced left ugly buttons in LogViewer by custom buttons inside MessagePanel
Laurent Bessard
parents:
982
diff
changeset
|
194 |
return self.Size |
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
195 |
|
983
7dd481eef3b5
Replaced left ugly buttons in LogViewer by custom buttons inside MessagePanel
Laurent Bessard
parents:
982
diff
changeset
|
196 |
def SetPosition(self, x, y): |
7dd481eef3b5
Replaced left ugly buttons in LogViewer by custom buttons inside MessagePanel
Laurent Bessard
parents:
982
diff
changeset
|
197 |
self.Position = wx.Point(x, y) |
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
198 |
|
983
7dd481eef3b5
Replaced left ugly buttons in LogViewer by custom buttons inside MessagePanel
Laurent Bessard
parents:
982
diff
changeset
|
199 |
def HitTest(self, x, y): |
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
200 |
rect = wx.Rect(self.Position.x, self.Position.y, |
983
7dd481eef3b5
Replaced left ugly buttons in LogViewer by custom buttons inside MessagePanel
Laurent Bessard
parents:
982
diff
changeset
|
201 |
self.Size.width, self.Size.height) |
7dd481eef3b5
Replaced left ugly buttons in LogViewer by custom buttons inside MessagePanel
Laurent Bessard
parents:
982
diff
changeset
|
202 |
if rect.InsideXY(x, y): |
7dd481eef3b5
Replaced left ugly buttons in LogViewer by custom buttons inside MessagePanel
Laurent Bessard
parents:
982
diff
changeset
|
203 |
return True |
7dd481eef3b5
Replaced left ugly buttons in LogViewer by custom buttons inside MessagePanel
Laurent Bessard
parents:
982
diff
changeset
|
204 |
return False |
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
205 |
|
983
7dd481eef3b5
Replaced left ugly buttons in LogViewer by custom buttons inside MessagePanel
Laurent Bessard
parents:
982
diff
changeset
|
206 |
def ProcessCallback(self): |
7dd481eef3b5
Replaced left ugly buttons in LogViewer by custom buttons inside MessagePanel
Laurent Bessard
parents:
982
diff
changeset
|
207 |
if self.Callback is not None: |
7dd481eef3b5
Replaced left ugly buttons in LogViewer by custom buttons inside MessagePanel
Laurent Bessard
parents:
982
diff
changeset
|
208 |
wx.CallAfter(self.Callback) |
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
209 |
|
983
7dd481eef3b5
Replaced left ugly buttons in LogViewer by custom buttons inside MessagePanel
Laurent Bessard
parents:
982
diff
changeset
|
210 |
def Draw(self, dc): |
7dd481eef3b5
Replaced left ugly buttons in LogViewer by custom buttons inside MessagePanel
Laurent Bessard
parents:
982
diff
changeset
|
211 |
dc.SetPen(wx.TRANSPARENT_PEN) |
7dd481eef3b5
Replaced left ugly buttons in LogViewer by custom buttons inside MessagePanel
Laurent Bessard
parents:
982
diff
changeset
|
212 |
dc.SetBrush(wx.Brush(wx.NamedColour("LIGHT GREY"))) |
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
213 |
|
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
214 |
dc.DrawRectangle(self.Position.x, self.Position.y, |
983
7dd481eef3b5
Replaced left ugly buttons in LogViewer by custom buttons inside MessagePanel
Laurent Bessard
parents:
982
diff
changeset
|
215 |
self.Size.width, self.Size.height) |
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
216 |
|
983
7dd481eef3b5
Replaced left ugly buttons in LogViewer by custom buttons inside MessagePanel
Laurent Bessard
parents:
982
diff
changeset
|
217 |
w, h = dc.GetTextExtent(self.Label) |
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
218 |
dc.DrawText(self.Label, |
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
219 |
self.Position.x + (self.Size.width - w) / 2, |
983
7dd481eef3b5
Replaced left ugly buttons in LogViewer by custom buttons inside MessagePanel
Laurent Bessard
parents:
982
diff
changeset
|
220 |
self.Position.y + (self.Size.height - h) / 2) |
7dd481eef3b5
Replaced left ugly buttons in LogViewer by custom buttons inside MessagePanel
Laurent Bessard
parents:
982
diff
changeset
|
221 |
|
978 | 222 |
DATE_INFO_SIZE = 10 |
997 | 223 |
MESSAGE_INFO_SIZE = 18 |
978 | 224 |
|
225 |
class LogMessage: |
|
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
226 |
|
978 | 227 |
def __init__(self, tv_sec, tv_nsec, level, level_bitmap, msg): |
1076
2a02c6404124
Fixed bug in displayed datetime, using local timezone instead of UTC
Laurent Bessard
parents:
1071
diff
changeset
|
228 |
self.Date = datetime.utcfromtimestamp(tv_sec) |
978 | 229 |
self.Seconds = self.Date.second + tv_nsec * 1e-9 |
230 |
self.Date = self.Date.replace(second=0) |
|
982
e3c264099bd0
Added support in LogViewer for scrolling using relative timestamp
Laurent Bessard
parents:
981
diff
changeset
|
231 |
self.Timestamp = tv_sec + tv_nsec * 1e-9 |
978 | 232 |
self.Level = level |
233 |
self.LevelBitmap = level_bitmap |
|
234 |
self.Message = msg |
|
235 |
self.DrawDate = True |
|
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
236 |
|
978 | 237 |
def __cmp__(self, other): |
238 |
if self.Date == other.Date: |
|
239 |
return cmp(self.Seconds, other.Seconds) |
|
240 |
return cmp(self.Date, other.Date) |
|
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
241 |
|
993 | 242 |
def GetFullText(self): |
243 |
date = self.Date.replace(second=int(self.Seconds)) |
|
244 |
nsec = (self.Seconds % 1.) * 1e9 |
|
245 |
return "%s at %s.%9.9d:\n%s" % ( |
|
246 |
LogLevels[self.Level], |
|
247 |
str(date), nsec, |
|
248 |
self.Message) |
|
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
249 |
|
978 | 250 |
def Draw(self, dc, offset, width, draw_date): |
251 |
if draw_date: |
|
252 |
datetime_text = self.Date.strftime("%d/%m/%y %H:%M") |
|
253 |
dw, dh = dc.GetTextExtent(datetime_text) |
|
254 |
dc.DrawText(datetime_text, (width - dw) / 2, offset + (DATE_INFO_SIZE - dh) / 2) |
|
255 |
offset += DATE_INFO_SIZE |
|
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
256 |
|
978 | 257 |
seconds_text = "%12.9f" % self.Seconds |
258 |
sw, sh = dc.GetTextExtent(seconds_text) |
|
259 |
dc.DrawText(seconds_text, 5, offset + (MESSAGE_INFO_SIZE - sh) / 2) |
|
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
260 |
|
978 | 261 |
bw, bh = self.LevelBitmap.GetWidth(), self.LevelBitmap.GetHeight() |
262 |
dc.DrawBitmap(self.LevelBitmap, 10 + sw, offset + (MESSAGE_INFO_SIZE - bh) / 2) |
|
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
263 |
|
993 | 264 |
text = self.Message.replace("\n", " ") |
265 |
mw, mh = dc.GetTextExtent(text) |
|
266 |
dc.DrawText(text, 15 + sw + bw, offset + (MESSAGE_INFO_SIZE - mh) / 2) |
|
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
267 |
|
978 | 268 |
def GetHeight(self, draw_date): |
269 |
if draw_date: |
|
270 |
return DATE_INFO_SIZE + MESSAGE_INFO_SIZE |
|
271 |
return MESSAGE_INFO_SIZE |
|
272 |
||
273 |
SECOND = 1 |
|
274 |
MINUTE = 60 * SECOND |
|
275 |
HOUR = 60 * MINUTE |
|
276 |
DAY = 24 * HOUR |
|
277 |
||
278 |
CHANGE_TIMESTAMP_BUTTONS = [(_("1d"), DAY), |
|
279 |
(_("1h"), HOUR), |
|
986 | 280 |
(_("1m"), MINUTE), |
281 |
(_("1s"), SECOND)] |
|
978 | 282 |
|
283 |
class LogViewer(DebugViewer, wx.Panel): |
|
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
284 |
|
978 | 285 |
def __init__(self, parent, window): |
286 |
wx.Panel.__init__(self, parent, style=wx.TAB_TRAVERSAL|wx.SUNKEN_BORDER) |
|
287 |
DebugViewer.__init__(self, None, False, False) |
|
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
288 |
|
978 | 289 |
main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5) |
290 |
main_sizer.AddGrowableCol(0) |
|
291 |
main_sizer.AddGrowableRow(1) |
|
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
292 |
|
978 | 293 |
filter_sizer = wx.BoxSizer(wx.HORIZONTAL) |
294 |
main_sizer.AddSizer(filter_sizer, border=5, flag=wx.TOP|wx.LEFT|wx.RIGHT|wx.GROW) |
|
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
295 |
|
978 | 296 |
self.MessageFilter = wx.ComboBox(self, style=wx.CB_READONLY) |
297 |
self.MessageFilter.Append(_("All")) |
|
298 |
levels = LogLevels[:3] |
|
299 |
levels.reverse() |
|
300 |
for level in levels: |
|
301 |
self.MessageFilter.Append(_(level)) |
|
302 |
self.Bind(wx.EVT_COMBOBOX, self.OnMessageFilterChanged, self.MessageFilter) |
|
1094 | 303 |
filter_sizer.AddWindow(self.MessageFilter, 1, border=5, flag=wx.RIGHT|wx.ALIGN_CENTER_VERTICAL) |
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
304 |
|
981
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
305 |
self.SearchMessage = wx.SearchCtrl(self, style=wx.TE_PROCESS_ENTER) |
978 | 306 |
self.SearchMessage.ShowSearchButton(True) |
981
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
307 |
self.SearchMessage.ShowCancelButton(True) |
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
308 |
self.Bind(wx.EVT_TEXT_ENTER, self.OnSearchMessageChanged, self.SearchMessage) |
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
309 |
self.Bind(wx.EVT_SEARCHCTRL_SEARCH_BTN, |
981
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
310 |
self.OnSearchMessageSearchButtonClick, self.SearchMessage) |
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
311 |
self.Bind(wx.EVT_SEARCHCTRL_CANCEL_BTN, |
981
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
312 |
self.OnSearchMessageCancelButtonClick, self.SearchMessage) |
1094 | 313 |
filter_sizer.AddWindow(self.SearchMessage, 3, border=5, flag=wx.RIGHT|wx.ALIGN_CENTER_VERTICAL) |
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
314 |
|
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
315 |
self.CleanButton = wx.lib.buttons.GenBitmapButton(self, bitmap=GetBitmap("Clean"), |
1093 | 316 |
size=wx.Size(28, 28), style=wx.NO_BORDER) |
317 |
self.CleanButton.SetToolTipString(_("Clean log messages")) |
|
318 |
self.Bind(wx.EVT_BUTTON, self.OnCleanButton, self.CleanButton) |
|
319 |
filter_sizer.AddWindow(self.CleanButton) |
|
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
320 |
|
983
7dd481eef3b5
Replaced left ugly buttons in LogViewer by custom buttons inside MessagePanel
Laurent Bessard
parents:
982
diff
changeset
|
321 |
message_panel_sizer = wx.FlexGridSizer(cols=2, hgap=0, rows=1, vgap=0) |
7dd481eef3b5
Replaced left ugly buttons in LogViewer by custom buttons inside MessagePanel
Laurent Bessard
parents:
982
diff
changeset
|
322 |
message_panel_sizer.AddGrowableCol(0) |
978 | 323 |
message_panel_sizer.AddGrowableRow(0) |
324 |
main_sizer.AddSizer(message_panel_sizer, border=5, flag=wx.LEFT|wx.RIGHT|wx.BOTTOM|wx.GROW) |
|
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
325 |
|
978 | 326 |
self.MessagePanel = wx.Panel(self) |
327 |
if wx.Platform == '__WXMSW__': |
|
993 | 328 |
self.Font = wx.Font(8, wx.SWISS, wx.NORMAL, wx.NORMAL, faceName='Courier New') |
978 | 329 |
else: |
993 | 330 |
self.Font = wx.Font(10, wx.SWISS, wx.NORMAL, wx.NORMAL, faceName='Courier') |
984 | 331 |
self.MessagePanel.Bind(wx.EVT_LEFT_UP, self.OnMessagePanelLeftUp) |
993 | 332 |
self.MessagePanel.Bind(wx.EVT_RIGHT_UP, self.OnMessagePanelRightUp) |
986 | 333 |
self.MessagePanel.Bind(wx.EVT_LEFT_DCLICK, self.OnMessagePanelLeftDCLick) |
993 | 334 |
self.MessagePanel.Bind(wx.EVT_MOTION, self.OnMessagePanelMotion) |
335 |
self.MessagePanel.Bind(wx.EVT_LEAVE_WINDOW, self.OnMessagePanelLeaveWindow) |
|
981
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
336 |
self.MessagePanel.Bind(wx.EVT_MOUSEWHEEL, self.OnMessagePanelMouseWheel) |
988
30e7571c10d0
Reduced flicker on LogViewer and DebugGraphPanel on Windows
Laurent Bessard
parents:
987
diff
changeset
|
337 |
self.MessagePanel.Bind(wx.EVT_ERASE_BACKGROUND, self.OnMessagePanelEraseBackground) |
978 | 338 |
self.MessagePanel.Bind(wx.EVT_PAINT, self.OnMessagePanelPaint) |
339 |
self.MessagePanel.Bind(wx.EVT_SIZE, self.OnMessagePanelResize) |
|
340 |
message_panel_sizer.AddWindow(self.MessagePanel, flag=wx.GROW) |
|
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
341 |
|
983
7dd481eef3b5
Replaced left ugly buttons in LogViewer by custom buttons inside MessagePanel
Laurent Bessard
parents:
982
diff
changeset
|
342 |
self.MessageScrollBar = LogScrollBar(self, wx.Size(16, -1)) |
978 | 343 |
message_panel_sizer.AddWindow(self.MessageScrollBar, flag=wx.GROW) |
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
344 |
|
978 | 345 |
self.SetSizer(main_sizer) |
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
346 |
|
983
7dd481eef3b5
Replaced left ugly buttons in LogViewer by custom buttons inside MessagePanel
Laurent Bessard
parents:
982
diff
changeset
|
347 |
self.LeftButtons = [] |
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
348 |
for label, callback in [("+" + text, self.GenerateOnDurationButton(duration)) |
983
7dd481eef3b5
Replaced left ugly buttons in LogViewer by custom buttons inside MessagePanel
Laurent Bessard
parents:
982
diff
changeset
|
349 |
for text, duration in CHANGE_TIMESTAMP_BUTTONS]: |
7dd481eef3b5
Replaced left ugly buttons in LogViewer by custom buttons inside MessagePanel
Laurent Bessard
parents:
982
diff
changeset
|
350 |
self.LeftButtons.append(LogButton(label, callback)) |
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
351 |
|
983
7dd481eef3b5
Replaced left ugly buttons in LogViewer by custom buttons inside MessagePanel
Laurent Bessard
parents:
982
diff
changeset
|
352 |
self.RightButtons = [] |
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
353 |
for label, callback in [("-" + text, self.GenerateOnDurationButton(-duration)) |
983
7dd481eef3b5
Replaced left ugly buttons in LogViewer by custom buttons inside MessagePanel
Laurent Bessard
parents:
982
diff
changeset
|
354 |
for text, duration in CHANGE_TIMESTAMP_BUTTONS]: |
7dd481eef3b5
Replaced left ugly buttons in LogViewer by custom buttons inside MessagePanel
Laurent Bessard
parents:
982
diff
changeset
|
355 |
self.RightButtons.append(LogButton(label, callback)) |
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
356 |
|
978 | 357 |
self.MessageFilter.SetSelection(0) |
358 |
self.LogSource = None |
|
359 |
self.ResetLogMessages() |
|
360 |
self.ParentWindow = window |
|
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
361 |
|
979 | 362 |
self.LevelIcons = [GetBitmap("LOG_" + level) for level in LogLevels] |
978 | 363 |
self.LevelFilters = [range(i) for i in xrange(4, 0, -1)] |
364 |
self.CurrentFilter = self.LevelFilters[0] |
|
981
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
365 |
self.CurrentSearchValue = "" |
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
366 |
|
981
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
367 |
self.ScrollSpeed = 0. |
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
368 |
self.LastStartTime = None |
978 | 369 |
self.ScrollTimer = wx.Timer(self, -1) |
370 |
self.Bind(wx.EVT_TIMER, self.OnScrollTimer, self.ScrollTimer) |
|
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
371 |
|
993 | 372 |
self.LastMousePos = None |
373 |
self.MessageToolTip = None |
|
374 |
self.MessageToolTipTimer = wx.Timer(self, -1) |
|
375 |
self.Bind(wx.EVT_TIMER, self.OnMessageToolTipTimer, self.MessageToolTipTimer) |
|
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
376 |
|
978 | 377 |
def __del__(self): |
378 |
self.ScrollTimer.Stop() |
|
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
379 |
|
978 | 380 |
def ResetLogMessages(self): |
381 |
self.previous_log_count = [None]*LogLevelsCount |
|
382 |
self.OldestMessages = [] |
|
383 |
self.LogMessages = [] |
|
982
e3c264099bd0
Added support in LogViewer for scrolling using relative timestamp
Laurent Bessard
parents:
981
diff
changeset
|
384 |
self.LogMessagesTimestamp = numpy.array([]) |
978 | 385 |
self.CurrentMessage = None |
386 |
self.HasNewData = False |
|
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
387 |
|
978 | 388 |
def SetLogSource(self, log_source): |
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
389 |
self.LogSource = proxy(log_source) if log_source else None |
1093 | 390 |
self.CleanButton.Enable(self.LogSource is not None) |
978 | 391 |
if log_source is not None: |
392 |
self.ResetLogMessages() |
|
393 |
self.RefreshView() |
|
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
394 |
|
978 | 395 |
def GetLogMessageFromSource(self, msgidx, level): |
396 |
if self.LogSource is not None: |
|
397 |
answer = self.LogSource.GetLogMessage(level, msgidx) |
|
398 |
if answer is not None: |
|
399 |
msg, tick, tv_sec, tv_nsec = answer |
|
400 |
return LogMessage(tv_sec, tv_nsec, level, self.LevelIcons[level], msg) |
|
401 |
return None |
|
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
402 |
|
978 | 403 |
def SetLogCounters(self, log_count): |
404 |
new_messages = [] |
|
405 |
for level, count, prev in zip(xrange(LogLevelsCount), log_count, self.previous_log_count): |
|
406 |
if count is not None and prev != count: |
|
407 |
if prev is None: |
|
1195
8f8d9859e9fc
Fixed bug when collecting log messages from connector history for LogViewer
Laurent Bessard
parents:
1176
diff
changeset
|
408 |
dump_end = max(-1, count - 10) |
8f8d9859e9fc
Fixed bug when collecting log messages from connector history for LogViewer
Laurent Bessard
parents:
1176
diff
changeset
|
409 |
oldest_message = (-1, None) |
978 | 410 |
else: |
411 |
dump_end = prev - 1 |
|
412 |
for msgidx in xrange(count-1, dump_end,-1): |
|
413 |
new_message = self.GetLogMessageFromSource(msgidx, level) |
|
1093 | 414 |
if new_message is None: |
1195
8f8d9859e9fc
Fixed bug when collecting log messages from connector history for LogViewer
Laurent Bessard
parents:
1176
diff
changeset
|
415 |
if prev is None: |
8f8d9859e9fc
Fixed bug when collecting log messages from connector history for LogViewer
Laurent Bessard
parents:
1176
diff
changeset
|
416 |
oldest_message = (-1, None) |
1093 | 417 |
break |
418 |
if prev is None: |
|
1195
8f8d9859e9fc
Fixed bug when collecting log messages from connector history for LogViewer
Laurent Bessard
parents:
1176
diff
changeset
|
419 |
oldest_message = (msgidx, new_message) |
1093 | 420 |
if len(new_messages) == 0: |
421 |
new_messages = [new_message] |
|
978 | 422 |
else: |
423 |
new_messages.insert(0, new_message) |
|
1093 | 424 |
else: |
425 |
new_messages.insert(0, new_message) |
|
1079
6c8dfc4fc23b
Fixed bug in LogViewer when no Log Messages are available when first SetLogCounters
Laurent Bessard
parents:
1077
diff
changeset
|
426 |
if prev is None and len(self.OldestMessages) <= level: |
1195
8f8d9859e9fc
Fixed bug when collecting log messages from connector history for LogViewer
Laurent Bessard
parents:
1176
diff
changeset
|
427 |
self.OldestMessages.append(oldest_message) |
978 | 428 |
self.previous_log_count[level] = count |
429 |
new_messages.sort() |
|
430 |
if len(new_messages) > 0: |
|
431 |
self.HasNewData = True |
|
1071
5e740fe71fbe
Fixed bug in LogViewer when view is filtered and displaying last message and new messages appears
Laurent Bessard
parents:
1020
diff
changeset
|
432 |
if self.CurrentMessage is not None: |
5e740fe71fbe
Fixed bug in LogViewer when view is filtered and displaying last message and new messages appears
Laurent Bessard
parents:
1020
diff
changeset
|
433 |
current_is_last = self.GetNextMessage(self.CurrentMessage)[0] is None |
5e740fe71fbe
Fixed bug in LogViewer when view is filtered and displaying last message and new messages appears
Laurent Bessard
parents:
1020
diff
changeset
|
434 |
else: |
5e740fe71fbe
Fixed bug in LogViewer when view is filtered and displaying last message and new messages appears
Laurent Bessard
parents:
1020
diff
changeset
|
435 |
current_is_last = True |
978 | 436 |
for new_message in new_messages: |
437 |
self.LogMessages.append(new_message) |
|
982
e3c264099bd0
Added support in LogViewer for scrolling using relative timestamp
Laurent Bessard
parents:
981
diff
changeset
|
438 |
self.LogMessagesTimestamp = numpy.append(self.LogMessagesTimestamp, [new_message.Timestamp]) |
1071
5e740fe71fbe
Fixed bug in LogViewer when view is filtered and displaying last message and new messages appears
Laurent Bessard
parents:
1020
diff
changeset
|
439 |
if current_is_last: |
5e740fe71fbe
Fixed bug in LogViewer when view is filtered and displaying last message and new messages appears
Laurent Bessard
parents:
1020
diff
changeset
|
440 |
self.ScrollToLast(False) |
993 | 441 |
self.ResetMessageToolTip() |
442 |
self.MessageToolTipTimer.Stop() |
|
999
cbab4c1635bd
Replaced LogConsole TextCtrl by StyledTextCtrl
Laurent Bessard
parents:
997
diff
changeset
|
443 |
self.ParentWindow.SelectTab(self) |
978 | 444 |
self.NewDataAvailable(None) |
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
445 |
|
982
e3c264099bd0
Added support in LogViewer for scrolling using relative timestamp
Laurent Bessard
parents:
981
diff
changeset
|
446 |
def FilterLogMessage(self, message, timestamp=None): |
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
447 |
return (message.Level in self.CurrentFilter and |
982
e3c264099bd0
Added support in LogViewer for scrolling using relative timestamp
Laurent Bessard
parents:
981
diff
changeset
|
448 |
message.Message.find(self.CurrentSearchValue) != -1 and |
e3c264099bd0
Added support in LogViewer for scrolling using relative timestamp
Laurent Bessard
parents:
981
diff
changeset
|
449 |
(timestamp is None or message.Timestamp < timestamp)) |
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
450 |
|
982
e3c264099bd0
Added support in LogViewer for scrolling using relative timestamp
Laurent Bessard
parents:
981
diff
changeset
|
451 |
def GetMessageByTimestamp(self, timestamp): |
e3c264099bd0
Added support in LogViewer for scrolling using relative timestamp
Laurent Bessard
parents:
981
diff
changeset
|
452 |
if self.CurrentMessage is not None: |
e3c264099bd0
Added support in LogViewer for scrolling using relative timestamp
Laurent Bessard
parents:
981
diff
changeset
|
453 |
msgidx = numpy.argmin(abs(self.LogMessagesTimestamp - timestamp)) |
e3c264099bd0
Added support in LogViewer for scrolling using relative timestamp
Laurent Bessard
parents:
981
diff
changeset
|
454 |
message = self.LogMessages[msgidx] |
e3c264099bd0
Added support in LogViewer for scrolling using relative timestamp
Laurent Bessard
parents:
981
diff
changeset
|
455 |
if self.FilterLogMessage(message) and message.Timestamp > timestamp: |
e3c264099bd0
Added support in LogViewer for scrolling using relative timestamp
Laurent Bessard
parents:
981
diff
changeset
|
456 |
return self.GetPreviousMessage(msgidx, timestamp) |
e3c264099bd0
Added support in LogViewer for scrolling using relative timestamp
Laurent Bessard
parents:
981
diff
changeset
|
457 |
return message, msgidx |
e3c264099bd0
Added support in LogViewer for scrolling using relative timestamp
Laurent Bessard
parents:
981
diff
changeset
|
458 |
return None, None |
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
459 |
|
981
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
460 |
def GetNextMessage(self, msgidx): |
978 | 461 |
while msgidx < len(self.LogMessages) - 1: |
462 |
message = self.LogMessages[msgidx + 1] |
|
981
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
463 |
if self.FilterLogMessage(message): |
978 | 464 |
return message, msgidx + 1 |
465 |
msgidx += 1 |
|
466 |
return None, None |
|
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
467 |
|
982
e3c264099bd0
Added support in LogViewer for scrolling using relative timestamp
Laurent Bessard
parents:
981
diff
changeset
|
468 |
def GetPreviousMessage(self, msgidx, timestamp=None): |
978 | 469 |
message = None |
470 |
while 0 < msgidx < len(self.LogMessages): |
|
471 |
message = self.LogMessages[msgidx - 1] |
|
982
e3c264099bd0
Added support in LogViewer for scrolling using relative timestamp
Laurent Bessard
parents:
981
diff
changeset
|
472 |
if self.FilterLogMessage(message, timestamp): |
978 | 473 |
return message, msgidx - 1 |
474 |
msgidx -= 1 |
|
475 |
if len(self.LogMessages) > 0: |
|
476 |
message = self.LogMessages[0] |
|
1195
8f8d9859e9fc
Fixed bug when collecting log messages from connector history for LogViewer
Laurent Bessard
parents:
1176
diff
changeset
|
477 |
for idx, msg in self.OldestMessages: |
8f8d9859e9fc
Fixed bug when collecting log messages from connector history for LogViewer
Laurent Bessard
parents:
1176
diff
changeset
|
478 |
if msg is not None and msg > message: |
8f8d9859e9fc
Fixed bug when collecting log messages from connector history for LogViewer
Laurent Bessard
parents:
1176
diff
changeset
|
479 |
message = msg |
978 | 480 |
while message is not None: |
481 |
level = message.Level |
|
482 |
oldest_msgidx, oldest_message = self.OldestMessages[level] |
|
483 |
if oldest_msgidx > 0: |
|
1195
8f8d9859e9fc
Fixed bug when collecting log messages from connector history for LogViewer
Laurent Bessard
parents:
1176
diff
changeset
|
484 |
message = self.GetLogMessageFromSource(oldest_msgidx - 1, level) |
8f8d9859e9fc
Fixed bug when collecting log messages from connector history for LogViewer
Laurent Bessard
parents:
1176
diff
changeset
|
485 |
if message is not None: |
8f8d9859e9fc
Fixed bug when collecting log messages from connector history for LogViewer
Laurent Bessard
parents:
1176
diff
changeset
|
486 |
self.OldestMessages[level] = (oldest_msgidx - 1, message) |
978 | 487 |
else: |
488 |
self.OldestMessages[level] = (-1, None) |
|
489 |
else: |
|
1195
8f8d9859e9fc
Fixed bug when collecting log messages from connector history for LogViewer
Laurent Bessard
parents:
1176
diff
changeset
|
490 |
message = None |
978 | 491 |
self.OldestMessages[level] = (-1, None) |
1195
8f8d9859e9fc
Fixed bug when collecting log messages from connector history for LogViewer
Laurent Bessard
parents:
1176
diff
changeset
|
492 |
if message is not None: |
8f8d9859e9fc
Fixed bug when collecting log messages from connector history for LogViewer
Laurent Bessard
parents:
1176
diff
changeset
|
493 |
message_idx = 0 |
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
494 |
while (message_idx < len(self.LogMessages) and |
1195
8f8d9859e9fc
Fixed bug when collecting log messages from connector history for LogViewer
Laurent Bessard
parents:
1176
diff
changeset
|
495 |
self.LogMessages[message_idx] < message): |
8f8d9859e9fc
Fixed bug when collecting log messages from connector history for LogViewer
Laurent Bessard
parents:
1176
diff
changeset
|
496 |
message_idx += 1 |
8f8d9859e9fc
Fixed bug when collecting log messages from connector history for LogViewer
Laurent Bessard
parents:
1176
diff
changeset
|
497 |
if len(self.LogMessages) > 0: |
8f8d9859e9fc
Fixed bug when collecting log messages from connector history for LogViewer
Laurent Bessard
parents:
1176
diff
changeset
|
498 |
current_message = self.LogMessages[self.CurrentMessage] |
8f8d9859e9fc
Fixed bug when collecting log messages from connector history for LogViewer
Laurent Bessard
parents:
1176
diff
changeset
|
499 |
else: |
8f8d9859e9fc
Fixed bug when collecting log messages from connector history for LogViewer
Laurent Bessard
parents:
1176
diff
changeset
|
500 |
current_message = message |
8f8d9859e9fc
Fixed bug when collecting log messages from connector history for LogViewer
Laurent Bessard
parents:
1176
diff
changeset
|
501 |
self.LogMessages.insert(message_idx, message) |
8f8d9859e9fc
Fixed bug when collecting log messages from connector history for LogViewer
Laurent Bessard
parents:
1176
diff
changeset
|
502 |
self.LogMessagesTimestamp = numpy.insert( |
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
503 |
self.LogMessagesTimestamp, |
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
504 |
[message_idx], |
1195
8f8d9859e9fc
Fixed bug when collecting log messages from connector history for LogViewer
Laurent Bessard
parents:
1176
diff
changeset
|
505 |
[message.Timestamp]) |
8f8d9859e9fc
Fixed bug when collecting log messages from connector history for LogViewer
Laurent Bessard
parents:
1176
diff
changeset
|
506 |
self.CurrentMessage = self.LogMessages.index(current_message) |
8f8d9859e9fc
Fixed bug when collecting log messages from connector history for LogViewer
Laurent Bessard
parents:
1176
diff
changeset
|
507 |
if message_idx == 0 and self.FilterLogMessage(message, timestamp): |
8f8d9859e9fc
Fixed bug when collecting log messages from connector history for LogViewer
Laurent Bessard
parents:
1176
diff
changeset
|
508 |
return message, 0 |
978 | 509 |
for idx, msg in self.OldestMessages: |
510 |
if msg is not None and (message is None or msg > message): |
|
511 |
message = msg |
|
512 |
return None, None |
|
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
513 |
|
978 | 514 |
def RefreshNewData(self, *args, **kwargs): |
515 |
if self.HasNewData: |
|
516 |
self.HasNewData = False |
|
517 |
self.RefreshView() |
|
518 |
DebugViewer.RefreshNewData(self, *args, **kwargs) |
|
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
519 |
|
978 | 520 |
def RefreshView(self): |
521 |
width, height = self.MessagePanel.GetClientSize() |
|
522 |
bitmap = wx.EmptyBitmap(width, height) |
|
523 |
dc = wx.BufferedDC(wx.ClientDC(self.MessagePanel), bitmap) |
|
524 |
dc.Clear() |
|
525 |
dc.BeginDrawing() |
|
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
526 |
|
978 | 527 |
if self.CurrentMessage is not None: |
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
528 |
|
993 | 529 |
dc.SetFont(self.Font) |
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
530 |
|
983
7dd481eef3b5
Replaced left ugly buttons in LogViewer by custom buttons inside MessagePanel
Laurent Bessard
parents:
982
diff
changeset
|
531 |
for button in self.LeftButtons + self.RightButtons: |
7dd481eef3b5
Replaced left ugly buttons in LogViewer by custom buttons inside MessagePanel
Laurent Bessard
parents:
982
diff
changeset
|
532 |
button.Draw(dc) |
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
533 |
|
978 | 534 |
message_idx = self.CurrentMessage |
535 |
message = self.LogMessages[message_idx] |
|
536 |
draw_date = True |
|
537 |
offset = 5 |
|
538 |
while offset < height and message is not None: |
|
539 |
message.Draw(dc, offset, width, draw_date) |
|
540 |
offset += message.GetHeight(draw_date) |
|
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
541 |
|
981
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
542 |
previous_message, message_idx = self.GetPreviousMessage(message_idx) |
978 | 543 |
if previous_message is not None: |
544 |
draw_date = message.Date != previous_message.Date |
|
545 |
message = previous_message |
|
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
546 |
|
978 | 547 |
dc.EndDrawing() |
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
548 |
|
981
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
549 |
self.MessageScrollBar.RefreshThumbPosition() |
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
550 |
|
978 | 551 |
def IsMessagePanelTop(self, message_idx=None): |
552 |
if message_idx is None: |
|
553 |
message_idx = self.CurrentMessage |
|
554 |
if message_idx is not None: |
|
981
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
555 |
return self.GetNextMessage(message_idx)[0] is None |
978 | 556 |
return True |
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
557 |
|
978 | 558 |
def IsMessagePanelBottom(self, message_idx=None): |
559 |
if message_idx is None: |
|
560 |
message_idx = self.CurrentMessage |
|
561 |
if message_idx is not None: |
|
562 |
width, height = self.MessagePanel.GetClientSize() |
|
563 |
offset = 5 |
|
564 |
message = self.LogMessages[message_idx] |
|
565 |
draw_date = True |
|
566 |
while message is not None and offset < height: |
|
567 |
offset += message.GetHeight(draw_date) |
|
981
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
568 |
previous_message, message_idx = self.GetPreviousMessage(message_idx) |
978 | 569 |
if previous_message is not None: |
570 |
draw_date = message.Date != previous_message.Date |
|
571 |
message = previous_message |
|
572 |
return offset < height |
|
573 |
return True |
|
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
574 |
|
978 | 575 |
def ScrollMessagePanel(self, scroll): |
576 |
if self.CurrentMessage is not None: |
|
577 |
message = self.LogMessages[self.CurrentMessage] |
|
578 |
while scroll > 0 and message is not None: |
|
981
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
579 |
message, msgidx = self.GetNextMessage(self.CurrentMessage) |
978 | 580 |
if message is not None: |
581 |
self.CurrentMessage = msgidx |
|
582 |
scroll -= 1 |
|
583 |
while scroll < 0 and message is not None and not self.IsMessagePanelBottom(): |
|
981
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
584 |
message, msgidx = self.GetPreviousMessage(self.CurrentMessage) |
978 | 585 |
if message is not None: |
586 |
self.CurrentMessage = msgidx |
|
587 |
scroll += 1 |
|
588 |
self.RefreshView() |
|
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
589 |
|
986 | 590 |
def ScrollMessagePanelByPage(self, page): |
591 |
if self.CurrentMessage is not None: |
|
592 |
width, height = self.MessagePanel.GetClientSize() |
|
593 |
message_per_page = max(1, (height - DATE_INFO_SIZE) / MESSAGE_INFO_SIZE - 1) |
|
594 |
self.ScrollMessagePanel(page * message_per_page) |
|
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
595 |
|
982
e3c264099bd0
Added support in LogViewer for scrolling using relative timestamp
Laurent Bessard
parents:
981
diff
changeset
|
596 |
def ScrollMessagePanelByTimestamp(self, seconds): |
e3c264099bd0
Added support in LogViewer for scrolling using relative timestamp
Laurent Bessard
parents:
981
diff
changeset
|
597 |
if self.CurrentMessage is not None: |
e3c264099bd0
Added support in LogViewer for scrolling using relative timestamp
Laurent Bessard
parents:
981
diff
changeset
|
598 |
current_message = self.LogMessages[self.CurrentMessage] |
e3c264099bd0
Added support in LogViewer for scrolling using relative timestamp
Laurent Bessard
parents:
981
diff
changeset
|
599 |
message, msgidx = self.GetMessageByTimestamp(current_message.Timestamp + seconds) |
e3c264099bd0
Added support in LogViewer for scrolling using relative timestamp
Laurent Bessard
parents:
981
diff
changeset
|
600 |
if message is None or self.IsMessagePanelBottom(msgidx): |
e3c264099bd0
Added support in LogViewer for scrolling using relative timestamp
Laurent Bessard
parents:
981
diff
changeset
|
601 |
self.ScrollToFirst() |
e3c264099bd0
Added support in LogViewer for scrolling using relative timestamp
Laurent Bessard
parents:
981
diff
changeset
|
602 |
else: |
1020
2d20f25cd39f
Fixed bug log viewer not scrolling when clicking on +1s and +1m when time between 2 message is greater than 1s or 1m
Laurent Bessard
parents:
999
diff
changeset
|
603 |
if seconds > 0 and self.CurrentMessage == msgidx and msgidx < len(self.LogMessages) - 1: |
2d20f25cd39f
Fixed bug log viewer not scrolling when clicking on +1s and +1m when time between 2 message is greater than 1s or 1m
Laurent Bessard
parents:
999
diff
changeset
|
604 |
msgidx += 1 |
982
e3c264099bd0
Added support in LogViewer for scrolling using relative timestamp
Laurent Bessard
parents:
981
diff
changeset
|
605 |
self.CurrentMessage = msgidx |
984 | 606 |
self.RefreshView() |
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
607 |
|
981
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
608 |
def ResetMessagePanel(self): |
978 | 609 |
if len(self.LogMessages) > 0: |
610 |
self.CurrentMessage = len(self.LogMessages) - 1 |
|
611 |
message = self.LogMessages[self.CurrentMessage] |
|
981
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
612 |
while message is not None and not self.FilterLogMessage(message): |
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
613 |
message, self.CurrentMessage = self.GetPreviousMessage(self.CurrentMessage) |
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
614 |
self.RefreshView() |
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
615 |
|
981
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
616 |
def OnMessageFilterChanged(self, event): |
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
617 |
self.CurrentFilter = self.LevelFilters[self.MessageFilter.GetSelection()] |
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
618 |
self.ResetMessagePanel() |
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
619 |
event.Skip() |
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
620 |
|
981
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
621 |
def OnSearchMessageChanged(self, event): |
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
622 |
self.CurrentSearchValue = self.SearchMessage.GetValue() |
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
623 |
self.ResetMessagePanel() |
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
624 |
event.Skip() |
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
625 |
|
981
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
626 |
def OnSearchMessageSearchButtonClick(self, event): |
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
627 |
self.CurrentSearchValue = self.SearchMessage.GetValue() |
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
628 |
self.ResetMessagePanel() |
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
629 |
event.Skip() |
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
630 |
|
981
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
631 |
def OnSearchMessageCancelButtonClick(self, event): |
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
632 |
self.CurrentSearchValue = "" |
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
633 |
self.SearchMessage.SetValue("") |
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
634 |
self.ResetMessagePanel() |
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
635 |
event.Skip() |
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
636 |
|
1093 | 637 |
def OnCleanButton(self, event): |
638 |
if self.LogSource is not None: |
|
639 |
self.LogSource.ResetLogCount() |
|
640 |
self.ResetLogMessages() |
|
641 |
self.RefreshView() |
|
642 |
event.Skip() |
|
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
643 |
|
981
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
644 |
def GenerateOnDurationButton(self, duration): |
983
7dd481eef3b5
Replaced left ugly buttons in LogViewer by custom buttons inside MessagePanel
Laurent Bessard
parents:
982
diff
changeset
|
645 |
def OnDurationButton(): |
982
e3c264099bd0
Added support in LogViewer for scrolling using relative timestamp
Laurent Bessard
parents:
981
diff
changeset
|
646 |
self.ScrollMessagePanelByTimestamp(duration) |
981
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
647 |
return OnDurationButton |
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
648 |
|
993 | 649 |
def GetCopyMessageToClipboardFunction(self, message): |
650 |
def CopyMessageToClipboardFunction(event): |
|
651 |
self.ParentWindow.SetCopyBuffer(message.GetFullText()) |
|
652 |
return CopyMessageToClipboardFunction |
|
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
653 |
|
993 | 654 |
def GetMessageByScreenPos(self, posx, posy): |
983
7dd481eef3b5
Replaced left ugly buttons in LogViewer by custom buttons inside MessagePanel
Laurent Bessard
parents:
982
diff
changeset
|
655 |
if self.CurrentMessage is not None: |
986 | 656 |
width, height = self.MessagePanel.GetClientSize() |
657 |
message_idx = self.CurrentMessage |
|
658 |
message = self.LogMessages[message_idx] |
|
659 |
draw_date = True |
|
660 |
offset = 5 |
|
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
661 |
|
986 | 662 |
while offset < height and message is not None: |
663 |
if draw_date: |
|
664 |
offset += DATE_INFO_SIZE |
|
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
665 |
|
986 | 666 |
if offset <= posy < offset + MESSAGE_INFO_SIZE: |
993 | 667 |
return message |
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
668 |
|
986 | 669 |
offset += MESSAGE_INFO_SIZE |
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
670 |
|
986 | 671 |
previous_message, message_idx = self.GetPreviousMessage(message_idx) |
672 |
if previous_message is not None: |
|
673 |
draw_date = message.Date != previous_message.Date |
|
674 |
message = previous_message |
|
993 | 675 |
return None |
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
676 |
|
993 | 677 |
def OnMessagePanelLeftUp(self, event): |
678 |
if self.CurrentMessage is not None: |
|
679 |
posx, posy = event.GetPosition() |
|
680 |
for button in self.LeftButtons + self.RightButtons: |
|
681 |
if button.HitTest(posx, posy): |
|
682 |
button.ProcessCallback() |
|
683 |
break |
|
684 |
event.Skip() |
|
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
685 |
|
993 | 686 |
def OnMessagePanelRightUp(self, event): |
687 |
message = self.GetMessageByScreenPos(*event.GetPosition()) |
|
688 |
if message is not None: |
|
689 |
menu = wx.Menu(title='') |
|
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
690 |
|
993 | 691 |
new_id = wx.NewId() |
692 |
menu.Append(help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Copy")) |
|
693 |
self.Bind(wx.EVT_MENU, self.GetCopyMessageToClipboardFunction(message), id=new_id) |
|
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
694 |
|
993 | 695 |
self.MessagePanel.PopupMenu(menu) |
696 |
menu.Destroy() |
|
697 |
event.Skip() |
|
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
698 |
|
993 | 699 |
def OnMessagePanelLeftDCLick(self, event): |
700 |
message = self.GetMessageByScreenPos(*event.GetPosition()) |
|
701 |
if message is not None: |
|
702 |
self.SearchMessage.SetFocus() |
|
703 |
self.SearchMessage.SetValue(message.Message) |
|
704 |
event.Skip() |
|
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
705 |
|
993 | 706 |
def ResetMessageToolTip(self): |
707 |
if self.MessageToolTip is not None: |
|
708 |
self.MessageToolTip.Destroy() |
|
709 |
self.MessageToolTip = None |
|
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
710 |
|
993 | 711 |
def OnMessageToolTipTimer(self, event): |
712 |
if self.LastMousePos is not None: |
|
713 |
message = self.GetMessageByScreenPos(*self.LastMousePos) |
|
714 |
if message is not None: |
|
715 |
tooltip_pos = self.MessagePanel.ClientToScreen(self.LastMousePos) |
|
716 |
tooltip_pos.x += 10 |
|
717 |
tooltip_pos.y += 10 |
|
1169
53e4a2b775a7
Move CustomToolTip from GraphicCommons to controls
Laurent Bessard
parents:
1094
diff
changeset
|
718 |
self.MessageToolTip = CustomToolTip(self.MessagePanel, message.GetFullText(), False) |
993 | 719 |
self.MessageToolTip.SetFont(self.Font) |
1170
074e46cdedbc
Added support for displaying ToolTip, starting drag'n drop and Double click on Block connectors when debugging
Laurent Bessard
parents:
1169
diff
changeset
|
720 |
self.MessageToolTip.SetToolTipPosition(tooltip_pos) |
993 | 721 |
self.MessageToolTip.Show() |
722 |
event.Skip() |
|
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
723 |
|
993 | 724 |
def OnMessagePanelMotion(self, event): |
725 |
if not event.Dragging(): |
|
726 |
self.ResetMessageToolTip() |
|
727 |
self.LastMousePos = event.GetPosition() |
|
728 |
self.MessageToolTipTimer.Start(int(TOOLTIP_WAIT_PERIOD * 1000), oneShot=True) |
|
729 |
event.Skip() |
|
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
730 |
|
993 | 731 |
def OnMessagePanelLeaveWindow(self, event): |
732 |
self.ResetMessageToolTip() |
|
733 |
self.LastMousePos = None |
|
734 |
self.MessageToolTipTimer.Stop() |
|
986 | 735 |
event.Skip() |
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
736 |
|
981
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
737 |
def OnMessagePanelMouseWheel(self, event): |
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
738 |
self.ScrollMessagePanel(event.GetWheelRotation() / event.GetWheelDelta()) |
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
739 |
event.Skip() |
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
740 |
|
988
30e7571c10d0
Reduced flicker on LogViewer and DebugGraphPanel on Windows
Laurent Bessard
parents:
987
diff
changeset
|
741 |
def OnMessagePanelEraseBackground(self, event): |
30e7571c10d0
Reduced flicker on LogViewer and DebugGraphPanel on Windows
Laurent Bessard
parents:
987
diff
changeset
|
742 |
pass |
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
743 |
|
981
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
744 |
def OnMessagePanelPaint(self, event): |
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
745 |
self.RefreshView() |
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
746 |
event.Skip() |
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
747 |
|
981
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
748 |
def OnMessagePanelResize(self, event): |
984 | 749 |
width, height = self.MessagePanel.GetClientSize() |
750 |
offset = 2 |
|
751 |
for button in self.LeftButtons: |
|
752 |
button.SetPosition(offset, 2) |
|
753 |
w, h = button.GetSize() |
|
754 |
offset += w + 2 |
|
755 |
offset = width - 2 |
|
756 |
for button in self.RightButtons: |
|
757 |
w, h = button.GetSize() |
|
758 |
button.SetPosition(offset - w, 2) |
|
759 |
offset -= w + 2 |
|
981
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
760 |
if self.IsMessagePanelBottom(): |
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
761 |
self.ScrollToFirst() |
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
762 |
else: |
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
763 |
self.RefreshView() |
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
764 |
event.Skip() |
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
765 |
|
981
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
766 |
def OnScrollTimer(self, event): |
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
767 |
if self.ScrollSpeed != 0.: |
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
768 |
speed_norm = abs(self.ScrollSpeed) |
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
769 |
period = REFRESH_PERIOD / speed_norm |
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
770 |
self.ScrollMessagePanel(-speed_norm / self.ScrollSpeed) |
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
771 |
self.LastStartTime = gettime() |
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
772 |
self.ScrollTimer.Start(int(period * 1000), True) |
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
773 |
event.Skip() |
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
774 |
|
981
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
775 |
def SetScrollSpeed(self, speed): |
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
776 |
if speed == 0.: |
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
777 |
self.ScrollTimer.Stop() |
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
778 |
else: |
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
779 |
speed_norm = abs(speed) |
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
780 |
period = REFRESH_PERIOD / speed_norm |
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
781 |
current_time = gettime() |
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
782 |
if self.LastStartTime is not None: |
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
783 |
elapsed_time = current_time - self.LastStartTime |
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
784 |
if elapsed_time > period: |
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
785 |
self.ScrollMessagePanel(-speed_norm / speed) |
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
786 |
self.LastStartTime = current_time |
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
787 |
else: |
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
788 |
period -= elapsed_time |
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
789 |
else: |
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
790 |
self.LastStartTime = current_time |
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
791 |
self.ScrollTimer.Start(int(period * 1000), True) |
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
792 |
self.ScrollSpeed = speed |
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1195
diff
changeset
|
793 |
|
1071
5e740fe71fbe
Fixed bug in LogViewer when view is filtered and displaying last message and new messages appears
Laurent Bessard
parents:
1020
diff
changeset
|
794 |
def ScrollToLast(self, refresh=True): |
981
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
795 |
if len(self.LogMessages) > 0: |
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
796 |
self.CurrentMessage = len(self.LogMessages) - 1 |
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
797 |
message = self.LogMessages[self.CurrentMessage] |
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
798 |
if not self.FilterLogMessage(message): |
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
799 |
message, self.CurrentMessage = self.GetPreviousMessage(self.CurrentMessage) |
1071
5e740fe71fbe
Fixed bug in LogViewer when view is filtered and displaying last message and new messages appears
Laurent Bessard
parents:
1020
diff
changeset
|
800 |
if refresh: |
5e740fe71fbe
Fixed bug in LogViewer when view is filtered and displaying last message and new messages appears
Laurent Bessard
parents:
1020
diff
changeset
|
801 |
self.RefreshView() |
981
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
802 |
|
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
803 |
def ScrollToFirst(self): |
978 | 804 |
if len(self.LogMessages) > 0: |
805 |
message_idx = 0 |
|
806 |
message = self.LogMessages[message_idx] |
|
981
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
807 |
if not self.FilterLogMessage(message): |
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
808 |
next_message, msgidx = self.GetNextMessage(message_idx) |
978 | 809 |
if next_message is not None: |
810 |
message_idx = msgidx |
|
811 |
message = next_message |
|
812 |
while message is not None: |
|
981
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
813 |
message, msgidx = self.GetPreviousMessage(message_idx) |
978 | 814 |
if message is not None: |
815 |
message_idx = msgidx |
|
816 |
message = self.LogMessages[message_idx] |
|
981
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
817 |
if self.FilterLogMessage(message): |
978 | 818 |
while message is not None: |
981
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
979
diff
changeset
|
819 |
message, msgidx = self.GetNextMessage(message_idx) |
978 | 820 |
if message is not None: |
821 |
if not self.IsMessagePanelBottom(msgidx): |
|
822 |
break |
|
823 |
message_idx = msgidx |
|
824 |
self.CurrentMessage = message_idx |
|
825 |
else: |
|
826 |
self.CurrentMessage = None |
|
827 |
self.RefreshView() |