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