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");
}
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);
}
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();
}
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;
}
}
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);
}
Aggregations