Search in sources :

Example 1 with Pipe

use of com.cas.gas.vo.Pipe in project TeachingInSimulation by ScOrPiOzzy.

the class ConnectionController method selectPipe.

/**
 */
private void selectPipe() {
    if (!connectionHandler.checkChange()) {
        Dispatcher.getIns().getTip().showTip(ITip.ERROR, ConnectionUtil.CONNECTING_CANNOT_CHANGE);
        return;
    }
    setContentVisible("pipeColorsContent", "true");
    setContentVisible("wireColorsContent", "false");
    if (connectionHandler.getCurrLinker() instanceof Pipe) {
        // 当前是气管
        currentPipeIndex = currentPipeIndex + 1 > pipeColors.length - 1 ? 0 : currentPipeIndex + 1;
    }
    List<Element> pipeEles = findById("pipeColorsContent").getElements();
    for (int i = 0; i < pipeEles.size(); i++) {
        Element pipeEle = pipeEles.get(i);
        if (i == currentPipeIndex) {
            pipeEle.startEffect(EffectEventId.onHover);
        } else {
            pipeEle.stopEffect(EffectEventId.onHover);
        }
    }
    changePipeColor(String.valueOf(currentPipeIndex));
    // 2秒后隐藏
    selectHideTimer("pipeColorsContent");
}
Also used : Element(de.lessvoid.nifty.elements.Element) Pipe(com.cas.gas.vo.Pipe)

Example 2 with Pipe

use of com.cas.gas.vo.Pipe 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 3 with Pipe

use of com.cas.gas.vo.Pipe 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 4 with Pipe

use of com.cas.gas.vo.Pipe in project TeachingInSimulation by ScOrPiOzzy.

the class ConnectionHandler method bindWireOrPipe.

/**
 * 绑定端点
 * @param termOrPort 点击接线的端点信息对象,或者气口信息对象
 */
private void bindWireOrPipe(ILinkTarget termOrPort, Spatial mdl) {
    setHighLightLinker(selected, false);
    if (currLinker instanceof Cable && termOrPort instanceof Terminal) {
        Cable cable = ((Cable) currLinker);
        // 如果当前绑定为线缆上的导线
        cable.bindTerm(termOrPort, mdl);
        // 接完线 显示号码管对话框
        ui.setNumDialogueVisible(true);
        modifyLinker = currLinker;
        List<Wire> wires = new ArrayList<Wire>(cable.getMark_wire().values());
        // 线缆导线排序
        for (Wire w : cable.getBindWires()) {
            wires.remove(w);
        }
        Comparator<Wire> comparator = new Comparator<Wire>() {

            @Override
            public int compare(Wire wire1, Wire wire2) {
                return wire1.getPO().getStitch1().compareTo(wire2.getPO().getStitch1());
            }
        };
        Collections.sort(wires, comparator);
        if (wires.size() == 0) {
            cable.setNowConnectingWire(null);
        } else {
            cable.setNowConnectingWire(wires.get(0).getPO().getMark());
        }
    } else {
        // 其他普通情况绑定
        currLinker.bind(termOrPort);
        if (currLinker.isBothBinded() && currLinker instanceof Wire) {
            // 接完线 显示号码管对话框
            ui.setNumDialogueVisible(true);
            modifyLinker = currLinker;
        }
    }
    currLinker.getModels().put(mdl, termOrPort);
    // 显示或隐藏与鼠标连接的直线
    setLineVisible(true);
    if (!currLinker.isBothBinded()) {
        return;
    }
    setLineVisible(false);
    ui.initXianLanPanel(null, false);
    // 取消接线完成的元器件高亮
    if (currLinker instanceof Cable && ((Cable) currLinker).isElecComp()) {
        Map<Spatial, ILinkTarget> models = currLinker.getModels();
        for (Spatial spatial : models.keySet()) {
            // JmeUtil.setMaterialEffect(Dispatcher.getIns().getMainApp(), HightLightType.GLOW, spatial, ColorConsts.TRANSDUCERS, false);
            JmeUtil.setSpatialHighLight(spatial, ColorRGBA.BlackNoAlpha);
        }
    }
    if (termOrPort instanceof Terminal) {
        if (currLinker instanceof Cable) {
            Cable cable = new Cable();
            currLinker = cable;
        } else {
            Wire wire = new Wire(1, color);
            currLinker = wire;
        }
    } else if (termOrPort instanceof GasPort) {
        Pipe pipe = new Pipe(1, color);
        currLinker = pipe;
    } else if (termOrPort instanceof Jack) {
        Cable cable = new Cable();
        currLinker = cable;
    }
}
Also used : Cable(com.cas.circuit.vo.Cable) GasPort(com.cas.gas.vo.GasPort) ArrayList(java.util.ArrayList) Pipe(com.cas.gas.vo.Pipe) Wire(com.cas.circuit.vo.Wire) Terminal(com.cas.circuit.vo.Terminal) Comparator(java.util.Comparator) Spatial(com.jme3.scene.Spatial) Jack(com.cas.circuit.vo.Jack)

Example 5 with Pipe

use of com.cas.gas.vo.Pipe 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)

Aggregations

Pipe (com.cas.gas.vo.Pipe)8 Cable (com.cas.circuit.vo.Cable)7 Wire (com.cas.circuit.vo.Wire)7 Jack (com.cas.circuit.vo.Jack)3 Spatial (com.jme3.scene.Spatial)3 Terminal (com.cas.circuit.vo.Terminal)2 GasPort (com.cas.gas.vo.GasPort)2 LinkerMsg (com.cas.circuit.msg.LinkerMsg)1 Format (com.cas.circuit.vo.Format)1 Element (de.lessvoid.nifty.elements.Element)1 ArrayList (java.util.ArrayList)1 Comparator (java.util.Comparator)1