public GameObject RenderGcode() { Destroy(); float lineWidth = GcodeParser.GetInstance().GetLayerHeight() * 5; GcodeDrawLineManager.GetInstance().SetGcodeRenderBeans(GcodeParser.GetInstance().GetGcodeRenderPointList()); GcodeDrawLineManager.GetInstance().SetLineWidth(lineWidth); gcodeRenderGameObject = GameObject.CreatePrimitive(PrimitiveType.Cube); gcodeRenderGameObject.name = "gcodeRenderGameObject"; gcodeRenderGameObject.GetComponent <Renderer>().enabled = false; foreach (VectorLine vectorLine in GcodeDrawLineManager.GetInstance().GetVectorLineList_types()) { vectorLine.drawTransform = gcodeRenderGameObject.transform; vectorLine.active = true; } foreach (VectorLine vectorLine in GcodeDrawLineManager.GetInstance().GetVectorLine_topLayer()) { vectorLine.drawTransform = gcodeRenderGameObject.transform; vectorLine.active = true; } _struct.isRendered = true; initColorScheme(); UpdatGcodePreviewColors(); SetActive_Top_Layer(true); GcodeDrawLineManager.GetInstance().SetColor_topLayer(GcodeTypeColor.Top_Layer); return(gcodeRenderGameObject); }
public bool IsInBounds() { List <Vector2> list = GcodeParser.GetInstance().GetBounds(); if (list == null) { return(false); } Vector3 deviceSize = Global.GetInstance().GetPrinterParamsStruct().size; return ((list[0].x >= 0 && list[0].y <= deviceSize.x) && (list[1].x >= 0 && list[1].y <= deviceSize.y) && (list[2].y <= deviceSize.z)); }
/*************** public ***************/ public bool StartParseGcodeFile(string path) { if (string.IsNullOrEmpty(path) || path.Trim().Length == 0) { Debug.LogError("Error occur: StartParseGcodeFile [path is null]" + "\n"); return(false); } if (!File.Exists(path)) { Debug.LogError("Error occur: StartParseGcodeFile [file not exists:" + path + "]" + "\n"); return(false); } UnityEngine.Debug.Log("Start parse gcode file..." + "\n"); _struct.isParsing = true; _struct.isRendered = false; _struct.parseProgress = 0; StageManager.SetStage_Gcode_Render(); //cost long time if file is big GcodeParser.GetInstance().StartParseGcodeFile(path); if (GcodeParser.GetInstance().GetLayerCount() > 0) { foreach (Listener listener in _listenerList) { listener.OnGcodeParseSucceed(); } } else { foreach (Listener listener in _listenerList) { listener.OnGcodeParseFailed(); } } _struct.isParsing = false; _struct.parseProgress = 1; return(true); }
public InfoStruct GetInfo() { _struct.parseProgress = GcodeParser.GetInstance().GetParseProgress(); return(_struct); }
public int GetLayerCount() { return(GcodeParser.GetInstance().GetLayerCount()); }