Пример #1
0
	def updateText( self, novo, canvas ):
		desenho = qGMDraw.qGMDraw()
		for indice in self.shapesall:
			if indice.gettipo( ) == "texto":
				indice.Select( 0 ) # Desmarca o desenho
				canvas.diagram.RemoveShape( indice ) # Remove desenho do diagrama
				self.shapesall.remove( indice ) # Remove desenho da lista
				
				texto = Texto.Texto( 30, 22, novo )
				desenho.Draw2( texto, self.objeto.GetX( ) + 23, self.objeto.GetY( ) - self.objeto.gettamy( ) / 2 - 20, canvas )
				self.shapesall.append( texto )
				canvas.Refresh( )
Пример #2
0
 def CriaIterativo(self, processo, canvas=None):
     lista = []
     subprocessos = processo.childNodes
     for indice in range(subprocessos.length):
         if subprocessos.item(indice).nodeName != "#text":  # "#text" e a parte de dados do XML
             if subprocessos.item(indice).getAttribute("repr") == "env":
                 shape = self.CriaEnvelope(subprocessos.item(indice), canvas)
             elif subprocessos.item(indice).getAttribute("repr") == "iterativo":
                 shape = self.CriaIterativo(subprocessos.item(indice), canvas)
             else:
                 shape = self.CriaProcessos(subprocessos.item(indice), canvas)
             lista.append(shape)
     quantidade = processo.getAttribute("range").split(":")
     acao = processo.getAttribute("acao")
     x = processo.getAttribute("x")
     y = processo.getAttribute("y")
     if len(lista) != 1:
         return None
     shape = Iteracao.Iteracao(lista[0], quantidade[1].encode(), acao, canvas)
     desenho = qGMDraw.qGMDraw()
     desenho.Draw2(shape, float(x), float(y), canvas)
     return shape
Пример #3
0
	def CriaPP(self, operations):
		funcoes = qGMFunc.qGMFunc()
		desenho = qGMDraw.qGMDraw()
		position = [1, 1]
		lista = []
		parametro = ""
		
		for pos in range ((2**self.qubits)):
			shape = ConsElem.ConsElem( str(self.qubits), operations, str(pos), "BLACK", position[0], position[1], self.parent.rightwin )	
			shape.setParametro( parametro )
			desenho.Draw2( shape, position[0], position[1], self.parent.rightwin )
			lista.append(shape)


		while (len(lista) != 1):
			envs = []
			for indice in range (0,len(lista),2):
				objs = [lista[indice], lista[indice + 1]]
				
				envs.append (funcoes.CriaPP( objs, self.parent.rightwin ))
			lista = envs
		
		return lista[0]
