Search in sources :

Example 1 with Cable

use of com.cas.circuit.vo.Cable in project TeachingInSimulation by ScOrPiOzzy.

the class ConnectionController method linkTransduscers.

public void linkTransduscers(String indexStr) {
    if (Util.isEmpty(indexStr)) {
        return;
    }
    // 创建传感器接线
    Cable cable = (Cable) connectionHandler.getCurrLinker();
    cable.setNowConnectingWire(indexStr);
    int index = Arrays.asList(cableLabels).indexOf(indexStr);
    showBorder(index);
}
Also used : Cable(com.cas.circuit.vo.Cable)

Example 2 with Cable

use of com.cas.circuit.vo.Cable in project TeachingInSimulation by ScOrPiOzzy.

the class ConnectionController method selectCable.

/**
 */
public void selectCable() {
    setContentVisible("pipeColorsContent", "false");
    setContentVisible("wireColorsContent", "false");
    if (cableLabels == null) {
        if (!connectionHandler.checkChange()) {
            Dispatcher.getIns().getTip().showTip(ITip.ERROR, ConnectionUtil.CONNECTING_CANNOT_CHANGE);
            return;
        }
        connectionHandler.setCurrLinker(ConnectionUtil.CONNECT_CABLE, null);
        return;
    }
    if (connectionHandler.getCurrLinker() instanceof Cable) {
        currentCableIndex = currentCableIndex + 1 > cableLabels.length - 1 ? 0 : currentCableIndex + 1;
        List<Element> colorEles = findById("xianlanColorsContent").getElements();
        Cable cable = (Cable) connectionHandler.getCurrLinker();
        for (int i = 0; i < colorEles.size(); i++) {
            Element colorEle = colorEles.get(i);
            if (i == currentCableIndex) {
                colorEle.startEffect(EffectEventId.onActive);
                cable.setNowConnectingWire(cableLabels[currentCableIndex]);
            } else {
                colorEle.stopEffect(EffectEventId.onActive);
            }
        }
    }
}
Also used : Cable(com.cas.circuit.vo.Cable) Element(de.lessvoid.nifty.elements.Element)

Example 3 with Cable

use of com.cas.circuit.vo.Cable in project TeachingInSimulation by ScOrPiOzzy.

the class ConnectionHandler method onlineOrSaveLinker.

/**
 * 根据linkerInfo处理接线并记录
 */
private void onlineOrSaveLinker(LinkerMsg msg, boolean modifiable) {
    int key = msg.getKey();
    byte linkType = msg.getLinkType();
    ILinker linker = null;
    if (onlineAndSaves.containsKey(key)) {
        linker = onlineAndSaves.get(key);
    } else if (LinkerMsg.WIRE == linkType) {
        linker = new Wire(1, msg.getColor());
        onlineAndSaves.put(key, linker);
    } else if (LinkerMsg.PIPE == linkType) {
        linker = new Pipe(1, msg.getColor());
        onlineAndSaves.put(key, linker);
    } else if (LinkerMsg.CABLE_JACK == linkType || LinkerMsg.CABLE_TERM == linkType) {
        linker = cableMap.get(msg.getCableKey()).clone();
        if (msg.isElecComp()) {
            Cable cable = ((Cable) linker);
            linker = bindSaveTransEvent(msg.getElecCompKey(), cable, modifiable);
            if (linker != null) {
                onlineAndSaves.put(key, linker);
            }
            return;
        }
        onlineAndSaves.put(key, linker);
    }
    connectByLinkerInfo(msg, linker, modifiable);
}
Also used : Cable(com.cas.circuit.vo.Cable) Pipe(com.cas.gas.vo.Pipe) Wire(com.cas.circuit.vo.Wire)

Example 4 with Cable

use of com.cas.circuit.vo.Cable in project TeachingInSimulation by ScOrPiOzzy.

the class ConnectionHandler method refreshViewPort.

public void refreshViewPort(ILinker wireOrPipe) {
    Spatial viewMdl = null;
    if (wireOrPipe instanceof Wire) {
        viewMdl = ConnectionUtil.getWireTerm();
        viewMdl.scale(500);
        viewMdl.move(4.8f, -4, -5);
    } else if (wireOrPipe instanceof Pipe) {
        viewMdl = ConnectionUtil.getPipeTerm();
        viewMdl.scale(300);
        viewMdl.move(4.2f, -3.6f, -5);
    } else if (wireOrPipe instanceof Cable) {
        viewMdl = ConnectionUtil.getJackTerm(null);
        viewMdl.scale(100);
        viewMdl.rotate(FastMath.HALF_PI, FastMath.HALF_PI, 0);
        viewMdl.move(4, -3f, -3);
    }
    viewRoot.detachAllChildren();
    if (wireOrPipe == null) {
        // FilterUtil.getBorderFilter().setEnabled(false);
        if (ui != null) {
            ui.setViewAreaVisible(false);
        }
    } else {
        JmeUtil.changeColor(((Node) viewMdl).getChild("model"), wireOrPipe.getColor());
        viewRoot.attachChild(viewMdl);
        // FilterUtil.getBorderFilter().setEnabled(true);
        if (ui != null) {
            ui.setViewAreaVisible(true);
        }
    }
    viewRoot.updateGeometricState();
}
Also used : Cable(com.cas.circuit.vo.Cable) Spatial(com.jme3.scene.Spatial) Pipe(com.cas.gas.vo.Pipe) Wire(com.cas.circuit.vo.Wire)

