コード例 #1
0
ファイル: finder.py プロジェクト: mthunemann/Neuroptikon
class Finder(wx.Dialog):
    def __init__(self, *args, **kwds):
        self.display = args[0].display
        self.predicate = None

        # begin wxGlade: Finder.__init__
        kwds["style"] = wx.DEFAULT_DIALOG_STYLE
        wx.Dialog.__init__(self, *args, **kwds)
        self.notebook = wx.Notebook(self, -1, style=0)
        self.find_by_io_panel = wx.Panel(self.notebook, -1)
        self.find_by_text_panel = wx.Panel(self.notebook, -1)
        self.label_2 = wx.StaticText(self.find_by_text_panel, -1, "Find")
        self.text_object_type_choice = wx.Choice(
            self.find_by_text_panel,
            -1,
            choices=[
                "objects", "regions", "pathways", "neurons", "neurites",
                "synapses", "gap junctions", "muscles", "arborizations",
                "innervations", "stimuli"
            ])
        self.label_3 = wx.StaticText(self.find_by_text_panel, -1, "whose")
        self.text_field_choice = wx.Choice(
            self.find_by_text_panel,
            -1,
            choices=["name or abbreviation", "name", "abbreviation"])
        self.text_operator_choice = wx.Choice(
            self.find_by_text_panel,
            -1,
            choices=["contains", "starts with", "ends with"])
        self.find_text = wx.TextCtrl(self.find_by_text_panel, -1, "")
        self.label_4 = wx.StaticText(self.find_by_io_panel, -1, "Find")
        self.io_connection_type_choice = wx.Choice(
            self.find_by_io_panel,
            -1,
            choices=["connections", "pathways", "neurons"])
        self.label_5 = wx.StaticText(self.find_by_io_panel, -1, "which")
        self.input_output_choice = wx.Choice(self.find_by_io_panel,
                                             -1,
                                             choices=[
                                                 "send input to",
                                                 "receive input from",
                                                 "send to or recieve from"
                                             ])
        self.io_object_type_choice = wx.Choice(
            self.find_by_io_panel, -1, choices=["region", "neuron", "muscle"])
        self.io_object_choice = wx.Choice(self.find_by_io_panel,
                                          -1,
                                          choices=[])
        self.Cancel = wx.Button(self, wx.ID_CANCEL, "", style=wx.BU_EXACTFIT)
        self.Find = wx.Button(self, wx.ID_FIND, "", style=wx.BU_EXACTFIT)

        self.__set_properties()
        self.__do_layout()

        self.Bind(wx.EVT_CHOICE, self.on_io_object_type_change,
                  self.io_object_type_choice)
        self.Bind(wx.EVT_BUTTON, self.on_find, self.Find)
        # end wxGlade

        self.on_io_object_type_change(None)

    def __set_properties(self):
        # begin wxGlade: Finder.__set_properties
        self.SetTitle("Finder")
        self.text_object_type_choice.SetSelection(0)
        self.text_field_choice.SetSelection(0)
        self.text_operator_choice.SetSelection(0)
        self.io_connection_type_choice.SetSelection(0)
        self.input_output_choice.SetSelection(0)
        self.io_object_type_choice.SetSelection(0)
        self.Find.SetDefault()
        # end wxGlade

    def __do_layout(self):
        # begin wxGlade: Finder.__do_layout
        main_sizer = wx.BoxSizer(wx.VERTICAL)
        sizer_3 = wx.BoxSizer(wx.HORIZONTAL)
        sizer_5 = wx.BoxSizer(wx.VERTICAL)
        grid_sizer_2 = wx.FlexGridSizer(3, 2, 0, 0)
        sizer_4 = wx.BoxSizer(wx.VERTICAL)
        grid_sizer_1 = wx.FlexGridSizer(3, 2, 0, 0)
        grid_sizer_1.Add(self.label_2, 0, wx.ALL | wx.ALIGN_RIGHT, 4)
        grid_sizer_1.Add(self.text_object_type_choice, 0, wx.ALL, 4)
        grid_sizer_1.Add(self.label_3, 0, wx.ALL | wx.ALIGN_RIGHT, 4)
        grid_sizer_1.Add(self.text_field_choice, 0, wx.ALL, 4)
        grid_sizer_1.Add(self.text_operator_choice, 0, wx.ALL | wx.ALIGN_RIGHT,
                         4)
        grid_sizer_1.Add(self.find_text, 0, wx.ALL | wx.EXPAND, 4)
        grid_sizer_1.AddGrowableCol(1)
        sizer_4.Add(grid_sizer_1, 0, wx.ALL | wx.EXPAND, 4)
        self.find_by_text_panel.SetSizer(sizer_4)
        grid_sizer_2.Add(self.label_4, 0, wx.ALL | wx.ALIGN_RIGHT, 4)
        grid_sizer_2.Add(self.io_connection_type_choice, 0, wx.ALL, 4)
        grid_sizer_2.Add(self.label_5, 0, wx.ALL | wx.ALIGN_RIGHT, 4)
        grid_sizer_2.Add(self.input_output_choice, 0, wx.ALL, 4)
        grid_sizer_2.Add(self.io_object_type_choice, 0, wx.ALL, 4)
        grid_sizer_2.Add(self.io_object_choice, 0, wx.ALL, 4)
        sizer_5.Add(grid_sizer_2, 1, wx.ALL | wx.EXPAND, 4)
        self.find_by_io_panel.SetSizer(sizer_5)
        self.notebook.AddPage(self.find_by_text_panel, "Find by Text")
        self.notebook.AddPage(self.find_by_io_panel, "Find by I/O")
        main_sizer.Add(self.notebook, 1, wx.ALL | wx.EXPAND, 10)
        sizer_3.Add(self.Cancel, 0, wx.ALL, 5)
        sizer_3.Add(self.Find, 0, wx.ALL, 5)
        main_sizer.Add(sizer_3, 0, wx.ALIGN_RIGHT, 4)
        main_sizer.Add((20, 10), 0, wx.EXPAND | wx.ALIGN_CENTER_HORIZONTAL, 0)
        self.SetSizer(main_sizer)
        main_sizer.Fit(self)
        self.Layout()
        # end wxGlade

    def on_io_object_type_change(self,
                                 event):  # wxGlade: Finder.<event_handler>
        self.io_object_choice.Clear()
        typeChoice = self.io_object_type_choice.GetSelection()
        if typeChoice == 0:
            objects = self.display.network.objectsOfClass(
                network.region.Region)
            altName = gettext('<unnamed region>')
        elif typeChoice == 1:
            objects = self.display.network.objectsOfClass(
                network.neuron.Neuron)
            altName = gettext('<unnamed neuron>')
        elif typeChoice == 2:
            objects = self.display.network.objectsOfClass(
                network.muscle.Muscle)
            altName = gettext('<unnamed muscle>')
        else:
            objects = []
        objects.sort(key=lambda object: (object.name or altName).upper())
        for object in objects:
            self.io_object_choice.Append(object.name or altName, object)
        self.io_object_choice.SetSelection(0)
        if event != None:
            event.Skip()

    def on_find(self, event_):  # wxGlade: Finder.<event_handler>
        self.predicate = CompoundPredicate()

        if self.notebook.GetCurrentPage() == self.find_by_text_panel:
            if self.text_object_type_choice.GetCurrentSelection() == 1:
                self.predicate.addStatement(
                    lambda x: x.__class__ == network.region.Region)
            elif self.text_object_type_choice.GetCurrentSelection() == 2:
                self.predicate.addStatement(
                    lambda x: x.__class__ == network.pathway.Pathway)
            elif self.text_object_type_choice.GetCurrentSelection() == 3:
                self.predicate.addStatement(
                    lambda x: x.__class__ == network.neuron.Neuron)
            elif self.text_object_type_choice.GetCurrentSelection() == 4:
                self.predicate.addStatement(
                    lambda x: x.__class__ == network.neurite.Neurite)
            elif self.text_object_type_choice.GetCurrentSelection() == 5:
                self.predicate.addStatement(
                    lambda x: x.__class__ == network.synapse.Synapse)
            elif self.text_object_type_choice.GetCurrentSelection() == 6:
                self.predicate.addStatement(
                    lambda x: x.__class__ == network.gap_junction.GapJunction)
            elif self.text_object_type_choice.GetCurrentSelection() == 7:
                self.predicate.addStatement(
                    lambda x: x.__class__ == network.muscle.Muscle)
            elif self.text_object_type_choice.GetCurrentSelection() == 8:
                self.predicate.addStatement(
                    lambda x: x.__class__ == network.arborization.Arborization)
            elif self.text_object_type_choice.GetCurrentSelection() == 9:
                self.predicate.addStatement(
                    lambda x: x.__class__ == network.innervation.Innervation)
            elif self.text_object_type_choice.GetCurrentSelection() == 10:
                self.predicate.addStatement(
                    lambda x: x.__class__ == network.stimulus.Stimulus)

            findText = self.find_text.GetValue().upper()
            if self.text_operator_choice.GetCurrentSelection() == 0:
                namePredicate = Predicate(
                    lambda x: (x.name is None and findText == '') or
                    (x.name != None and x.name.upper().find(findText) != -1))
                abbreviationPredicate = Predicate(
                    lambda x: (x.abbreviation is None and findText == '') or
                    (x.abbreviation != None and x.abbreviation.upper().find(
                        self.find_text.GetValue().upper()) != -1))
            elif self.text_operator_choice.GetCurrentSelection() == 1:
                namePredicate = Predicate(lambda x: x.name != None and x.name.
                                          upper().startswith(findText))
                abbreviationPredicate = Predicate(
                    lambda x: x.abbreviation != None and x.abbreviation.upper(
                    ).startswith(self.find_text.GetValue().upper()))
            elif self.text_operator_choice.GetCurrentSelection() == 2:
                namePredicate = Predicate(lambda x: x.name != None and x.name.
                                          upper().endswith(findText))
                abbreviationPredicate = Predicate(
                    lambda x: x.abbreviation != None and x.abbreviation.upper(
                    ).endswith(findText))
            if self.text_field_choice.GetCurrentSelection(
            ) == 0:  # name or abbreviation
                fieldPredicate = CompoundPredicate()
                fieldPredicate.matchAll = False
                fieldPredicate.predicates.append(namePredicate)
                fieldPredicate.predicates.append(abbreviationPredicate)
                self.predicate.predicates.append(fieldPredicate)
            elif self.text_field_choice.GetCurrentSelection(
            ) == 1:  # just name
                self.predicate.predicates.append(namePredicate)
            elif self.text_field_choice.GetCurrentSelection(
            ) == 2:  # just abbreviation
                self.predicate.predicates.append(abbreviationPredicate)
        elif self.notebook.GetCurrentPage() == self.find_by_io_panel:
            if self.io_connection_type_choice.GetCurrentSelection() == 1:
                self.predicate.addStatement(
                    lambda x: x.__class__ == network.pathway.Pathway)
            elif self.text_object_type_choice.GetCurrentSelection() == 2:
                self.predicate.addStatement(
                    lambda x: x.__class__ == network.neuron.Neuron)

            sourceObject = self.io_object_choice.GetClientData(
                self.io_object_choice.GetCurrentSelection())
            inputs = sourceObject.inputs()
            outputs = sourceObject.outputs()
            if self.input_output_choice.GetCurrentSelection(
            ) == 0:  # just send
                self.predicate.addStatement(lambda x: x in inputs)
            elif self.input_output_choice.GetCurrentSelection(
            ) == 1:  # just receive
                self.predicate.addStatement(lambda x: x in outputs)
            elif self.input_output_choice.GetCurrentSelection(
            ) == 2:  # send or receive
                self.predicate.addStatement(
                    lambda x: x in inputs or x in outputs)

        self.EndModal(wx.ID_OK)