Пример #4
0
    def Sequencial(self, objs, canvas):  #### Pega a lista de objetos e cria um processo sequencial ####
        # objs = lista de objetos utilizados na construção do processo
        # canvas = referência do canvas onde será inserido o objeto

        # Verificação se existe algum teste determinístico depois de alguma soma não-determinística. Se houver não deve deixar construir
        qGMFunc.exinondet = 0  # Variável que informa se já foi encontrado um não-determinismo entre os objetos
        qGMFunc.exisomdet = (
            0
        )  # Variável que informa se já foi encontrado uma soma determinística depois de um não-determinismo
        resp = self.procuraSomDetposNonDet(objs)
        if resp == True:
            msg = wx.MessageDialog(
                canvas,
                qGMFunc.translate.translateById("ps_nd_error1")
                + "\n\n"
                + qGMFunc.translate.translateById("ps_nd_error2"),
                qGMFunc.translate.translateById("error"),
                wx.OK | wx.ICON_HAND,
            )
            msg.ShowModal()
            msg.Destroy()
            return None

            # Verifica o tipo dos itens envolvidos
        testeterm = 0
        for indice in objs:
            # print indice.gettipo()
            if indice.gettipo() == "terminicio" or indice.gettipo() == "termfim":
                testeterm = 1  # Informa que existem um terminador na lista de objetos
            if indice.gettipo() == "envelope":
                tmp = indice.verificahasTerm()  # Procura a ocorrência de terminadores no envelope
                if tmp == True:  # Se tiver algum terminador dentro de um envelope já não realiza a operação
                    msg = wx.MessageDialog(
                        canvas,
                        qGMFunc.translate.translateById("ps_error"),
                        qGMFunc.translate.translateById("error"),
                        wx.OK | wx.ICON_HAND,
                    )
                    msg.ShowModal()
                    msg.Destroy()
                    return None
        if len(objs) == 3 and testeterm == 1:
            if (
                objs[0].gettipo() == "terminicio"
                and (
                    objs[1].gettipo() == "conselem"
                    or objs[1].gettipo() == "projection"
                    or objs[1].gettipo() == "envelope"
                    or objs[1].gettipo() == "iterativo"
                    or objs[1].gettipo() == "recursivo"
                    or objs[1].gettipo() == "macro"
                )
                and objs[2].gettipo() == "termfim"
            ):
                testeterm = 2  # Teste é igual a 2 se existir os dois terminadores e estiverem na posição correta
        if testeterm == 1:  # Se o teste for 1 é porque existe um terminador mas não estão na ordem correta
            msg = wx.MessageDialog(
                canvas,
                qGMFunc.translate.translateById("ps_order_error"),
                qGMFunc.translate.translateById("error"),
                wx.OK | wx.ICON_HAND,
            )
            msg.ShowModal()
            msg.Destroy()
            return None
            # Verificação se existe mais de um objeto para realizar o produto sequencial
            # se tiver menos que um a função é abortada
        if len(objs) <= 1:
            return None
        else:
            for objeto in objs:
                # Verifica se existe algum objeto diferente desses na lista dos objetos
                # So aceitará os objetos relacionados abaixo
                if (
                    objeto.gettipo() != "conselem"
                    and objeto.gettipo() != "partquantum"
                    and objeto.gettipo() != "projection"
                    and objeto.gettipo() != "envelope"
                    and objeto.gettipo() != "macro"
                    and objeto.gettipo() != "iterativo"
                    and objeto.gettipo() != "probability"
                    and objeto.gettipo() != "recursivo"
                    and objeto.gettipo() != "terminicio"
                    and objeto.gettipo() != "termfim"
                ):
                    return None
            tamx = 0  # tamanho x do envelope
            tamy = 0  # tamanho y do envelope
            posicoes = []
            posic = []
            referencial = []
            if canvas != None:
                # Realizado para aumentar o espaço entre dois processos
                # Para que possa caber a representação da repetição
                contador = 0  # Contador de quantas vezes ocorreu dois objetos juntos com repetição
                for indice in range(len(objs)):
                    if indice == 0:
                        objs[indice].SetX(objs[indice].GetX())
                    elif objs[indice].gettipo() == "envelope" and objs[indice - 1].gettipo() == "envelope":
                        if objs[indice].getrepr() == "recursivo" and objs[indice - 1].getrepr() == "recursivo":
                            contador = contador + 1  # Ocorrência de dois objetos juntos com repetição
                            objs[indice].SetX(
                                objs[indice - 1].GetX() + objs[indice - 1].gettamx() / 2 + objs[indice].gettamx() / 2
                            )
                        else:
                            objs[indice].SetX(
                                objs[indice - 1].GetX()
                                + objs[indice - 1].gettamx() / 2
                                + objs[indice].gettamx() / 2
                                - 10
                            )
                    else:
                        objs[indice].SetX(
                            objs[indice - 1].GetX() + objs[indice - 1].gettamx() / 2 + objs[indice].gettamx() / 2 - 10
                        )

                        # Parte da função para ajustar o posicionamento dos processos
                for indice in range(len(objs)):
                    if tamx == 0 and tamy == 0:
                        tamx = objs[indice].gettamx()
                        tamy = objs[indice].gettamy()
                    else:
                        difx = (
                            objs[indice - 1].GetX() + objs[indice - 1].gettamx() / 2 + objs[indice].gettamx() / 2 - 10
                        ) - (
                            objs[indice].GetX()
                        )  # Define diferença entre um objeto e outro (x)
                        dify = (objs[indice - 1].GetY()) - (
                            objs[indice].GetY()
                        )  # Define diferença entre um objeto e outro (y)
                        if (
                            objs[indice].gettipo() == "envelope" or objs[indice].gettipo() == "iterativo"
                        ):  # Se for um envelope, move todos objetos internos
                            objs[indice].onmove(difx, dify)
                        objs[indice].SetY(objs[indice - 1].GetY())

                        tamx = tamx + objs[indice].gettamx()
                        if tamy < objs[indice].gettamy():
                            tamy = objs[indice].gettamy()
                    if objs[indice].gettipo() == "conselem" or objs[indice].gettipo() == "projection":
                        posicoes.append([objs[indice].getposicao()])
                    elif objs[indice].gettipo() == "terminicio" or objs[indice].gettipo() == "termfim":
                        pass  # Se for terminadores eles não tem posição então não faz nada aqui
                    elif objs[indice].gettipo() not in [
                        "probability",
                        "macro",
                        "iterativo",
                    ]:  # Se for um envelope, iterativo ou recursivo
                        posicoes.append(objs[indice].getposicao())

                if testeterm == 2:
                    objs[0].SetX(objs[0].GetX() - 12)
                    objs[2].SetX(objs[2].GetX() + 10)

                    # Função para Criar Envelope
                tamx = tamx - (len(objs) - 1) * 10  # Ajustes no tamanho x do envelope
                tamx = tamx + contador * 10  # Ajusta o número de objetos com repetição que estão juntos
                if testeterm == 2:
                    tamx = (
                        tamx + 22
                    )  # Valor aumentado nas linhas acima para distanciar os terminadores do processo do meio
                posic = []  # Para informar as posições afetadas pelo processo
                posic = self.Posic(posicoes)

                # Informa Referenciais, utilizado para ajustar a posição dos objetos durante a utilização do programa
                referencial = []
                for indice in objs:
                    if (
                        indice.gettipo() == "envelope"
                        or indice.gettipo() == "iterativo"
                        or indice.gettipo() == "recursivo"
                        or indice.gettipo() == "conselem"
                        or indice.gettipo() == "projection"
                        or indice.gettipo() == "probability"
                    ):
                        indice.ajuste(indice.GetX(), indice.GetY())  # Ajusta envelopes na criação de outros objetos
                    ref = []
                    ref.append(indice.GetX() - objs[0].GetX() + (objs[0].gettamx() / 2) - (tamx / 2))
                    ref.append(indice.GetY() - objs[0].GetY())
                    referencial.append(ref)
                    # Fim Informa Referenciais

            env = Envelope.Envelope(tamx, tamy, objs, posic, "seq", referencial)  # Criação do Envelope
            if canvas != None:
                desenho = qGMDraw.qGMDraw()
                desenho.Draw2(env, objs[0].GetX() - (objs[0].gettamx() / 2) + (tamx / 2), objs[0].GetY(), canvas)
                # Função para informar aos processos filhos quem é seu processo pai
                env.setFilhos()
                # Fim Função para Criar Envelope
            return env
