dialogs/SFCDivergenceDialog.py
author Andrey Skvortsov <andrej.skvortzov@gmail.com>
Wed, 07 Dec 2016 18:23:59 +0300
changeset 1593 6a27490fed96
parent 1585 60c0db313ec9
child 1696 8043f32de7b8
permissions -rw-r--r--
don't crash on trying to change IP interface for Beremiz_service using taskbar icon if IP wasn't previously


By default IP is not set (None) and service listen only on localhost interface.
1571
486f94a8032c fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1259
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: 1259
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: 1259
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: 1259
diff changeset
     7
# Copyright (C) 2007: 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: 1259
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: 1259
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: 1259
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: 1259
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: 1259
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: 1259
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: 1259
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: 1259
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: 1259
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: 1259
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: 1259
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: 1259
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
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    25
import wx
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    26
1251
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
    27
from graphics.GraphicCommons import SELECTION_DIVERGENCE, \
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
    28
    SELECTION_CONVERGENCE, SIMULTANEOUS_DIVERGENCE, SIMULTANEOUS_CONVERGENCE
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
    29
from graphics.SFC_Objects import SFC_Divergence
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
    30
from BlockPreviewDialog import BlockPreviewDialog
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    31
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    32
#-------------------------------------------------------------------------------
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    33
#                         Create New Divergence Dialog
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    34
#-------------------------------------------------------------------------------
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    35
1251
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
    36
"""
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
    37
Class that implements a dialog for defining parameters for creating a new
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
    38
divergence graphic element
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
    39
"""
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
    40
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
    41
class SFCDivergenceDialog(BlockPreviewDialog):
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    42
    
1584
431f4ef34bde make only correct blocks(by IEC 61131-3 standard) available in wire popup menu in SFC Viewer
Sergey Surkov <surkovsv93@gmail.com>
parents: 1571
diff changeset
    43
    def __init__(self, parent, controller, tagname, poss_div_types = None):
1251
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
    44
        """
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
    45
        Constructor
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
    46
        @param parent: Parent wx.Window of dialog for modal
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
    47
        @param controller: Reference to project controller
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
    48
        @param tagname: Tagname of project POU edited
1584
431f4ef34bde make only correct blocks(by IEC 61131-3 standard) available in wire popup menu in SFC Viewer
Sergey Surkov <surkovsv93@gmail.com>
parents: 1571
diff changeset
    49
        @param poss_div_types: Types of divergence that will be available in the dialog window
1251
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
    50
        """
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
    51
        BlockPreviewDialog.__init__(self, parent, controller, tagname, 
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
    52
              size=wx.Size(500, 300), 
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    53
              title=_('Create a new divergence or convergence'))
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    54
        
1251
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
    55
        # Init common sizers
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
    56
        self._init_sizers(2, 0, 7, None, 2, 1)
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    57
        
1251
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
    58
        # Create label for divergence type
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
    59
        type_label = wx.StaticText(self, label=_('Type:'))
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
    60
        self.LeftGridSizer.AddWindow(type_label, flag=wx.GROW)
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    61
        
1251
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
    62
        # Create radio buttons for selecting divergence type
1584
431f4ef34bde make only correct blocks(by IEC 61131-3 standard) available in wire popup menu in SFC Viewer
Sergey Surkov <surkovsv93@gmail.com>
parents: 1571
diff changeset
    63
        divergence_buttons = [
431f4ef34bde make only correct blocks(by IEC 61131-3 standard) available in wire popup menu in SFC Viewer
Sergey Surkov <surkovsv93@gmail.com>
parents: 1571
diff changeset
    64
            (SELECTION_DIVERGENCE, _('Selection Divergence')),
431f4ef34bde make only correct blocks(by IEC 61131-3 standard) available in wire popup menu in SFC Viewer
Sergey Surkov <surkovsv93@gmail.com>
parents: 1571
diff changeset
    65
            (SELECTION_CONVERGENCE, _('Selection Convergence')),
431f4ef34bde make only correct blocks(by IEC 61131-3 standard) available in wire popup menu in SFC Viewer
Sergey Surkov <surkovsv93@gmail.com>
parents: 1571
diff changeset
    66
            (SIMULTANEOUS_DIVERGENCE, _('Simultaneous Divergence')),
431f4ef34bde make only correct blocks(by IEC 61131-3 standard) available in wire popup menu in SFC Viewer
Sergey Surkov <surkovsv93@gmail.com>
parents: 1571
diff changeset
    67
            (SIMULTANEOUS_CONVERGENCE, _('Simultaneous Convergence'))]
431f4ef34bde make only correct blocks(by IEC 61131-3 standard) available in wire popup menu in SFC Viewer
Sergey Surkov <surkovsv93@gmail.com>
parents: 1571
diff changeset
    68
        poss_div_btns = []
431f4ef34bde make only correct blocks(by IEC 61131-3 standard) available in wire popup menu in SFC Viewer
Sergey Surkov <surkovsv93@gmail.com>
parents: 1571
diff changeset
    69
        if poss_div_types is not None:
431f4ef34bde make only correct blocks(by IEC 61131-3 standard) available in wire popup menu in SFC Viewer
Sergey Surkov <surkovsv93@gmail.com>
parents: 1571
diff changeset
    70
             for val in poss_div_types:
431f4ef34bde make only correct blocks(by IEC 61131-3 standard) available in wire popup menu in SFC Viewer
Sergey Surkov <surkovsv93@gmail.com>
parents: 1571
diff changeset
    71
                 poss_div_btns.append(divergence_buttons[val])
431f4ef34bde make only correct blocks(by IEC 61131-3 standard) available in wire popup menu in SFC Viewer
Sergey Surkov <surkovsv93@gmail.com>
parents: 1571
diff changeset
    72
        else:
