controls/PouInstanceVariablesPanel.py
author Edouard Tisserant
Thu, 24 Nov 2022 11:47:56 +0100
changeset 3690 f41733be17a8
parent 3649 61fa60130ad6
child 3657 e0d6f5f0dcc2
permissions -rw-r--r--
SVGHMI: move declaration of "xmlns" javascript const so that widgets can use it.

This was broken in earlier commit, when changing initial execution order because of implementing websocket reconnect.
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
     1
#!/usr/bin/env python
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
     2
# -*- coding: utf-8 -*-
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
     3
1571
486f94a8032c fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1498
diff changeset
     4
# This file is part of Beremiz, a Integrated Development Environment for
486f94a8032c fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1498
diff changeset
     5
# programming IEC 61131-3 automates supporting plcopen standard and CanFestival.
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
     6
#
1571
486f94a8032c fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1498
diff changeset
     7
# Copyright (C) 2012: Edouard TISSERANT and Laurent BESSARD
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
     8
#
1571
486f94a8032c fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1498
diff changeset
     9
# See COPYING file for copyrights details.
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    10
#
1571
486f94a8032c fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1498
diff changeset
    11
# This program is free software; you can redistribute it and/or
486f94a8032c fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1498
diff changeset
    12
# modify it under the terms of the GNU General Public License
486f94a8032c fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1498
diff changeset
    13
# as published by the Free Software Foundation; either version 2
486f94a8032c fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1498
diff changeset
    14
# of the License, or (at your option) any later version.
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    15
#
1571
486f94a8032c fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1498
diff changeset
    16
# This program is distributed in the hope that it will be useful,
486f94a8032c fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1498
diff changeset
    17
# but WITHOUT ANY WARRANTY; without even the implied warranty of
486f94a8032c fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1498
diff changeset
    18
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
486f94a8032c fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1498
diff changeset
    19
# GNU General Public License for more details.
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    20
#
1571
486f94a8032c fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1498
diff changeset
    21
# You should have received a copy of the GNU General Public License
486f94a8032c fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1498
diff changeset
    22
# along with this program; if not, write to the Free Software
486f94a8032c fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1498
diff changeset
    23
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    24
1881
091005ec69c4 fix pylint py3k conversion warning: "(no-absolute-import) import missing `from __future__ import absolute_import`"
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1878
diff changeset
    25
091005ec69c4 fix pylint py3k conversion warning: "(no-absolute-import) import missing `from __future__ import absolute_import`"
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1878
diff changeset
    26
from __future__ import absolute_import
2437
105c20fdeb19 python3 support: pylint, W1619 #(old-division) division w/o __future__ statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1948
diff changeset
    27
from __future__ import division
1343
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
    28
from collections import namedtuple
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
    29
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    30
import wx
1281
47131e3388f4 Various cleanup and optimization
Edouard Tisserant
parents: 1277
diff changeset
    31
import wx.lib.agw.customtreectrl as CT
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    32
import wx.lib.buttons
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    33
1948
b9a3f771aaab Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents: 1881
diff changeset
    34
from plcopen.types_enums import *
1783
3311eea28d56 clean-up: fix PEP8 E402 module level import not at top of file
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1782
diff changeset
    35
3311eea28d56 clean-up: fix PEP8 E402 module level import not at top of file
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1782
diff changeset
    36
from util.BitmapLibrary import GetBitmap
3311eea28d56 clean-up: fix PEP8 E402 module level import not at top of file
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1782
diff changeset
    37
3311eea28d56 clean-up: fix PEP8 E402 module level import not at top of file
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1782
diff changeset
    38
1343
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
    39
# Customize CustomTreeItem for adding icon on item right
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
    40
CT.GenericTreeItem._rightimages = []
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
    41
1736
7e61baa047f0 clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1730
diff changeset
    42
1343
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
    43
def SetRightImages(self, images):
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
    44
    self._rightimages = images
1749
d73b64672238 clean-up: fix PEP8 E305 expected 2 blank lines after class or function definition
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1742
diff changeset
    45
d73b64672238 clean-up: fix PEP8 E305 expected 2 blank lines after class or function definition
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1742
diff changeset
    46
1343
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
    47
CT.GenericTreeItem.SetRightImages = SetRightImages
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
    48
1736
7e61baa047f0 clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1730
diff changeset
    49
1343
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
    50
def GetRightImages(self):
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
    51
    return self._rightimages
1749
d73b64672238 clean-up: fix PEP8 E305 expected 2 blank lines after class or function definition
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1742
diff changeset
    52
d73b64672238 clean-up: fix PEP8 E305 expected 2 blank lines after class or function definition
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1742
diff changeset
    53
1343
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
    54
CT.GenericTreeItem.GetRightImages = GetRightImages
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
    55
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
    56
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
    57
class CustomTreeCtrlWithRightImage(CT.CustomTreeCtrl):
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
    58
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
    59
    def SetRightImageList(self, imageList):
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
    60
        self._imageListRight = imageList
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
    61
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
    62
    def GetLineHeight(self, item):
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
    63
        height = CT.CustomTreeCtrl.GetLineHeight(self, item)
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
    64
        rightimages = item.GetRightImages()
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
    65
        if len(rightimages) > 0:
1847
6198190bc121 explicitly mark unused variables found by pylint with _ or dummy
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1846
diff changeset
    66
            _r_image_w, r_image_h = self._imageListRight.GetSize(rightimages[0])
1343
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
    67
            return max(height, r_image_h + 8)
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
    68
        return height
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
    69
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
    70
    def GetItemRightImagesBBox(self, item):
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
    71
        rightimages = item.GetRightImages()
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
    72
        if len(rightimages) > 0:
1847
6198190bc121 explicitly mark unused variables found by pylint with _ or dummy
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1846
diff changeset
    73
            w, _h = self.GetClientSize()
1343
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
    74
            total_h = self.GetLineHeight(item)
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
    75
            r_image_w, r_image_h = self._imageListRight.GetSize(rightimages[0])
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1669
diff changeset
    76
1343
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
    77
            bbox_width = (r_image_w + 4) * len(rightimages) + 4
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
    78
            bbox_height = r_image_h + 8
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
    79
            bbox_x = w - bbox_width