Пример #5
0
    def CriaPP(self, objs, canvas):  ####Cria Produto Paralelo ####
        # canvas = Referência do canvas onde será inserido o objeto
        posicoes = []
        for indice in objs:  #### Não aceita objetos de soma determinística ####
            if (
                indice.gettipo() == "somdet"
                or indice.gettipo() == "universal"
                or indice.gettipo() == "existencial"
                or indice.gettipo() == "terminicio"
                or indice.gettipo() == "termfim"
            ):
                msg = wx.MessageDialog(
                    canvas,
                    qGMFunc.translate.translateById("wrong_pp_items"),
                    qGMFunc.translate.translateById("error"),
                    wx.OK | wx.ICON_HAND,
                )
                msg.ShowModal()
                msg.Destroy()
                return "Erro"

                # Verifica se existem terminadores entre os processos que irão compor o paralelo
        testeterm = 0
        for indice in objs:
            if indice.gettipo() == "terminicio" or indice.gettipo() == "termfim":
                testeterm = 1  # Informa que existem um terminador na lista de objetos
            if indice.gettipo() == "envelope":
                tmp = indice.verificahasTerm()  # Procura a ocorrência de terminadores no envelope
                if tmp == True:  # Se tiver algum terminador dentro de um envelope já não realiza a operação
                    testeterm = 1
            if testeterm == 1:
                msg = wx.MessageDialog(
                    canvas,
                    qGMFunc.translate.translateById("par_error2"),
                    qGMFunc.translate.translateById("error"),
                    wx.OK | wx.ICON_HAND,
                )
                msg.ShowModal()
                msg.Destroy()
                return None

        list = []  #### Lista dos Objetos dentro do PP ####
        if len(objs) != 0:
            listtmp = []
            for indice in objs:
                listtmp.append(indice)
            list.append(listtmp)
            #### Teste de Conflito de Memória ####
            for indice in list:  #### Passa para posições o valor da posição de cada item de list ####
                #### Ex: [ ['k', 'k'] , ['l' , 'l'], ['g', 'g'] ] ####
                for indice2 in indice:
                    if indice2.gettipo() != "macro" and indice2.gettipo() != "partquantum":
                        pos = indice2.getposicao()
                        if indice2.gettipo() == "conselem" or indice2.gettipo() == "projection":
                            posicoes.append([pos])
                        else:  # Se for um envelope ou uma macro
                            posicoes.append(pos)

                ########################### Cancelar temporariamente o teste de conflito #############################################
            # 			conflito = self.TesteConflito( posicoes ) #### Teste de Conflitos ####
            #
            # 			if conflito == 1: #### Se houver conflito de memória ####
            # 				msg = wx.MessageDialog( canvas, qGMFunc.translate.translateById("pp_memory_conflict"), qGMFunc.translate.translateById("memory_conflict"), wx.OK | wx.ICON_HAND )
            # 				msg.ShowModal( )
            # 				msg.Destroy( )
            # 				return "Erro"
            #################################
            if len(objs) > 1:
                temp = 0  #### temp = tamanho y do objeto ####
                for indice in objs:
                    temp = temp + indice.gettamy()
                esq = Paralelo.ParaleloEsq(len(objs), temp)  #### Construção da parte esquerda do PP ####
                dir = Paralelo.ParaleloDir(len(objs), temp)  #### Construção da parte direita do PP ####
                listbarras = []
                listbarras.append(esq)
                listbarras.append(dir)
                list.insert(0, listbarras)

                maior = self.MaiorObjX(objs)
                desenho = qGMDraw.qGMDraw()
                if canvas != None:
                    if len(objs) % 2 == 0:
                        pos = (len(objs)) / 2 - 1
                        desenho.Draw2(
                            esq,
                            maior.GetX() - maior.gettamx() / 2 - 7,
                            objs[pos].GetY() + objs[0].gettamy() / 2 + 7,
                            canvas,
                        )
                        desenho.Draw2(
                            dir,
                            maior.GetX() + maior.gettamx() / 2 + 7,
                            objs[pos].GetY() + objs[0].gettamy() / 2 + 7,
                            canvas,
                        )
                    else:
                        pos = len(objs) / 2
                        desenho.Draw2(esq, maior.GetX() - maior.gettamx() / 2 - 7, objs[pos].GetY(), canvas)
                        desenho.Draw2(dir, maior.GetX() + maior.gettamx() / 2 + 7, objs[pos].GetY(), canvas)

                posicao = (
                    esq.GetY() - esq.gettamy() / 2 - 10 * (len(objs) - 1)
                )  # 10 * (len(objs)-1) e a margem da extremidade
                for ind in objs:
                    y = ind.GetY()
                    ind.SetY(posicao + ind.gettamy() / 2)
                    posicao = posicao + ind.gettamy() + 20  # 20 e o intervalo entre objetos
                    if ind.gettipo() == "envelope":
                        ind.onmove(0, ind.GetY() - y)
            else:
                return "Erro"

            pos = objs.index(maior)  # Guarda posição do objeto maior
            objs.remove(maior)
            linhas = []
            for ind in objs:  # Cria ligações em objetos menores
                x = ind.GetX()
                ind.SetX(maior.GetX())
                if ind.gettipo() == "envelope":
                    ind.onmove(ind.GetX() - x, 0)
                line = Linhas.Linhas((esq.GetX() + esq.gettamx() / 2), (ind.GetX() - ind.gettamx() / 2))
                line2 = Linhas.Linhas((dir.GetX() - dir.gettamx() / 2), (ind.GetX() + ind.gettamx() / 2))
                if canvas != None:
                    desenho.Draw2(
                        line,
                        ((ind.GetX() - ind.gettamx() / 2) + (esq.GetX() + esq.gettamx() / 2)) / 2,
                        ind.GetY(),
                        canvas,
                    )
                    desenho.Draw2(
                        line2,
                        ((ind.GetX() + ind.gettamx() / 2) + (dir.GetX() - dir.gettamx() / 2)) / 2,
                        ind.GetY(),
                        canvas,
                    )
                linhas.append(line)
                linhas.append(line2)
            objs.insert(pos, maior)

            for ind in objs:  # Deseleciona os objetos
                ind.Select(0)

                ####### Função para criar Envelope ######
            posic = self.Posic(posicoes)
            tamx = maior.gettamx() + 28
            temp = 0
            for indice in objs:
                temp = temp + indice.gettamy()
                ### =  borda    + tamy +  tamanho intervalos ###
            tamy = 10 + 10 + temp + (20 * (len(objs) - 1))

            # Informa Referenciais
            referencial = []
            for indice in objs:
                if (
                    indice.gettipo() == "envelope"
                    or indice.gettipo() == "iterativo"
                    or indice.gettipo() == "recursivo"
                    or indice.gettipo() == "conselem"
                    or indice.gettipo() == "projection"
                    or indice.gettipo() == "somdet"
                    or indice.gettipo() == "universal"
                    or indice.gettipo() == "existencial"
                    or indice.gettipo() == "partquantum"
                ):
                    indice.ajuste(indice.GetX(), indice.GetY())  # Ajusta envelopes na criação de outros objetos
                ref = []
                ref.append(indice.GetX() - esq.GetX() - (tamx / 2) + 7)
                ref.append(indice.GetY() - esq.GetY())
                referencial.append(ref)
            for indice in esq, dir:
                ref = []
                ref.append(indice.GetX() - esq.GetX() - (tamx / 2) + 7)
                ref.append(indice.GetY() - esq.GetY())
                referencial.append(ref)
            for indice in linhas:
                ref = []
                ref.append(indice.GetX() - esq.GetX() - (tamx / 2) + 7)
                ref.append(indice.GetY() - esq.GetY())
                referencial.append(ref)
                # Fim Informa Referenciais
            env = Envelope.Envelope(tamx, tamy, objs + [esq, dir] + linhas, posic, "paralelo", referencial)
            if canvas != None:
                desenho.Draw2(env, (esq.GetX() - 7) + (tamx / 2), esq.GetY(), canvas)
                # Função para informar aos processos filhos quem é o processo pai
            env.setFilhos()
            #######################################
            return env
