dialogs/LDPowerRailDialog.py
author Andrey Skvortsov <andrej.skvortzov@gmail.com>
Fri, 15 Sep 2017 20:28:54 +0300
changeset 1813 c18adf359d21
parent 1782 5b6ad7a7fd9d
child 1850 614396cbffbf
permissions -rw-r--r--
lazy locale initialization

wx.Locale() can't be called without wx.App. So don't call it at
import. It makes PLCOpenEditor simpler.
1571
486f94a8032c fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1357
diff changeset
     1
#!/usr/bin/env python
814
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: 1357
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: 1357
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: 1357
diff changeset
     7
# Copyright (C) 2007: Edouard TISSERANT and Laurent BESSARD
1696
8043f32de7b8 make all dialog have non-fixed size
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1571
diff changeset
     8
# Copyright (C) 2017: Andrey Skvortsov <andrej.skvortzov@gmail.com>
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
     9
#
1571
486f94a8032c fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1357
diff changeset
    10
# See COPYING file for copyrights details.
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    11
#
1571
486f94a8032c fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1357
diff changeset
    12
# 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: 1357
diff changeset
    13
# 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: 1357
diff changeset
    14
# 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: 1357
diff changeset
    15
# of the License, or (at your option) any later version.
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    16
#
1571
486f94a8032c fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1357
diff changeset
    17
# 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: 1357
diff changeset
    18
# 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: 1357
diff changeset
    19
# 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: 1357
diff changeset
    20
# GNU General Public License for more details.
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    21
#
1571
486f94a8032c fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1357
diff changeset
    22
# 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: 1357
diff changeset
    23
# 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: 1357
diff changeset
    24
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    25
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    26
import wx
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    27
1249
b956c924cbbd Rewrite LDPowerRailDialog
Laurent Bessard
parents: 814
diff changeset
    28
from graphics.GraphicCommons import LEFTRAIL, RIGHTRAIL, LD_LINE_SIZE
b956c924cbbd Rewrite LDPowerRailDialog
Laurent Bessard
parents: 814
diff changeset
    29
from graphics.LD_Objects import LD_PowerRail
b956c924cbbd Rewrite LDPowerRailDialog
Laurent Bessard
parents: 814
diff changeset
    30
from BlockPreviewDialog import BlockPreviewDialog
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    31
1782
5b6ad7a7fd9d clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1768
diff changeset
    32
# -------------------------------------------------------------------------------
1249
b956c924cbbd Rewrite LDPowerRailDialog
Laurent Bessard
parents: 814
diff changeset
    33
#                    Set Ladder Power Rail Parameters Dialog
1782
5b6ad7a7fd9d clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1768
diff changeset
    34
# -------------------------------------------------------------------------------
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    35
1249
b956c924cbbd Rewrite LDPowerRailDialog
Laurent Bessard
parents: 814
diff changeset
    36
b956c924cbbd Rewrite LDPowerRailDialog
Laurent Bessard
parents: 814
diff changeset
    37
class LDPowerRailDialog(BlockPreviewDialog):
1736
7e61baa047f0 clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1730
diff changeset
    38
    """
7e61baa047f0 clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1730
diff changeset
    39
    Class that implements a dialog for defining parameters of a power rail graphic
7e61baa047f0 clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1730
diff changeset
    40
    element
7e61baa047f0 clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1730
diff changeset
    41
    """
1249
b956c924cbbd Rewrite LDPowerRailDialog
Laurent Bessard
parents: 814
diff changeset
    42
    def __init__(self, parent, controller, tagname):
