Skip to content

Commit 0cda31e

Browse files
author
Dilawar Singh
committed
Squashed 'moose-gui/' content from commit a3d3a06
git-subtree-dir: moose-gui git-subtree-split: a3d3a067901ee0f1f183f50f667a98bebf3e447f
0 parents  commit 0cda31e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+48069
-0
lines changed

MdiArea.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
from PyQt4 import Qt, QtCore, QtGui
2+
from PyQt4.QtGui import *
3+
import os
4+
5+
APPLICATION_BACKGROUND_PATH = os.path.join( os.path.dirname(os.path.realpath(__file__))
6+
, "icons/moose_icon_large.png"
7+
)
8+
9+
10+
class MdiArea(QMdiArea):
11+
def __init__(self):
12+
super(MdiArea, self).__init__()
13+
self.backgroundImage = QImage(APPLICATION_BACKGROUND_PATH)
14+
self.background = None
15+
16+
def resizeEvent(self,event):
17+
# http://qt-project.org/faq/answer/when_setting_a_background_pixmap_for_a_widget_it_is_tiled_if_the_pixmap_is_
18+
self.background = QImage(event.size(), QImage.Format_ARGB32_Premultiplied)
19+
painter = QPainter(self.background)
20+
painter.fillRect(self.background.rect(), QColor(243, 239, 238, 255))
21+
scaled = self.backgroundImage.scaled(event.size() , QtCore.Qt.KeepAspectRatio)
22+
scaledRect = scaled.rect()
23+
scaledRect.moveCenter(self.background.rect().center())
24+
painter.drawImage(scaledRect, scaled)
25+
self.setBackground(QBrush(self.background))
26+
super(MdiArea, self).resizeEvent(event)