コード例 #2
0
ファイル: finder.py プロジェクト: JaneliaSciComp/Neuroptikon
class Finder(wx.Dialog):
    def __init__(self, *args, **kwds):
        self.display = args[0].display
        self.predicate = None
        
        # begin wxGlade: Finder.__init__
        kwds["style"] = wx.DEFAULT_DIALOG_STYLE
        wx.Dialog.__init__(self, *args, **kwds)
        self.notebook = wx.Notebook(self, -1, style=0)
        self.find_by_io_panel = wx.Panel(self.notebook, -1)
        self.find_by_text_panel = wx.Panel(self.notebook, -1)
        self.label_2 = wx.StaticText(self.find_by_text_panel, -1, "Find")
        self.text_object_type_choice = wx.Choice(self.find_by_text_panel, -1, choices=["objects", "regions", "pathways", "neurons", "neurites", "synapses", "gap junctions", "muscles", "arborizations", "innervations", "stimuli"])
        self.label_3 = wx.StaticText(self.find_by_text_panel, -1, "whose")
        self.text_field_choice = wx.Choice(self.find_by_text_panel, -1, choices=["name or abbreviation", "name", "abbreviation"])
        self.text_operator_choice = wx.Choice(self.find_by_text_panel, -1, choices=["contains", "starts with", "ends with"])
        self.find_text = wx.TextCtrl(self.find_by_text_panel, -1, "")
        self.label_4 = wx.StaticText(self.find_by_io_panel, -1, "Find")
        self.io_connection_type_choice = wx.Choice(self.find_by_io_panel, -1, choices=["connections", "pathways", "neurons"])
        self.label_5 = wx.StaticText(self.find_by_io_panel, -1, "which")
        self.input_output_choice = wx.Choice(self.find_by_io_panel, -1, choices=["send input to", "receive input from", "send to or recieve from"])
        self.io_object_type_choice = wx.Choice(self.find_by_io_panel, -1, choices=["region", "neuron", "muscle"])
        self.io_object_choice = wx.Choice(self.find_by_io_panel, -1, choices=[])
        self.Cancel = wx.Button(self, wx.ID_CANCEL, "", style=wx.BU_EXACTFIT)
        self.Find = wx.Button(self, wx.ID_FIND, "", style=wx.BU_EXACTFIT)

        self.__set_properties()
        self.__do_layout()

        self.Bind(wx.EVT_CHOICE, self.on_io_object_type_change, self.io_object_type_choice)
        self.Bind(wx.EVT_BUTTON, self.on_find, self.Find)
        # end wxGlade
        
        self.on_io_object_type_change(None)
    
    
    def __set_properties(self):
        # begin wxGlade: Finder.__set_properties
        self.SetTitle("Finder")
        self.text_object_type_choice.SetSelection(0)
        self.text_field_choice.SetSelection(0)
        self.text_operator_choice.SetSelection(0)
        self.io_connection_type_choice.SetSelection(0)
        self.input_output_choice.SetSelection(0)
        self.io_object_type_choice.SetSelection(0)
        self.Find.SetDefault()
        # end wxGlade
    
    
    def __do_layout(self):
        # begin wxGlade: Finder.__do_layout
        main_sizer = wx.BoxSizer(wx.VERTICAL)
        sizer_3 = wx.BoxSizer(wx.HORIZONTAL)
        sizer_5 = wx.BoxSizer(wx.VERTICAL)
        grid_sizer_2 = wx.FlexGridSizer(3, 2, 0, 0)
        sizer_4 = wx.BoxSizer(wx.VERTICAL)
        grid_sizer_1 = wx.FlexGridSizer(3, 2, 0, 0)
        grid_sizer_1.Add(self.label_2, 0, wx.ALL|wx.ALIGN_RIGHT, 4)
        grid_sizer_1.Add(self.text_object_type_choice, 0, wx.ALL, 4)
        grid_sizer_1.Add(self.label_3, 0, wx.ALL|wx.ALIGN_RIGHT, 4)
        grid_sizer_1.Add(self.text_field_choice, 0, wx.ALL, 4)
        grid_sizer_1.Add(self.text_operator_choice, 0, wx.ALL|wx.ALIGN_RIGHT, 4)
        grid_sizer_1.Add(self.find_text, 0, wx.ALL|wx.EXPAND, 4)
        grid_sizer_1.AddGrowableCol(1)
        sizer_4.Add(grid_sizer_1, 0, wx.ALL|wx.EXPAND, 4)
        self.find_by_text_panel.SetSizer(sizer_4)
        grid_sizer_2.Add(self.label_4, 0, wx.ALL|wx.ALIGN_RIGHT, 4)
        grid_sizer_2.Add(self.io_connection_type_choice, 0, wx.ALL, 4)
        grid_sizer_2.Add(self.label_5, 0, wx.ALL|wx.ALIGN_RIGHT, 4)
        grid_sizer_2.Add(self.input_output_choice, 0, wx.ALL, 4)
        grid_sizer_2.Add(self.io_object_type_choice, 0, wx.ALL, 4)
        grid_sizer_2.Add(self.io_object_choice, 0, wx.ALL, 4)
        sizer_5.Add(grid_sizer_2, 1, wx.ALL|wx.EXPAND, 4)
        self.find_by_io_panel.SetSizer(sizer_5)
        self.notebook.AddPage(self.find_by_text_panel, "Find by Text")
        self.notebook.AddPage(self.find_by_io_panel, "Find by I/O")
        main_sizer.Add(self.notebook, 1, wx.ALL|wx.EXPAND, 10)
        sizer_3.Add(self.Cancel, 0, wx.ALL, 5)
        sizer_3.Add(self.Find, 0, wx.ALL, 5)
        main_sizer.Add(sizer_3, 0, wx.ALIGN_RIGHT, 4)
        main_sizer.Add((20, 10), 0, wx.EXPAND|wx.ALIGN_CENTER_HORIZONTAL, 0)
        self.SetSizer(main_sizer)
        main_sizer.Fit(self)
        self.Layout()
        # end wxGlade
    
    
    def on_io_object_type_change(self, event): # wxGlade: Finder.<event_handler>
        self.io_object_choice.Clear()
        typeChoice = self.io_object_type_choice.GetSelection()
        if typeChoice == 0:
            objects = self.display.network.objectsOfClass(network.region.Region)
            altName = gettext('<unnamed region>')
        elif typeChoice == 1:
            objects = self.display.network.objectsOfClass(network.neuron.Neuron)
            altName = gettext('<unnamed neuron>')
        elif typeChoice == 2:
            objects = self.display.network.objectsOfClass(network.muscle.Muscle)
            altName = gettext('<unnamed muscle>')
        else:
            objects = []
        objects.sort(key=lambda object: (object.name or altName).upper())
        for object in objects:
            self.io_object_choice.Append(object.name or altName, object)
        self.io_object_choice.SetSelection(0)
        if event != None:
            event.Skip()
    
    
    def on_find(self, event_): # wxGlade: Finder.<event_handler>
        self.predicate = CompoundPredicate()
        
        if self.notebook.GetCurrentPage() == self.find_by_text_panel:
            if self.text_object_type_choice.GetCurrentSelection() == 1:
                self.predicate.addStatement(lambda x: x.__class__ == network.region.Region)
            elif self.text_object_type_choice.GetCurrentSelection() == 2:
                self.predicate.addStatement(lambda x: x.__class__ == network.pathway.Pathway)
            elif self.text_object_type_choice.GetCurrentSelection() == 3:
                self.predicate.addStatement(lambda x: x.__class__ == network.neuron.Neuron)
            elif self.text_object_type_choice.GetCurrentSelection() == 4:
                self.predicate.addStatement(lambda x: x.__class__ == network.neurite.Neurite)
            elif self.text_object_type_choice.GetCurrentSelection() == 5:
                self.predicate.addStatement(lambda x: x.__class__ == network.synapse.Synapse)
            elif self.text_object_type_choice.GetCurrentSelection() == 6:
                self.predicate.addStatement(lambda x: x.__class__ == network.gap_junction.GapJunction)
            elif self.text_object_type_choice.GetCurrentSelection() == 7:
                self.predicate.addStatement(lambda x: x.__class__ == network.muscle.Muscle)
            elif self.text_object_type_choice.GetCurrentSelection() == 8:
                self.predicate.addStatement(lambda x: x.__class__ == network.arborization.Arborization)
            elif self.text_object_type_choice.GetCurrentSelection() == 9:
                self.predicate.addStatement(lambda x: x.__class__ == network.innervation.Innervation)
            elif self.text_object_type_choice.GetCurrentSelection() == 10:
                self.predicate.addStatement(lambda x: x.__class__ == network.stimulus.Stimulus)
            
            findText = self.find_text.GetValue().upper()
            if self.text_operator_choice.GetCurrentSelection() == 0:
                namePredicate = Predicate(lambda x: (x.name is None and findText == '') or (x.name != None and x.name.upper().find(findText) != -1))
                abbreviationPredicate = Predicate(lambda x: (x.abbreviation is None and findText == '') or (x.abbreviation != None and x.abbreviation.upper().find(self.find_text.GetValue().upper()) != -1))
            elif self.text_operator_choice.GetCurrentSelection() == 1:
                namePredicate = Predicate(lambda x: x.name != None and x.name.upper().startswith(findText))
                abbreviationPredicate = Predicate(lambda x: x.abbreviation != None and x.abbreviation.upper().startswith(self.find_text.GetValue().upper()))
            elif self.text_operator_choice.GetCurrentSelection() == 2:
                namePredicate = Predicate(lambda x: x.name != None and x.name.upper().endswith(findText))
                abbreviationPredicate = Predicate(lambda x: x.abbreviation != None and x.abbreviation.upper().endswith(findText))
            if self.text_field_choice.GetCurrentSelection() == 0:   # name or abbreviation
                fieldPredicate = CompoundPredicate()
                fieldPredicate.matchAll = False
                fieldPredicate.predicates.append(namePredicate)
                fieldPredicate.predicates.append(abbreviationPredicate)
                self.predicate.predicates.append(fieldPredicate)
            elif self.text_field_choice.GetCurrentSelection() == 1: # just name
                self.predicate.predicates.append(namePredicate)
            elif self.text_field_choice.GetCurrentSelection() == 2: # just abbreviation
                self.predicate.predicates.append(abbreviationPredicate)
        elif self.notebook.GetCurrentPage() == self.find_by_io_panel:
            if self.io_connection_type_choice.GetCurrentSelection() == 1:
                self.predicate.addStatement(lambda x: x.__class__ == network.pathway.Pathway)
            elif self.text_object_type_choice.GetCurrentSelection() == 2:
                self.predicate.addStatement(lambda x: x.__class__ == network.neuron.Neuron)
            
            sourceObject = self.io_object_choice.GetClientData(self.io_object_choice.GetCurrentSelection())
            inputs = sourceObject.inputs()
            outputs = sourceObject.outputs()
            if self.input_output_choice.GetCurrentSelection() == 0:   # just send
                self.predicate.addStatement(lambda x: x in inputs)
            elif self.input_output_choice.GetCurrentSelection() == 1:   # just receive
                self.predicate.addStatement(lambda x: x in outputs)
            elif self.input_output_choice.GetCurrentSelection() == 2:   # send or receive
                self.predicate.addStatement(lambda x: x in inputs or x in outputs)
            
        self.EndModal(wx.ID_OK)
