def ShowProjectData(self): """ Display data for current project If current project is new one, do nothing """ self.tc_name.SetValue(str(self.record.Name)) from_prj = cdml.GetRecordByKey(DB.Projects, self.record.DerivedFrom) if from_prj: self.tc_from.SetValue(str(from_prj.Name)) self.tc_created.SetValue(self.record.CreatedOn) self.tc_modified.SetValue(self.record.LastModified) self.tc_notes.SetValue(str(self.record.Notes)) self.cc_pset.SetValue(self.record.PrimaryPopulationSetID) self.cc_model.SetValue(self.record.PrimaryModelID) self.tc_simsteps.SetValue(self.record.NumberOfSimulationSteps) self.tc_repet.SetValue(self.record.NumberOfRepetitions) self.tab0_list.DeleteAllItems() self.tab1_list.DeleteAllItems() self.tab3_list.DeleteAllItems() for rule in self.record.SimulationRules: item = (str(rule.AffectedParam), str(rule.OccurrenceProbability), str(rule.AppliedFormula), str(rule.Notes), -1) list = getattr(self, 'tab' + str(rule.SimulationPhase) + '_list') list.AddItem(item, list.GetItemCount()) self.ClearPanel(self.panel_combo) self.tc_name.SetFocus() self.tc_name.SetInsertionPoint(0)
def SetValues(self, record, init=False): """ Write current data in controls on a row panel RowPanel class must implement this method. """ self.Key = record.ID self.tc_name.SetValue(str(record.Name)) self.tc_source.SetValue(str(record.Source)) self.tc_created.SetValue(record.CreatedOn) self.tc_modified.SetValue(record.LastModified) self.tc_notes.SetValue(str(record.Notes)) # Special treatment needed to discover if a record is distribution # based if record.IsDistributionBased(): self.tc_definitiontype.SetValue('Distribution based') else: self.tc_definitiontype.SetValue('Data based') from_pset = cdml.GetRecordByKey(DB.PopulationSets, record.DerivedFrom) if from_pset: self.tc_derived.SetValue(str(from_pset.Name)) self.DerivedFrom = record.DerivedFrom self.DataColumns = record.DataColumns self.Data = record.Data self.Objectives = record.Objectives
def OnButtonDblClick(self, event): """ Event handler to open child form """ tc = event.GetEventObject() cc = tc.GetParent() if cc.Id in [cdml.IDP_BUTTON1, cdml.IDP_BUTTON2]: collection = DB.States key = cc.GetValue() form = 'States' type_parm = '' elif tc.Id == cdml.IDP_BUTTON3: collection = DB.Params key = tc.GetValue() form = 'Parameters' if tc.Id == cdml.IDP_BUTTON3: type_parm = ['Number', 'Integer', 'Epression'] else: raise ValueError, "Assertion Error: Button does not exist" if key == '' or key == 0: msg = 'This ' + form[:-1] + ' is not defined yet.\n' msg += "Do you want to create a new " + form[:-1] + '?' ans = cdml.dlgSimpleMsg('ERROR', msg, wx.YES_NO, wx.ICON_ERROR, Parent=self) if ans == wx.ID_NO: return cdml.OpenForm(form, self, cdml.ID_MODE_SINGL, key, type_parm) elif not cdml.GetRecordByKey(collection, key): msg = 'The entry "' + str( key) + '" does not exist in ' + form + '.' ans = cdml.dlgSimpleMsg('ERROR', msg, wx.OK, wx.ICON_ERROR, Parent=self) return else: frame = self.GetTopLevelParent() cdml.OpenForm(form, self, cdml.ID_MODE_SINGL, key, type_parm, frame.idPrj)
def SetValues(self, record, init=False): """ Write current data in controls on a row panel RowPanel class must implement this method. """ # Since there are combo items in use, first populate their list self.SetComboItem() self.Key = record.ID self.tc_name.SetValue(str(record.Name)) self.tc_created.SetValue(record.CreatedOn) self.tc_modified.SetValue(record.LastModified) self.tc_notes.SetValue(str(record.Notes)) from_model = cdml.GetRecordByKey(DB.StudyModels, record.DerivedFrom) if from_model: self.tc_from.SetValue(str(from_model.Name)) self.DerivedFrom = record.DerivedFrom if record.MainProcess: self.cc_main_proc.SetValue(record.MainProcess)
def Initialize(self): """ Assign initial values to the controls """ self.record.ID = self.idPrj project = cdml.GetRecordByKey(DB.Projects, self.idPrj) if cdml.Exist(project): # if project != None, create temporary copy of the project data self.record.Name = str(project.Name) self.record.Notes = str(project.Notes) self.record.PrimaryModelID = project.PrimaryModelID self.record.DerivedFrom = project.DerivedFrom self.record.PrimaryPopulationSetID = project.PrimaryPopulationSetID self.record.NumberOfSimulationSteps = project.NumberOfSimulationSteps self.record.NumberOfRepetitions = project.NumberOfRepetitions self.record.CreatedOn = project.CreatedOn self.record.LastModified = project.LastModified self.record.SimulationRules = project.SimulationRules self.SimRule = [[], [], [], []] for rule in self.record.SimulationRules: self.SimRule[rule.SimulationPhase].append(rule) self.ShowProjectData()
def GetParameterList(self): """ Open a dialog and get parameter list to display """ types = ['ALL User Accessible'] types.extend(DB.ParameterTypes) # Decide if to include system reserve parameters according to if # admin mode was set if not cdml.GetAdminMode(): types.remove('State Indicator') types.remove('System Reserved') else: types.append('ALL') if self.openData == None: # if no specific parameter was requested show a dialog box dlg = wx.MultiChoiceDialog( self, 'Please select parameter type you want to see.\n Some parameter types may take long time to display.', 'Select Parameter', types, wx.CHOICEDLG_STYLE) dlg.SetSelections([0]) # set default selection dlg.CenterOnScreen() if dlg.ShowModal() != wx.ID_OK: return [] # If 'Cancel' button is clicked indexes = dlg.GetSelections() # Get selection index dlg.Destroy() selections = [types[i] for i in indexes] # extract selected parameter types if selections == []: params = [] elif selections[0] == 'ALL User Accessible': # Sort the entries according to key and filter params = [ Entry for (Key, Entry) in sorted(DB.Params.iteritems()) if Entry.ParameterType not in ['State Indicator', 'System Reserved'] ] elif selections[-1] == 'ALL': # Sort the entries according to key params = [ Entry for (Key, Entry) in sorted(DB.Params.iteritems()) ] else: # Sort the entries according to key and filter params = [ Entry for (Key, Entry) in sorted(DB.Params.iteritems()) if Entry.ParameterType in selections ] else: # The form was called with a particular parameter in mind parm = cdml.GetRecordByKey(getattr(DB, self.Collection), self.openData) if parm == None or parm.ParameterType not in types: params = [] else: params = [parm] return params