--- a/DataTypeEditor.py Sat Mar 26 22:54:33 2011 +0100
+++ b/DataTypeEditor.py Thu Mar 31 17:37:47 2011 +0200
@@ -479,7 +479,7 @@
pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
self.ArrayBaseType = wx.ComboBox(id=ID_DATATYPEEDITORARRAYBASETYPE,
- name='SubrangeBaseType', parent=self.ArrayPanel, pos=wx.Point(0, 0),
+ name='ArrayBaseType', parent=self.ArrayPanel, pos=wx.Point(0, 0),
size=wx.Size(0, 28), style=wx.CB_READONLY)
self.Bind(wx.EVT_COMBOBOX, self.OnInfosChanged, id=ID_DATATYPEEDITORARRAYBASETYPE)
--- a/LDViewer.py Sat Mar 26 22:54:33 2011 +0100
+++ b/LDViewer.py Thu Mar 31 17:37:47 2011 +0200
@@ -448,6 +448,46 @@
event.Skip()
#-------------------------------------------------------------------------------
+# Model adding functions from Drop Target
+#-------------------------------------------------------------------------------
+
+ def AddVariableBlock(self, x, y, scaling, var_class, var_name, var_type):
+ if var_type == "BOOL":
+ id = self.GetNewId()
+ if var_class == INPUT:
+ contact = LD_Contact(self, CONTACT_NORMAL, var_name, id)
+ width, height = contact.GetMinSize()
+ if scaling is not None:
+ x = round(float(x) / float(scaling[0])) * scaling[0]
+ y = round(float(y) / float(scaling[1])) * scaling[1]
+ width = round(float(width) / float(scaling[0]) + 0.5) * scaling[0]
+ height = round(float(height) / float(scaling[1]) + 0.5) * scaling[1]
+ contact.SetPosition(x, y)
+ contact.SetSize(width, height)
+ self.AddBlock(contact)
+ self.Controler.AddEditedElementContact(self.GetTagName(), id)
+ self.RefreshContactModel(contact)
+ else:
+ coil = LD_Coil(self, COIL_NORMAL, var_name, id)
+ width, height = coil.GetMinSize()
+ if scaling is not None:
+ x = round(float(x) / float(scaling[0])) * scaling[0]
+ y = round(float(y) / float(scaling[1])) * scaling[1]
+ width = round(float(width) / float(scaling[0]) + 0.5) * scaling[0]
+ height = round(float(height) / float(scaling[1]) + 0.5) * scaling[1]
+ coil.SetPosition(x, y)
+ coil.SetSize(width, height)
+ self.AddBlock(coil)
+ self.Controler.AddEditedElementCoil(self.GetTagName(), id)
+ self.RefreshCoilModel(coil)
+ self.RefreshBuffer()
+ self.RefreshScrollBars()
+ self.RefreshVisibleElements()
+ self.Refresh(False)
+ else:
+ Viewer.AddVariableBlock(self, x, y, scaling, var_class, var_name, var_type)
+
+#-------------------------------------------------------------------------------
# Adding element functions
#-------------------------------------------------------------------------------
--- a/PLCControler.py Sat Mar 26 22:54:33 2011 +0100
+++ b/PLCControler.py Thu Mar 31 17:37:47 2011 +0200
@@ -898,9 +898,33 @@
# Create variable and change its properties
tempvar = plcopen.varListPlain_variable()
tempvar.setname(var["Name"])
-
+
var_type = plcopen.dataType()
- if var["Type"] in self.GetBaseTypes():
+ if isinstance(var["Type"], TupleType):
+ if var["Type"][0] == "array":
+ array_type, base_type_name, dimensions = var["Type"]
+ array = plcopen.derivedTypes_array()
+ for i, dimension in enumerate(dimensions):
+ dimension_range = plcopen.rangeSigned()
+ dimension_range.setlower(dimension[0])
+ dimension_range.setupper(dimension[1])
+ if i == 0:
+ array.setdimension([dimension_range])
+ else:
+ array.appenddimension(dimension_range)
+ if base_type_name in self.GetBaseTypes():
+ if base_type_name == "STRING":
+ array.baseType.setcontent({"name" : "string", "value" : plcopen.elementaryTypes_string()})
+ elif base_type_name == "WSTRING":
+ array.baseType.setcontent({"name" : "wstring", "value" : plcopen.wstring()})
+ else:
+ array.baseType.setcontent({"name" : base_type_name, "value" : None})
+ else:
+ derived_datatype = plcopen.derivedTypes_derived()
+ derived_datatype.setname(base_type_name)
+ array.baseType.setcontent({"name" : "derived", "value" : derived_datatype})
+ var_type.setcontent({"name" : "array", "value" : array})
+ elif var["Type"] in self.GetBaseTypes():
if var["Type"] == "STRING":
var_type.setcontent({"name" : "string", "value" : plcopen.elementaryTypes_string()})
elif var["Type"] == "WSTRING":
@@ -941,6 +965,16 @@
vartype_content = var.gettype().getcontent()
if vartype_content["name"] == "derived":
tempvar["Type"] = vartype_content["value"].getname()
+ elif vartype_content["name"] == "array":
+ dimensions = []
+ for dimension in vartype_content["value"].getdimension():
+ dimensions.append((dimension.getlower(), dimension.getupper()))
+ base_type = vartype_content["value"].baseType.getcontent()
+ if base_type["value"] is None:
+ base_type_name = base_type["name"]
+ else:
+ base_type_name = base_type["value"].getname()
+ tempvar["Type"] = ("array", base_type_name, dimensions)
elif vartype_content["name"] in ["string", "wstring"]:
tempvar["Type"] = vartype_content["name"].upper()
else:
--- a/PLCGenerator.py Sat Mar 26 22:54:33 2011 +0100
+++ b/PLCGenerator.py Thu Mar 31 17:37:47 2011 +0200
@@ -265,6 +265,20 @@
# Variable type is a string type
elif vartype_content["name"] in ["string", "wstring"]:
var_type = vartype_content["name"].upper()
+ # Variable type is an array
+ elif vartype_content["name"] == "array":
+ base_type = vartype_content["value"].baseType.getcontent()
+ # Array derived directly from a user defined type
+ if base_type["name"] == "derived":
+ basetype_name = base_type["value"].getname()
+ self.GenerateDataType(basetype_name)
+ # Array derived directly from a string type
+ elif base_type["name"] in ["string", "wstring"]:
+ basetype_name = base_type["name"].upper()
+ # Array derived directly from an elementary type
+ else:
+ basetype_name = base_type["name"]
+ var_type = "ARRAY [%s] OF %s" % (",".join(map(lambda x : "%s..%s" % (dimension.getlower(), dimension.getupper()), vartype_content["value"].getdimension())), basetype_name)
# Variable type is an elementary type
else:
var_type = vartype_content["name"]
@@ -320,6 +334,20 @@
# Variable type is a string type
elif vartype_content["name"] in ["string", "wstring"]:
var_type = vartype_content["name"].upper()
+ # Variable type is an array
+ elif vartype_content["name"] == "array":
+ base_type = vartype_content["value"].baseType.getcontent()
+ # Array derived directly from a user defined type
+ if base_type["name"] == "derived":
+ basetype_name = base_type["value"].getname()
+ self.GenerateDataType(basetype_name)
+ # Array derived directly from a string type
+ elif base_type["name"] in ["string", "wstring"]:
+ basetype_name = base_type["name"].upper()
+ # Array derived directly from an elementary type
+ else:
+ basetype_name = base_type["name"]
+ var_type = "ARRAY [%s] OF %s" % (",".join(map(lambda x : "%s..%s" % (dimension.getlower(), dimension.getupper()), vartype_content["value"].getdimension())), basetype_name)
# Variable type is an elementary type
else:
var_type = vartype_content["name"]
@@ -588,14 +616,27 @@
initial_value = None
address = var.getaddress()
if vartype_content["name"] in ["string", "wstring"]:
- if address is not None:
- located.append((vartype_content["name"].upper(), var.getname(), address, initial_value))
+ var_type = vartype_content["name"].upper()
+ # Variable type is an array
+ elif vartype_content["name"] == "array":
+ base_type = vartype_content["value"].baseType.getcontent()
+ # Array derived directly from a user defined type
+ if base_type["name"] == "derived":
+ basetype_name = base_type["value"].getname()
+ self.GenerateDataType(basetype_name)
+ # Array derived directly from a string type
+ elif base_type["name"] in ["string", "wstring"]:
+ basetype_name = base_type["name"].upper()
+ # Array derived directly from an elementary type
else:
- variables.append((vartype_content["name"].upper(), var.getname(), None, initial_value))
- elif address is not None:
- located.append((vartype_content["name"], var.getname(), address, initial_value))
+ basetype_name = base_type["name"]
+ var_type = "ARRAY [%s] OF %s" % (",".join(map(lambda x : "%s..%s" % (x.getlower(), x.getupper()), vartype_content["value"].getdimension())), basetype_name)
else:
- variables.append((vartype_content["name"], var.getname(), None, initial_value))
+ var_type = vartype_content["name"]
+ if address is not None:
+ located.append((var_type, var.getname(), address, initial_value))
+ else:
+ variables.append((var_type, var.getname(), None, initial_value))
if varlist["value"].getconstant():
option = "CONSTANT"
elif varlist["value"].getretain():
--- a/PLCOpenEditor.py Sat Mar 26 22:54:33 2011 +0100
+++ b/PLCOpenEditor.py Thu Mar 31 17:37:47 2011 +0200
@@ -83,14 +83,19 @@
# Get folder containing translation files
localedir = os.path.join(CWD,"locale")
# Get the default language
-langid = wx.LANGUAGE_DEFAULT
+langid = wx.LANGUAGE_SPANISH#wx.LANGUAGE_DEFAULT
# Define translation domain (name of translation files)
domain = "PLCOpenEditor"
# Define locale for wx
loc = __builtin__.__dict__.get('loc', None)
if loc is None:
- loc = wx.Locale(langid)
+ test_loc = wx.Locale(langid)
+ test_loc.AddCatalogLookupPathPrefix(localedir)
+ if test_loc.AddCatalog(domain):
+ loc = wx.Locale(langid)
+ else:
+ loc = wx.Locale(wx.LANGUAGE_ENGLISH)
__builtin__.__dict__['loc'] = loc
# Define location for searching translation files
loc.AddCatalogLookupPathPrefix(localedir)
@@ -727,15 +732,7 @@
window = self.TabsOpened.GetPage(selected)
if not window.IsDebugging():
self.VariablePanelIndexer.RemoveVariablePanel(window.GetTagName())
- # Refresh Tab selection
- if self.TabsOpened.GetPageCount() > 0:
- new_index = min(selected, self.TabsOpened.GetPageCount() - 1)
- self.TabsOpened.SetSelection(new_index)
- window = self.TabsOpened.GetPage(selected)
- if not window.IsDebugging():
- self.VariablePanelIndexer.ChangeVariablePanel(window.GetTagName())
- # Refresh all window elements that have changed
- wx.CallAfter(self._Refresh, TITLE, TOOLBAR, FILEMENU, EDITMENU, DISPLAYMENU)
+
wx.CallAfter(self.RefreshTabCtrlEvent)
event.Skip()
@@ -1249,7 +1246,9 @@
def GenerateTypesTreeBranch(self, root, infos, topology=False):
to_delete = []
item_name = infos["name"]
- self.TypesTree.SetItemText(root, _(item_name))
+ if infos["type"] in ITEMS_UNEDITABLE:
+ item_name = _(item_name)
+ self.TypesTree.SetItemText(root, item_name)
self.TypesTree.SetPyData(root, infos["type"])
if infos.get("tagname", None) in self.Errors:
self.TypesTree.SetItemBackgroundColour(root, wx.Colour(255, 255, 0))
@@ -1568,7 +1567,6 @@
self.TabsOpened.SetSelection(i)
window.SetFocus()
self.RefreshPageTitles()
- self._Refresh(FILEMENU, EDITMENU, TOOLBAR)
def OnTypesTreeRightUp(self, event):
if wx.Platform == '__WXMSW__':
--- a/VariablePanel.py Sat Mar 26 22:54:33 2011 +0100
+++ b/VariablePanel.py Thu Mar 31 17:37:47 2011 +0200
@@ -28,6 +28,7 @@
from plcopen.structures import LOCATIONDATATYPES, TestIdentifier, IEC_KEYWORDS
from PLCControler import LOCATION_PLUGIN, LOCATION_MODULE, LOCATION_GROUP, LOCATION_VAR_INPUT, LOCATION_VAR_OUTPUT, LOCATION_VAR_MEMORY
+from dialogs import ArrayTypeDialog
CWD = os.path.split(os.path.realpath(__file__))[0]
@@ -70,6 +71,7 @@
_(" Input"): _("Input"), _(" Output"): _("Output"), _(" InOut"): _("InOut"),
_(" External"): _("External"), _("Variables"): _("Variables"), _(" Local"): _("Local"),
_(" Temp"): _("Temp"), _("Global"): _("Global")}#, _("Access") : _("Access")}
+VARIABLE_CHOICES_DICT = dict([(_(_class), _class) for _class in GetFilterChoiceTransfer().iterkeys()])
VARIABLE_CLASSES_DICT = dict([(_(_class), _class) for _class in GetFilterChoiceTransfer().itervalues()])
CheckOptionForClass = {"Local": lambda x: x,
@@ -120,7 +122,11 @@
if col == 0:
return self.data[row]["Number"]
colname = self.GetColLabelValue(col, False)
- value = str(self.data[row].get(colname, ""))
+ value = self.data[row].get(colname, "")
+ if colname == "Type" and isinstance(value, TupleType):
+ if value[0] == "array":
+ return "ARRAY [%s] OF %s" % (",".join(map(lambda x : "..".join(x), value[2])), value[1])
+ value = str(value)
if colname in ["Class", "Option"]:
return _(value)
return value
@@ -250,6 +256,11 @@
else:
grid.SetCellTextColour(row, col, wx.BLACK)
grid.SetCellBackgroundColour(row, col, wx.WHITE)
+ if wx.Platform == '__WXMSW__':
+ grid.SetRowMinimalHeight(row, 20)
+ else:
+ grid.SetRowMinimalHeight(row, 28)
+ grid.AutoSizeRow(row, False)
def SetData(self, data):
self.data = data
@@ -633,7 +644,7 @@
event.Skip()
def OnClassFilter(self, event):
- self.Filter = self.FilterChoiceTransfer[self.ClassFilter.GetStringSelection()]
+ self.Filter = self.FilterChoiceTransfer[VARIABLE_CHOICES_DICT[self.ClassFilter.GetStringSelection()]]
self.RefreshTypeList()
self.RefreshValues()
self.RefreshButtons()
@@ -774,7 +785,11 @@
bodytype = self.Controler.GetEditedElementBodyType(self.TagName)
pouname, poutype = self.Controler.GetEditedElementType(self.TagName)
classtype = self.Table.GetValueByName(row, "Class")
-
+
+ #new_id = wx.NewId()
+ #AppendMenu(type_menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Array"))
+ #self.Bind(wx.EVT_MENU, self.VariableArrayTypeFunction, id=new_id)
+
if classtype in ["Input", "Output", "InOut", "External", "Global"] or \
poutype != "function" and bodytype in ["ST", "IL"]:
functionblock_menu = wx.Menu(title='')
@@ -807,6 +822,20 @@
self.ParentWindow._Refresh(TITLE, FILEMENU, EDITMENU, INSTANCESTREE, LIBRARYTREE)
return VariableTypeFunction
+ def VariableArrayTypeFunction(self, event):
+ row = self.VariablesGrid.GetGridCursorRow()
+ dialog = ArrayTypeDialog(self,
+ self.Controler.GetDataTypes(self.TagName),
+ self.Table.GetValueByName(row, "Type"))
+ if dialog.ShowModal() == wx.ID_OK:
+ self.Table.SetValueByName(row, "Type", dialog.GetValue())
+ self.Table.ResetView(self.VariablesGrid)
+ self.SaveValues(False)
+ self.ParentWindow.RefreshEditor(variablepanel = False)
+ self.Controler.BufferProject()
+ self.ParentWindow._Refresh(TITLE, FILEMENU, EDITMENU, INSTANCESTREE, LIBRARYTREE)
+ dialog.Destroy()
+
def OnVariablesGridCellLeftClick(self, event):
row = event.GetRow()
if event.GetCol() == 0 and self.Table.GetValueByName(row, "Edit"):
@@ -1204,4 +1233,3 @@
message.Destroy()
else:
self.EndModal(wx.ID_OK)
-
\ No newline at end of file
--- a/Viewer.py Sat Mar 26 22:54:33 2011 +0100
+++ b/Viewer.py Thu Mar 31 17:37:47 2011 +0200
@@ -281,26 +281,10 @@
var_type = values[2]
else:
var_type = LOCATIONDATATYPES.get(values[0][2], ["BOOL"])[0]
- id = self.ParentWindow.GetNewId()
- variable = FBD_Variable(self.ParentWindow, var_class, var_name, var_type, id)
- width, height = variable.GetMinSize()
- if scaling is not None:
- x = round(float(x) / float(scaling[0])) * scaling[0]
- y = round(float(y) / float(scaling[1])) * scaling[1]
- width = round(float(width) / float(scaling[0]) + 0.5) * scaling[0]
- height = round(float(height) / float(scaling[1]) + 0.5) * scaling[1]
- variable.SetPosition(x, y)
- variable.SetSize(width, height)
- self.ParentWindow.AddBlock(variable)
if not var_name.upper() in [name.upper() for name in self.ParentWindow.Controler.GetEditedElementVariables(tagname, self.ParentWindow.Debug)]:
self.ParentWindow.Controler.AddEditedElementPouVar(tagname, var_type, var_name, values[0], values[4])
- self.ParentWindow.Controler.AddEditedElementVariable(tagname, id, var_class)
- self.ParentWindow.RefreshVariableModel(variable)
- self.ParentWindow.RefreshBuffer()
- self.ParentWindow.RefreshScrollBars()
- self.ParentWindow.RefreshVisibleElements()
self.ParentWindow.ParentWindow.RefreshVariablePanel(tagname)
- self.ParentWindow.Refresh(False)
+ self.ParentWindow.AddVariableBlock(x, y, scaling, var_class, var_name, var_type)
elif values[3] == tagname:
if values[1] == "Output":
var_class = OUTPUT
@@ -315,7 +299,7 @@
self.GenerateTreeMenu(x, y, scaling, menu, "", var_class, [(values[0], values[2], tree)])
self.ParentWindow.PopupMenuXY(menu)
else:
- self.AddParentVariableBlock(x, y, scaling, var_class, values[0], values[2])
+ self.ParentWindow.AddVariableBlock(x, y, scaling, var_class, values[0], values[2])
else:
message = _("Unknown variable \"%s\" for this POU!") % values[0]
else:
@@ -343,28 +327,9 @@
def GetAddVariableBlockFunction(self, x, y, scaling, var_class, var_name, var_type):
def AddVariableFunction(event):
- self.AddParentVariableBlock(x, y, scaling, var_class, var_name, var_type)
+ self.ParentWindow.AddVariableBlock(x, y, scaling, var_class, var_name, var_type)
return AddVariableFunction
- def AddParentVariableBlock(self, x, y, scaling, var_class, var_name, var_type):
- id = self.ParentWindow.GetNewId()
- variable = FBD_Variable(self.ParentWindow, var_class, var_name, var_type, id)
- width, height = variable.GetMinSize()
- if scaling is not None:
- x = round(float(x) / float(scaling[0])) * scaling[0]
- y = round(float(y) / float(scaling[1])) * scaling[1]
- width = round(float(width) / float(scaling[0]) + 0.5) * scaling[0]
- height = round(float(height) / float(scaling[1]) + 0.5) * scaling[1]
- variable.SetPosition(x, y)
- variable.SetSize(width, height)
- self.ParentWindow.AddBlock(variable)
- self.ParentWindow.Controler.AddEditedElementVariable(self.ParentWindow.GetTagName(), id, var_class)
- self.ParentWindow.RefreshVariableModel(variable)
- self.ParentWindow.RefreshBuffer()
- self.ParentWindow.RefreshScrollBars()
- self.ParentWindow.RefreshVisibleElements()
- self.ParentWindow.Refresh(False)
-
def ShowMessage(self, message):
message = wx.MessageDialog(self.ParentWindow, message, _("Error"), wx.OK|wx.ICON_ERROR)
message.ShowModal()
@@ -1761,6 +1726,29 @@
event.Skip()
#-------------------------------------------------------------------------------
+# Model adding functions from Drop Target
+#-------------------------------------------------------------------------------
+
+ def AddVariableBlock(self, x, y, scaling, var_class, var_name, var_type):
+ id = self.GetNewId()
+ variable = FBD_Variable(self, var_class, var_name, var_type, id)
+ width, height = variable.GetMinSize()
+ if scaling is not None:
+ x = round(float(x) / float(scaling[0])) * scaling[0]
+ y = round(float(y) / float(scaling[1])) * scaling[1]
+ width = round(float(width) / float(scaling[0]) + 0.5) * scaling[0]
+ height = round(float(height) / float(scaling[1]) + 0.5) * scaling[1]
+ variable.SetPosition(x, y)
+ variable.SetSize(width, height)
+ self.AddBlock(variable)
+ self.Controler.AddEditedElementVariable(self.GetTagName(), id, var_class)
+ self.RefreshVariableModel(variable)
+ self.RefreshBuffer()
+ self.RefreshScrollBars()
+ self.RefreshVisibleElements()
+ self.Refresh(False)
+
+#-------------------------------------------------------------------------------
# Model adding functions
#-------------------------------------------------------------------------------
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/dialogs/ArrayTypeDialog.py Thu Mar 31 17:37:47 2011 +0200
@@ -0,0 +1,147 @@
+# -*- coding: utf-8 -*-
+
+#This file is part of PLCOpenEditor, a library implementing an IEC 61131-3 editor
+#based on the plcopen standard.
+#
+#Copyright (C) 2007: Edouard TISSERANT and Laurent BESSARD
+#
+#See COPYING file for copyrights details.
+#
+#This library is free software; you can redistribute it and/or
+#modify it under the terms of the GNU General Public
+#License as published by the Free Software Foundation; either
+#version 2.1 of the License, or (at your option) any later version.
+#
+#This library is distributed in the hope that it will be useful,
+#but WITHOUT ANY WARRANTY; without even the implied warranty of
+#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+#General Public License for more details.
+#
+#You should have received a copy of the GNU General Public
+#License along with this library; if not, write to the Free Software
+#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+import re
+from types import TupleType
+
+import wx
+import wx.gizmos
+
+DIMENSION_MODEL = re.compile("([0-9]+)\.\.([0-9]+)$")
+
+[ID_ARRAYTYPEDIALOG, ID_ARRAYTYPEDIALOGBASETYPE,
+ ID_ARRAYTYPEDIALOGDIMENSIONS, ID_ARRAYTYPEDIALOGDIALOGSTATICTEXT1,
+] = [wx.NewId() for _init_ctrls in range(4)]
+
+class ArrayTypeDialog(wx.Dialog):
+
+ if wx.VERSION < (2, 6, 0):
+ def Bind(self, event, function, id = None):
+ if id is not None:
+ event(self, id, function)
+ else:
+ event(self, function)
+
+ def _init_coll_flexGridSizer1_Items(self, parent):
+ parent.AddSizer(self.TopSizer, 0, border=20, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT)
+ parent.AddWindow(self.Dimensions, 0, border=20, flag=wx.GROW|wx.ALIGN_RIGHT|wx.LEFT|wx.RIGHT)
+ parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT)
+
+ def _init_coll_flexGridSizer1_Growables(self, parent):
+ parent.AddGrowableCol(0)
+ parent.AddGrowableRow(1)
+
+ def _init_coll_TopSizer_Items(self, parent):
+ parent.AddWindow(self.staticText1, 1, border=0, flag=wx.GROW)
+ parent.AddWindow(self.BaseType, 1, border=0, flag=wx.GROW)
+
+ def _init_sizers(self):
+ self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=3, vgap=10)
+ self.TopSizer = wx.BoxSizer(wx.HORIZONTAL)
+
+ self._init_coll_flexGridSizer1_Items(self.flexGridSizer1)
+ self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1)
+ self._init_coll_TopSizer_Items(self.TopSizer)
+
+ self.SetSizer(self.flexGridSizer1)
+
+ def _init_ctrls(self, prnt):
+ wx.Dialog.__init__(self, id=ID_ARRAYTYPEDIALOG,
+ name='ArrayTypeDialog', parent=prnt, pos=wx.Point(376, 223),
+ size=wx.Size(500, 300), style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER,
+ title=_('Edit array type properties'))
+ self.SetClientSize(wx.Size(500, 300))
+
+ self.staticText1 = wx.StaticText(id=ID_ARRAYTYPEDIALOGDIALOGSTATICTEXT1,
+ label=_('Base Type:'), name='staticText1', parent=self,
+ pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
+
+ self.BaseType = wx.ComboBox(id=ID_ARRAYTYPEDIALOGBASETYPE,
+ name='BaseType', parent=self, pos=wx.Point(0, 0),
+ size=wx.Size(0, 28), style=wx.CB_READONLY)
+
+ self.Dimensions = wx.gizmos.EditableListBox(id=ID_ARRAYTYPEDIALOGDIMENSIONS,
+ name='ArrayDimensions', parent=self, label=_("Dimensions:"), pos=wx.Point(0, 0),
+ size=wx.Size(0, 24), style=wx.gizmos.EL_ALLOW_NEW | wx.gizmos.EL_ALLOW_EDIT | wx.gizmos.EL_ALLOW_DELETE)
+ self.Dimensions.GetListCtrl().Bind(wx.EVT_LIST_END_LABEL_EDIT, self.OnDimensionsChanged)
+ new_button = self.Dimensions.GetNewButton()
+ new_button.SetToolTipString(_("New item"))
+ new_button.Bind(wx.EVT_BUTTON, self.OnDimensionsChanged)
+ del_button = self.Dimensions.GetDelButton()
+ del_button.SetToolTipString(_("Delete item"))
+ del_button.Bind(wx.EVT_BUTTON, self.OnDimensionsChanged)
+ up_button = self.Dimensions.GetUpButton()
+ up_button.SetToolTipString(_("Move up"))
+ up_button.Bind(wx.EVT_BUTTON, self.OnDimensionsChanged)
+ down_button = self.Dimensions.GetDownButton()
+ down_button.SetToolTipString(_("Move down"))
+ down_button.Bind(wx.EVT_BUTTON, self.OnDimensionsChanged)
+
+ self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE)
+ if wx.VERSION >= (2, 5, 0):
+ self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetAffirmativeButton().GetId())
+ else:
+ self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetChildren()[0].GetSizer().GetChildren()[0].GetWindow().GetId())
+
+ self._init_sizers()
+
+ def __init__(self, parent, datatypes, infos):
+ self._init_ctrls(parent)
+
+ for datatype in datatypes:
+ self.BaseType.Append(datatype)
+
+ if isinstance(infos, TupleType) and infos[0] == "array":
+ self.BaseType.SetStringSelection(infos[1])
+ self.Dimensions.SetStrings(map(lambda x : "..".join(x), infos[2]))
+ elif infos in datatypes:
+ self.BaseType.SetStringSelection(infos)
+
+ def GetDimensions(self):
+ dimensions_list = []
+ for dimensions in self.Dimensions.GetStrings():
+ result = DIMENSION_MODEL.match(dimensions)
+ if result is None:
+ message = wx.MessageDialog(self, _("\"%s\" value isn't a valid array dimension!")%dimensions, _("Error"), wx.OK|wx.ICON_ERROR)
+ message.ShowModal()
+ message.Destroy()
+ return None
+ bounds = result.groups()
+ if int(bounds[0]) >= int(bounds[1]):
+ message = wx.MessageDialog(self, _("\"%s\" value isn't a valid array dimension!\nRight value must be greater than left value.")%dimensions, _("Error"), wx.OK|wx.ICON_ERROR)
+ message.ShowModal()
+ message.Destroy()
+ return None
+ dimensions_list.append(bounds)
+ return dimensions_list
+
+ def OnDimensionsChanged(self, event):
+ wx.CallAfter(self.GetDimensions)
+ event.Skip()
+
+ def OnOK(self, event):
+ if self.GetDimensions() is not None:
+ self.EndModal(wx.ID_OK)
+
+ def GetValue(self):
+ return "array", self.BaseType.GetStringSelection(), self.GetDimensions()
\ No newline at end of file
--- a/dialogs/__init__.py Sat Mar 26 22:54:33 2011 +0100
+++ b/dialogs/__init__.py Thu Mar 31 17:37:47 2011 +0200
@@ -34,4 +34,5 @@
from SFCStepNameDialog import SFCStepNameDialog
from SFCTransitionDialog import SFCTransitionDialog
from SFCDivergenceDialog import SFCDivergenceDialog
-from ForceVariableDialog import ForceVariableDialog
\ No newline at end of file
+from ForceVariableDialog import ForceVariableDialog
+from ArrayTypeDialog import ArrayTypeDialog
--- a/graphics/LD_Objects.py Sat Mar 26 22:54:33 2011 +0100
+++ b/graphics/LD_Objects.py Thu Mar 31 17:37:47 2011 +0200
@@ -417,9 +417,15 @@
self.Parent.UpdateRefreshRect(self.GetRedrawRect())
def SetValue(self, value):
+ if self.Type == CONTACT_RISING:
+ refresh = self.Value and not self.PreviousValue
+ elif self.Type == CONTACT_FALLING:
+ refresh = not self.Value and self.PreviousValue
+ else:
+ refresh = False
self.PreviousValue = self.Value
self.Value = value
- if self.Value != self.PreviousValue:
+ if self.Value != self.PreviousValue or refresh:
if self.Visible:
self.Parent.UpdateRefreshRect(self.GetRedrawRect())
self.SpreadCurrent()
@@ -436,7 +442,7 @@
elif self.Type == CONTACT_RISING:
spreading &= self.Value and not self.PreviousValue
elif self.Type == CONTACT_FALLING:
- spreading &= self.Value and not self.PreviousValue
+ spreading &= not self.Value and self.PreviousValue
else:
spreading = False
if spreading and not self.PreviousSpreading:
@@ -635,7 +641,7 @@
if self.Type == CONTACT_NORMAL and self.Value or \
self.Type == CONTACT_REVERSE and not self.Value or \
self.Type == CONTACT_RISING and self.Value and not self.PreviousValue or \
- self.Type == CONTACT_RISING and self.Value and not self.PreviousValue:
+ self.Type == CONTACT_RISING and not self.Value and self.PreviousValue:
if self.Forced:
dc.SetPen(wx.CYAN_PEN)
else: