Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 19 additions & 14 deletions Container.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@
import WizardGUI
import LabelGUI

RED = '#d91e1e'
GREEN = '#90ee90'
BLACK = '#000000'
BLUE = '#add8e6'

import Components

if builtins.__dict__.get('GUI_FLAG',True):
Expand Down Expand Up @@ -1184,7 +1189,7 @@ class Shape(ShapeEvtHandler):
""" Shape class
"""

FILL = ['#add8e6']
FILL = [BLUE]

def __init__(self, x=[], y=[]):
""" Constructor
Expand Down Expand Up @@ -2814,7 +2819,7 @@ def __init__(self, line):
"""
Shape.__init__(self)

self.fill = ['#d91e1e']
self.fill = [RED]
self.x = array.array('d', line.x)
self.y = array.array('d', line.y)

Expand Down Expand Up @@ -3847,7 +3852,7 @@ class ContainerBlock(Block, Diagram):
""" ContainerBlock(label, inputs, outputs)
"""

FILL = ['#90ee90']
FILL = [GREEN]

###
def __init__(self, label = 'ContainerBlock', nb_inputs = 1, nb_outputs = 1):
Expand Down Expand Up @@ -4114,7 +4119,7 @@ def draw(self, dc):
x,y = self.item.getPortXY('input', self.index)
self.moveto(x, y)

self.fill = ['#00b400'] #GREEN
self.fill = [GREEN]

dc.SetFont(wx.Font(10, wx.MODERN, wx.NORMAL, wx.NORMAL))

Expand Down Expand Up @@ -4185,7 +4190,7 @@ def draw(self, dc):
"""
x,y = self.item.getPortXY('output', self.index)
self.moveto(x, y)
self.fill = ['#ff0000']
self.fill = [RED]

dc.SetFont(wx.Font(10, wx.MODERN, wx.NORMAL, wx.NORMAL))
#dc.SetPen(wx.Pen(wx.NamedColour('black'), 20))
Expand Down Expand Up @@ -4225,7 +4230,7 @@ def __init__(self, item, index, cf, t = 'rect'):
"""
Node.__init__(self, item, index, cf, t)

self.fill = ['#000000'] #BLACK
self.fill = [BLACK]

def draw(self, dc):
""" Drawing method.
Expand Down Expand Up @@ -4325,7 +4330,7 @@ def draw(self, dc):
"""

CircleShape.draw(self, dc)
w,h = dc.GetTextExtent(self.label)
w,h = dc.GetTextExtent(self.label)

### label position manager
if self.label_pos == 'bottom':
Expand All @@ -4342,8 +4347,8 @@ def draw(self, dc):
dc.DrawText(self.label, mx, my)

if self.lock_flag:
img = wx.Bitmap(os.path.join(ICON_PATH_16_16, 'lock.png'),wx.BITMAP_TYPE_ANY)
dc.DrawBitmap( img, self.x[0]+w/3, self.y[0])
img = wx.Bitmap(os.path.join(ICON_PATH_16_16, 'lock.png'),wx.BITMAP_TYPE_ANY)
dc.DrawBitmap(img, self.x[0]+w/3, self.y[0])

def leftUp(self, event):
""" Left up event has been invoked.
Expand Down Expand Up @@ -4403,15 +4408,15 @@ def __repr__(self):

#------------------------------------------------------------------
class iPort(Port):
""" IPort(label)
""" IPort(label) for ContainerBlock (coupled model)
"""

def __init__(self, label = 'iPort'):
""" Constructor
""" Constructor.
"""

Port.__init__(self, 50, 60, 100, 120, label)
self.fill= ['#add8e6'] # fill color
self.fill= [GREEN]
#self.AddAttribute('id')
self.label_pos = 'bottom'
self.input = 0
Expand All @@ -4430,15 +4435,15 @@ def __repr__(self):

#----------------------------------------------------------------
class oPort(Port):
""" OPort(label)
""" OPort(label) for ContainerBlock (coupled model)
"""