2437
105c20fdeb19 python3 support: pylint, W1619 #(old-division) division w/o __future__ statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1948
diff changeset
    80
            bbox_y = item.GetY() + ((total_h > r_image_h) and [(total_h-r_image_h)//2] or [0])[0]
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1669
diff changeset
    81
1343
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
    82
            return wx.Rect(bbox_x, bbox_y, bbox_width, bbox_height)
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1669
diff changeset
    83
1343
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
    84
        return None
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
    85
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
    86
    def IsOverItemRightImage(self, item, point):
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
    87
        rightimages = item.GetRightImages()
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
    88
        if len(rightimages) > 0:
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
    89
            point = self.CalcUnscrolledPosition(point)
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
    90
            r_image_w, r_image_h = self._imageListRight.GetSize(rightimages[0])
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
    91
            images_bbx = self.GetItemRightImagesBBox(item)
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1669
diff changeset
    92
1343
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
    93
            rect = wx.Rect(images_bbx.x + 4, images_bbx.y + 4,
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
    94
                           r_image_w, r_image_h)
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
    95
            for r_image in rightimages:
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
    96
                if rect.Inside(point):
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
    97
                    return r_image
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
    98
                rect.x += r_image_w + 4
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1669
diff changeset
    99
1343
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   100
            return None
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1669
diff changeset
   101
1343
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   102
    def PaintItem(self, item, dc, level, align):
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   103
        CT.CustomTreeCtrl.PaintItem(self, item, dc, level, align)
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1669
diff changeset
   104
1343
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   105
        rightimages = item.GetRightImages()
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   106
        if len(rightimages) > 0:
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   107
            images_bbx = self.GetItemRightImagesBBox(item)
1847
6198190bc121 explicitly mark unused variables found by pylint with _ or dummy
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1846
diff changeset
   108
            r_image_w, _r_image_h = self._imageListRight.GetSize(rightimages[0])
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1669
diff changeset
   109
1636
ad3dee8b6d48 change white background for icons in PouInstanceVariablePanel to transparent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1571
diff changeset
   110
            dc.SetBrush(wx.TRANSPARENT_BRUSH)
1343
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   111
            dc.SetPen(wx.TRANSPARENT_PEN)
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1669
diff changeset
   112
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1669
diff changeset
   113
            dc.DrawRectangle(images_bbx.x, images_bbx.y,
1343
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   114
                             images_bbx.width, images_bbx.height)
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   115
            x_pos = images_bbx.x + 4
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   116
            for r_image in rightimages:
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   117
                self._imageListRight.Draw(
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   118
                    r_image, dc, x_pos, images_bbx.y + 4,
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   119
                    wx.IMAGELIST_DRAW_TRANSPARENT)
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   120
                x_pos += r_image_w + 4
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1669
diff changeset
   121
1749
d73b64672238 clean-up: fix PEP8 E305 expected 2 blank lines after class or function definition
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1742
diff changeset
   122
1343
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   123
_ButtonCallbacks = namedtuple("ButtonCallbacks", ["leftdown", "dclick"])
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   124
1736
7e61baa047f0 clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1730
diff changeset
   125
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   126
class PouInstanceVariablesPanel(wx.Panel):
1362
077bcba2d485 Cleaner matplotlib import preventing noisy warnings
Edouard Tisserant
parents: 1348
diff changeset
   127
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   128
    def __init__(self, parent, window, controller, debug):
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1669
diff changeset
   129
        wx.Panel.__init__(self, name='PouInstanceTreePanel',
1768
691083b5682a clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1754
diff changeset
   130
                          parent=parent, pos=wx.Point(0, 0),
691083b5682a clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1754
diff changeset
   131
                          size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL)
691083b5682a clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1754
diff changeset
   132
691083b5682a clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1754
diff changeset
   133
        self.ParentButton = wx.lib.buttons.GenBitmapButton(
691083b5682a clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1754
diff changeset
   134
            self, bitmap=GetBitmap("top"), size=wx.Size(28, 28), style=wx.NO_BORDER)
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   135
        self.ParentButton.SetToolTipString(_("Parent instance"))
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1669
diff changeset
   136
        self.Bind(wx.EVT_BUTTON, self.OnParentButtonClick,
1768
691083b5682a clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1754
diff changeset
   137
                  self.ParentButton)
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1669
diff changeset
   138
821
3667bb14aeca Fix bug debug instance button not visible in PouInstanceVariablesPanel when instance path is too long
laurent
parents: 814
diff changeset
   139
        self.InstanceChoice = wx.ComboBox(self, size=wx.Size(0, 0), style=wx.CB_READONLY)
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   140
        self.Bind(wx.EVT_COMBOBOX, self.OnInstanceChoiceChanged,
1768
691083b5682a clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1754
diff changeset
   141
                  self.InstanceChoice)
691083b5682a clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1754
diff changeset
   142
691083b5682a clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1754
diff changeset
   143
        self.DebugButton = wx.lib.buttons.GenBitmapButton(
691083b5682a clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1754
diff changeset
   144
            self, bitmap=GetBitmap("debug_instance"), size=wx.Size(28, 28), style=wx.NO_BORDER)
1082
5a08404d5dda Fixed bug in PouInstanceVariablesPanel buttons tooltips
Laurent Bessard
parents: 1031
diff changeset
   145
        self.DebugButton.SetToolTipString(_("Debug instance"))
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1669
diff changeset
   146
        self.Bind(wx.EVT_BUTTON, self.OnDebugButtonClick,
1768
691083b5682a clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1754
diff changeset
   147
                  self.DebugButton)
691083b5682a clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1754
diff changeset
   148
691083b5682a clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1754
diff changeset
   149
        self.VariablesList = CustomTreeCtrlWithRightImage(
691083b5682a clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1754
diff changeset
   150
            self,
691083b5682a clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1754
diff changeset
   151
            style=wx.SUNKEN_BORDER,
691083b5682a clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1754
diff changeset
   152
            agwStyle=(CT.TR_NO_BUTTONS |
691083b5682a clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1754
diff changeset
   153
                      CT.TR_SINGLE |
691083b5682a clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1754
diff changeset
   154
                      CT.TR_HAS_VARIABLE_ROW_HEIGHT |
691083b5682a clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1754
diff changeset
   155
                      CT.TR_HIDE_ROOT |
691083b5682a clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1754
diff changeset
   156
                      CT.TR_NO_LINES |
691083b5682a clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1754
diff changeset
   157
                      getattr(CT, "TR_ALIGN_WINDOWS_RIGHT", CT.TR_ALIGN_WINDOWS)))
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   158
        self.VariablesList.SetIndent(0)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   159
        self.VariablesList.SetSpacing(5)
1740
b789b695b5c6 clean-up: fix PEP8 E231 missing whitespace after ':' or ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1736
diff changeset
   160
        self.VariablesList.DoSelectItem = lambda *x, **y: True
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   161
        self.VariablesList.Bind(CT.EVT_TREE_ITEM_ACTIVATED,
1768
691083b5682a clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1754
diff changeset
   162
                                self.OnVariablesListItemActivated)
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   163
        self.VariablesList.Bind(wx.EVT_LEFT_DOWN, self.OnVariablesListLeftDown)
1031
5743398071eb Fix bug when pressing left arrow key in PouInstanceVariablesPanel
Laurent Bessard
parents: 930
diff changeset
   164
        self.VariablesList.Bind(wx.EVT_KEY_DOWN, self.OnVariablesListKeyDown)
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1669
diff changeset
   165
1343
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   166
        self.TreeRightImageList = wx.ImageList(24, 24)
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   167
        self.EditImage = self.TreeRightImageList.Add(GetBitmap("edit"))
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   168
        self.DebugInstanceImage = self.TreeRightImageList.Add(GetBitmap("debug_instance"))
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   169
        self.VariablesList.SetRightImageList(self.TreeRightImageList)
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1669
diff changeset
   170
1343
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   171
        self.ButtonCallBacks = {
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   172
            self.EditImage: _ButtonCallbacks(
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   173
                self.EditButtonCallback, None),
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   174
            self.DebugInstanceImage: _ButtonCallbacks(
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   175
                self.DebugButtonCallback, self.DebugButtonDClickCallback)}
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1669
diff changeset
   176
3649
61fa60130ad6 IDE: Added filtering in POU instance variables panel.
Edouard Tisserant
parents: 2437
diff changeset
   177
        self.FilterCtrl = wx.SearchCtrl(self)
61fa60130ad6 IDE: Added filtering in POU instance variables panel.
Edouard Tisserant
parents: 2437
diff changeset
   178
        self.FilterCtrl.ShowCancelButton(True)
61fa60130ad6 IDE: Added filtering in POU instance variables panel.
Edouard Tisserant
parents: 2437
diff changeset
   179
        self.FilterCtrl.Bind(wx.EVT_TEXT, self.OnFilterUpdate)
61fa60130ad6 IDE: Added filtering in POU instance variables panel.
Edouard Tisserant
parents: 2437
diff changeset
   180
        self.FilterCtrl.Bind(wx.EVT_SEARCHCTRL_CANCEL_BTN, self.OnFilterCancel)
61fa60130ad6 IDE: Added filtering in POU instance variables panel.
Edouard Tisserant
parents: 2437
diff changeset
   181
61fa60130ad6 IDE: Added filtering in POU instance variables panel.
Edouard Tisserant
parents: 2437
diff changeset
   182
        searchMenu = wx.Menu()
61fa60130ad6 IDE: Added filtering in POU instance variables panel.
Edouard Tisserant
parents: 2437
diff changeset
   183
        item = searchMenu.AppendCheckItem(-1, _("Match Case"))
61fa60130ad6 IDE: Added filtering in POU instance variables panel.
Edouard Tisserant
parents: 2437
diff changeset
   184
        self.Bind(wx.EVT_MENU, self.OnSearchMenu, item)
61fa60130ad6 IDE: Added filtering in POU instance variables panel.
Edouard Tisserant
parents: 2437
diff changeset
   185
        item = searchMenu.AppendCheckItem(-1, _("Whole Words"))
61fa60130ad6 IDE: Added filtering in POU instance variables panel.
Edouard Tisserant
parents: 2437
diff changeset
   186
        self.Bind(wx.EVT_MENU, self.OnSearchMenu, item)
61fa60130ad6 IDE: Added filtering in POU instance variables panel.
Edouard Tisserant
parents: 2437
diff changeset
   187
        self.FilterCtrl.SetMenu(searchMenu)
61fa60130ad6 IDE: Added filtering in POU instance variables panel.
Edouard Tisserant
parents: 2437
diff changeset
   188
61fa60130ad6 IDE: Added filtering in POU instance variables panel.
Edouard Tisserant
parents: 2437
diff changeset
   189
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   190
        buttons_sizer = wx.FlexGridSizer(cols=3, hgap=0, rows=1, vgap=0)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   191
        buttons_sizer.AddWindow(self.ParentButton)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   192
        buttons_sizer.AddWindow(self.InstanceChoice, flag=wx.GROW)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   193
        buttons_sizer.AddWindow(self.DebugButton)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   194
        buttons_sizer.AddGrowableCol(1)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   195
        buttons_sizer.AddGrowableRow(0)
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1669
diff changeset
   196
3649
61fa60130ad6 IDE: Added filtering in POU instance variables panel.
Edouard Tisserant
parents: 2437
diff changeset
   197
        main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=3, vgap=0)
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   198
        main_sizer.AddSizer(buttons_sizer, flag=wx.GROW)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   199
        main_sizer.AddWindow(self.VariablesList, flag=wx.GROW)
3649
61fa60130ad6 IDE: Added filtering in POU instance variables panel.
Edouard Tisserant
parents: 2437
diff changeset
   200
        main_sizer.AddWindow(self.FilterCtrl, flag=wx.GROW)
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   201
        main_sizer.AddGrowableCol(0)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   202
        main_sizer.AddGrowableRow(1)
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1669
diff changeset
   203
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   204
        self.SetSizer(main_sizer)
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1669
diff changeset
   205
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   206
        self.ParentWindow = window
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   207
        self.Controller = controller
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   208
        self.Debug = debug
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   209
        if not self.Debug:
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   210
            self.DebugButton.Hide()
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1669
diff changeset
   211
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   212
        self.PouTagName = None
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   213
        self.PouInfos = None
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   214
        self.PouInstance = None
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1669
diff changeset
   215
3649
61fa60130ad6 IDE: Added filtering in POU instance variables panel.
Edouard Tisserant
parents: 2437
diff changeset
   216
        self.Filter = None
61fa60130ad6 IDE: Added filtering in POU instance variables panel.
Edouard Tisserant
parents: 2437
diff changeset
   217
        self.FilterCaseSensitive = False
61fa60130ad6 IDE: Added filtering in POU instance variables panel.
Edouard Tisserant
parents: 2437
diff changeset
   218
        self.FilterWholeWord = False
61fa60130ad6 IDE: Added filtering in POU instance variables panel.
Edouard Tisserant
parents: 2437
diff changeset
   219
61fa60130ad6 IDE: Added filtering in POU instance variables panel.
Edouard Tisserant
parents: 2437
diff changeset
   220
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   221
    def __del__(self):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   222
        self.Controller = None
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1669
diff changeset
   223
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   224
    def SetTreeImageList(self, tree_image_list):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   225
        self.VariablesList.SetImageList(tree_image_list)
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1669
diff changeset
   226
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   227
    def SetController(self, controller):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   228
        self.Controller = controller
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1669
diff changeset
   229
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   230
        self.RefreshView()
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1669
diff changeset
   231
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   232
    def SetPouType(self, tagname, pou_instance=None):
1222
775b48a2be3b Fixed flickering and lag when refreshing PouInstanceVariablesPanel
Laurent Bessard
parents: 1217
diff changeset
   233
        if self.Controller is not None:
1233
5e6d0969bb5d Fixed bugs in refresh of PouInstanceVariablesPanel
Laurent Bessard
parents: 1222
diff changeset
   234
            if tagname == "Project":
915
8dc28b21bdac Fix bug when closing project
Laurent Bessard
parents: 900
diff changeset
   235
                config_name = self.Controller.GetProjectMainConfigurationName()
8dc28b21bdac Fix bug when closing project
Laurent Bessard
parents: 900
diff changeset
   236
                if config_name is not None:
1948
b9a3f771aaab Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents: 1881
diff changeset
   237
                    tagname = ComputeConfigurationName(config_name)
915
8dc28b21bdac Fix bug when closing project
Laurent Bessard
parents: 900
diff changeset
   238
            if pou_instance is not None:
8dc28b21bdac Fix bug when closing project
Laurent Bessard
parents: 900
diff changeset
   239
                self.PouInstance = pou_instance
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1669
diff changeset
   240
1233
5e6d0969bb5d Fixed bugs in refresh of PouInstanceVariablesPanel
Laurent Bessard
parents: 1222
diff changeset
   241
            if self.PouTagName != tagname:
5e6d0969bb5d Fixed bugs in refresh of PouInstanceVariablesPanel
Laurent Bessard
parents: 1222
diff changeset
   242
                self.PouTagName = tagname
5e6d0969bb5d Fixed bugs in refresh of PouInstanceVariablesPanel
Laurent Bessard
parents: 1222
diff changeset
   243
                self.RefreshView()
5e6d0969bb5d Fixed bugs in refresh of PouInstanceVariablesPanel
Laurent Bessard
parents: 1222
diff changeset
   244
            else:
5e6d0969bb5d Fixed bugs in refresh of PouInstanceVariablesPanel
Laurent Bessard
parents: 1222
diff changeset
   245
                self.RefreshInstanceChoice()
5e6d0969bb5d Fixed bugs in refresh of PouInstanceVariablesPanel
Laurent Bessard
parents: 1222
diff changeset
   246
        else:
5e6d0969bb5d Fixed bugs in refresh of PouInstanceVariablesPanel
Laurent Bessard
parents: 1222
diff changeset
   247
            self.RefreshView()
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1669
diff changeset
   248
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   249
    def ResetView(self):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   250
        self.Controller = None
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1669
diff changeset
   251
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   252
        self.PouTagName = None
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   253
        self.PouInfos = None
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   254
        self.PouInstance = None
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1669
diff changeset
   255
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   256
        self.RefreshView()
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1669
diff changeset
   257
3649
61fa60130ad6 IDE: Added filtering in POU instance variables panel.
Edouard Tisserant
parents: 2437
diff changeset
   258
    def OnSearchMenu(self, event):
61fa60130ad6 IDE: Added filtering in POU instance variables panel.
Edouard Tisserant
parents: 2437
diff changeset
   259
        searchMenu = self.FilterCtrl.GetMenu().GetMenuItems()
61fa60130ad6 IDE: Added filtering in POU instance variables panel.
Edouard Tisserant
parents: 2437
diff changeset
   260
        self.FilterCaseSensitive = searchMenu[0].IsChecked()
61fa60130ad6 IDE: Added filtering in POU instance variables panel.
Edouard Tisserant
parents: 2437
diff changeset
   261
        self.FilterWholeWord = searchMenu[1].IsChecked()
61fa60130ad6 IDE: Added filtering in POU instance variables panel.
Edouard Tisserant
parents: 2437
diff changeset
   262
        self.RefreshView()
61fa60130ad6 IDE: Added filtering in POU instance variables panel.
Edouard Tisserant
parents: 2437
diff changeset
   263
61fa60130ad6 IDE: Added filtering in POU instance variables panel.
Edouard Tisserant
parents: 2437
diff changeset
   264
    def OnFilterUpdate(self, event):
61fa60130ad6 IDE: Added filtering in POU instance variables panel.
Edouard Tisserant
parents: 2437
diff changeset
   265
        self.Filter = self.FilterCtrl.GetValue()
61fa60130ad6 IDE: Added filtering in POU instance variables panel.
Edouard Tisserant
parents: 2437
diff changeset
   266
        self.RefreshView()
61fa60130ad6 IDE: Added filtering in POU instance variables panel.
Edouard Tisserant
parents: 2437
diff changeset
   267
        event.Skip()
61fa60130ad6 IDE: Added filtering in POU instance variables panel.
Edouard Tisserant
parents: 2437
diff changeset
   268
61fa60130ad6 IDE: Added filtering in POU instance variables panel.
Edouard Tisserant
parents: 2437
diff changeset
   269
    def OnFilterCancel(self, event):
61fa60130ad6 IDE: Added filtering in POU instance variables panel.
Edouard Tisserant
parents: 2437
diff changeset
   270
        self.FilterCtrl.SetValue('')
61fa60130ad6 IDE: Added filtering in POU instance variables panel.
Edouard Tisserant
parents: 2437
diff changeset
   271
        event.Skip()
61fa60130ad6 IDE: Added filtering in POU instance variables panel.
Edouard Tisserant
parents: 2437
diff changeset
   272
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   273
    def RefreshView(self):
1222
775b48a2be3b Fixed flickering and lag when refreshing PouInstanceVariablesPanel
Laurent Bessard
parents: 1217
diff changeset
   274
        self.Freeze()
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   275
        self.VariablesList.DeleteAllItems()
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1669
diff changeset
   276
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   277
        if self.Controller is not None and self.PouTagName is not None:
1669
54da2cfe0180 fix debug button and variable tree generate for actions and transitions in POU instance variable panel
Surkov Sergey <surkovsv93@gmail.com>
parents: 1636
diff changeset
   278
            if self.PouTagName.split('::')[0] in ['A', 'T']:
54da2cfe0180 fix debug button and variable tree generate for actions and transitions in POU instance variable panel
Surkov Sergey <surkovsv93@gmail.com>
parents: 1636
diff changeset
   279
                self.PouInfos = self.Controller.GetPouVariables('P::%s' % self.PouTagName.split('::')[1], self.Debug)
54da2cfe0180 fix debug button and variable tree generate for actions and transitions in POU instance variable panel
Surkov Sergey <surkovsv93@gmail.com>
parents: 1636
diff changeset
   280
            else:
54da2cfe0180 fix debug button and variable tree generate for actions and transitions in POU instance variable panel
Surkov Sergey <surkovsv93@gmail.com>
parents: 1636
diff changeset
   281
                self.PouInfos = self.Controller.GetPouVariables(self.PouTagName, self.Debug)
54da2cfe0180 fix debug button and variable tree generate for actions and transitions in POU instance variable panel
Surkov Sergey <surkovsv93@gmail.com>
parents: 1636
diff changeset
   282
            if None in self.Controller.GetEditedElementType(self.PouTagName, self.Debug) and self.PouInfos is not None:
54da2cfe0180 fix debug button and variable tree generate for actions and transitions in POU instance variable panel
Surkov Sergey <surkovsv93@gmail.com>
parents: 1636
diff changeset
   283
                self.PouInfos.debug = False
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   284
        else:
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   285
            self.PouInfos = None
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   286
        if self.PouInfos is not None:
1669
54da2cfe0180 fix debug button and variable tree generate for actions and transitions in POU instance variable panel
Surkov Sergey <surkovsv93@gmail.com>
parents: 1636
diff changeset
   287
            root = self.VariablesList.AddRoot("", data=self.PouInfos)
1348
aee0a7eb833a Fixed pou variables instance information loading stylesheet
Laurent Bessard
parents: 1343
diff changeset
   288
            for var_infos in self.PouInfos.variables:
3649
61fa60130ad6 IDE: Added filtering in POU instance variables panel.
Edouard Tisserant
parents: 2437
diff changeset
   289
                if self.Filter:
61fa60130ad6 IDE: Added filtering in POU instance variables panel.
Edouard Tisserant
parents: 2437
diff changeset
   290
                    pattern = self.Filter
61fa60130ad6 IDE: Added filtering in POU instance variables panel.
Edouard Tisserant
parents: 2437
diff changeset
   291
                    varname = var_infos.name
61fa60130ad6 IDE: Added filtering in POU instance variables panel.
Edouard Tisserant
parents: 2437
diff changeset
   292
                    if not self.FilterCaseSensitive:
61fa60130ad6 IDE: Added filtering in POU instance variables panel.
Edouard Tisserant
parents: 2437
diff changeset
   293
                        pattern = pattern.upper()
61fa60130ad6 IDE: Added filtering in POU instance variables panel.
Edouard Tisserant
parents: 2437
diff changeset
   294
                        varname = varname.upper()
61fa60130ad6 IDE: Added filtering in POU instance variables panel.
Edouard Tisserant
parents: 2437
diff changeset
   295
                    if ((pattern != varname) if self.FilterWholeWord else
61fa60130ad6 IDE: Added filtering in POU instance variables panel.
Edouard Tisserant
parents: 2437
diff changeset
   296
                        (pattern not in varname)):
61fa60130ad6 IDE: Added filtering in POU instance variables panel.
Edouard Tisserant
parents: 2437
diff changeset
   297
                        continue
1348
aee0a7eb833a Fixed pou variables instance information loading stylesheet
Laurent Bessard
parents: 1343
diff changeset
   298
                if var_infos.type is not None:
aee0a7eb833a Fixed pou variables instance information loading stylesheet
Laurent Bessard
parents: 1343
diff changeset
   299
                    text = "%s (%s)" % (var_infos.name, var_infos.type)
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   300
                else:
1348
aee0a7eb833a Fixed pou variables instance information loading stylesheet
Laurent Bessard
parents: 1343
diff changeset
   301
                    text = var_infos.name
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1669
diff changeset
   302
1343
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   303
                right_images = []
1364
e9e17d3b2849 Remove old debug panels and viewers not using matplotlib
Laurent Bessard
parents: 1362
diff changeset
   304
                if var_infos.edit:
1343
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   305
                    right_images.append(self.EditImage)
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1669
diff changeset
   306
1348
aee0a7eb833a Fixed pou variables instance information loading stylesheet
Laurent Bessard
parents: 1343
diff changeset
   307
                if var_infos.debug and self.Debug:
1343
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   308
                    right_images.append(self.DebugInstanceImage)
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1669
diff changeset
   309
1343
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   310
                item = self.VariablesList.AppendItem(root, text)
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   311
                item.SetRightImages(right_images)
1348
aee0a7eb833a Fixed pou variables instance information loading stylesheet
Laurent Bessard
parents: 1343
diff changeset
   312
                self.VariablesList.SetItemImage(item, self.ParentWindow.GetTreeImage(var_infos.var_class))
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   313
                self.VariablesList.SetPyData(item, var_infos)
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1669
diff changeset
   314
1238
24577755485d Fixed bug with InstanceChoice values in PouInstanceVariablesPanel
Laurent Bessard
parents: 1233
diff changeset
   315
        self.RefreshInstanceChoice()
1233
5e6d0969bb5d Fixed bugs in refresh of PouInstanceVariablesPanel
Laurent Bessard
parents: 1222
diff changeset
   316
        self.RefreshButtons()
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1669
diff changeset
   317
1233
5e6d0969bb5d Fixed bugs in refresh of PouInstanceVariablesPanel
Laurent Bessard
parents: 1222
diff changeset
   318
        self.Thaw()
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1669
diff changeset
   319
1233
5e6d0969bb5d Fixed bugs in refresh of PouInstanceVariablesPanel
Laurent Bessard
parents: 1222
diff changeset
   320
    def RefreshInstanceChoice(self):
1238
24577755485d Fixed bug with InstanceChoice values in PouInstanceVariablesPanel
Laurent Bessard
parents: 1233
diff changeset
   321
        self.InstanceChoice.Clear()
24577755485d Fixed bug with InstanceChoice values in PouInstanceVariablesPanel
Laurent Bessard
parents: 1233
diff changeset
   322
        self.InstanceChoice.SetValue("")
1233
5e6d0969bb5d Fixed bugs in refresh of PouInstanceVariablesPanel
Laurent Bessard
parents: 1222
diff changeset
   323
        if self.Controller is not None and self.PouInfos is not None:
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   324
            instances = self.Controller.SearchPouInstances(self.PouTagName, self.Debug)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   325
            for instance in instances:
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   326
                self.InstanceChoice.Append(instance)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   327
            if len(instances) == 1:
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   328
                self.PouInstance = instances[0]
1348
aee0a7eb833a Fixed pou variables instance information loading stylesheet
Laurent Bessard
parents: 1343
diff changeset
   329
            if self.PouInfos.var_class in [ITEM_CONFIGURATION, ITEM_RESOURCE]:
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   330
                self.PouInstance = None
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   331
                self.InstanceChoice.SetSelection(0)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   332
            elif self.PouInstance in instances:
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   333
                self.InstanceChoice.SetStringSelection(self.PouInstance)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   334
            else:
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   335
                self.PouInstance = None
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   336
                self.InstanceChoice.SetValue(_("Select an instance"))
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1669
diff changeset
   337
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   338
    def RefreshButtons(self):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   339
        enabled = self.InstanceChoice.GetSelection() != -1
1348
aee0a7eb833a Fixed pou variables instance information loading stylesheet
Laurent Bessard
parents: 1343
diff changeset
   340
        self.ParentButton.Enable(enabled and self.PouInfos.var_class != ITEM_CONFIGURATION)
aee0a7eb833a Fixed pou variables instance information loading stylesheet
Laurent Bessard
parents: 1343
diff changeset
   341
        self.DebugButton.Enable(enabled and self.PouInfos.debug and self.Debug)
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1669
diff changeset
   342
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   343
        root = self.VariablesList.GetRootItem()
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   344
        if root is not None and root.IsOk():
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   345
            item, item_cookie = self.VariablesList.GetFirstChild(root)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   346
            while item is not None and item.IsOk():
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   347
                panel = self.VariablesList.GetItemWindow(item)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   348
                if panel is not None:
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   349
                    for child in panel.GetChildren():
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   350
                        if child.GetName() != "edit":
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   351
                            child.Enable(enabled)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   352
                item, item_cookie = self.VariablesList.GetNextChild(root, item_cookie)
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1669
diff changeset
   353
1343
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   354
    def EditButtonCallback(self, infos):
1348
aee0a7eb833a Fixed pou variables instance information loading stylesheet
Laurent Bessard
parents: 1343
diff changeset
   355
        var_class = infos.var_class
1343
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   356
        if var_class == ITEM_RESOURCE:
1948
b9a3f771aaab Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents: 1881
diff changeset
   357
            tagname = ComputeConfigurationResourceName(
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1669
diff changeset
   358
                self.InstanceChoice.GetStringSelection(),
1348
aee0a7eb833a Fixed pou variables instance information loading stylesheet
Laurent Bessard
parents: 1343
diff changeset
   359
                infos.name)
1343
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   360
        elif var_class == ITEM_TRANSITION:
1948
b9a3f771aaab Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents: 1881
diff changeset
   361
            tagname = ComputePouTransitionName(
1343
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   362
                self.PouTagName.split("::")[1],
1348
aee0a7eb833a Fixed pou variables instance information loading stylesheet
Laurent Bessard
parents: 1343
diff changeset
   363
                infos.name)
1343
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   364
        elif var_class == ITEM_ACTION:
1948
b9a3f771aaab Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents: 1881
diff changeset
   365
            tagname = ComputePouActionName(
1343
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   366
                self.PouTagName.split("::")[1],
1348
aee0a7eb833a Fixed pou variables instance information loading stylesheet
Laurent Bessard
parents: 1343
diff changeset
   367
                infos.name)
1343
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   368
        else:
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   369
            var_class = ITEM_POU
1948
b9a3f771aaab Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents: 1881
diff changeset
   370
            tagname = ComputePouName(infos.type)
1343
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   371
        self.ParentWindow.EditProjectElement(var_class, tagname)
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1669
diff changeset
   372
1343
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   373
    def DebugButtonCallback(self, infos):
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   374
        if self.InstanceChoice.GetSelection() != -1:
1348
aee0a7eb833a Fixed pou variables instance information loading stylesheet
Laurent Bessard
parents: 1343
diff changeset
   375
            var_class = infos.var_class
1669
54da2cfe0180 fix debug button and variable tree generate for actions and transitions in POU instance variable panel
Surkov Sergey <surkovsv93@gmail.com>
parents: 1636
diff changeset
   376
            instance_path = self.InstanceChoice.GetStringSelection()
54da2cfe0180 fix debug button and variable tree generate for actions and transitions in POU instance variable panel
Surkov Sergey <surkovsv93@gmail.com>
parents: 1636
diff changeset
   377
            if self.PouTagName.split("::")[0] in ["A", "T"]:
54da2cfe0180 fix debug button and variable tree generate for actions and transitions in POU instance variable panel
Surkov Sergey <surkovsv93@gmail.com>
parents: 1636
diff changeset
   378
                pos = instance_path.rfind('.')
54da2cfe0180 fix debug button and variable tree generate for actions and transitions in POU instance variable panel
Surkov Sergey <surkovsv93@gmail.com>
parents: 1636
diff changeset
   379
                instance_path = instance_path[0:pos]
54da2cfe0180 fix debug button and variable tree generate for actions and transitions in POU instance variable panel
Surkov Sergey <surkovsv93@gmail.com>
parents: 1636
diff changeset
   380
            var_path = "%s.%s" % (instance_path, infos.name)
1343
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   381
            if var_class in ITEMS_VARIABLE:
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   382
                self.ParentWindow.AddDebugVariable(var_path, force=True)
826
098f822ef308 Adding transition and action in list of instances of SFC POU in PouInstanceVariablesPanel
laurent
parents: 821
diff changeset
   383
            elif var_class == ITEM_TRANSITION:
1343
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   384
                self.ParentWindow.OpenDebugViewer(
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   385
                    var_class,
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   386
                    var_path,
1948
b9a3f771aaab Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents: 1881
diff changeset
   387
                    ComputePouTransitionName(
1343
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   388
                        self.PouTagName.split("::")[1],
1348
aee0a7eb833a Fixed pou variables instance information loading stylesheet
Laurent Bessard
parents: 1343
diff changeset
   389
                        infos.name))
826
098f822ef308 Adding transition and action in list of instances of SFC POU in PouInstanceVariablesPanel
laurent
parents: 821
diff changeset
   390
            elif var_class == ITEM_ACTION:
1343
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   391
                self.ParentWindow.OpenDebugViewer(
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   392
                    var_class,
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   393
                    var_path,
1948
b9a3f771aaab Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents: 1881
diff changeset
   394
                    ComputePouActionName(
1343
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   395
                        self.PouTagName.split("::")[1],
1348
aee0a7eb833a Fixed pou variables instance information loading stylesheet
Laurent Bessard
parents: 1343
diff changeset
   396
                        infos.name))
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   397
            else:
1343
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   398
                self.ParentWindow.OpenDebugViewer(
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   399
                    var_class,
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   400
                    var_path,
1948
b9a3f771aaab Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents: 1881
diff changeset
   401
                    ComputePouName(infos.type))
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1669
diff changeset
   402
1343
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   403
    def DebugButtonDClickCallback(self, infos):
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   404
        if self.InstanceChoice.GetSelection() != -1:
1348
aee0a7eb833a Fixed pou variables instance information loading stylesheet
Laurent Bessard
parents: 1343
diff changeset
   405
            if infos.var_class in ITEMS_VARIABLE:
1343
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   406
                self.ParentWindow.AddDebugVariable(
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1669
diff changeset
   407
                    "%s.%s" % (self.InstanceChoice.GetStringSelection(),
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1669
diff changeset
   408
                               infos.name),
1343
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   409
                    force=True,
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   410
                    graph=True)
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1669
diff changeset
   411
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   412
    def ShowInstanceChoicePopup(self):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   413
        self.InstanceChoice.SetFocusFromKbd()
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   414
        size = self.InstanceChoice.GetSize()
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   415
        event = wx.MouseEvent(wx.EVT_LEFT_DOWN._getEvtType())
2437
105c20fdeb19 python3 support: pylint, W1619 #(old-division) division w/o __future__ statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1948
diff changeset
   416
        event.x = size.width // 2
105c20fdeb19 python3 support: pylint, W1619 #(old-division) division w/o __future__ statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1948
diff changeset
   417
        event.y = size.height // 2
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   418
        event.SetEventObject(self.InstanceChoice)
1782
5b6ad7a7fd9d clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1768
diff changeset
   419
        # event = wx.KeyEvent(wx.EVT_KEY_DOWN._getEvtType())
5b6ad7a7fd9d clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1768
diff changeset
   420
        # event.m_keyCode = wx.WXK_SPACE
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   421
        self.InstanceChoice.GetEventHandler().ProcessEvent(event)
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1669
diff changeset
   422
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   423
    def OnParentButtonClick(self, event):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   424
        if self.InstanceChoice.GetSelection() != -1:
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   425
            parent_path = self.InstanceChoice.GetStringSelection().rsplit(".", 1)[0]
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   426
            tagname = self.Controller.GetPouInstanceTagName(parent_path, self.Debug)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   427
            if tagname is not None:
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   428
                wx.CallAfter(self.SetPouType, tagname, parent_path)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   429
                wx.CallAfter(self.ParentWindow.SelectProjectTreeItem, tagname)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   430
        event.Skip()
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1669
diff changeset
   431
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   432
    def OnInstanceChoiceChanged(self, event):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   433
        self.RefreshButtons()
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   434
        event.Skip()
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1669
diff changeset
   435
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   436
    def OnDebugButtonClick(self, event):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   437
        if self.InstanceChoice.GetSelection() != -1:
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   438
            self.ParentWindow.OpenDebugViewer(
1348
aee0a7eb833a Fixed pou variables instance information loading stylesheet
Laurent Bessard
parents: 1343
diff changeset
   439
                self.PouInfos.var_class,
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   440
                self.InstanceChoice.GetStringSelection(),
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   441
                self.PouTagName)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   442
        event.Skip()
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1669
diff changeset
   443
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   444
    def OnVariablesListItemActivated(self, event):
1189
93a4431a0cd8 Fixed bug in PouInstanceVariablesPanel, exploring child FunctionBlock variables if no instance selected
Laurent Bessard
parents: 1107
diff changeset
   445
        selected_item = event.GetItem()
93a4431a0cd8 Fixed bug in PouInstanceVariablesPanel, exploring child FunctionBlock variables if no instance selected
Laurent Bessard
parents: 1107
diff changeset
   446
        if selected_item is not None and selected_item.IsOk():
93a4431a0cd8 Fixed bug in PouInstanceVariablesPanel, exploring child FunctionBlock variables if no instance selected
Laurent Bessard
parents: 1107
diff changeset
   447
            item_infos = self.VariablesList.GetPyData(selected_item)
1343
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   448
            if item_infos is not None:
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1669
diff changeset
   449
1343
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   450
                item_button = self.VariablesList.IsOverItemRightImage(
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   451
                    selected_item, event.GetPoint())
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   452
                if item_button is not None:
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   453
                    callback = self.ButtonCallBacks[item_button].dclick
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   454
                    if callback is not None:
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   455
                        callback(item_infos)
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1669
diff changeset
   456
1348
aee0a7eb833a Fixed pou variables instance information loading stylesheet
Laurent Bessard
parents: 1343
diff changeset
   457
                elif item_infos.var_class not in ITEMS_VARIABLE:
1343
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   458
                    instance_path = self.InstanceChoice.GetStringSelection()
1348
aee0a7eb833a Fixed pou variables instance information loading stylesheet
Laurent Bessard
parents: 1343
diff changeset
   459
                    if item_infos.var_class == ITEM_RESOURCE:
1343
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   460
                        if instance_path != "":
1948
b9a3f771aaab Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents: 1881
diff changeset
   461
                            tagname = ComputeConfigurationResourceName(
1878
fb73a6b6622d fix pylint warning '(bad-continuation) Wrong hanging indentation before block'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1847
diff changeset
   462
                                instance_path,
fb73a6b6622d fix pylint warning '(bad-continuation) Wrong hanging indentation before block'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1847
diff changeset
   463
                                item_infos.name)
1343
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   464
                        else:
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   465
                            tagname = None
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   466
                    else:
1669
54da2cfe0180 fix debug button and variable tree generate for actions and transitions in POU instance variable panel
Surkov Sergey <surkovsv93@gmail.com>
parents: 1636
diff changeset
   467
                        parent_infos = self.VariablesList.GetPyData(selected_item.GetParent())
54da2cfe0180 fix debug button and variable tree generate for actions and transitions in POU instance variable panel
Surkov Sergey <surkovsv93@gmail.com>
parents: 1636
diff changeset
   468
                        if item_infos.var_class == ITEM_ACTION:
1948
b9a3f771aaab Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents: 1881
diff changeset
   469
                            tagname = ComputePouActionName(parent_infos.type, item_infos.name)
1669
54da2cfe0180 fix debug button and variable tree generate for actions and transitions in POU instance variable panel
Surkov Sergey <surkovsv93@gmail.com>
parents: 1636
diff changeset
   470
                        elif item_infos.var_class == ITEM_TRANSITION:
1948
b9a3f771aaab Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents: 1881
diff changeset
   471
                            tagname = ComputePouTransitionName(parent_infos.type, item_infos.name)
1669
54da2cfe0180 fix debug button and variable tree generate for actions and transitions in POU instance variable panel
Surkov Sergey <surkovsv93@gmail.com>
parents: 1636
diff changeset
   472
                        else:
1948
b9a3f771aaab Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents: 1881
diff changeset
   473
                            tagname = ComputePouName(item_infos.type)
1343
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   474
                    if tagname is not None:
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   475
                        if instance_path != "":
1348
aee0a7eb833a Fixed pou variables instance information loading stylesheet
Laurent Bessard
parents: 1343
diff changeset
   476
                            item_path = "%s.%s" % (instance_path, item_infos.name)
1343
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   477
                        else:
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   478
                            item_path = None
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   479
                        self.SetPouType(tagname, item_path)
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   480
                        self.ParentWindow.SelectProjectTreeItem(tagname)
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   481
        event.Skip()
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1669
diff changeset
   482
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   483
    def OnVariablesListLeftDown(self, event):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   484
        if self.InstanceChoice.GetSelection() == -1:
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   485
            wx.CallAfter(self.ShowInstanceChoicePopup)
898
6b2958f04f30 Adding drag'n drop of debug variable from DebugVariable grid and PouInstance variable list
Laurent Bessard
parents: 885
diff changeset
   486
        else:
6b2958f04f30 Adding drag'n drop of debug variable from DebugVariable grid and PouInstance variable list
Laurent Bessard
parents: 885
diff changeset
   487
            instance_path = self.InstanceChoice.GetStringSelection()
6b2958f04f30 Adding drag'n drop of debug variable from DebugVariable grid and PouInstance variable list
Laurent Bessard
parents: 885
diff changeset
   488
            item, flags = self.VariablesList.HitTest(event.GetPosition())
1343
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   489
            if item is not None:
898
6b2958f04f30 Adding drag'n drop of debug variable from DebugVariable grid and PouInstance variable list
Laurent Bessard
parents: 885
diff changeset
   490
                item_infos = self.VariablesList.GetPyData(item)
1343
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   491
                if item_infos is not None:
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1669
diff changeset
   492
1343
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   493
                    item_button = self.VariablesList.IsOverItemRightImage(
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   494
                        item, event.GetPosition())
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   495
                    if item_button is not None:
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   496
                        callback = self.ButtonCallBacks[item_button].leftdown
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   497
                        if callback is not None:
a76a020b8822 Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents: 1281
diff changeset
   498
                            callback(item_infos)
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1669
diff changeset
   499
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1669
diff changeset
   500
                    elif (flags & CT.TREE_HITTEST_ONITEMLABEL and
1369
9bd4c783c98d Fixed bug Drag'n drop variables from left panel to debug panel disabled
Laurent Bessard
parents: 1364
diff changeset
   501
                          item_infos.var_class in ITEMS_VARIABLE):
9bd4c783c98d Fixed bug Drag'n drop variables from left panel to debug panel disabled
Laurent Bessard
parents: 1364
diff changeset
   502
                        self.ParentWindow.EnsureTabVisible(
9bd4c783c98d Fixed bug Drag'n drop variables from left panel to debug panel disabled
Laurent Bessard
parents: 1364
diff changeset
   503
                            self.ParentWindow.DebugVariablePanel)
9bd4c783c98d Fixed bug Drag'n drop variables from left panel to debug panel disabled
Laurent Bessard
parents: 1364
diff changeset
   504
                        item_path = "%s.%s" % (instance_path, item_infos.name)
9bd4c783c98d Fixed bug Drag'n drop variables from left panel to debug panel disabled
Laurent Bessard
parents: 1364
diff changeset
   505
                        data = wx.TextDataObject(str((item_path, "debug")))
9bd4c783c98d Fixed bug Drag'n drop variables from left panel to debug panel disabled
Laurent Bessard
parents: 1364
diff changeset
   506
                        dragSource = wx.DropSource(self.VariablesList)
9bd4c783c98d Fixed bug Drag'n drop variables from left panel to debug panel disabled
Laurent Bessard
parents: 1364
diff changeset
   507
                        dragSource.SetData(data)
9bd4c783c98d Fixed bug Drag'n drop variables from left panel to debug panel disabled
Laurent Bessard
parents: 1364
diff changeset
   508
                        dragSource.DoDragDrop()
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   509
        event.Skip()
1031
5743398071eb Fix bug when pressing left arrow key in PouInstanceVariablesPanel
Laurent Bessard
parents: 930
diff changeset
   510
5743398071eb Fix bug when pressing left arrow key in PouInstanceVariablesPanel
Laurent Bessard
parents: 930
diff changeset
   511
    def OnVariablesListKeyDown(self, event):
5743398071eb Fix bug when pressing left arrow key in PouInstanceVariablesPanel
Laurent Bessard
parents: 930
diff changeset
   512
        keycode = event.GetKeyCode()
5743398071eb Fix bug when pressing left arrow key in PouInstanceVariablesPanel
Laurent Bessard
parents: 930
diff changeset
   513
        if keycode != wx.WXK_LEFT:
5743398071eb Fix bug when pressing left arrow key in PouInstanceVariablesPanel
Laurent Bessard
parents: 930
diff changeset
   514
            event.Skip()