Example #1
0
 def start_calculation(self, zoom_protozoon):
     """Start rendering of protozoon."""
     self._protozoon = zoom_protozoon
     if self._protozoon is not None:
         widget = self._widget_list.get_widget('zoomarea')
         task = ka_task.GeneratorTask(self.task_render,
                                      self.on_zoom_completed, 'zoomarea')
         task.start(self._protozoon, -1, widget.allocation.width,
                    widget.allocation.height)
Example #2
0
 def start_calculation(self, protozoon):
     """Start explaining of a protozoon.
     pre: protozoon is not None
     """
     #        ka_debug.info('DetailsController.start_calculation %s' %
     #                                                   (protozoon.get_unique_id()))
     task = ka_task.GeneratorTask(self.task_explain,
                                  self.on_explain_completed, 'explain')
     task.start(protozoon)
Example #3
0
 def on_awfull_activate(self, *args):
     """Set last ranking for this protozoon.
     pre: len(args) >= 1
     """
     #        ka_debug.info('on_awfull_activate [%s]' % args[0].get_name())
     index = ka_controller.name_to_index(args[0].get_name())
     self.model.reduce_fitness(index)
     self._update_population_gui()
     ka_task.GeneratorTask(self.task_breed_single, self.on_model_completed,
                           args[0].get_name()).start(index)
Example #4
0
    def on_random_generation(self, *args):
        if ka_task.GeneratorTask.is_completed():
            #            ka_debug.info('on_random_generation entry')
            self._gencount += 1
            ka_task.GeneratorTask(self.task_random_generation,
                                  self.on_model_completed,
                                  'random_' + str(self._gencount)).start()
#            ka_debug.info('on_random_generation exit')
        else:
            ka_debug.info('on_random_generation ignored')
Example #5
0
 def start_calculation(self, concerned):
     """
     pre: len(concerned) > 0
     pre: forall(concerned, lambda x: 0 <= x <= self.model.size)
     """
     for cell_index in concerned:
         widget_name = 'drawingarea_' + str(cell_index)
         widget = self._widget_list.get_widget(widget_name)
         task = ka_task.GeneratorTask(self.task_render,
                                      self.on_image_completed, widget_name)
         task.start(self.model.protozoans[cell_index], cell_index,
                    widget.allocation.width, widget.allocation.height)
 def export(self, width, height):
     """
     pre: width > 0
     pre: height > 0
     pre: width == height
     """
     task = ka_task.GeneratorTask(
         self.task_render, self.on_render_completed,
         'export_png' + self._protozoon.get_unique_id())
     task.start(self._protozoon, -1, width, height)
     ka_debug.info('export: start_calculation %ux%u for %s' %
                   (width, height, self._protozoon.get_unique_id()))
 def append_protozoon(self, incoming_protozoon):
     """ Append incoming protozoon and manage capacity.
     pre: incoming_protozoon is not None
     """
     #        ka_debug.info('incoming: append protozoon')
     while len(self.incoming_protozoans) >= self._capacity:
         iid = self.incoming_id[0]
         del self.incoming_id[0]
         del self.incoming_protozoans[iid]
         if self.incoming_surface_cache.has_key(iid):
             del self.incoming_surface_cache[iid]
     KandidIncoming.ids += 1
     self.incoming_id.append(KandidIncoming.ids)
     self.incoming_protozoans[KandidIncoming.ids] = incoming_protozoon
     index = len(self.incoming_id) - 1
     widget_name = 'incomingarea_' + str(index)
     widget = self._widget_list.get_widget(widget_name)
     task = ka_task.GeneratorTask(self.task_render, self.on_image_completed,
                                  widget_name)
     task.start(incoming_protozoon, KandidIncoming.ids,
                widget.allocation.width, widget.allocation.height)