def __init__(self, label = 'oPort'):
""" Construcotr
"""

Port.__init__(self, 50, 60, 100, 120, label)
self.fill = ['#90ee90']
self.fill = [RED]
#self.AddAttribute('id')
self.label_pos = 'bottom'
self.input = 1
Expand Down
26 changes: 19 additions & 7 deletions DetachedFrame.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,12 @@
wx.ST_SIZEGRIP = wx.STB_SIZEGRIP

if __name__ == '__main__':
builtins.__dict__['DEVS_DIR_PATH_DICT'] = {'PyDEVS':os.path.join(os.pardir,'DEVSKernel','PyDEVS'),'PyPDEVS':os.path.join(os.pardir,'DEVSKernel','PyPDEVS')}
builtins.__dict__['DEFAULT_DEVS_DIRNAME'] = 'PyPDEVS'
builtins.__dict__['GUI_FLAG'] = True
builtins.__dict__['HOME_PATH'] = os.path.abspath(os.path.dirname(sys.argv[0]))
builtins.__dict__['DEFAULT_DEVS_DIRNAME'] = "PyDEVS"
builtins.__dict__['DEVS_DIR_PATH_DICT'] = {\
'PyDEVS':os.path.join(os.pardir,'DEVSKernel','PyDEVS'),\
'PyPDEVS':os.path.join(os.pardir,'DEVSKernel','PyPDEVS', 'old')}

import Container
import Menu
Expand Down Expand Up @@ -61,11 +65,14 @@ def __init__(self, parent=None, ID=wx.NewIdRef(), title="", diagram=None, name="
name=name,
style=wx.DEFAULT_FRAME_STYLE | wx.CLIP_CHILDREN)

self.default_style = self.GetWindowStyle()

### local Copy
self.title = title
self.parent = parent
self.diagram = diagram


