2006-04-16 20:25:54 +02:00
|
|
|
#!/usr/bin/python
|
|
|
|
|
|
|
|
import sys
|
|
|
|
|
|
|
|
import pygtk
|
|
|
|
pygtk.require('2.0')
|
|
|
|
import gtk
|
|
|
|
import gtk.gdk
|
|
|
|
import gtk.glade
|
|
|
|
import gnome
|
|
|
|
import gnome.ui
|
2006-04-20 12:27:58 +02:00
|
|
|
import scipy
|
2006-04-25 11:53:35 +02:00
|
|
|
import pango
|
|
|
|
from system import project, workflow, dataset, logger, plots, navigator, dialogs
|
|
|
|
|
2006-04-16 20:25:54 +02:00
|
|
|
|
|
|
|
PROGRAM_NAME = 'fluent'
|
|
|
|
VERSION = '0.1.0'
|
|
|
|
GLADEFILENAME = 'system/fluent.glade'
|
|
|
|
|
|
|
|
class FluentApp:
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
# Application variables
|
2006-04-22 23:46:44 +02:00
|
|
|
self.project = None
|
2006-04-20 12:27:58 +02:00
|
|
|
self.current_data = None
|
2006-04-24 11:53:07 +02:00
|
|
|
|
2006-04-16 20:25:54 +02:00
|
|
|
gtk.glade.set_custom_handler(self.custom_object_factory)
|
2006-04-19 21:59:55 +02:00
|
|
|
self.widget_tree = gtk.glade.XML(GLADEFILENAME, 'appwindow')
|
2006-04-22 23:46:44 +02:00
|
|
|
self.workflow = workflow.EmptyWorkflow(self)
|
|
|
|
|
|
|
|
def set_project(self, project):
|
|
|
|
logger.log('notice', 'Creating a new project')
|
|
|
|
self.project = project
|
2006-04-20 17:30:29 +02:00
|
|
|
self.workflow.add_project(self.project)
|
2006-04-22 23:46:44 +02:00
|
|
|
self.navigator_view.add_project(self.project)
|
|
|
|
|
|
|
|
def set_workflow(self, workflow):
|
|
|
|
self.workflow = workflow
|
|
|
|
self.wf_menu.set_workflow(self.workflow)
|
2006-04-16 20:25:54 +02:00
|
|
|
|
|
|
|
def custom_object_factory(self, glade, function_name, widget_name,\
|
|
|
|
str1, str2, int1, int2):
|
|
|
|
handler = getattr(self, function_name)
|
|
|
|
return handler(str1, str2, int1, int2)
|
|
|
|
|
|
|
|
def create_logview(self, str1, str2, int1, int2):
|
|
|
|
# Set up log view
|
|
|
|
self.log_view = logger.LogView(logger.logger)
|
2006-04-24 16:52:21 +02:00
|
|
|
self.log_view.set_level('notice')
|
2006-04-16 20:25:54 +02:00
|
|
|
self.log_view.show()
|
|
|
|
return self.log_view
|
|
|
|
|
2006-04-18 00:30:53 +02:00
|
|
|
def create_main_view(self, str1, str2, int1, int2):
|
|
|
|
self.main_view = plots.MainView()
|
|
|
|
self.main_view.show()
|
|
|
|
return self.main_view
|
|
|
|
|
2006-04-17 22:27:39 +02:00
|
|
|
def create_small_view(self, str1, str2, int1, int2):
|
|
|
|
self.small_view = plots.SmallView()
|
|
|
|
self.small_view.show()
|
|
|
|
return self.small_view
|
|
|
|
|
2006-04-20 12:27:58 +02:00
|
|
|
def create_large_view(self, str1, str2, int1, int2,project):
|
2006-04-17 22:27:39 +02:00
|
|
|
self.large_view = plots.LargeView()
|
|
|
|
self.large_view.show()
|
|
|
|
return self.large_view
|
|
|
|
|
2006-04-16 20:25:54 +02:00
|
|
|
def create_navigator_view(self, str1, str2, int1, int2):
|
2006-04-22 23:46:44 +02:00
|
|
|
# tree = self.project.data_tree
|
|
|
|
self.navigator_view = navigator.NavigatorView(None, self)
|
2006-04-16 20:25:54 +02:00
|
|
|
self.navigator_view.show()
|
|
|
|
return self.navigator_view
|
|
|
|
|
|
|
|
def show(self):
|
|
|
|
self.init_gui()
|
|
|
|
|
|
|
|
def init_gui(self):
|
2006-04-19 21:59:55 +02:00
|
|
|
self['appwindow'].set_size_request(800, 600)
|
2006-04-16 20:25:54 +02:00
|
|
|
|
|
|
|
# Set up workflow
|
2006-04-22 23:46:44 +02:00
|
|
|
self.wf_menu = workflow.WorkflowView(self.workflow)
|
|
|
|
self.wf_menu.show()
|
|
|
|
self['workflow_vbox'].pack_end(self.wf_menu)
|
2006-04-19 20:25:44 +02:00
|
|
|
|
2006-04-16 20:25:54 +02:00
|
|
|
# Set up plot toolbar
|
2006-04-19 21:59:55 +02:00
|
|
|
# self['plot_toolbar_dock'].add(plot.get_toolbar(self.app))
|
2006-04-16 20:25:54 +02:00
|
|
|
|
|
|
|
# Connect signals
|
|
|
|
signals = {'on_quit1_activate' : (gtk.main_quit),
|
|
|
|
'on_appwindow_delete_event' : (gtk.main_quit),
|
2006-04-17 22:27:39 +02:00
|
|
|
'on_zoom_in_button_clicked' : (self.on_single_view),
|
2006-04-22 23:46:44 +02:00
|
|
|
'on_zoom_out_button_clicked' : (self.on_multiple_view),
|
2006-04-22 23:56:30 +02:00
|
|
|
'on_new1_activate' : (self.on_create_project),
|
|
|
|
'on_button_new_clicked' : (self.on_create_project),
|
|
|
|
'on_about1_activate' : (self.on_help_about)}
|
2006-04-16 20:25:54 +02:00
|
|
|
self.widget_tree.signal_autoconnect(signals)
|
|
|
|
|
|
|
|
# Log that we've set up the app now
|
|
|
|
logger.log('debug', 'Program started')
|
|
|
|
|
|
|
|
def change_plot(self, plot):
|
2006-04-18 00:30:53 +02:00
|
|
|
pt = self.widget_tree.get_widget('main_view')
|
|
|
|
pt.insert_view(plot)
|
2006-04-16 20:25:54 +02:00
|
|
|
|
2006-04-17 22:27:39 +02:00
|
|
|
def on_single_view(self, button):
|
2006-04-18 00:30:53 +02:00
|
|
|
nb = self.widget_tree.get_widget('main_view')
|
|
|
|
nb.goto_large()
|
2006-04-17 22:27:39 +02:00
|
|
|
|
|
|
|
def on_multiple_view(self, button):
|
2006-04-18 00:30:53 +02:00
|
|
|
nb = self.widget_tree.get_widget('main_view')
|
|
|
|
nb.goto_small()
|
2006-04-16 20:25:54 +02:00
|
|
|
|
2006-04-19 21:59:55 +02:00
|
|
|
def __getitem__(self, key):
|
|
|
|
return self.widget_tree.get_widget(key)
|
|
|
|
|
2006-04-22 23:46:44 +02:00
|
|
|
def on_create_project(self, *rest):
|
|
|
|
d = dialogs.CreateProjectDruid(self)
|
|
|
|
d.run()
|
|
|
|
|
2006-04-22 23:56:30 +02:00
|
|
|
def on_help_about(self, *rest):
|
|
|
|
widget_tree = gtk.glade.XML(GLADEFILENAME, 'aboutdialog')
|
|
|
|
about = widget_tree.get_widget('aboutdialog')
|
|
|
|
about.run()
|
|
|
|
|
2006-04-16 20:25:54 +02:00
|
|
|
if __name__ == '__main__':
|
|
|
|
gnome.program_init(PROGRAM_NAME, VERSION)
|
|
|
|
app = FluentApp()
|
|
|
|
app.show()
|
|
|
|
gtk.main()
|
|
|
|
|
2006-04-18 16:25:46 +02:00
|
|
|
|