Search in sources :

Example 16 with Wire

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

the class ConnectionController method selectWire.

/**
 */
private void selectWire() {
    if (!connectionHandler.checkChange()) {
        Dispatcher.getIns().getTip().showTip(ITip.ERROR, ConnectionUtil.CONNECTING_CANNOT_CHANGE);
        return;
    }
    setContentVisible("pipeColorsContent", "false");
    setContentVisible("wireColorsContent", "true");
    if (connectionHandler.getCurrLinker() instanceof Wire) {
        // 当前是导线
        currentWireIndex = currentWireIndex + 1 > wireColors.length - 1 ? 0 : currentWireIndex + 1;
    }
    List<Element> colorEles = findById("wireColorsContent").getElements();
    for (int i = 0; i < colorEles.size(); i++) {
        Element colorEle = colorEles.get(i);
        if (i == currentWireIndex) {
            colorEle.startEffect(EffectEventId.onHover);
        } else {
            colorEle.stopEffect(EffectEventId.onHover);
        }
    }
    changeWireColor(String.valueOf(currentWireIndex));
    // 2秒后隐藏
    selectHideTimer("wireColorsContent");
}
Also used : Element(de.lessvoid.nifty.elements.Element) Wire(com.cas.circuit.vo.Wire)

Example 17 with Wire

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

the class ConnectionHandler method checkStandard.

public boolean checkStandard(ILinkTarget target, ILinker linker) {
    // List<LinkerMsg> checks = standardData.getLinkerMapForCheck().get(target.getElecCompKey() + target.getTargetKey());
    // if (checks == null || checks.size() == 0) {
    // return false;
    // }
    ILinkTarget anotherTarget = linker.getLinkTarget1();
    if (anotherTarget == null) {
        anotherTarget = linker.getLinkTarget2();
    }
    if (anotherTarget == null) {
        return true;
    }
    List<LinkerMsg> checks = standardData.getLinkerMapForCheck().get(anotherTarget.getElecCompKey() + anotherTarget.getTargetKey());
    if (checks == null) {
        return false;
    }
    for (LinkerMsg check : checks) {
        List<LinkerMsg> checkAnothers = standardData.getLinkerMapForRead().get(check.getKey());
        for (LinkerMsg anothers : checkAnothers) {
            if (anothers.equals(check)) {
                continue;
            }
            if (linker instanceof Cable && ((Cable) linker).isSinglePlug()) {
                Cable cable = (Cable) linker;
                Wire wire = cable.getNowConnectingWire();
                if (anothers.getElecCompKey().equals(target.getElecCompKey()) && anothers.getTargetKey().equals(target.getTargetKey()) && anothers.getWireMark().equals(wire.getPO().getMark())) {
                    return true;
                }
            } else if (anothers.getElecCompKey().equals(target.getElecCompKey()) && anothers.getTargetKey().equals(target.getTargetKey())) {
                return true;
            }
        }
    }
    return false;
}
Also used : Cable(com.cas.circuit.vo.Cable) Wire(com.cas.circuit.vo.Wire) LinkerMsg(com.cas.circuit.msg.LinkerMsg)

Example 18 with Wire

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

the class ConnectionHandler method setCurrLinker.

/**
 * 设置当前用户选择的导线或者气管
 * @param wireOrPipe
 */
public void setCurrLinker(int connectType, ColorRGBA color) {
    this.color = color;
    if (ConnectionUtil.CONNECT_WIRE == connectType) {
        currLinker = new Wire(1, color);
    } else if (ConnectionUtil.CONNECT_PIPE == connectType) {
        currLinker = new Pipe(1, color);
    } else if (ConnectionUtil.CONNECT_CABLE == connectType) {
        currLinker = new Cable();
    } else {
        currLinker = null;
    }
    refreshViewPort(currLinker);
}
Also used : Cable(com.cas.circuit.vo.Cable) Pipe(com.cas.gas.vo.Pipe) Wire(com.cas.circuit.vo.Wire)

Example 19 with Wire

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

the class ConnectionHandler method modifyWireNum.