b956c924cbbd Rewrite LDPowerRailDialog
Laurent Bessard
parents: 814
diff changeset
    43
        """
b956c924cbbd Rewrite LDPowerRailDialog
Laurent Bessard
parents: 814
diff changeset
    44
        Constructor
b956c924cbbd Rewrite LDPowerRailDialog
Laurent Bessard
parents: 814
diff changeset
    45
        @param parent: Parent wx.Window of dialog for modal
b956c924cbbd Rewrite LDPowerRailDialog
Laurent Bessard
parents: 814
diff changeset
    46
        @param controller: Reference to project controller
b956c924cbbd Rewrite LDPowerRailDialog
Laurent Bessard
parents: 814
diff changeset
    47
        @param tagname: Tagname of project POU edited
b956c924cbbd Rewrite LDPowerRailDialog
Laurent Bessard
parents: 814
diff changeset
    48
        """
b956c924cbbd Rewrite LDPowerRailDialog
Laurent Bessard
parents: 814
diff changeset
    49
        BlockPreviewDialog.__init__(self, parent, controller, tagname,
1768
691083b5682a clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1745
diff changeset
    50
                                    title=_('Power Rail Properties'))
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1696
diff changeset
    51
1250
7e6de17c687a Rewrite SFCStepDialog and factorize code for creating common dialog sizers
Laurent Bessard
parents: 1249
diff changeset
    52
        # Init common sizers
7e6de17c687a Rewrite SFCStepDialog and factorize code for creating common dialog sizers
Laurent Bessard
parents: 1249
diff changeset
    53
        self._init_sizers(2, 0, 5, None, 2, 1)
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1696
diff changeset
    54
1249
b956c924cbbd Rewrite LDPowerRailDialog
Laurent Bessard
parents: 814
diff changeset
    55
        # Create label for connection type
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    56
        type_label = wx.StaticText(self, label=_('Type:'))
1250
7e6de17c687a Rewrite SFCStepDialog and factorize code for creating common dialog sizers
Laurent Bessard
parents: 1249
diff changeset
    57
        self.LeftGridSizer.AddWindow(type_label, flag=wx.GROW)
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1696
diff changeset
    58
1249
b956c924cbbd Rewrite LDPowerRailDialog
Laurent Bessard
parents: 814
diff changeset
    59
        # Create radio buttons for selecting power rail type
b956c924cbbd Rewrite LDPowerRailDialog
Laurent Bessard
parents: 814
diff changeset
    60
        self.TypeRadioButtons = {}
b956c924cbbd Rewrite LDPowerRailDialog
Laurent Bessard
parents: 814
diff changeset
    61
        first = True
b956c924cbbd Rewrite LDPowerRailDialog
Laurent Bessard
parents: 814
diff changeset
    62
        for type, label in [(LEFTRAIL, _('Left PowerRail')),
b956c924cbbd Rewrite LDPowerRailDialog
Laurent Bessard
parents: 814
diff changeset
    63
                            (RIGHTRAIL, _('Right PowerRail'))]:
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1696
diff changeset
    64
            radio_button = wx.RadioButton(self, label=label,
1768
691083b5682a clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1745
diff changeset
    65
                                          style=(wx.RB_GROUP if first else 0))
1249
b956c924cbbd Rewrite LDPowerRailDialog
Laurent Bessard
parents: 814
diff changeset
    66
            radio_button.SetValue(first)
b956c924cbbd Rewrite LDPowerRailDialog
Laurent Bessard
parents: 814
diff changeset
    67
            self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, radio_button)
1250
7e6de17c687a Rewrite SFCStepDialog and factorize code for creating common dialog sizers
Laurent Bessard
parents: 1249
diff changeset
    68
            self.LeftGridSizer.AddWindow(radio_button, flag=wx.GROW)
1249
b956c924cbbd Rewrite LDPowerRailDialog
Laurent Bessard
parents: 814
diff changeset
    69
            self.TypeRadioButtons[type] = radio_button
b956c924cbbd Rewrite LDPowerRailDialog
Laurent Bessard
parents: 814
diff changeset
    70
            first = False
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1696
diff changeset
    71
1249
b956c924cbbd Rewrite LDPowerRailDialog
Laurent Bessard
parents: 814
diff changeset
    72
        # Create label for power rail pin number
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    73
        pin_number_label = wx.StaticText(self, label=_('Pin number:'))
