From 720d90c1fdc5af8b9dd28e7a78f265ee0377729a Mon Sep 17 00:00:00 2001 From: giovaneneves7 Date: Fri, 25 Oct 2024 22:05:53 -0300 Subject: [PATCH] =?UTF-8?q?feat(connect):=20Adiciona=20l=C3=B3gica=20de=20?= =?UTF-8?q?conex=C3=A3o=20personalizada=20da=20bomba=20centr=C3=ADfuga?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/EquipamentoController.java | 17 +++++++++++++---- .../java/br/com/ifba/ipss/helper/GapHelper.java | 3 +++ src/main/resources/files/ferramentas.json | 1 + 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/main/java/br/com/ifba/ipss/feature/equipamento/controller/EquipamentoController.java b/src/main/java/br/com/ifba/ipss/feature/equipamento/controller/EquipamentoController.java index c14b390..be7b23a 100644 --- a/src/main/java/br/com/ifba/ipss/feature/equipamento/controller/EquipamentoController.java +++ b/src/main/java/br/com/ifba/ipss/feature/equipamento/controller/EquipamentoController.java @@ -365,7 +365,6 @@ public void connectEquipament(Label movedLabel, Label target){ } else if (target.getEquipamento().getAxios().equals(Constantes.HORIZONTAL) && movedLabel.getEquipamento().getAxios().equals(Constantes.VERTICAL)) { - System.out.println("Horizontal e vertical"); int diferencaX = movedLabel.getX() - target.getX(); int diferencaY = movedLabel.getY() - target.getY(); int xOrigem = 0; @@ -429,14 +428,19 @@ public void connectEquipament(Label movedLabel, Label target){ } else{ // O alvo está na vertical e o equipamento a se conectar está na horizontal - if(!target.getEquipamento().isCanLeftConnect() && !target.getEquipamento().isCanRightConnect()) return; + if(!target.getEquipamento().isCanLeftConnect() && !target.getEquipamento().isCanRightConnect()){ + + WarningModal.createWarningModal(tr("this_connection_is_invalid"), tr("invalid_connection")); + return; + + } int diferencaX = movedLabel.getX() - target.getX(); int xOrigem = 0; int yOrigem = 0; if(diferencaX <= 0) { // movedLabel está à direita do alvo - + System.out.println("direita"); if(!target.getEquipamento().isCanRightConnect()){ WarningModal.createWarningModal(tr("this_connection_is_invalid"), tr("invalid_connection")); @@ -513,7 +517,12 @@ public void connectEquipament(Label movedLabel, Label target){ yOrigem = target.getY() - movedLabel.getHeight() + GapHelper.CONEXAO_3_Y_GAP; - } else{ + } else if(target.getEquipamento().getType() == EquipamentType.BOMBA_CENTRIFUGA){ + + xOrigem = target.getX() + (target.getWidth() / 2) - (movedLabel.getWidth() / 2) + GapHelper.TUBULACAO_BOMBA_CENTRIFUGA_X_GAP; + yOrigem = target.getY() - movedLabel.getHeight() + GapHelper.TUBULACAO_BOMBA_CENTRIFUGA_Y_GAP; + + }else{ xOrigem = target.getX() + (target.getWidth() / 2) - (movedLabel.getWidth() / 2); yOrigem = target.getY() - movedLabel.getHeight(); diff --git a/src/main/java/br/com/ifba/ipss/helper/GapHelper.java b/src/main/java/br/com/ifba/ipss/helper/GapHelper.java index 7fefac6..c425965 100644 --- a/src/main/java/br/com/ifba/ipss/helper/GapHelper.java +++ b/src/main/java/br/com/ifba/ipss/helper/GapHelper.java @@ -20,6 +20,7 @@ public class GapHelper { // INFO: Valores em px. public static final int BOMBA_CENTRIFUGA_TUBULACAO_X_GAP = 17; + public static final int CONEXAO_1_BOTTOM_X_GAP = 9; public static final int CONEXAO_1_TOP_X_GAP = 9; @@ -54,6 +55,8 @@ public class GapHelper { public static final int TROCADOR_CALOR_TOP_X_GAP = 26; public static final int TROCADOR_CALOR_Y_GAP = 18; + public static final int TUBULACAO_BOMBA_CENTRIFUGA_X_GAP = 57; + public static final int TUBULACAO_BOMBA_CENTRIFUGA_Y_GAP = 52; public static final int TUBULACAO_CONEXAO_3_X_GAP = 16; public static final int VALVULA_ESFERA_X_GAP = 16; diff --git a/src/main/resources/files/ferramentas.json b/src/main/resources/files/ferramentas.json index 7980053..1368f9b 100644 --- a/src/main/resources/files/ferramentas.json +++ b/src/main/resources/files/ferramentas.json @@ -249,6 +249,7 @@ "axios" : "vertical", "can_bottom_connect": 0, "can_horizontal_connect" : 1, + "can_left_connect" : 1, "can_right_connect" : 0, "can_top_connect" : 1, "type" : "bomba_centrifuga",