Пример #6
0
	def Repeticao1( self ): # Cria Objetos Repetição 1
		# Criação das Linhas da Repetição
		# Linha 1:
		x1 = self.objeto.GetX( ) + self.objeto.gettamx( ) / 2 - 5
		x2 = self.objeto.GetX( ) + self.objeto.gettamx( ) / 2 - 5
		y1 = self.objeto.GetY( )
		y2 = self.objeto.GetY( ) - self.objeto.gettamy( ) / 2 - 19
		linha = Linhas.Linhas( x1, x2, y1, y2 )
		desenho = qGMDraw.qGMDraw( )
		desenho.Draw2( linha, x1, y2 + linha.gettamy( ) / 2, self.canvas )
		self.linhas.append( linha )
		
		# Linha 2:
		x1 = self.objeto.GetX( ) + self.objeto.gettamx( ) / 2 - 4
		x2 = self.objeto.GetX( ) + 21
		y1 = self.objeto.GetY( ) - self.objeto.gettamy( ) / 2 - 20
		y2 = self.objeto.GetY( ) - self.objeto.gettamy( ) / 2 - 20
		linha = Linhas.Linhas( x1, x2, y1, y2 )
		desenho.Draw2( linha, x2 + linha.gettamx( ) / 2, y1, self.canvas )
		self.linhas.append( linha )
		
		# Retângulo 3:
		x1 = self.objeto.GetX( ) - 20
		x2 = self.objeto.GetX( ) + 20
		y1 = self.objeto.GetY( ) - self.objeto.gettamy( ) / 2 - 30
		y2 = self.objeto.GetY( ) - self.objeto.gettamy( ) / 2 - 30
		linha = Linhas.Linhas( x1, x2, y1, y2 )
		desenho.Draw2( linha, self.objeto.GetX( ), y1, self.canvas )
		self.linhas.append( linha )
		
		x1 = self.objeto.GetX( ) - 20
		x2 = self.objeto.GetX( ) + 20
		y1 = self.objeto.GetY( ) - self.objeto.gettamy( ) / 2 - 10
		y2 = self.objeto.GetY( ) - self.objeto.gettamy( ) / 2 - 10
		linha = Linhas.Linhas( x1, x2, y1, y2 )
		desenho.Draw2( linha, self.objeto.GetX( ), y1, self.canvas )
		self.linhas.append( linha )
		
		x1 = self.objeto.GetX( ) - 20
		x2 = self.objeto.GetX( ) - 20
		y1 = self.objeto.GetY( ) - self.objeto.gettamy( ) / 2 - 30
		y2 = self.objeto.GetY( ) - self.objeto.gettamy( ) / 2 - 10
		linha = Linhas.Linhas( x1, x2, y1, y2 )
		desenho.Draw2( linha, x1, self.objeto.GetY( ) - self.objeto.gettamy( ) / 2 - 20, self.canvas )
		self.linhas.append( linha )
		
		x1 = self.objeto.GetX( ) + 20
		x2 = self.objeto.GetX( ) + 20
		y1 = self.objeto.GetY( ) - self.objeto.gettamy( ) / 2 - 30
		y2 = self.objeto.GetY( ) - self.objeto.gettamy( ) / 2 - 10
		linha = Linhas.Linhas( x1, x2, y1, y2 )
		desenho.Draw2( linha, x1, self.objeto.GetY( ) - self.objeto.gettamy( ) / 2 - 20, self.canvas )
		self.linhas.append( linha )
		
		# Linha 4:
		x1 = self.objeto.GetX( ) - self.objeto.gettamx( ) / 2 + 5
		x2 = self.objeto.GetX( ) - 19
		y1 = self.objeto.GetY( ) - self.objeto.gettamy( ) / 2 - 20
		y2 = self.objeto.GetY( ) - self.objeto.gettamy( ) /2 - 20
		linha = Linhas.Linhas( x1, x2, y1, y2 )
		desenho.Draw2( linha, x1 + linha.gettamx( ) / 2, y1, self.canvas )
		self.linhas.append( linha )
		
		# Linha 5:
		x1 = self.objeto.GetX( ) - self.objeto.gettamx( ) / 2 + 5
		x2 = self.objeto.GetX( ) - self.objeto.gettamx( ) / 2 + 5
		y1 = self.objeto.GetY( )
		y2 = self.objeto.GetY( ) - self.objeto.gettamy( ) / 2 - 19
		linha = Linhas.Linhas( x1, x2, y1, y2 )
		desenho.Draw2( linha, x1, y2 + linha.gettamy( ) / 2, self.canvas )
		self.linhas.append( linha )
		
		# Linha 6:
		x1 = self.objeto.GetX( ) - self.objeto.gettamx( ) / 2 + 5
		x2 = self.objeto.GetX( ) - self.objeto.gettamx( ) / 2 + 7
		y1 = self.objeto.GetY( )
		y2 = self.objeto.GetY( ) - 10
		linha = Linhas.Linhas( x1, x2, y1, y2 )
		desenho.Draw2( linha, x1 + 2, y1 - linha.gettamy( ) / 2, self.canvas )
		self.linhas.append( linha )
		
		# Linha 7:
		x1 = self.objeto.GetX( ) - self.objeto.gettamx( ) / 2 + 5
		x2 = self.objeto.GetX( ) - self.objeto.gettamx( ) / 2 + 3
		y1 = self.objeto.GetY( )
		y2 = self.objeto.GetY( ) - 10
		linha = Linhas.Linhas( x1, x2, y1, y2 )
		desenho.Draw2( linha, x1 - 2, y1 - linha.gettamy( ) /2, self.canvas )
		self.linhas.append( linha )
		
		# Texto:
		fonte = wx.Font( 8, wx.SWISS, wx.NORMAL, wx.NORMAL )
		texto = Texto.Texto( 50, 22, self.quantidade, fonte )
		desenho.Draw2( texto, self.objeto.GetX( ), self.objeto.GetY( ) - self.objeto.gettamy( ) / 2 - 20, self.canvas )
		self.linhas.append( texto )
		self.texto.append( texto )
Пример #7
0
	def Repeticao2( self ): # Cria Objetos Repetição 2
		# Criação das Linhas da Repetição
		# Linha 1:
		x1 = self.objeto.GetX( )
		x2 = self.objeto.GetX( )
		y1 = self.objeto.GetY( ) + self.objeto.gettamy( ) / 2
		y2 = self.objeto.GetY( ) + self.objeto.gettamy( ) / 2 + 20
		linha = Linhas.Linhas( x1, x2, y1, y2 )
		desenho = qGMDraw.qGMDraw( )
		desenho.Draw2( linha, x1, self.objeto.GetY( ) + self.objeto.gettamy( ) / 2 + 10, self.canvas )
		self.linhas.append( linha )
		
		# Linha 2:
		x1 = self.objeto.GetX( )
		x2 = self.objeto.GetX( ) + self.objeto.gettamx( ) / 2 - 7
		y1 = self.objeto.GetY( ) + self.objeto.gettamy( ) / 2 + 20
		y2 = self.objeto.GetY( ) + self.objeto.gettamy( ) / 2 + 20
		linha = Linhas.Linhas( x1, x2, y1, y2 )
		desenho.Draw2( linha, x1 + linha.gettamx( ) / 2, y1, self.canvas )
		self.linhas.append( linha )
		
		# Linha 3:
		x1 = self.objeto.GetX( ) + self.objeto.gettamx( ) / 2 - 7
		x2 = self.objeto.GetX( ) + self.objeto.gettamx( ) / 2 - 7
		y1 = self.objeto.GetY( ) + self.objeto.gettamy( ) / 2 + 20
		y2 = self.objeto.GetY( ) - self.objeto.gettamy( ) / 2 - 20
		linha = Linhas.Linhas( x1, x2, y1, y2 )
		desenho.Draw2( linha, x1, y2 + linha.gettamy( ) / 2, self.canvas )
		self.linhas.append( linha )
		
		# Linha 4:
		x1 = self.objeto.GetX( ) + self.objeto.gettamx( ) / 2 - 7
		x2 = self.objeto.GetX( ) + 37
		y1 = self.objeto.GetY( ) - self.objeto.gettamy( ) / 2 - 20
		y2 = self.objeto.GetY( ) - self.objeto.gettamy( ) / 2 - 20
		linha = Linhas.Linhas( x1, x2, y1, y2 )
		desenho.Draw2( linha, x2 + linha.gettamx( ) / 2, y1, self.canvas )
		self.linhas.append( linha )
		
		# Retângulo
		x1 = self.objeto.GetX( ) + 8
		x2 = self.objeto.GetX( ) + 8
		y1 = self.objeto.GetY( ) - self.objeto.gettamy( ) / 2 - 30
		y2 = self.objeto.GetY( ) - self.objeto.gettamy( ) / 2 - 10
		linha = Linhas.Linhas( x1, x2, y1, y2 )
		desenho.Draw2( linha, x1, y2 - 10, self.canvas )
		self.linhas.append( linha )
		
		x1 = self.objeto.GetX( ) + 38
		x2 = self.objeto.GetX( ) + 38
		y1 = self.objeto.GetY( ) - self.objeto.gettamy( ) / 2 - 30
		y2 = self.objeto.GetY( ) - self.objeto.gettamy( ) / 2 - 10
		linha = Linhas.Linhas( x1, x2, y1, y2 )
		desenho.Draw2( linha, x1, y2 - 10, self.canvas )
		self.linhas.append( linha )
		
		x1 = self.objeto.GetX( ) + 8
		x2 = self.objeto.GetX( ) + 38
		y1 = self.objeto.GetY( ) - self.objeto.gettamy( ) / 2 - 30
		y2 = self.objeto.GetY( ) - self.objeto.gettamy( ) / 2 - 30
		linha = Linhas.Linhas( x1, x2, y1, y2 )
		desenho.Draw2( linha, ( x1 + x2 ) / 2, y1, self.canvas )
		self.linhas.append( linha )
		
		x1 = self.objeto.GetX( ) + 8
		x2 = self.objeto.GetX( ) + 38
		y1 = self.objeto.GetY( ) - self.objeto.gettamy( ) / 2 - 10
		y2 = self.objeto.GetY( ) - self.objeto.gettamy( ) / 2 - 10
		linha = Linhas.Linhas( x1, x2, y1, y2 )
		desenho.Draw2( linha, ( x1 + x2 ) / 2, y1, self.canvas )
		self.linhas.append( linha )
		
		# Linha 6:
		x1 = self.objeto.GetX( )
		x2 = self.objeto.GetX( ) + 8
		y1 = self.objeto.GetY( ) - self.objeto.gettamy( ) / 2 - 20
		y2 = self.objeto.GetY( ) - self.objeto.gettamy( ) / 2 - 20
		linha = Linhas.Linhas( x1, x2, y1, y2 )
		desenho.Draw2( linha, x1 + 4, y1, self.canvas )
		self.linhas.append( linha )
		
		# Linha 7:
		x1 = self.objeto.GetX( )
		x2 = self.objeto.GetX( )
		y1 = self.objeto.GetY( ) - self.objeto.gettamy( ) / 2
		y2 = self.objeto.GetY( ) - self.objeto.gettamy( ) / 2 - 20
		linha = Linhas.Linhas( x1, x2, y1, y2 )
		desenho.Draw2( linha, x1, y1 - 10, self.canvas )
		self.linhas.append( linha )
		
		# Linha 8:
		x1 = self.objeto.GetX( )
		x2 = self.objeto.GetX( ) - 2
		y1 = self.objeto.GetY( ) - self.objeto.gettamy( ) / 2
		y2 = self.objeto.GetY( ) - self.objeto.gettamy( ) / 2 - 10
		linha = Linhas.Linhas( x1, x2, y1, y2 )
		desenho.Draw2( linha, x1 - 2, y1 - 5, self.canvas )
		self.linhas.append( linha )
		
		# Linha 9:
		x1 = self.objeto.GetX( )
		x2 = self.objeto.GetX( ) + 2
		y1 = self.objeto.GetY( ) - self.objeto.gettamy( ) / 2
		y2 = self.objeto.GetY( ) - self.objeto.gettamy( ) / 2 - 10
		linha = Linhas.Linhas( x1, x2, y1, y2 )
		desenho.Draw2( linha, x1 + 2 , y1 - 5, self.canvas )
		self.linhas.append( linha )
		
		# Texto:
		fonte = wx.Font( 8, wx.SWISS, wx.NORMAL, wx.NORMAL )
		texto = Texto.Texto( 30, 22, self.quantidade, fonte )
		desenho.Draw2( texto, self.objeto.GetX( ) + 23, self.objeto.GetY( ) - self.objeto.gettamy( ) / 2 - 20, self.canvas )
		self.linhas.append( texto )
		self.texto.append( texto )