Example 5 with Cable

use of com.cas.circuit.vo.Cable in project TeachingInSimulation by ScOrPiOzzy.

the class ConnectionHandler method deleteTmpLinker.

/**
 * 删除临时接线处理
 * @param linker 临时接线对象
 * @param modifiable 可以被当前用户修改的临时接线对象
 * @return
 */
private byte deleteTmpLinker(ILinker linker, boolean modifiable) {
    if (linker == null || linker.isBothBinded() || (linker.getLinkTarget1() == null && linker.getLinkTarget2() == null)) {
        return LinkerMsg.NONE_MSG;
    }
    if (!(linker instanceof Cable) || !((Cable) linker).isSinglePlug()) {
        deleteLinker(linker, modifiable);
        return LinkerMsg.DELETE_LINKER;
    }
    Cable cable = (Cable) linker;
    List<Wire> bindWires = cable.getBindWires();
    if (cable.getBindWires().size() == 0) {
        deleteLinker(linker, modifiable);
        ui.initXianLanPanel(null, false);
        return LinkerMsg.DELETE_LINKER;
    }
    Wire wire = bindWires.get(bindWires.size() - 1);
    cable.getBindWires().remove(wire);
    cable.setPrevWire(wire);
    cable.setNowConnectingWire(wire.getPO().getMark());
    Map<Spatial, ILinkTarget> mdls = wire.getModels();
    for (Spatial linkTerm : mdls.keySet()) {
        JmeUtil.detachModel(linkTerm);
        wire.getModels().remove(linkTerm);
        cable.getModels().remove(linkTerm);
    }
    wire.unbind(wire.getLinkTarget2());
    if (!modifiable) {
        return LinkerMsg.DELETE_SINGLE_TARGET;
    }
    List<Wire> wires = new ArrayList<Wire>(cable.getMark_wire().values());
    for (Wire w : cable.getBindWires()) {
        wires.remove(w);
    }
    if (wires.size() == 0) {
        ui.initXianLanPanel(null, false);
        setLineVisible(false);
    } else {
        ui.initXianLanPanel(wires, true);
        ILinkTarget target = null;
        if (bindWires.size() == 0) {
            target = cable.getLinkTarget1();
        } else {
            Wire currWire = bindWires.get(bindWires.size() - 1);
            target = currWire.getLinkTarget2();
        }
        showLineBetweenLinker(cable);
        Map<Spatial, ILinkTarget> termMdls = cable.getModels();
        for (Entry<Spatial, ILinkTarget> set : termMdls.entrySet()) {
            if (set.getValue().equals(target)) {
                refreshLineBetweenLinker(set.getKey());
                break;
            }
        }
    }
    return LinkerMsg.DELETE_SINGLE_TARGET;
}
Also used : Cable(com.cas.circuit.vo.Cable) Spatial(com.jme3.scene.Spatial) ArrayList(java.util.ArrayList) Wire(com.cas.circuit.vo.Wire)

Aggregations

Cable (com.cas.circuit.vo.Cable)17 Wire (com.cas.circuit.vo.Wire)13 Spatial (com.jme3.scene.Spatial)8 Pipe (com.cas.gas.vo.Pipe)7 Jack (com.cas.circuit.vo.Jack)4 Terminal (com.cas.circuit.vo.Terminal)4 ArrayList (java.util.ArrayList)4 LinkerMsg (com.cas.circuit.msg.LinkerMsg)3 GasPort (com.cas.gas.vo.GasPort)3 LinkerEventAdapter (com.cas.circuit.event.LinkerEventAdapter)2 LinkerEventHandler (com.cas.circuit.event.LinkerEventHandler)2 Node (com.jme3.scene.Node)2 ElecComp (com.cas.circuit.vo.ElecComp)1 ElecCompDef (com.cas.circuit.vo.ElecCompDef)1 Format (com.cas.circuit.vo.Format)1 BitmapText (com.jme3.font.BitmapText)1 ColorRGBA (com.jme3.math.ColorRGBA)1 Element (de.lessvoid.nifty.elements.Element)1 FileNotFoundException (java.io.FileNotFoundException)1 Comparator (java.util.Comparator)1