editors/Viewer.py
changeset 1749 d73b64672238
parent 1747 6046ffa2280f
child 1750 acf02488f37f
equal deleted inserted replaced
1748:ba5f64fe0e00 1749:d73b64672238
    62     if wx.VERSION >= (2, 6, 0):
    62     if wx.VERSION >= (2, 6, 0):
    63         parent.Append(help=help, id=id, kind=kind, text=text)
    63         parent.Append(help=help, id=id, kind=kind, text=text)
    64     else:
    64     else:
    65         parent.Append(helpString=help, id=id, kind=kind, item=text)
    65         parent.Append(helpString=help, id=id, kind=kind, item=text)
    66 
    66 
       
    67 
    67 if wx.Platform == '__WXMSW__':
    68 if wx.Platform == '__WXMSW__':
    68     faces = {
    69     faces = {
    69         'times': 'Times New Roman',
    70         'times': 'Times New Roman',
    70         'mono':  'Courier New',
    71         'mono':  'Courier New',
    71         'helv':  'Arial',
    72         'helv':  'Arial',
   113     def powerRailCreationFunction(viewer, id, specific_values):
   114     def powerRailCreationFunction(viewer, id, specific_values):
   114         return LD_PowerRail(viewer, powerrail_type, id,
   115         return LD_PowerRail(viewer, powerrail_type, id,
   115                                     specific_values.connectors)
   116                                     specific_values.connectors)
   116     return powerRailCreationFunction
   117     return powerRailCreationFunction
   117 
   118 
       
   119 
   118 NEGATED_VALUE = lambda x: x if x is not None else False
   120 NEGATED_VALUE = lambda x: x if x is not None else False
   119 MODIFIER_VALUE = lambda x: x if x is not None else 'none'
   121 MODIFIER_VALUE = lambda x: x if x is not None else 'none'
   120 
   122 
   121 CONTACT_TYPES = {(True, "none"): CONTACT_REVERSE,
   123 CONTACT_TYPES = {(True, "none"): CONTACT_REVERSE,
   122                  (False, "rising"): CONTACT_RISING,
   124                  (False, "rising"): CONTACT_RISING,
   126 def contactCreationFunction(viewer, id, specific_values):
   128 def contactCreationFunction(viewer, id, specific_values):
   127     contact_type = CONTACT_TYPES.get((NEGATED_VALUE(specific_values.negated),
   129     contact_type = CONTACT_TYPES.get((NEGATED_VALUE(specific_values.negated),
   128                                       MODIFIER_VALUE(specific_values.edge)),
   130                                       MODIFIER_VALUE(specific_values.edge)),
   129                                      CONTACT_NORMAL)
   131                                      CONTACT_NORMAL)
   130     return LD_Contact(viewer, contact_type, specific_values.name, id)
   132     return LD_Contact(viewer, contact_type, specific_values.name, id)
       
   133 
   131 
   134 
   132 COIL_TYPES = {(True, "none", "none"): COIL_REVERSE,
   135 COIL_TYPES = {(True, "none", "none"): COIL_REVERSE,
   133               (False, "none", "set"): COIL_SET,
   136               (False, "none", "set"): COIL_SET,
   134               (False, "none", "reset"): COIL_RESET,
   137               (False, "none", "reset"): COIL_RESET,
   135               (False, "rising", "none"): COIL_RISING,
   138               (False, "rising", "none"): COIL_RISING,
   158     transition = SFC_Transition(viewer, specific_values.condition_type,
   161     transition = SFC_Transition(viewer, specific_values.condition_type,
   159                                         specific_values.condition,
   162                                         specific_values.condition,
   160                                         specific_values.priority, id)
   163                                         specific_values.priority, id)
   161     return transition
   164     return transition
   162 
   165 
       
   166 
   163 divergence_types = [SELECTION_DIVERGENCE,
   167 divergence_types = [SELECTION_DIVERGENCE,
   164                     SELECTION_CONVERGENCE, SIMULTANEOUS_DIVERGENCE, SIMULTANEOUS_CONVERGENCE]
   168                     SELECTION_CONVERGENCE, SIMULTANEOUS_DIVERGENCE, SIMULTANEOUS_CONVERGENCE]
   165 
   169 
   166 
   170 
   167 def GetDivergenceCreationFunction(divergence_type):
   171 def GetDivergenceCreationFunction(divergence_type):
   175     return SFC_Jump(viewer, specific_values.target, id)
   179     return SFC_Jump(viewer, specific_values.target, id)
   176 
   180 
   177 
   181 
   178 def actionBlockCreationFunction(viewer, id, specific_values):
   182 def actionBlockCreationFunction(viewer, id, specific_values):
   179     return SFC_ActionBlock(viewer, specific_values.actions, id)
   183     return SFC_ActionBlock(viewer, specific_values.actions, id)
       
   184 
   180 
   185 
   181 ElementCreationFunctions = {
   186 ElementCreationFunctions = {
   182     "input": GetVariableCreationFunction(INPUT),
   187     "input": GetVariableCreationFunction(INPUT),
   183     "output": GetVariableCreationFunction(OUTPUT),
   188     "output": GetVariableCreationFunction(OUTPUT),
   184     "inout": GetVariableCreationFunction(INOUT),
   189     "inout": GetVariableCreationFunction(INOUT),
   209         return cmp(y1, y2)
   214         return cmp(y1, y2)
   210 
   215 
   211 #-------------------------------------------------------------------------------
   216 #-------------------------------------------------------------------------------
   212 #                       Graphic elements Viewer base class
   217 #                       Graphic elements Viewer base class
   213 #-------------------------------------------------------------------------------
   218 #-------------------------------------------------------------------------------
       
   219 
   214 
   220 
   215 # ID Constants for alignment menu items
   221 # ID Constants for alignment menu items
   216 [ID_VIEWERALIGNMENTMENUITEMS0, ID_VIEWERALIGNMENTMENUITEMS1,
   222 [ID_VIEWERALIGNMENTMENUITEMS0, ID_VIEWERALIGNMENTMENUITEMS1,
   217  ID_VIEWERALIGNMENTMENUITEMS2, ID_VIEWERALIGNMENTMENUITEMS4,
   223  ID_VIEWERALIGNMENTMENUITEMS2, ID_VIEWERALIGNMENTMENUITEMS4,
   218  ID_VIEWERALIGNMENTMENUITEMS5, ID_VIEWERALIGNMENTMENUITEMS6,
   224  ID_VIEWERALIGNMENTMENUITEMS5, ID_VIEWERALIGNMENTMENUITEMS6,