1250
7e6de17c687a Rewrite SFCStepDialog and factorize code for creating common dialog sizers
Laurent Bessard
parents: 1249
diff changeset
    74
        self.LeftGridSizer.AddWindow(pin_number_label, flag=wx.GROW)
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1696
diff changeset
    75
1249
b956c924cbbd Rewrite LDPowerRailDialog
Laurent Bessard
parents: 814
diff changeset
    76
        # Create spin control for defining power rail pin number
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    77
        self.PinNumber = wx.SpinCtrl(self, min=1, max=50,
1768
691083b5682a clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1745
diff changeset
    78
                                     style=wx.SP_ARROW_KEYS)
1357
b8d577c7eb4b Fixed bug wrong pin number in dialog when creating new power rail on Windows
Laurent Bessard
parents: 1259
diff changeset
    79
        self.PinNumber.SetValue(1)
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    80
        self.Bind(wx.EVT_SPINCTRL, self.OnPinNumberChanged, self.PinNumber)
1250
7e6de17c687a Rewrite SFCStepDialog and factorize code for creating common dialog sizers
Laurent Bessard
parents: 1249
diff changeset
    81
        self.LeftGridSizer.AddWindow(self.PinNumber, flag=wx.GROW)
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1696
diff changeset
    82
1249
b956c924cbbd Rewrite LDPowerRailDialog
Laurent Bessard
parents: 814
diff changeset
    83
        # Add preview panel and associated label to sizers
1250
7e6de17c687a Rewrite SFCStepDialog and factorize code for creating common dialog sizers
Laurent Bessard
parents: 1249
diff changeset
    84
        self.RightGridSizer.AddWindow(self.PreviewLabel, flag=wx.GROW)
7e6de17c687a Rewrite SFCStepDialog and factorize code for creating common dialog sizers
Laurent Bessard
parents: 1249
diff changeset
    85
        self.RightGridSizer.AddWindow(self.Preview, flag=wx.GROW)
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1696
diff changeset
    86
1249
b956c924cbbd Rewrite LDPowerRailDialog
Laurent Bessard
parents: 814
diff changeset
    87
        # Add buttons sizer to sizers
1768
691083b5682a clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1745
diff changeset
    88
        self.MainSizer.AddSizer(
691083b5682a clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1745
diff changeset
    89
            self.ButtonSizer, border=20,
691083b5682a clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1745
diff changeset
    90
            flag=wx.ALIGN_RIGHT | wx.BOTTOM | wx.LEFT | wx.RIGHT)
1696
8043f32de7b8 make all dialog have non-fixed size
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1571
diff changeset
    91
        self.Fit()
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1696
diff changeset
    92
1249
b956c924cbbd Rewrite LDPowerRailDialog
Laurent Bessard
parents: 814
diff changeset
    93
        # Left Power Rail radio button is default control having keyboard focus
b956c924cbbd Rewrite LDPowerRailDialog
Laurent Bessard
parents: 814
diff changeset
    94
        self.TypeRadioButtons[LEFTRAIL].SetFocus()
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1696
diff changeset
    95
1249
b956c924cbbd Rewrite LDPowerRailDialog
Laurent Bessard
parents: 814
diff changeset
    96
    def GetMinElementSize(self):
b956c924cbbd Rewrite LDPowerRailDialog
Laurent Bessard
parents: 814
diff changeset
    97
        """
b956c924cbbd Rewrite LDPowerRailDialog
Laurent Bessard
parents: 814
diff changeset
    98
        Get minimal graphic element size
b956c924cbbd Rewrite LDPowerRailDialog
Laurent Bessard
parents: 814
diff changeset
    99
        @return: Tuple containing minimal size (width, height) or None if no
b956c924cbbd Rewrite LDPowerRailDialog
Laurent Bessard
parents: 814
diff changeset
   100
        element defined
b956c924cbbd Rewrite LDPowerRailDialog
Laurent Bessard
parents: 814
diff changeset
   101
        """
1259
8350222a81c3 Added support for adding graphic element when dropping wire in midair
Laurent Bessard
parents: 1251
diff changeset
   102
        return self.Element.GetMinSize(True)
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1696
diff changeset
   103
1249
b956c924cbbd Rewrite LDPowerRailDialog
Laurent Bessard
parents: 814
diff changeset
   104
    def GetPowerRailType(self):
b956c924cbbd Rewrite LDPowerRailDialog
Laurent Bessard
parents: 814
diff changeset
   105
        """
b956c924cbbd Rewrite LDPowerRailDialog
Laurent Bessard
parents: 814
diff changeset
   106
        Return type selected for power rail
b956c924cbbd Rewrite LDPowerRailDialog
Laurent Bessard
parents: 814
diff changeset
   107
        @return: Type selected (LEFTRAIL or RIGHTRAIL)
b956c924cbbd Rewrite LDPowerRailDialog
Laurent Bessard
parents: 814
diff changeset
   108
        """
b956c924cbbd Rewrite LDPowerRailDialog
Laurent Bessard
parents: 814
diff changeset
   109
        return (LEFTRAIL
b956c924cbbd Rewrite LDPowerRailDialog
Laurent Bessard
parents: 814
diff changeset
   110
                if self.TypeRadioButtons[LEFTRAIL].GetValue()
b956c924cbbd Rewrite LDPowerRailDialog
Laurent Bessard
parents: 814
diff changeset
   111
                else RIGHTRAIL)
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1696
diff changeset
   112
1249
b956c924cbbd Rewrite LDPowerRailDialog
Laurent Bessard
parents: 814
diff changeset
   113
    def SetValues(self, values):
b956c924cbbd Rewrite LDPowerRailDialog
Laurent Bessard
parents: 814
diff changeset
   114
        """
b956c924cbbd Rewrite LDPowerRailDialog
Laurent Bessard
parents: 814
diff changeset
   115
        Set default power rail parameters
b956c924cbbd Rewrite LDPowerRailDialog
Laurent Bessard
parents: 814
diff changeset
   116
        @param values: Power rail parameters values
b956c924cbbd Rewrite LDPowerRailDialog
Laurent Bessard
parents: 814
diff changeset
   117
        """
b956c924cbbd Rewrite LDPowerRailDialog
Laurent Bessard
parents: 814
diff changeset
   118
        # For each parameters defined, set corresponding control value
b956c924cbbd Rewrite LDPowerRailDialog
Laurent Bessard
parents: 814
diff changeset
   119
        for name, value in values.items():
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1696
diff changeset
   120
1249
b956c924cbbd Rewrite LDPowerRailDialog
Laurent Bessard
parents: 814
diff changeset
   121
            # Parameter is power rail type
b956c924cbbd Rewrite LDPowerRailDialog
Laurent Bessard
parents: 814
diff changeset
   122
            if name == "type":
b956c924cbbd Rewrite LDPowerRailDialog
Laurent Bessard
parents: 814
diff changeset
   123
                self.TypeRadioButtons[value].SetValue(True)
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1696
diff changeset
   124
1249
b956c924cbbd Rewrite LDPowerRailDialog
Laurent Bessard
parents: 814
diff changeset
   125
            # Parameter is power rail pin number
b956c924cbbd Rewrite LDPowerRailDialog
Laurent Bessard
parents: 814
diff changeset
   126
            elif name == "pin_number":
b956c924cbbd Rewrite LDPowerRailDialog
Laurent Bessard
parents: 814
diff changeset
   127
                self.PinNumber.SetValue(value)
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   128
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   129
    def GetValues(self):
