Ejemplo n.º 1
0
 def set_new_view(self, input_exp):
     if Fractal.is_working:
         return
     try:
         Fractal(ShowPanel.parent, input_exp)
     except Exception as e:
         error_content = '{}\n{}\n{}\n{}'.format(YOUR_EXP, input_exp,
                                                 HAS_ERR, e.args[0])
         ShowPanel.errDialog(error_content)
         StatusPanel.set_status(ERR_INVALID_EXP, StatusPanel.INFO_ERROR)
         return None
     ShowPanel.exp = input_exp
     info = self.__history[0]
     self.__history.clear()
     self.refresh_view(info.shiftx, info.shifty, info.rx, info.ry, True)
Ejemplo n.º 2
0
 def refresh_hist_view(self, is_record):
     if ShowPanel.rect is None:
         ShowPanel.rect = Rectangle(0, 0, PIC_WIDTH, PIC_HEIGHT)
     info = self.__history[-1]
     shiftx = info.shiftx - info.rx / PIC_WIDTH * int(
         PIC_WIDTH // 2 - ShowPanel.rect.x -
         ShowPanel.rect.width // 2) * 2 * (-1 if ShowPanel.is_moving else 1)
     shifty = info.shifty - info.ry / PIC_HEIGHT * int(
         PIC_HEIGHT // 2 - ShowPanel.rect.y - ShowPanel.rect.height //
         2) * 2 * (-1 if ShowPanel.is_moving else 1)
     rx = info.rx / (PIC_WIDTH / ShowPanel.rect.width)
     ry = info.ry / (PIC_HEIGHT / ShowPanel.rect.height)
     if rx < 1e-10 or ry < 1e-10:
         StatusPanel.set_status(ERR_TOO_LARGE_SCALE, StatusPanel.INFO_ERROR)
         return
     self.refresh_view(shiftx, shifty, rx, ry, is_record)
Ejemplo n.º 3
0
 def update_status(self, w0, w1):
     if w0 == FINISHED_SIG or w1 == FINISHED_SIG:
         progress = FINISHED_SIG
     else:
         progress = w0 + w1
     Fractal.pic = QPixmap(PIC_WIDTH, PIC_HEIGHT)
     painter = QPainter()
     painter.begin(Fractal.pic)
     painter.drawPixmap(0, 0, PIC_WIDTH, PIC_HEIGHT // 2, self.pic0)
     painter.drawPixmap(0, PIC_HEIGHT // 2, PIC_WIDTH, PIC_HEIGHT // 2,
                        self.pic1)
     if FractalThread.workers[0] != FINISHED_SIG or FractalThread.workers[
             1] != FINISHED_SIG:
         h0 = PIC_WIDTH / 2 if w0 == FINISHED_SIG else w0 + 1
         h1 = PIC_WIDTH / 2 if w1 == FINISHED_SIG else (PIC_HEIGHT - w1) - 1
         try:
             painter.setPen(QPen(COLOR_UPDATE_LINE, WIDTH_UPDATE_LINE))
         except Exception as e:
             print(e)
         painter.drawLine(0, h0, PIC_WIDTH, h0)
         painter.drawLine(0, h1, PIC_WIDTH, h1)
     painter.end()
     self.__root.update_pic(Fractal.pic)
     if progress != FINISHED_SIG:
         StatusPanel.set_status(
             '{:.2f}%'.format(progress * 100 / PIC_HEIGHT),
             StatusPanel.INFO_PROCESS)
     else:
         if FractalThread.workers[
                 0] != FINISHED_SIG or FractalThread.workers[
                     1] != FINISHED_SIG:
             return
         # Both workers are finished
         StatusPanel.set_status(time.clock() - self.t,
                                StatusPanel.INFO_SUCCESS)
         Fractal.is_working = False