Commit 923a6761 authored by Jorn Bruggeman's avatar Jorn Bruggeman
Browse files

python driver: use new type_internal_variable convention; enable coupling choices

parent d17debb9
......@@ -36,13 +36,13 @@
link => model%links_postcoupling%first
do while (associated(link))
if (.not.link%target%read_indices%is_empty().and.link%target%state_indices%is_empty()) then
select type (object=>link%target)
class is (type_bulk_variable)
if (.not.associated(model%environment%data(object%read_indices%pointers(1)%p)%p)) n = n+1
class is (type_horizontal_variable)
if (.not.associated(model%environment%data_hz(object%read_indices%pointers(1)%p)%p)) n = n+1
class is (type_scalar_variable)
if (.not.associated(model%environment%data_scalar(object%read_indices%pointers(1)%p)%p)) n = n+1
select case (link%target%domain)
case (domain_bulk)
if (.not.associated(model%environment%data(link%target%read_indices%pointers(1)%p)%p)) n = n+1
case (domain_bottom,domain_surface)
if (.not.associated(model%environment%data_hz(link%target%read_indices%pointers(1)%p)%p)) n = n+1
case (domain_scalar)
if (.not.associated(model%environment%data_scalar(link%target%read_indices%pointers(1)%p)%p)) n = n+1
end select
end if
link => link%next
......@@ -57,38 +57,38 @@
link => model%links_postcoupling%first
do while (associated(link))
if (.not.link%target%read_indices%is_empty().and.link%target%state_indices%is_empty()) then
select type (object=>link%target)
class is (type_bulk_variable)
if (.not.associated(model%environment%data(object%read_indices%pointers(1)%p)%p)) then
select case (link%target%domain)
case (domain_bulk)
if (.not.associated(model%environment%data(link%target%read_indices%pointers(1)%p)%p)) then
n = n + 1
if (object%standard_variable%is_null()) then
if (.not.associated(link%target%standard_variable)) then
environment_names(n) = trim(link%name)
environment_units(n) = trim(object%units)
environment_units(n) = trim(link%target%units)
else
environment_names(n) = trim(object%standard_variable%name)
environment_units(n) = trim(object%standard_variable%units)
environment_names(n) = trim(link%target%standard_variable%name)
environment_units(n) = trim(link%target%standard_variable%units)
end if
end if
class is (type_horizontal_variable)
if (.not.associated(model%environment%data_hz(object%read_indices%pointers(1)%p)%p)) then
case (domain_bottom,domain_surface)
if (.not.associated(model%environment%data_hz(link%target%read_indices%pointers(1)%p)%p)) then
n = n + 1
if (object%standard_variable%is_null()) then
if (.not.associated(link%target%standard_variable)) then
environment_names(n) = trim(link%name)
environment_units(n) = trim(object%units)
environment_units(n) = trim(link%target%units)
else
environment_names(n) = trim(object%standard_variable%name)
environment_units(n) = trim(object%standard_variable%units)
environment_names(n) = trim(link%target%standard_variable%name)
environment_units(n) = trim(link%target%standard_variable%units)
end if
end if
class is (type_scalar_variable)
if (.not.associated(model%environment%data_scalar(object%read_indices%pointers(1)%p)%p)) then
case (domain_scalar)
if (.not.associated(model%environment%data_scalar(link%target%read_indices%pointers(1)%p)%p)) then
n = n + 1
if (object%standard_variable%is_null()) then
if (.not.associated(link%target%standard_variable)) then
environment_names(n) = trim(link%name)
environment_units(n) = trim(object%units)
environment_units(n) = trim(link%target%units)
else
environment_names(n) = trim(object%standard_variable%name)
environment_units(n) = trim(object%standard_variable%units)
environment_names(n) = trim(link%target%standard_variable%name)
environment_units(n) = trim(link%target%standard_variable%units)
end if
end if
end select
......
......@@ -238,7 +238,7 @@ class Coupling(Variable):
return strlong_name.value
def setValue(self,value):
# TBI
print 'New coupling specified: %s' % value
pass
def getOptions(self):
......
import pyfabm
from PySide import QtCore,QtGui
class Delegate(QtGui.QStyledItemDelegate):
def __init__(self,parent=None):
QtGui.QStyledItemDelegate.__init__(self,parent)
def createEditor(self,parent,option,index):
assert index.isValid()
data = index.internalPointer().object
if not isinstance(data,basestring):
options = data.getOptions()
if options is not None:
widget = QtGui.QComboBox(parent)
widget.addItems(options)
return widget
return QtGui.QStyledItemDelegate.createEditor(self,parent,option,index)
def setEditorData(self,editor,index):
if isinstance(editor,QtGui.QComboBox):
data = index.internalPointer().object
if not isinstance(data,basestring):
options = data.getOptions()
if options is not None:
editor.setCurrentIndex(list(options).index(data.value))
return
return QtGui.QStyledItemDelegate.setEditorData(self,editor,index)
def setModelData(self,editor,model,index):
if isinstance(editor,QtGui.QComboBox):
data = index.internalPointer().object
if not isinstance(data,basestring):
options = data.getOptions()
if options is not None:
i = editor.currentIndex()
model.setData(index,options[i],QtCore.Qt.EditRole)
return
return QtGui.QStyledItemDelegate.setModelData(self,editor,model,index)
class Entry(object):
def __init__(self,object=None,name=''):
if name=='' and object is not None: name = object
......
......@@ -17,7 +17,7 @@
use fabm
use fabm_config
use fabm_types, only:rk,attribute_length,type_model_list_node,type_base_model,factory,type_link,type_link_list,type_internal_variable,type_bulk_variable
use fabm_types, only:rk,attribute_length,type_model_list_node,type_base_model,factory,type_link,type_link_list,type_internal_variable
use fabm_driver, only: type_base_driver, driver
use fabm_properties
use fabm_python_helper
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment