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
3 changes: 3 additions & 0 deletions ControlNotebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
import wx
import os

import gettext
_ = gettext.gettext

from Patterns.Observer import Observer
from LibPanel import LibPanel
from PropPanel import PropPanel
Expand Down
3 changes: 3 additions & 0 deletions LibPanel.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
import wx
import os

import gettext
_ = gettext.gettext

from LibraryTree import LibraryTree

import Menu
Expand Down
34 changes: 34 additions & 0 deletions PlotGUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@

_ = wx.GetTranslation

import wx.lib.agw.aui as aui
import matplotlib as mpl

from matplotlib.backends.backend_wxagg import (
FigureCanvasWxAgg as FigureCanvas,
NavigationToolbar2WxAgg as NavigationToolbar)

# for spectrum
try:
from numpy import *
Expand Down Expand Up @@ -89,6 +96,33 @@ def PlotManager(parent, label, atomicModel, xl, yl):
frame.CenterOnParent()
frame.Show()

class PlotPanel(wx.Panel):
def __init__(self, parent, id=-1, dpi=None, **kwargs):
wx.Panel.__init__(self, parent, id=id, **kwargs)
self.figure = mpl.figure.Figure(dpi=dpi, figsize=(2, 2))
self.canvas = FigureCanvas(self, -1, self.figure)
self.toolbar = NavigationToolbar(self.canvas)
self.toolbar.Realize()

sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(self.canvas, 1, wx.EXPAND)
sizer.Add(self.toolbar, 0, wx.LEFT | wx.EXPAND)
self.SetSizer(sizer)
self.SetAutoLayout(True)

class PlotNotebook(wx.Panel):
def __init__(self, parent, id=-1):
wx.Panel.__init__(self, parent, id=id)
self.nb = aui.AuiNotebook(self)
sizer = wx.BoxSizer()
sizer.Add(self.nb, 1, wx.EXPAND)
self.SetSizer(sizer)
self.SetAutoLayout(True)

def add(self, name="plot"):
page = PlotPanel(self.nb)
self.nb.AddPage(page, name)
return page.figure

class PlotFrame(wx.Frame):
def __init__(self, parent=None, id=wx.NewIdRef(), title="Time Plotting"):
Expand Down
35 changes: 27 additions & 8 deletions SpreadSheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ def OnGraph(self, event):
### globals containt the time and value variables after exec of the statement
exec(str(s), globals())
except Exception as info:
sys.stdout.write(info)
sys.stdout.write(str(info))
else:
### if value is a list, we must choose an index to plot amoung the values of the list
if isinstance(value, list):
Expand All @@ -434,22 +434,41 @@ def OnGraph(self, event):
if select in range(0,len(value)-1) and not isinstance(value[select], str):
data.append((time, float(value[select])))
else:
wx.MessageBox(_('Value to plot must be digit!'), _('Warning'), wx.OK | wx.ICON_WARNING)
break
#wx.MessageBox(_('Value to plot must be digit!'), _('Warning'), wx.OK | wx.ICON_WARNING)
data.append((time, value[select]))

### first if int is digit or if float is digit
else:
v = str(format(value,'f')).lstrip('-')
if v.isdigit() or v.replace(".", "", 1).isdigit():
data.append((time,float(value)))
else:
wx.MessageBox(_('Type of data should be float or int : %s')%str(value), _('Info'))
break
#wx.MessageBox(_('Type of data should be float or int: %s')%str(value), _('Info'))
data.append((time, value))

if data:
frame = StaticPlot(self, wx.NewIdRef(), title, data)
frame.Center()
frame.Show()
### if the first value of y is str, we plot with tick in y axe
if isinstance(data[0][-1], str):
x,y = zip(*data)
frame = wx.Frame(self, -1, _('Plotter'))
plotter = PlotNotebook(frame)
axes1 = plotter.add(title).gca()
axes1.set_xlabel(_('Time'), fontsize=16)
axes1.set_ylabel(_('State'), fontsize=16)
axes1.step(x, y)
axes1.grid(True)
axes1.set_title(title)

#axes2 = plotter.add('figure 2').gca()
#axes2.plot([1, 2, 3, 4, 5], [2, 1, 4, 2, 3])

frame.Show()

### values of y is digits
else:
frame = StaticPlot(self, wx.NewIdRef(), title, data)
frame.Center()
frame.Show()

##if __name__ == '__main__':
## import builtins
Expand Down
5 changes: 3 additions & 2 deletions devsimpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,13 +502,15 @@ def Seti18n(self):
self.locale.AddCatalogLookupPathPrefix(localedir)
self.locale.AddCatalog(domain)


# language config from .devsimpy file
if self.language == 'en':
locale.setlocale(locale.LC_ALL, 'en')
translation = gettext.translation(domain, localedir, languages=['en']) # English
elif self.language =='fr':
locale.setlocale(locale.LC_ALL, 'fr')
translation = gettext.translation(domain, localedir, languages=['fr']) # French
else:
locale.setlocale(locale.LC_ALL, '')
#installing os language by default
translation = gettext.translation(domain, localedir, [self.locale.GetCanonicalName()], fallback = True)

Expand Down Expand Up @@ -2465,7 +2467,6 @@ def OnInit(self):
splash = AdvancedSplashScreen(self)
splash.Show()


return True

def SetExceptionHook(self):
Expand Down
12 changes: 6 additions & 6 deletions plugins/state_trajectory.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,12 @@ def PlotStateTrajectory(m):
frame = wx.Frame(None, -1, 'Plotter')
plotter = PlotNotebook(frame)
axes1 = plotter.add('%s State Trajectory'%label).gca()
axes1.set_yticks(range(len(states)))
axes1.set_yticklabels(states)
axes1.set_xlabel('time',fontsize=16)
axes1.set_ylabel('state',fontsize=16)
axes1.plot(x, y)
axes1.set_xlabel('Time',fontsize=16)
axes1.set_ylabel('State',fontsize=16)
axes1.step(x, y)
axes1.grid(True)
axes1.set_title(label)

#axes2 = plotter.add('figure 2').gca()
#axes2.plot([1, 2, 3, 4, 5], [2, 1, 4, 2, 3])

Expand Down