### current abstract level
#=======================================================================
if hasattr(diagram, 'layers') and hasattr(diagram, 'current_level'):
Expand Down Expand Up @@ -100,7 +107,7 @@ def __init__(self, parent=None, ID=wx.NewIdRef(), title="", diagram=None, name="
self.toggle_list = wx.GetApp().GetTopWindow().toggle_list
else:
sys.stdout.write(_('Alone mode for DetachedFrame: Connector buttons are not binded\n'))
self.toggle_list = [wx.NewIdRef(), wx.NewIdRef(), wx.NewIdRef(), wx.NewIdRef(), wx.NewIdRef(), wx.NewIdRef()]
self.toggle_list = [wx.NewIdRef() for i in range(6)]

if wx.VERSION_STRING < '2.9':
self.tools = [ toolbar.AddTool(Menu.ID_SAVE, wx.Bitmap(os.path.join(ICON_PATH,'save.png')), shortHelpString=_('Save File') ,longHelpString=_('Save the current diagram'), clientData=self.canvas),
Expand Down Expand Up @@ -155,7 +162,6 @@ def __init__(self, parent=None, ID=wx.NewIdRef(), title="", diagram=None, name="
ID_DOWNWARD = self.toggle_list[5]

if wx.VERSION_STRING < '2.9':

self.tools.append(toolbar.AddTool(ID_DOWNWARD, wx.Bitmap(os.path.join(ICON_PATH,'downward.png')), shortHelpString=_('Downward rules'), longHelpString=_('Define Downward rules atomic model')))
self.tools.append(toolbar.AddTool(ID_UPWARD, wx.Bitmap(os.path.join(ICON_PATH,'upward.png')), shortHelpString=_('Upward rules'), longHelpString=_('Define Upward rules atomic model')))
else:
Expand Down Expand Up @@ -213,10 +219,18 @@ def __binding(self):
self.Bind(wx.EVT_TOOL, self.OnSaveAsFile, id=Menu.ID_SAVEAS)
self.Bind(wx.EVT_CLOSE, self.OnClose)

def OnStayOnTop(self, event):
"""
"""

if self.GetWindowStyle()==self.default_style:
self.SetWindowStyle(wx.CLIP_CHILDREN | wx.STAY_ON_TOP)
else:
self.SetWindowStyle(self.default_style)

def OnSaveFile(self, event):
""" Save button has been clicked
"""

### OnSaveFile of the mainW is activated
mainW = wx.GetApp().GetTopWindow()
mainW.OnSaveFile(event)
Expand Down Expand Up @@ -283,7 +297,6 @@ def OnInit(self):

import gettext


#builtins.__dict__['PYDEVS_SIM_STRATEGY_DICT'] = {'original':'SimStrategy1', 'bag-based':'SimStrategy2', 'direct-coupling':'SimStrategy3'}
#builtins.__dict__['PYPDEVS_SIM_STRATEGY_DICT'] = {'original':'SimStrategy4', 'distributed':'SimStrategy5', 'parallel':'SimStrategy6'}

Expand All @@ -302,6 +315,5 @@ def OnQuit(self, event):
self.Close()

if __name__ == '__main__':

app = TestApp(0)
app.MainLoop()
20 changes: 17 additions & 3 deletions Menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@
# Experiment
ID_GEN_EXPERIMENT = wx.NewIdRef()

# Stay on top
ID_STAY_ON_TOP = wx.NewIdRef()

# Library popup menu identifiers
ID_NEW_LIB = wx.NewIdRef()
ID_IMPORT_LIB = wx.NewIdRef()
Expand Down Expand Up @@ -825,7 +828,7 @@ def __init__(self, parent):
add_constants.SetBitmap(wx.Bitmap(os.path.join(ICON_PATH_16_16,'properties.png')))
preview_dia.SetBitmap(wx.Bitmap(os.path.join(ICON_PATH_16_16,'print-preview.png')))
generate_experiment.SetBitmap(wx.Bitmap(os.path.join(ICON_PATH_16_16,'generation.png')))

AppendItem = self.AppendItem if wx.VERSION_STRING < '4.0' else self.Append

### append items
Expand All @@ -836,7 +839,19 @@ def __init__(self, parent):
AppendItem(preview_dia)
AppendItem(generate_experiment)

self.Enable(ID_PASTE_SHAPE, not Container.clipboard == [])
### Stay on top always for the detached frame (not for diagram into devsimpy as tab of notebook)
if isinstance(self.parent.parent, wx.Frame):
if self.parent.parent.GetWindowStyle() == self.parent.parent.default_style:
stay_on_top = wx.MenuItem(self, ID_STAY_ON_TOP, _('Enable stay on top'), _('Coupled model frame stay on top'))
stay_on_top.SetBitmap(wx.Bitmap(os.path.join(ICON_PATH_16_16,'pin_out.png')))
else:
stay_on_top = wx.MenuItem(self, ID_STAY_ON_TOP, _('Disable stay on top'), _('Coupled model frame not stay on top'))
stay_on_top.SetBitmap(wx.Bitmap(os.path.join(ICON_PATH_16_16,'pin_in.png')))

AppendItem(stay_on_top)
parent.Bind(wx.EVT_MENU, parent.parent.OnStayOnTop, id=ID_STAY_ON_TOP)

self.Enable(ID_PASTE_SHAPE, Container.clipboard != [])

### binding
parent.Bind(wx.EVT_MENU, parent.OnNewModel, id=ID_NEW_SHAPE)
Expand All @@ -845,7 +860,6 @@ def __init__(self, parent):
parent.Bind(wx.EVT_MENU, parent.diagram.OnAddConstants, id=ID_ADD_CONSTANTS)
parent.Bind(wx.EVT_MENU, parent.parent.PrintPreview, id=ID_PREVIEW_PRINT)
parent.Bind(wx.EVT_MENU, ExperimentGenerator(os.path.join(HOME_PATH,'out')).OnExperiment, id=ID_GEN_EXPERIMENT)

class ShapePopupMenu(wx.Menu):
""" Shape menu class
"""
Expand Down
Binary file added icons/16x16/pin_in.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/16x16/pin_out.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/pin_in.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/pin_out.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.