コード例 #3
0
ファイル: finder.py プロジェクト: mthunemann/Neuroptikon
    def on_find(self, event_):  # wxGlade: Finder.<event_handler>
        self.predicate = CompoundPredicate()

        if self.notebook.GetCurrentPage() == self.find_by_text_panel:
            if self.text_object_type_choice.GetCurrentSelection() == 1:
                self.predicate.addStatement(
                    lambda x: x.__class__ == network.region.Region)
            elif self.text_object_type_choice.GetCurrentSelection() == 2:
                self.predicate.addStatement(
                    lambda x: x.__class__ == network.pathway.Pathway)
            elif self.text_object_type_choice.GetCurrentSelection() == 3:
                self.predicate.addStatement(
                    lambda x: x.__class__ == network.neuron.Neuron)
            elif self.text_object_type_choice.GetCurrentSelection() == 4:
                self.predicate.addStatement(
                    lambda x: x.__class__ == network.neurite.Neurite)
            elif self.text_object_type_choice.GetCurrentSelection() == 5:
                self.predicate.addStatement(
                    lambda x: x.__class__ == network.synapse.Synapse)
            elif self.text_object_type_choice.GetCurrentSelection() == 6:
                self.predicate.addStatement(
                    lambda x: x.__class__ == network.gap_junction.GapJunction)
            elif self.text_object_type_choice.GetCurrentSelection() == 7:
                self.predicate.addStatement(
                    lambda x: x.__class__ == network.muscle.Muscle)
            elif self.text_object_type_choice.GetCurrentSelection() == 8:
                self.predicate.addStatement(
                    lambda x: x.__class__ == network.arborization.Arborization)
            elif self.text_object_type_choice.GetCurrentSelection() == 9:
                self.predicate.addStatement(
                    lambda x: x.__class__ == network.innervation.Innervation)
            elif self.text_object_type_choice.GetCurrentSelection() == 10:
                self.predicate.addStatement(
                    lambda x: x.__class__ == network.stimulus.Stimulus)

            findText = self.find_text.GetValue().upper()
            if self.text_operator_choice.GetCurrentSelection() == 0:
                namePredicate = Predicate(
                    lambda x: (x.name is None and findText == '') or
                    (x.name != None and x.name.upper().find(findText) != -1))
                abbreviationPredicate = Predicate(
                    lambda x: (x.abbreviation is None and findText == '') or
                    (x.abbreviation != None and x.abbreviation.upper().find(
                        self.find_text.GetValue().upper()) != -1))
            elif self.text_operator_choice.GetCurrentSelection() == 1:
                namePredicate = Predicate(lambda x: x.name != None and x.name.
                                          upper().startswith(findText))
                abbreviationPredicate = Predicate(
                    lambda x: x.abbreviation != None and x.abbreviation.upper(
                    ).startswith(self.find_text.GetValue().upper()))
            elif self.text_operator_choice.GetCurrentSelection() == 2:
                namePredicate = Predicate(lambda x: x.name != None and x.name.
                                          upper().endswith(findText))
                abbreviationPredicate = Predicate(
                    lambda x: x.abbreviation != None and x.abbreviation.upper(
                    ).endswith(findText))
            if self.text_field_choice.GetCurrentSelection(
            ) == 0:  # name or abbreviation
                fieldPredicate = CompoundPredicate()
                fieldPredicate.matchAll = False
                fieldPredicate.predicates.append(namePredicate)
                fieldPredicate.predicates.append(abbreviationPredicate)
                self.predicate.predicates.append(fieldPredicate)
            elif self.text_field_choice.GetCurrentSelection(
            ) == 1:  # just name
                self.predicate.predicates.append(namePredicate)
            elif self.text_field_choice.GetCurrentSelection(
            ) == 2:  # just abbreviation
                self.predicate.predicates.append(abbreviationPredicate)
        elif self.notebook.GetCurrentPage() == self.find_by_io_panel:
            if self.io_connection_type_choice.GetCurrentSelection() == 1:
                self.predicate.addStatement(
                    lambda x: x.__class__ == network.pathway.Pathway)
            elif self.text_object_type_choice.GetCurrentSelection() == 2:
                self.predicate.addStatement(
                    lambda x: x.__class__ == network.neuron.Neuron)

            sourceObject = self.io_object_choice.GetClientData(
                self.io_object_choice.GetCurrentSelection())
            inputs = sourceObject.inputs()
            outputs = sourceObject.outputs()
            if self.input_output_choice.GetCurrentSelection(
            ) == 0:  # just send
                self.predicate.addStatement(lambda x: x in inputs)
            elif self.input_output_choice.GetCurrentSelection(
            ) == 1:  # just receive
                self.predicate.addStatement(lambda x: x in outputs)
            elif self.input_output_choice.GetCurrentSelection(
            ) == 2:  # send or receive
                self.predicate.addStatement(
                    lambda x: x in inputs or x in outputs)

        self.EndModal(wx.ID_OK)