Пример #8
0
    def CriaProcessos(self, processo, canvas=None):
        x = processo.getAttribute("x")
        y = processo.getAttribute("y")
        if processo.getAttribute("repr") == "terminicio":
            cor = processo.getAttribute("cor")
            shape = Terminadores.TermInicio(cor)

        elif processo.getAttribute("repr") == "termfim":
            cor = processo.getAttribute("cor")
            shape = Terminadores.TermFim(cor)

        elif processo.getAttribute("repr") == "partquantum":
            acao = processo.getAttribute("acao")
            start_pos = processo.getAttribute("start_pos")
            end_pos = processo.getAttribute("end_pos")
            parametro = processo.getAttribute("parametro")
            cor = processo.getAttribute("cor")
            qubits = processo.getAttribute("qubits")
            shape = PartQuantumProcess.PartQuantumProcess(
                acao, start_pos, end_pos, qubits, cor, float(x), float(y), canvas
            )
            shape.setParametro(parametro)

        elif processo.getAttribute("repr") == "conselem":
            acao = processo.getAttribute("acao")
            pos = processo.getAttribute("pos")
            parametro = processo.getAttribute("parametro")
            cor = processo.getAttribute("cor")
            qubits = processo.getAttribute("qubits")
            shape = ConsElem.ConsElem(qubits, acao, pos, cor, float(x), float(y), canvas)
            shape.setParametro(parametro)

        elif processo.getAttribute("repr") == "projection":
            acao = processo.getAttribute("acao")
            pos = processo.getAttribute("pos")
            parametro = processo.getAttribute("parametro")
            cor = processo.getAttribute("cor")
            shape = ProjectionComponent.ProjectionComponent(acao, pos, cor, float(x), float(y), canvas)
            shape.setParametro(parametro)

        elif processo.getAttribute("repr") == "probability":
            pos = processo.getAttribute("pos").encode()
            cor = processo.getAttribute("cor")
            shape = ProbabilityComponent.ProbabilityComponent(cor, float(x), float(y), canvas)
            shape.setPosic(pos)

        elif processo.getAttribute("repr") == "macro":
            ## Gets the parameters to bild the macro ##
            parametro = processo.getAttribute("parametro").encode()
            macroName = processo.getAttribute("name").encode()
            cor = processo.getAttribute("cor")
            shape = Macro.Macro(cor, (x, y), macroName, parametro, canvas)

            ## Sets the remain parameters ##
            pos = processo.getAttribute("pos").encode()
            shape.setPosicoes(pos)
            ## Build the process representation of the macro ##
            subprocessos = processo.childNodes  # Get child nodes of the macro
            for element in subprocessos:
                if element.nodeName != "#text":
                    if element.getAttribute("repr") == "env":
                        procs = self.CriaEnvelope(element)
                    elif element.getAttribute("repr") == "iterativo":
                        procs = self.CriaIterativo(element)
                    elif element.getAttribute("repr") != "detproj":
                        procs = self.CriaProcessos(element)
            shape.setChilds(procs)
            ## Only draws the macro ##
        desenho = qGMDraw.qGMDraw()
        desenho.Draw2(shape, float(x), float(y), canvas)
        return shape