PlotWidgetContainer.py

Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
from __future__ import print_function
4+
5+
"""
6+
"""
7+
8+
__author__ = "Aviral Goel"
9+
__credits__ = ["Upi Lab"]
10+
__license__ = "GPL3"
11+
__version__ = "1.0.0"
12+
__maintainer__ = "Aviral Goel"
13+
__email__ = "[email protected]"
14+
__status__ = "Development"
15+
16+
17+
import sys
18+
import os
19+
import PyQt4
20+
from PyQt4 import QtGui, Qt
21+
from PyQt4.QtGui import QWidget
22+
from PyQt4.QtGui import QSizeGrip
23+
from PyQt4.QtGui import QDockWidget
24+
from PyQt4.QtGui import QLayout
25+
from PyQt4.QtGui import QVBoxLayout
26+
from PyQt4.QtGui import QGridLayout
27+
from PyQt4.QtGui import QScrollArea
28+
from PyQt4.QtGui import QToolBar
29+
from PyQt4.QtGui import QSizeGrip
30+
from PyQt4.QtGui import QSplitter
31+
32+
import moose
33+
import default
34+
import sidebar
35+
# from default import PlotWidget
36+
37+
ELECTRICAL = 0
38+
CHEMICAL = 1
39+
class PlotWidgetContainer(QWidget):
40+
41+
def __init__(self, modelRoot, *args, **kwargs):
42+
43+
super(PlotWidgetContainer, self).__init__(*args)
44+
self.modelRoot = modelRoot
45+
if len(moose.wildcardFind(modelRoot + "/##[ISA=ChemCompt]")) == 0:
46+
self.modelType = ELECTRICAL
47+
else:
48+
self.modelType = CHEMICAL
49+
50+
self.model = moose.element(self.modelRoot)
51+
if self.modelRoot != "/":
52+
if moose.exists(modelRoot + "/data"):
53+
self.data = moose.element(self.modelRoot + "/data")
54+
else:
55+
self.data = moose.Neutral(self.modelRoot + "/data")
56+
57+
else:
58+
self.data = moose.element("/data")
59+
60+
self._layout = QVBoxLayout()
61+
self.graphs = QSplitter()
62+
self.graphs.setOrientation(PyQt4.QtCore.Qt.Vertical)
63+
self.graphsArea = QScrollArea()
64+
# self.graphsLayout = QGridLayout()
65+
# self.menubar = self.createMenuBar()
66+
self.rowIndex = 0
67+
# self.setSizePolicy( QtGui.QSizePolicy.Expanding
68+
# , QtGui.QSizePolicy.Expanding
69+
# )
70+
71+
self.graphs.setSizePolicy( QtGui.QSizePolicy.Expanding
72+
, QtGui.QSizePolicy.Expanding
73+
)
74+
self.setAcceptDrops(True)
75+
# self._layout.setSizeConstraint( QLayout.SetNoConstraint )
76+
# self.graphs.setLayout(self.graphsLayout)
77+
self.graphsArea.setWidget(self.graphs)
78+
self.graphsArea.setWidgetResizable(True)
79+
self.graphWidgets = []
80+
# self._layout.addWidget(self.menubar)
81+
self._layout.addWidget(self.graphsArea)
82+
self.setLayout(self._layout)
83+
84+
for graph in self.data.children:
85+
self.addPlotWidget(graph = graph)
86+
87+
if len(self.data.children) == 0:
88+
self.addPlotWidget()
89+
90+
def deleteWidget(self, graphWidget):
91+
# print("Deleted => ", graphWidget)
92+
self.graphWidgets.remove(graphWidget)
93+
graphWidget.setParent(None)
94+
graphWidget.close()
95+
96+
def createMenuBar(self):
97+
bar = sidebar.sidebar()
98+
bar.addAction(sidebar.add_graph_action(bar, lambda event: self.addPlotWidget() ))
99+
# bar.addAction(sidebar.delete_graph_action(bar, lambda event: self.addPlotWidget() ))
100+
# bar.addAction(sidebar.list_action(bar, self.showPlotView))
101+
return bar
102+
103+
def addPlotWidget(self, row = None, col = 0, graph = None):
104+
if graph == None:
105+
graph = moose.Neutral(self.data.path + "/graph_" + str(self.rowIndex))
106+
widget = default.PlotWidget(self.model, graph, self.rowIndex, self)
107+
108+
if self.modelType == ELECTRICAL:
109+
for axes in widget.canvas.axes.values():
110+
# axes.autoscale(False, axis='x', tight=True)
111+
axes.set_ylim(bottom = -0.07, top= 0.03)
112+
113+
if row == None:
114+
row = self.rowIndex
115+
self.graphs.addWidget(widget)
116+
self.rowIndex += 1
117+
self.graphWidgets.append(widget)
118+
widget.widgetClosedSignal.connect(self.deleteWidget)
119+
widget.addGraph.connect(lambda event : self.addPlotWidget())
120+
# widget.resize(1, 1);
121+
return widget
122+
123+
def showPlotView(self):
124+
pass
125+
126+
def setModelRoot(self, *args):
127+
pass
128+
129+
def getMenus(self, *args):
130+
return []
131+
132+
def setDataRoot(self, *args):
133+
pass
134+
135+
def updatePlots(self):
136+
for graphWidget in self.graphWidgets:
137+
graphWidget.updatePlots()
138+
139+
def rescalePlots(self):
140+
for graphWidget in self.graphWidgets:
141+
graphWidget.rescalePlots()
142+
143+
def extendXAxes(self, xlim):
144+
for graphWidget in self.graphWidgets:
145+
graphWidget.extendXAxes(xlim)
146+
147+
def plotAllData(self):
148+
for graphWidget in self.graphWidgets:
149+
graphWidget.plotAllData()
150+
151+
#print(graphWidget)
152+
# def plotAll(self):
153+
# self.apply(lambda obj: obj.plotAll())
154+
155+
# def plotAllData(self):
156+
# selt.plotWidgetContainer.plotAllData()
157+
158+
# def genColorMap(self,tableObject):
159+
# pass
160+
161+
# def onclick(self,event1):
162+
# pass
163+
164+
# def addTimeSeries(self, table, *args, **kwargs):
165+
# pass
166+
167+
# def addRasterPlot(self, eventtable, yoffset=0, *args, **kwargs):
168+
# pass
169+
170+
# def extendXAxes(self, xlim):
171+
# pass
172+
173+
# def saveCsv(self, line,directory):
174+
# pass
175+
176+
# def saveAllCsv(self):
177+
# pass

README

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
File: README
2+
Author: Subhasis Ray
3+
Created: 2012-11-29
4+
5+
Requirements:
6+
7+
Required:
8+
9+
PyQt4 (4.8 or higher)
10+
numpy
11+
matplotlib
12+
13+
Optional:
14+
python-qscintilla (prettier Python shell with autocomplete)
15+
16+
17+
This directory contains scripts for the MOOSE GUI.
18+
19+
mgui.py : main driver for the gui. This provides a main window and
20+
basic menubar and toolbar.
21+
22+
plugins/ : All plugins should be added to this directory.
23+
24+
25+
Each plugin should be derived from MoosePlugin in plugins/default.py.
26+
27+
Each plugin provides three views: EditorView, PlotView and RunView.
28+
29+
EditorView: the view for editing models
30+
31+
PlotView: this is for advanced users to select fine details of
32+
plotting.
33+
34+
RunView: this view is for displaying dynamic updates when the
35+
simulation is executed.

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# moose-gui

