Ejemplo n.º 1
0
    def __init__(self, parent):
        wx.Panel.__init__(self, parent, OBSTACLE_ID)
        b = Borg()
        self.dbProxy = b.dbProxy
        mainSizer = wx.BoxSizer(wx.VERTICAL)
        mainSizer.Add(
            WidgetFactory.buildTextSizer(self, 'Name', (87, 30),
                                         OBSTACLE_TEXTNAME_ID), 0, wx.EXPAND)
        self.nameCtrl = self.FindWindowById(OBSTACLE_TEXTNAME_ID)
        self.notebook = ObstacleEnvironmentNotebook(self, self.dbProxy)

        mainSizer.Add(self.notebook, 1, wx.EXPAND)
        mainSizer.Add(
            WidgetFactory.buildCommitButtonSizer(self,
                                                 OBSTACLE_BUTTONCOMMIT_ID,
                                                 True), 0, wx.CENTER)
        self.definitionCtrl = self.notebook.FindWindowById(
            OBSTACLE_TEXTDEFINITION_ID)
        self.categoryCtrl = self.notebook.FindWindowById(
            OBSTACLE_COMBOCATEGORY_ID)
        self.goalAssociationCtrl = self.notebook.FindWindowById(
            OBSTACLE_LISTGOALS_ID)
        self.subGoalAssociationCtrl = self.notebook.FindWindowById(
            OBSTACLE_LISTSUBGOALS_ID)
        self.cCtrl = self.notebook.FindWindowById(OBSTACLE_LISTCONCERNS_ID)
        self.SetSizer(mainSizer)
Ejemplo n.º 2
0
    def __init__(self, parent, dp):
        wx.Panel.__init__(self, parent, OBSTACLE_PANELENVIRONMENT_ID)
        self.dbProxy = dp
        self.theObstacleId = None
        self.theEnvironmentDictionary = {}
        self.theSelectedIdx = -1

        mainSizer = wx.BoxSizer(wx.HORIZONTAL)
        environmentBox = wx.StaticBox(self)
        environmentListSizer = wx.StaticBoxSizer(environmentBox, wx.HORIZONTAL)
        mainSizer.Add(environmentListSizer, 0, wx.EXPAND)
        self.environmentList = EnvironmentListCtrl(
            self, OBSTACLE_LISTENVIRONMENTS_ID, self.dbProxy)
        environmentListSizer.Add(self.environmentList, 1, wx.EXPAND)
        environmentDimSizer = wx.BoxSizer(wx.VERTICAL)
        mainSizer.Add(environmentDimSizer, 1, wx.EXPAND)

        nbBox = wx.StaticBox(self, -1)
        nbSizer = wx.StaticBoxSizer(nbBox, wx.VERTICAL)
        environmentDimSizer.Add(nbSizer, 1, wx.EXPAND)
        self.notebook = ObstacleEnvironmentNotebook(self, self.dbProxy)
        nbSizer.Add(self.notebook, 1, wx.EXPAND)

        self.labelCtrl = self.notebook.FindWindowById(OBSTACLE_TEXTLABEL_ID)
        self.probCtrl = self.notebook.FindWindowById(
            OBSTACLE_TEXTPROBABILITY_ID)
        self.categoryCtrl = self.notebook.FindWindowById(
            OBSTACLE_COMBOCATEGORY_ID)
        self.definitionCtrl = self.notebook.FindWindowById(
            OBSTACLE_TEXTDEFINITION_ID)
        self.goalAssociationCtrl = self.notebook.FindWindowById(
            OBSTACLE_LISTGOALS_ID)
        self.subGoalAssociationCtrl = self.notebook.FindWindowById(
            OBSTACLE_LISTSUBGOALS_ID)
        self.concernsCtrl = self.notebook.FindWindowById(
            OBSTACLE_LISTCONCERNS_ID)

        self.SetSizer(mainSizer)
        self.environmentList.Bind(wx.EVT_LIST_INSERT_ITEM,
                                  self.OnAddEnvironment)
        self.environmentList.Bind(wx.EVT_LIST_DELETE_ITEM,
                                  self.OnDeleteEnvironment)

        self.categoryCtrl.Disable()
        self.definitionCtrl.Disable()
        self.goalAssociationCtrl.Disable()
        self.subGoalAssociationCtrl.Disable()
        self.concernsCtrl.Disable()