private void modifyWireNum(ILinker linker, String wireNum) {
    if (Util.isEmpty(wireNum)) {
        return;
    }
    if (linker instanceof Cable && ((Cable) linker).getBindWires().size() != 0) {
        List<Wire> bindWires = ((Cable) linker).getBindWires();
        linker = bindWires.get(bindWires.size() - 1);
    }
    for (Spatial model : linker.getModels().keySet()) {
        Spatial parent = ((Node) model).getChild("Label");
        if (parent == null) {
            continue;
        }
        for (Spatial bitmapText : ((Node) parent).getChildren()) {
            if (bitmapText instanceof BitmapText) {
                ((BitmapText) bitmapText).setText(wireNum.toUpperCase());
                // //					有的号码三个英文字母  塞不下  所以过大的 做一下压缩
                // float lineWidth = ((BitmapText) bitmapText).getLineWidth();
                // if (lineWidth > 80) {
                // bitmapText.scale(80f / lineWidth, 1, 1);
                // } else {
                bitmapText.setLocalScale(bitmapText.getLocalScale().y);
            // }
            }
        }
    }
}
Also used : Cable(com.cas.circuit.vo.Cable) BitmapText(com.jme3.font.BitmapText) Spatial(com.jme3.scene.Spatial) Node(com.jme3.scene.Node) Wire(com.cas.circuit.vo.Wire)

Example 20 with Wire

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

the class ConnectionHandler method deleteLinker.

private void deleteLinker(ILinker linker, boolean modifiable) {
    if (linker == null) {
        return;
    }
    // 去除模型高亮选中效果
    setHighLightLinker(linker, false);
    // 重新整理端子上的接线头
    ILinkTarget term1 = linker.getLinkTarget1();
    ILinkTarget term2 = linker.getLinkTarget2();
    // 删除线缆上的导线绑定模型
    Map<Spatial, ILinkTarget> models = linker.getModels();
    if (linker instanceof Cable && ((Cable) linker).isElecComp()) {
        for (Entry<String, Wire> set : ((Cable) linker).getMark_wire().entrySet()) {
            Map<Spatial, ILinkTarget> mdls = set.getValue().getModels();
            for (Spatial linkTerm : mdls.keySet()) {
                JmeUtil.detachModel(linkTerm);
            }
        }
        if (term2 != null) {
            JmeUtil.detachModel(linker.getLinkMdlByTarget(term2).get(0));
        }
        if (modifiable) {
            // 给模型未接线状态(只有传感器接线才会受到影响)
            for (Spatial linkMdl : models.keySet()) {
                JmeUtil.setSpatialHighLight(linkMdl, ColorConsts.TRANSDUCERS);
            }
        }
    } else {
        for (Spatial linkTerm : models.keySet()) {
            JmeUtil.detachModel(linkTerm);
        }
    }
    // 记录准备存档的信息
    linkerData.removeLinker(linker);
    linker.unbind();
    resetLinks(term1);
    resetLinks(term2);
    setLineVisible(false);
    if (currLinker instanceof Wire) {
        Wire wire = new Wire(1, color);
        currLinker = wire;
    } else if (currLinker instanceof Pipe) {
        Pipe pipe = new Pipe(1, color);
        currLinker = pipe;
    } else if (currLinker instanceof Cable) {
        Cable cable = new Cable();
        currLinker = cable;
    }
}
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)

Aggregations

Wire (com.cas.circuit.vo.Wire)23 Cable (com.cas.circuit.vo.Cable)13 Spatial (com.jme3.scene.Spatial)9 ArrayList (java.util.ArrayList)9 Pipe (com.cas.gas.vo.Pipe)7 Terminal (com.cas.circuit.vo.Terminal)6 Jack (com.cas.circuit.vo.Jack)5 LinkerMsg (com.cas.circuit.msg.LinkerMsg)4 Node (com.jme3.scene.Node)4 ElecCompDef (com.cas.circuit.vo.ElecCompDef)3 GasPort (com.cas.gas.vo.GasPort)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3 ResisRelation (com.cas.circuit.vo.ResisRelation)2 HintControl (com.cas.sim.tis.app.control.HintControl)2 TagNameControl (com.cas.sim.tis.app.control.TagNameControl)2 WireNumberControl (com.cas.sim.tis.app.control.WireNumberControl)2 MouseEvent (com.cas.sim.tis.app.event.MouseEvent)2 MouseEventAdapter (com.cas.sim.tis.app.event.MouseEventAdapter)2 IContent (com.cas.sim.tis.view.control.IContent)2