431f4ef34bde make only correct blocks(by IEC 61131-3 standard) available in wire popup menu in SFC Viewer
Sergey Surkov <surkovsv93@gmail.com>
parents: 1571
diff changeset
    73
            poss_div_btns = divergence_buttons
1251
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
    74
        self.TypeRadioButtons = {}
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
    75
        first = True
1584
431f4ef34bde make only correct blocks(by IEC 61131-3 standard) available in wire popup menu in SFC Viewer
Sergey Surkov <surkovsv93@gmail.com>
parents: 1571
diff changeset
    76
        focusbtn = None
431f4ef34bde make only correct blocks(by IEC 61131-3 standard) available in wire popup menu in SFC Viewer
Sergey Surkov <surkovsv93@gmail.com>
parents: 1571
diff changeset
    77
        for type, label in poss_div_btns:
1251
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
    78
            radio_button = wx.RadioButton(self, label=label, 
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
    79
                  style=(wx.RB_GROUP if first else 0))
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
    80
            radio_button.SetValue(first)
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
    81
            self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, radio_button)
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
    82
            self.LeftGridSizer.AddWindow(radio_button, flag=wx.GROW)
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
    83
            self.TypeRadioButtons[type] = radio_button
1584
431f4ef34bde make only correct blocks(by IEC 61131-3 standard) available in wire popup menu in SFC Viewer
Sergey Surkov <surkovsv93@gmail.com>
parents: 1571
diff changeset
    84
            if first: focusbtn = type
1251
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
    85
            first = False
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    86
1251
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
    87
        # Create label for number of divergence sequences
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    88
        sequences_label = wx.StaticText(self, 
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    89
              label=_('Number of sequences:'))
1251
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
    90
        self.LeftGridSizer.AddWindow(sequences_label, flag=wx.GROW)
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    91
        
1251
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
    92
        # Create spin control for defining number of divergence sequences
1585
60c0db313ec9 fix initial(equal to the min) number of sequences in SFC Divergence dialog.
Sergey Surkov <surkovsv93@gmail.com>
parents: 1584
diff changeset
    93
        self.Sequences = wx.SpinCtrl(self, min=2, max=20, initial=2)
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    94
        self.Bind(wx.EVT_SPINCTRL, self.OnSequencesChanged, self.Sequences)
1251
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
    95
        self.LeftGridSizer.AddWindow(self.Sequences, flag=wx.GROW)
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    96
        
1251
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
    97
        # Add preview panel and associated label to sizers
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
    98
        self.RightGridSizer.AddWindow(self.PreviewLabel, flag=wx.GROW)
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
    99
        self.RightGridSizer.AddWindow(self.Preview, flag=wx.GROW)
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   100
        
1251
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
   101
        # Add buttons sizer to sizers
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
   102
        self.MainSizer.AddSizer(self.ButtonSizer, border=20, 
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
   103
              flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT)
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   104
        
1251
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
   105
        # Selection divergence radio button is default control having keyboard
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
   106
        # focus
1584
431f4ef34bde make only correct blocks(by IEC 61131-3 standard) available in wire popup menu in SFC Viewer
Sergey Surkov <surkovsv93@gmail.com>
parents: 1571
diff changeset
   107
        self.TypeRadioButtons[focusbtn].SetFocus()
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   108
    
1251
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
   109
    def GetMinElementSize(self):
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
   110
        """
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
   111
        Get minimal graphic element size
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
   112
        @return: Tuple containing minimal size (width, height) or None if no
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
   113
        element defined
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
   114
        """
1259
8350222a81c3 Added support for adding graphic element when dropping wire in midair
Laurent Bessard
parents: 1251
diff changeset
   115
        return self.Element.GetMinSize(True)
1251
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
   116
    
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
   117
    def GetDivergenceType(self):
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
   118
        """
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
   119
        Return type selected for SFC divergence
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
   120
        @return: Type selected (None if not found)
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
   121
        """
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
   122
        # Go through radio buttons and return type associated to the one that
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
   123
        # is selected
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
   124
        for type, control in self.TypeRadioButtons.iteritems():
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
   125
            if control.GetValue():
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
   126
                return type
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
   127
        return None
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):
1251
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
   130
        """
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
   131
        Set default SFC divergence parameters
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
   132
        @param values: Divergence parameters values
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
   133
        """
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
   134
        return {"type": self.GetDivergenceType(),
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
   135
                "number": self.Sequences.GetValue()}
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   136
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   137
    def OnTypeChanged(self, event):
1251
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
   138
        """
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
   139
        Called when SFC divergence type changed
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
   140
        @param event: wx.RadioButtonEvent
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
   141
        """
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   142
        self.RefreshPreview()
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   143
        event.Skip()
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   144
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   145
    def OnSequencesChanged(self, event):
1251
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
   146
        """
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
   147
        Called when SFC divergence number of sequences changed
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
   148
        @param event: wx.SpinEvent
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
   149
        """
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   150
        self.RefreshPreview()
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   151
        event.Skip()
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   152
        
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   153
    def RefreshPreview(self):
1251
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
   154
        """
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
   155
        Refresh preview panel of graphic element
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
   156
        Override BlockPreviewDialog function
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
   157
        """
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
   158
        # Set graphic element displayed, creating a SFC divergence
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
   159
        self.Element = SFC_Divergence(self.Preview, 
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
   160
                                      self.GetDivergenceType(), 
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
   161
                                      self.Sequences.GetValue())
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
   162
        
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
   163
        # Call BlockPreviewDialog function
d9ed42e44a50 Rewrite SFCDivergenceDialog
Laurent Bessard
parents: 814
diff changeset
   164
        BlockPreviewDialog.RefreshPreview(self)
1571
486f94a8032c fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1259
diff changeset
   165