コード例 #4
0
ファイル: finder.py プロジェクト: JaneliaSciComp/Neuroptikon
 def on_find(self, event_): # wxGlade: Finder.<event_handler>
     self.predicate = CompoundPredicate()
     
     if self.notebook.GetCurrentPage() == self.find_by_text_panel:
         if self.text_object_type_choice.GetCurrentSelection() == 1:
             self.predicate.addStatement(lambda x: x.__class__ == network.region.Region)
         elif self.text_object_type_choice.GetCurrentSelection() == 2:
             self.predicate.addStatement(lambda x: x.__class__ == network.pathway.Pathway)
         elif self.text_object_type_choice.GetCurrentSelection() == 3:
             self.predicate.addStatement(lambda x: x.__class__ == network.neuron.Neuron)
         elif self.text_object_type_choice.GetCurrentSelection() == 4:
             self.predicate.addStatement(lambda x: x.__class__ == network.neurite.Neurite)
         elif self.text_object_type_choice.GetCurrentSelection() == 5:
             self.predicate.addStatement(lambda x: x.__class__ == network.synapse.Synapse)
         elif self.text_object_type_choice.GetCurrentSelection() == 6:
             self.predicate.addStatement(lambda x: x.__class__ == network.gap_junction.GapJunction)
         elif self.text_object_type_choice.GetCurrentSelection() == 7:
             self.predicate.addStatement(lambda x: x.__class__ == network.muscle.Muscle)
         elif self.text_object_type_choice.GetCurrentSelection() == 8:
             self.predicate.addStatement(lambda x: x.__class__ == network.arborization.Arborization)
         elif self.text_object_type_choice.GetCurrentSelection() == 9:
             self.predicate.addStatement(lambda x: x.__class__ == network.innervation.Innervation)
         elif self.text_object_type_choice.GetCurrentSelection() == 10:
             self.predicate.addStatement(lambda x: x.__class__ == network.stimulus.Stimulus)
         
         findText = self.find_text.GetValue().upper()
         if self.text_operator_choice.GetCurrentSelection() == 0:
             namePredicate = Predicate(lambda x: (x.name is None and findText == '') or (x.name != None and x.name.upper().find(findText) != -1))
             abbreviationPredicate = Predicate(lambda x: (x.abbreviation is None and findText == '') or (x.abbreviation != None and x.abbreviation.upper().find(self.find_text.GetValue().upper()) != -1))
         elif self.text_operator_choice.GetCurrentSelection() == 1:
             namePredicate = Predicate(lambda x: x.name != None and x.name.upper().startswith(findText))
             abbreviationPredicate = Predicate(lambda x: x.abbreviation != None and x.abbreviation.upper().startswith(self.find_text.GetValue().upper()))
         elif self.text_operator_choice.GetCurrentSelection() == 2:
             namePredicate = Predicate(lambda x: x.name != None and x.name.upper().endswith(findText))
             abbreviationPredicate = Predicate(lambda x: x.abbreviation != None and x.abbreviation.upper().endswith(findText))
         if self.text_field_choice.GetCurrentSelection() == 0:   # name or abbreviation
             fieldPredicate = CompoundPredicate()
             fieldPredicate.matchAll = False
             fieldPredicate.predicates.append(namePredicate)
             fieldPredicate.predicates.append(abbreviationPredicate)
             self.predicate.predicates.append(fieldPredicate)
         elif self.text_field_choice.GetCurrentSelection() == 1: # just name
             self.predicate.predicates.append(namePredicate)
         elif self.text_field_choice.GetCurrentSelection() == 2: # just abbreviation
             self.predicate.predicates.append(abbreviationPredicate)
     elif self.notebook.GetCurrentPage() == self.find_by_io_panel:
         if self.io_connection_type_choice.GetCurrentSelection() == 1:
             self.predicate.addStatement(lambda x: x.__class__ == network.pathway.Pathway)
         elif self.text_object_type_choice.GetCurrentSelection() == 2:
             self.predicate.addStatement(lambda x: x.__class__ == network.neuron.Neuron)
         
         sourceObject = self.io_object_choice.GetClientData(self.io_object_choice.GetCurrentSelection())
         inputs = sourceObject.inputs()
         outputs = sourceObject.outputs()
         if self.input_output_choice.GetCurrentSelection() == 0:   # just send
             self.predicate.addStatement(lambda x: x in inputs)
         elif self.input_output_choice.GetCurrentSelection() == 1:   # just receive
             self.predicate.addStatement(lambda x: x in outputs)
         elif self.input_output_choice.GetCurrentSelection() == 2:   # send or receive
             self.predicate.addStatement(lambda x: x in inputs or x in outputs)
         
     self.EndModal(wx.ID_OK)