Ejemplo n.º 3
0
class ObstacleEnvironmentPanel(wx.Panel):
    def __init__(self, parent, dp):
        wx.Panel.__init__(self, parent, OBSTACLE_PANELENVIRONMENT_ID)
        self.dbProxy = dp
        self.theObstacleId = None
        self.theEnvironmentDictionary = {}
        self.theSelectedIdx = -1

        mainSizer = wx.BoxSizer(wx.HORIZONTAL)
        environmentBox = wx.StaticBox(self)
        environmentListSizer = wx.StaticBoxSizer(environmentBox, wx.HORIZONTAL)
        mainSizer.Add(environmentListSizer, 0, wx.EXPAND)
        self.environmentList = EnvironmentListCtrl(
            self, OBSTACLE_LISTENVIRONMENTS_ID, self.dbProxy)
        environmentListSizer.Add(self.environmentList, 1, wx.EXPAND)
        environmentDimSizer = wx.BoxSizer(wx.VERTICAL)
        mainSizer.Add(environmentDimSizer, 1, wx.EXPAND)

        nbBox = wx.StaticBox(self, -1)
        nbSizer = wx.StaticBoxSizer(nbBox, wx.VERTICAL)
        environmentDimSizer.Add(nbSizer, 1, wx.EXPAND)
        self.notebook = ObstacleEnvironmentNotebook(self, self.dbProxy)
        nbSizer.Add(self.notebook, 1, wx.EXPAND)

        self.labelCtrl = self.notebook.FindWindowById(OBSTACLE_TEXTLABEL_ID)
        self.probCtrl = self.notebook.FindWindowById(
            OBSTACLE_TEXTPROBABILITY_ID)
        self.categoryCtrl = self.notebook.FindWindowById(
            OBSTACLE_COMBOCATEGORY_ID)
        self.definitionCtrl = self.notebook.FindWindowById(
            OBSTACLE_TEXTDEFINITION_ID)
        self.goalAssociationCtrl = self.notebook.FindWindowById(
            OBSTACLE_LISTGOALS_ID)
        self.subGoalAssociationCtrl = self.notebook.FindWindowById(
            OBSTACLE_LISTSUBGOALS_ID)
        self.concernsCtrl = self.notebook.FindWindowById(
            OBSTACLE_LISTCONCERNS_ID)

        self.SetSizer(mainSizer)
        self.environmentList.Bind(wx.EVT_LIST_INSERT_ITEM,
                                  self.OnAddEnvironment)
        self.environmentList.Bind(wx.EVT_LIST_DELETE_ITEM,
                                  self.OnDeleteEnvironment)

        self.categoryCtrl.Disable()
        self.definitionCtrl.Disable()
        self.goalAssociationCtrl.Disable()
        self.subGoalAssociationCtrl.Disable()
        self.concernsCtrl.Disable()

    def loadControls(self, obstacle):
        self.environmentList.Unbind(wx.EVT_LIST_ITEM_SELECTED)
        self.environmentList.Unbind(wx.EVT_LIST_ITEM_DESELECTED)
        self.theObstacleId = obstacle.id()
        environmentNames = []
        for cp in obstacle.environmentProperties():
            environmentNames.append(cp.name())
        self.environmentList.load(environmentNames)

        for cp in obstacle.environmentProperties():
            environmentName = cp.name()
            self.theEnvironmentDictionary[environmentName] = cp
            environmentNames.append(environmentName)
        environmentName = environmentNames[0]
        p = self.theEnvironmentDictionary[environmentName]

        self.labelCtrl.SetValue(p.label())
        self.probCtrl.SetValue(str(p.probability()))
        self.categoryCtrl.SetValue(p.category())
        self.definitionCtrl.SetValue(p.definition())
        self.goalAssociationCtrl.setEnvironment(environmentName)
        self.goalAssociationCtrl.load(p.goalRefinements())
        self.subGoalAssociationCtrl.setEnvironment(environmentName)
        self.concernsCtrl.setEnvironment(environmentName)
        self.subGoalAssociationCtrl.load(p.subGoalRefinements())
        self.concernsCtrl.load(p.concerns())

        self.environmentList.Select(0)
        self.environmentList.Bind(wx.EVT_LIST_ITEM_SELECTED,
                                  self.OnEnvironmentSelected)
        self.environmentList.Bind(wx.EVT_LIST_ITEM_DESELECTED,
                                  self.OnEnvironmentDeselected)

        self.categoryCtrl.Enable()
        self.definitionCtrl.Enable()
        self.goalAssociationCtrl.Enable()
        self.subGoalAssociationCtrl.Enable()
        self.concernsCtrl.Enable()
        self.theSelectedIdx = 0

    def OnEnvironmentSelected(self, evt):
        self.theSelectedIdx = evt.GetIndex()
        environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
        p = self.theEnvironmentDictionary[environmentName]

        self.labelCtrl.SetValue(p.label())
        self.probCtrl.SetValue(str(p.probability()))
        self.categoryCtrl.SetValue(p.category())
        self.definitionCtrl.SetValue(p.definition())
        self.goalAssociationCtrl.setEnvironment(environmentName)
        self.goalAssociationCtrl.load(p.goalRefinements())
        self.subGoalAssociationCtrl.setEnvironment(environmentName)
        self.concernsCtrl.setEnvironment(environmentName)
        self.subGoalAssociationCtrl.load(p.subGoalRefinements())
        self.concernsCtrl.load(p.concerns())

        self.categoryCtrl.Enable()
        self.definitionCtrl.Enable()
        self.goalAssociationCtrl.Enable()
        self.subGoalAssociationCtrl.Enable()
        self.concernsCtrl.Enable()

    def OnEnvironmentDeselected(self, evt):
        self.theSelectedIdx = evt.GetIndex()
        environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
        self.theEnvironmentDictionary[
            environmentName] = ObstacleEnvironmentProperties(
                environmentName, self.labelCtrl.GetValue(),
                self.definitionCtrl.GetValue(), self.categoryCtrl.GetValue(),
                self.goalAssociationCtrl.dimensions(),
                self.subGoalAssociationCtrl.dimensions(),
                self.concernsCtrl.dimensions())
        self.labelCtrl.SetValue('')
        self.probCtrl.SetValue('')
        self.categoryCtrl.SetValue('')
        self.definitionCtrl.SetValue('')
        self.goalAssociationCtrl.DeleteAllItems()
        self.goalAssociationCtrl.setEnvironment('')
        self.subGoalAssociationCtrl.DeleteAllItems()
        self.concernsCtrl.DeleteAllItems()
        self.subGoalAssociationCtrl.setEnvironment('')
        self.concernsCtrl.setEnvironment('')
        self.theSelectedIdx = -1
        self.categoryCtrl.Disable()
        self.definitionCtrl.Disable()
        self.goalAssociationCtrl.Disable()
        self.subGoalAssociationCtrl.Disable()
        self.concernsCtrl.Disable()

    def OnAddEnvironment(self, evt):
        self.theSelectedIdx = evt.GetIndex()
        environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
        self.theEnvironmentDictionary[
            environmentName] = ObstacleEnvironmentProperties(environmentName)
        self.environmentList.Select(self.theSelectedIdx)
        self.labelCtrl.SetValue('')
        self.probCtrl.SetValue('')
        self.categoryCtrl.SetValue('')
        self.definitionCtrl.SetValue('None')
        self.goalAssociationCtrl.setEnvironment(environmentName)
        self.goalAssociationCtrl.DeleteAllItems()
        self.subGoalAssociationCtrl.setEnvironment(environmentName)
        self.concernsCtrl.setEnvironment(environmentName)
        self.subGoalAssociationCtrl.DeleteAllItems()
        self.concernsCtrl.DeleteAllItems()
        self.categoryCtrl.Enable()
        self.definitionCtrl.Enable()
        self.goalAssociationCtrl.Enable()
        self.subGoalAssociationCtrl.Enable()
        self.concernsCtrl.Enable()
        inheritedEnv = self.environmentList.inheritedEnvironment()
        if (inheritedEnv != '' and self.theObstacleId != None):
            p = self.dbProxy.inheritedObstacleProperties(
                self.theObstacleId, inheritedEnv)
            self.theEnvironmentDictionary[environmentName] = p
            self.labelCtrl.SetValue(p.label())
            self.labelCtrl.SetValue(str(p.probability()))
            self.categoryCtrl.SetValue(p.category())
            self.definitionCtrl.SetValue(p.definition())
            self.goalAssociationCtrl.setEnvironment(environmentName)
            self.goalAssociationCtrl.load(p.goalRefinements())
            self.subGoalAssociationCtrl.setEnvironment(environmentName)
            self.concernsCtrl.setEnvironment(environmentName)
            self.subGoalAssociationCtrl.load(p.subGoalRefinements())
            self.concernsCtrl.load(p.concerns())

    def OnDeleteEnvironment(self, evt):
        selectedIdx = evt.GetIndex()
        environmentName = self.environmentList.GetItemText(selectedIdx)
        del self.theEnvironmentDictionary[environmentName]
        self.theSelectedIdx = -1
        self.labelCtrl.SetValue('')
        self.probCtrl.SetValue('')
        self.categoryCtrl.SetValue('')
        self.definitionCtrl.SetValue('')
        self.goalAssociationCtrl.DeleteAllItems()
        self.goalAssociationCtrl.setEnvironment('')
        self.subGoalAssociationCtrl.DeleteAllItems()
        self.subGoalAssociationCtrl.setEnvironment('')
        self.concernsCtrl.DeleteAllItems()
        self.concernsCtrl.setEnvironment('')
        self.categoryCtrl.Disable()
        self.definitionCtrl.Disable()
        self.goalAssociationCtrl.Disable()
        self.subGoalAssociationCtrl.Disable()
        self.concernsCtrl.Disable()

    def environmentProperties(self):
        if (self.theSelectedIdx != -1):
            environmentName = self.environmentList.GetItemText(
                self.theSelectedIdx)
            self.theEnvironmentDictionary[
                environmentName] = ObstacleEnvironmentProperties(
                    environmentName, self.labelCtrl.GetValue(),
                    self.definitionCtrl.GetValue(),
                    self.categoryCtrl.GetValue(),
                    self.goalAssociationCtrl.dimensions(),
                    self.subGoalAssociationCtrl.dimensions(),
                    self.concernsCtrl.dimensions())
        return self.theEnvironmentDictionary.values()