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