RunWidget.py

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
from __future__ import print_function
4+
5+
"""Sidebar for plugins. The sidebar comprises of actions.
6+
Currently mode, connect and settings are defined.
7+
"""
8+
9+
__author__ = "Aviral Goel"
10+
__credits__ = ["Upi Lab"]
11+
__license__ = "GPL3"
12+
__version__ = "1.0.0"
13+
__maintainer__ = "Aviral Goel"
14+
__email__ = "[email protected]"
15+
__status__ = "Development"
16+
17+
18+
import sys
19+
import os
20+
import SettingsDialog
21+
from PyQt4 import QtGui, Qt
22+
from PyQt4.QtGui import QWidget
23+
from PyQt4.QtGui import QScrollArea
24+
from PyQt4.QtGui import QGridLayout
25+
from PyQt4.QtGui import QSplitter
26+
27+
class RunWidget(QSplitter):
28+
29+
def __init__(self, modelRoot, *args, **kwargs):
30+
super(RunWidget, self).__init__(None)
31+
self.modelRoot = modelRoot
32+
layout = QGridLayout()
33+
self.setLayout(layout)
34+
self.plotWidgetContainer = None
35+
def setChildWidget(self, widget, wrap, row, col, rowspan = 1, colspan = 1):
36+
if wrap:
37+
scrollArea = QScrollArea()
38+
scrollArea.setWidget(widget)
39+
scrollArea.setWidgetResizable(True);
40+
self.layout().addWidget(scrollArea, row, col, rowspan, colspan)
41+
else:
42+
self.addWidget(widget)
43+
# self.layout().addWidget(widget, row, col, rowspan, colspan)
44+
45+
def setPlotWidgetContainer(self, widget):
46+
self.plotWidgetContainer = widget
47+
48+
def setModelRoot(self, *args):
49+
pass
50+
51+
def getMenus(self, *args):
52+
return []
53+
54+
def setDataRoot(self, *args):
55+
pass
56+
57+
def updatePlots(self):
58+
self.plotWidgetContainer.updatePlots()
59+
60+
def rescalePlots(self):
61+
self.plotWidgetContainer.rescalePlots()
62+
63+
def extendXAxes(self, xlim):
64+
self.plotWidgetContainer.extendXAxes(xlim)
65+
66+
def plotAllData(self):
67+
self.plotWidgetContainer.plotAllData()

SettingsDialog.py

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
from __future__ import print_function
4+
5+
"""Dialog for settings. Currently only plot settings are supported
6+
"""
7+
8+
__author__ = "Aviral Goel"
9+
__credits__ = ["Upi Lab"]
10+
__license__ = "GPL3"
11+
__version__ = "1.0.0"
12+
__maintainer__ = "Aviral Goel"
13+
__email__ = "[email protected]"
14+
__status__ = "Development"
15+
16+
17+
import sys
18+
import os
19+
from PyQt4 import QtGui, Qt
20+
from PyQt4.QtGui import QWidget
21+
from PyQt4.QtGui import QLabel
22+
from PyQt4.QtGui import QComboBox
23+
from PyQt4.QtGui import QGridLayout
24+
from PyQt4.QtGui import QTabWidget
25+
26+
class SettingsWidget(QTabWidget):
27+
def __init__( self
28+
, plotFieldMap
29+
, parent = None
30+
):
31+
super(SettingsWidget, self).__init__(parent)
32+
33+
self.plotFieldMap = plotFieldMap
34+
35+
self.addTab(self.plotSettingsPage(),"Plot Settings");
36+
self.addTab(self.plotSettingsPage(),"Other Settings");
37+
38+
def plotSettingsPage(self):
39+
page = QWidget()
40+
layout = QGridLayout()
41+
page.setLayout(layout)
42+
index = 0
43+
for key, values in self.plotFieldMap.iteritems() :
44+
label = QLabel(key, page)
45+
combo = QComboBox(page)
46+
for value in values:
47+
combo.addItem(value)
48+
layout.addWidget(label,index,0, Qt.Qt.AlignRight)
49+
layout.addWidget(combo,index,1, Qt.Qt.AlignLeft)
50+
index += 1
51+
return page
52+
53+
# combo.move(50, 50)
54+
# self.lbl.move(50, 150)
55+
56+
# combo.activated[str].connect(self.onActivated)
57+
58+
# self.setGeometry(300, 300, 300, 200)
59+
# self.setWindowTitle('QtGui.QComboBox')
60+
# self.show()
61+
62+
63+
def main():
64+
app = QtGui.QApplication(sys.argv)
65+
window = QtGui.QMainWindow()
66+
dialog = SettingsWidget({
67+
'LeakyIaF':['Vm'],
68+
'Compartment':['Vm','Im'],
69+
'HHChannel':['Ik','Gk'],
70+
'ZombiePool':['n','conc'],
71+
'ZombieBufPool':['n','conc'],
72+
'HHChannel2D':['Ik','Gk'],
73+
'CaConc':['Ca']
74+
}
75+
)
76+
dialog.show()
77+
sys.exit(app.exec_())
78+
79+
80+
if __name__ == "__main__":
81+
main()

__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
all = [ "plugins" ]

0 commit comments

Comments
 (0)