1249
b956c924cbbd Rewrite LDPowerRailDialog
Laurent Bessard
parents: 814
diff changeset
   130
        """
b956c924cbbd Rewrite LDPowerRailDialog
Laurent Bessard
parents: 814
diff changeset
   131
        Return power rail parameters defined in dialog
b956c924cbbd Rewrite LDPowerRailDialog
Laurent Bessard
parents: 814
diff changeset
   132
        @return: {parameter_name: parameter_value,...}
b956c924cbbd Rewrite LDPowerRailDialog
Laurent Bessard
parents: 814
diff changeset
   133
        """
b956c924cbbd Rewrite LDPowerRailDialog
Laurent Bessard
parents: 814
diff changeset
   134
        values = {
b956c924cbbd Rewrite LDPowerRailDialog
Laurent Bessard
parents: 814
diff changeset
   135
            "type": self.GetPowerRailType(),
b956c924cbbd Rewrite LDPowerRailDialog
Laurent Bessard
parents: 814
diff changeset
   136
            "pin_number": self.PinNumber.GetValue()}
b956c924cbbd Rewrite LDPowerRailDialog
Laurent Bessard
parents: 814
diff changeset
   137
        values["width"], values["height"] = self.Element.GetSize()
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   138
        return values
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   139
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   140
    def OnTypeChanged(self, event):
1249
b956c924cbbd Rewrite LDPowerRailDialog
Laurent Bessard
parents: 814
diff changeset
   141
        """
b956c924cbbd Rewrite LDPowerRailDialog
Laurent Bessard
parents: 814
diff changeset
   142
        Called when power rail type changed
b956c924cbbd Rewrite LDPowerRailDialog
Laurent Bessard
parents: 814
diff changeset
   143
        @param event: wx.RadioButtonEvent
b956c924cbbd Rewrite LDPowerRailDialog
Laurent Bessard
parents: 814
diff changeset
   144
        """
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   145
        self.RefreshPreview()
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   146
        event.Skip()
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   147
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   148
    def OnPinNumberChanged(self, event):
1249
b956c924cbbd Rewrite LDPowerRailDialog
Laurent Bessard
parents: 814
diff changeset
   149
        """
b956c924cbbd Rewrite LDPowerRailDialog
Laurent Bessard
parents: 814
diff changeset
   150
        Called when power rail pin number value changed
b956c924cbbd Rewrite LDPowerRailDialog
Laurent Bessard
parents: 814
diff changeset
   151
        @param event: wx.SpinEvent
b956c924cbbd Rewrite LDPowerRailDialog
Laurent Bessard
parents: 814
diff changeset
   152
        """
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   153
        self.RefreshPreview()
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   154
        event.Skip()
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   155
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   156
    def RefreshPreview(self):
1249
b956c924cbbd Rewrite LDPowerRailDialog
Laurent Bessard
parents: 814
diff changeset
   157
        """
b956c924cbbd Rewrite LDPowerRailDialog
Laurent Bessard
parents: 814
diff changeset
   158
        Refresh preview panel of graphic element
b956c924cbbd Rewrite LDPowerRailDialog
Laurent Bessard
parents: 814
diff changeset
   159
        Override BlockPreviewDialog function
b956c924cbbd Rewrite LDPowerRailDialog
Laurent Bessard
parents: 814
diff changeset
   160
        """
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1696
diff changeset
   161
1249
b956c924cbbd Rewrite LDPowerRailDialog
Laurent Bessard
parents: 814
diff changeset
   162
        # Set graphic element displayed, creating a power rail element
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1696
diff changeset
   163
        self.Element = LD_PowerRail(self.Preview,
1768
691083b5682a clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1745
diff changeset
   164
                                    self.GetPowerRailType(),
691083b5682a clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1745
diff changeset
   165
                                    connectors=self.PinNumber.GetValue())
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1696
diff changeset
   166
1249
b956c924cbbd Rewrite LDPowerRailDialog
Laurent Bessard
parents: 814
diff changeset
   167
        # Call BlockPreviewDialog function
b956c924cbbd Rewrite LDPowerRailDialog
Laurent Bessard
parents: 814
diff changeset
   168
        BlockPreviewDialog.RefreshPreview(self)