- if not name: return
- study = getStudy()
- builder = study.NewBuilder()
- father = findOrCreateComponent()
- case = addObjectInStudy( builder, father, name, GUIcontext.CASE_ID )
- varE = addObjectInStudy( builder, case, "E", GUIcontext.VARIABLE_ID )
- setValueToVariable( builder, varE, 210.e9 )
- varF = addObjectInStudy( builder, case, "F", GUIcontext.VARIABLE_ID )
- setValueToVariable( builder, varF, 1000. )
- varL = addObjectInStudy( builder, case, "L", GUIcontext.VARIABLE_ID )
- setValueToVariable( builder, varL, 1.5 )
- varI = addObjectInStudy( builder, case, "I", GUIcontext.VARIABLE_ID )
- setValueToVariable( builder, varI, 2.e-6 )
-
- inputVarList = [study_exchange_vars.Variable("E"),
- study_exchange_vars.Variable("F"),
- study_exchange_vars.Variable("L"),
- study_exchange_vars.Variable("I")]
- outputVarList = [study_exchange_vars.Variable("dev")]
- exchVars = study_exchange_vars.ExchangeVariables(inputVarList, outputVarList)
- study_exchange_vars.createSObjectForExchangeVariables(case, exchVars, icon = VARS_ICON)
-
- sg.updateObjBrowser( True )
- print "GENERICSOLVERGUI.CreateCase : exit"
- pass
-
-###
-# Get the selected deterministic case
-###
-def GetSelectedCase():
- entry = sg.getSelected( 0 )
- if entry != '':
- study = getStudy()
- sobj = study.FindObjectID( entry )
- if ( sobj ):
- test, attr = sobj.FindAttribute( "AttributeLocalID" )
- print "GENERICSOLVERGUI.GetSelectedCase : test=%d attr=%d" % (test,attr.Value())
- if attr.Value() == GUIcontext.CASE_ID: # This is a case entry
- if hasChildren( sobj ):
- return entry
- else:
- print "GENERICSOLVERGUI.GetSelectedCase : ERROR! no child for case"
- pass
- else:
- print "GENERICSOLVERGUI.GetSelectedCase : ERROR! not a case"
- pass
- else:
- print "GENERICSOLVERGUI.GetSelectedCase : ERROR! selected object not found in study"
- pass
- else:
- print "GENERICSOLVERGUI.GetSelectedCase : ERROR! no selection"
- return None
-
-###
-# Retrieve data from selected case
-###
-def GetDataFromCase( caseEntry ):
- theCase = []
- study = getStudy()
- case = study.FindObjectID( caseEntry )
- builder = study.NewBuilder()
- # Get the values of the variables and make them a list
- for name in ("E", "F", "L", "I"):
- var = getSubSObjectByName( case, name )
- if var == None:
- print "GENERICSOLVERGUI.GetDataFromCase : ERROR! no variable '%s'" % name
- break
- theCase.append( getValueOfVariable( builder, var ) )
- return theCase
-
-###
-# Add some variable to the case
-###
-def AddDataToCase( caseEntry, varName, varValue ):
- study = getStudy()
- case = study.FindObjectID( caseEntry )
- builder = study.NewBuilder()
- var = addObjectInStudy( builder, case, varName, GUIcontext.VARIABLE_ID )
- setValueToVariable( builder, var, varValue )
- sg.updateObjBrowser( True )
- pass
-
-###
+ if not name:
+ return
+ ed = getStudyEditor()
+ father = ed.findOrCreateComponent(GUIcontext.MODULE_NAME,
+ icon=GUIcontext.MODULE_PIXMAP)
+ ed.setTypeId(father, GUIcontext.MODULE_ID)
+ case = ed.findItem(father, name)
+ if case is None:
+ case = ed.createItem(father, name, typeId=GUIcontext.CASE_ID)
+ varE = ed.createItem(case, "E", typeId=GUIcontext.VARIABLE_ID)
+ ed.setAttributeValue(varE, "AttributeReal", 210.e9)
+ varF = ed.createItem(case, "F", typeId=GUIcontext.VARIABLE_ID)
+ ed.setAttributeValue(varF, "AttributeReal", 1000.)
+ varL = ed.createItem(case, "L", typeId=GUIcontext.VARIABLE_ID)
+ ed.setAttributeValue(varL, "AttributeReal", 1.5)
+ varI = ed.createItem(case, "I", typeId=GUIcontext.VARIABLE_ID)
+ ed.setAttributeValue(varI, "AttributeReal", 2.e-6)
+
+ inputVarList = [study_exchange_vars.Variable("E"),
+ study_exchange_vars.Variable("F"),
+ study_exchange_vars.Variable("L"),
+ study_exchange_vars.Variable("I")]
+ outputVarList = [study_exchange_vars.Variable("dev")]
+ exchVars = study_exchange_vars.ExchangeVariables(inputVarList, outputVarList)
+ study_exchange_vars.createSObjectForExchangeVariables(case, exchVars, icon=VARS_ICON)
+
+ salome.sg.updateObjBrowser(True)
+ logger.debug("GENERICSOLVERGUI.CreateCase : exit")
+
+
+# ##