void toggleChanged(Toggle sender) { if (sender == toggle_Show_Shell) { Debug.Log("toggle_Show_Shell"); GcodeRenderManager.GetInstance().SetActive_WALL_INNER(sender.isOn); GcodeRenderManager.GetInstance().SetActive_WALL_OUTER(sender.isOn); GcodeRenderManager.GetInstance().SetActive_SKIN(sender.isOn); } else if (sender == toggle_Skirt_Brim) { Debug.Log("toggle_Skirt_Brim"); GcodeRenderManager.GetInstance().SetActive_SKIRT(sender.isOn); } else if (sender == toggle_Support_Raft) { Debug.Log("toggle_Support_Raft"); GcodeRenderManager.GetInstance().SetActive_SUPPORT(sender.isOn); GcodeRenderManager.GetInstance().SetActive_UNKNOWN(sender.isOn); } else if (sender == toggle_Infill) { Debug.Log("toggle_Infill"); GcodeRenderManager.GetInstance().SetActive_FILL(sender.isOn); } else if (sender == toggle_Travels) { Debug.Log("toggle_Travels"); GcodeRenderManager.GetInstance().SetActive_Travel(sender.isOn); } else if (sender == toggle_Top_Layer) { Debug.Log("toggle_Top_Layer"); GcodeRenderManager.GetInstance().SetActive_Top_Layer(sender.isOn); } }
void LateUpdate() { switch (StageManager.GetCurStage()) { case StageManager.Stage_Enum.Gcode_Send: GcodeRenderManager.GetInstance().ShowLayerLessThanZ(GcodeSenderManager.GetInstance().GetInfo().completedZ); GcodeRenderManager.GetInstance().DrawLayers(); break; case StageManager.Stage_Enum.Gcode_Render: if (GcodeRenderManager.GetInstance().GetInfo().isRendered) { if (_isDraging || Input.GetAxis("Mouse ScrollWheel") != 0.0f) { GcodeRenderManager.GetInstance().DrawLayers(); if (Input.GetAxis("Mouse ScrollWheel") != 0.0f) { GcodeRenderManager.GetInstance().AutoSetLineWidth(_tr_mainCamera.position.z + 500); } } } break; } }
public void Redo() { //1.check if (!CanExecuteRedo()) { Debug.Log("Can not execute redo" + "\n"); return; } //handle gcode render GcodeCreateManager.GetInstance().UnavailableCurGcodeCreateBean(); GcodeRenderManager.GetInstance().Destroy(); //_undoStack Pop and _redoStack push _undoStack.Push(_redoStack.Pop()); OperateBean targetRenderBean = _undoStack.Peek(); Debug.Log("redo:" + "\n" + _curOperateBean + "-->" + "\n" + targetRenderBean + "\n"); operateRenderModel(targetRenderBean); _curOperateBean = targetRenderBean.DeepCopy(); }
void Update() { //hide operate container when click empty place. check update_mode if (!EventSystem.current.IsPointerOverGameObject()) { if (Input.GetKeyDown(KeyCode.Mouse0)) { _mode = Mode_Enum.None; } } /*************** btn_export ***************/ bool exportable = StageManager.GetStageList().Contains(StageManager.Stage_Enum.Gcode_Render) && GcodeRenderManager.GetInstance().GetInfo().isRendered&& StageManager.GetCurStage() != StageManager.Stage_Enum.Gcode_Send && GcodeRenderManager.GetInstance().IsInBounds(); if (exportable) { btn_export.spriteState = _ss_exportEnable; btn_export.gameObject.GetComponent <Image>().sprite = _sp_export_normal; } else { btn_export.spriteState = _ss_exportDisable; btn_export.gameObject.GetComponent <Image>().sprite = _sp_export_disable; } /*************** btn_print ***************/ bool active_print = StageManager.GetStageList().Contains(StageManager.Stage_Enum.Gcode_Render) && !GcodeRenderManager.GetInstance().GetInfo().isParsing&& StageManager.GetCurStage() != StageManager.Stage_Enum.Gcode_Send && PortConnectManager.GetInstance().IsConnected() && GcodeRenderManager.GetInstance().IsInBounds(); btn_print.interactable = active_print; /*************** other widget ***************/ switch (StageManager.GetCurStage()) { case StageManager.Stage_Enum.Idle: btn_open.interactable = true; btn_move.interactable = false; btn_scale.interactable = false; btn_rotate.interactable = false; img_moveContainer.GetComponent <Transform>().gameObject.SetActive(false); img_scaleContainer.GetComponent <Transform>().gameObject.SetActive(false); img_rotateContainer.GetComponent <Transform>().gameObject.SetActive(false); break; case StageManager.Stage_Enum.Load_Model: if (ModelManager.GetInstance().GetInfo().isParsing) { btn_open.interactable = false; btn_move.interactable = false; btn_scale.interactable = false; btn_rotate.interactable = false; img_moveContainer.GetComponent <Transform>().gameObject.SetActive(false); img_scaleContainer.GetComponent <Transform>().gameObject.SetActive(false); img_rotateContainer.GetComponent <Transform>().gameObject.SetActive(false); } else { btn_open.interactable = true; btn_move.interactable = true; btn_scale.interactable = true; btn_rotate.interactable = true; update_mode(); } break; case StageManager.Stage_Enum.Gcode_Create: btn_open.interactable = false; btn_move.interactable = false; btn_scale.interactable = false; btn_rotate.interactable = false; img_moveContainer.GetComponent <Transform>().gameObject.SetActive(false); img_scaleContainer.GetComponent <Transform>().gameObject.SetActive(false); img_rotateContainer.GetComponent <Transform>().gameObject.SetActive(false); break; case StageManager.Stage_Enum.Gcode_Render: //Sigle thread so far //todo: Rendering/Rendered if (GcodeRenderManager.GetInstance().GetInfo().isParsing) { btn_open.interactable = false; btn_move.interactable = false; btn_scale.interactable = false; btn_rotate.interactable = false; img_moveContainer.GetComponent <Transform>().gameObject.SetActive(false); img_scaleContainer.GetComponent <Transform>().gameObject.SetActive(false); img_rotateContainer.GetComponent <Transform>().gameObject.SetActive(false); } else { btn_open.interactable = true; btn_move.interactable = true; btn_scale.interactable = true; btn_rotate.interactable = true; update_mode(); } break; case StageManager.Stage_Enum.Gcode_Send: btn_open.interactable = false; btn_move.interactable = false; btn_scale.interactable = false; btn_rotate.interactable = false; img_moveContainer.GetComponent <Transform>().gameObject.SetActive(false); img_scaleContainer.GetComponent <Transform>().gameObject.SetActive(false); img_rotateContainer.GetComponent <Transform>().gameObject.SetActive(false); break; } if (ModelManager.GetInstance().GetRenderOperateBean() != null) { if (!input_moveX.isFocused) { input_moveX.text = (ModelManager.GetInstance().GetRenderOperateBean().move.x).ToString("0.0"); } if (!input_moveY.isFocused) { input_moveY.text = (ModelManager.GetInstance().GetRenderOperateBean().move.y).ToString("0.0"); } if (!input_scale.isFocused) { input_scale.text = (ModelManager.GetInstance().GetRenderOperateBean().scale * 100).ToString("0.0"); } if (!input_rotateX.isFocused) { input_rotateX.text = (ModelManager.GetInstance().GetRenderOperateBean().rotate.x).ToString("0.0"); } if (!input_rotateY.isFocused) { input_rotateY.text = (ModelManager.GetInstance().GetRenderOperateBean().rotate.y).ToString("0.0"); } if (!input_rotateZ.isFocused) { input_rotateZ.text = (ModelManager.GetInstance().GetRenderOperateBean().rotate.z).ToString("0.0"); } slider_moveX.value = ModelManager.GetInstance().GetRenderOperateBean().move.x; slider_moveY.value = ModelManager.GetInstance().GetRenderOperateBean().move.y; slider_scale.value = ModelManager.GetInstance().GetRenderOperateBean().scale; slider_rotateX.value = ModelManager.GetInstance().GetRenderOperateBean().rotate.x; slider_rotateY.value = ModelManager.GetInstance().GetRenderOperateBean().rotate.y; slider_rotateZ.value = ModelManager.GetInstance().GetRenderOperateBean().rotate.z; } }
void animalOnUpdate() { GcodeRenderManager.GetInstance().DrawLayers(); }
public void OnOperateEnd() { //1.check if (_model3d == null) { return; } OperateBean lastBean = _undoStack.Peek(); if (lastBean.scale == _curOperateBean.scale && lastBean.move == _curOperateBean.move && lastBean.rotate == _curOperateBean.rotate) { Debug.Log("Model is not moved/scaled/rotated, return" + "\n"); GcodeRenderManager.GetInstance().SetActive_gcodeRender(true); return; } UnityEngine.Debug.Log("************************ OnOperateEnd ***************************" + "\n"); //2.release about gcode GcodeCreateManager.GetInstance().UnavailableCurGcodeCreateBean(); GcodeRenderManager.GetInstance().Destroy(); //3.operate bool moveChanged = lastBean.move != _curOperateBean.move; bool scaleChanged = lastBean.scale != _curOperateBean.scale; bool rotateChanged = lastBean.rotate != _curOperateBean.rotate; if (moveChanged) { Debug.Log("Model is moved" + "\n"); } if (scaleChanged) { Debug.Log("Model is scaled" + "\n"); } if (rotateChanged) { Debug.Log("Model is rotated" + "\n"); } //case1: only move param changed if (moveChanged && !scaleChanged && !rotateChanged) { //No need to update dataModel, vertical value not changed //update dataModel may costs lot time Debug.Log("Model is only moved" + "\n"); } else { //case2: scale/rotate changed Debug.Log("Model is scaled/rotated" + "\n"); //UpdateCurDataModel //dataModel will change _model3d.UpdateCurDataModel( _curOperateBean.scale, _curOperateBean.move.x, _curOperateBean.move.y, _curOperateBean.rotate.x, _curOperateBean.rotate.y, _curOperateBean.rotate.z ); //set render position float minZ_cur = _model3d.dataModel_cur.GetMinZ(); float minZ_origin = _model3d.dataModel_origin.GetMinZ(); float disZ = minZ_origin - minZ_cur; Vector3 newPosition = _model3d.renderedModel.shellCube.transform.localPosition; float y = -(_deviceSize.y - _model3d.GetOriginDataSize().z) / 2.0f; float localY = y / _deviceSize.y; newPosition.y = localY + disZ / _deviceSize.y; _model3d.renderedModel.shellCube.transform.localPosition = newPosition; //record _curOperateBean.localPosition = newPosition; //after UpdateCurDataModel and operate render model, //the dataModel_cur.GetSize is actural renderModel size _curOperateBean.size = _model3d.dataModel_cur.GetSize(); } //4.undo/redo _undoStack.Push(_curOperateBean.DeepCopy()); _redoStack.Clear(); UnityEngine.Debug.Log("***************************************************" + "\n"); }
public void OnOperateStart() { GcodeRenderManager.GetInstance().SetActive_gcodeRender(false); }
void Update() { btn_pause.GetComponent <Transform> ().gameObject.SetActive(false); switch (StageManager.GetCurStage()) { case StageManager.Stage_Enum.Idle: case StageManager.Stage_Enum.Load_Model: panel_content.SetActive(false); break; case StageManager.Stage_Enum.Gcode_Create: panel_content.SetActive(true); //widget : invisible btn_stop.GetComponent <Transform> ().gameObject.SetActive(false); text_nozzle.GetComponent <Transform> ().gameObject.SetActive(false); text_bed.GetComponent <Transform> ().gameObject.SetActive(false); text_nozzle_temp.GetComponent <Transform> ().gameObject.SetActive(false); text_bed_temp.GetComponent <Transform> ().gameObject.SetActive(false); // btn_pause.interactable = false; // btn_stop.interactable = false; // btn_pause.GetComponentInChildren<Text> ().text = "Pause"; // img_pause_icon.sprite = Resources.Load ("Images/Pause-Icon", typeof(Sprite))as Sprite; //progress float sliceProgress = GcodeCreateManager.GetInstance().GetInfo().progress; text_print_progress.text = "Slicing : " + (((int)(sliceProgress * 1000)) / 10.0f).ToString("0.0") + "%"; image_print_progress.fillAmount = sliceProgress; break; case StageManager.Stage_Enum.Gcode_Render: //widget : invisible btn_stop.GetComponent <Transform> ().gameObject.SetActive(false); text_nozzle.GetComponent <Transform> ().gameObject.SetActive(false); text_bed.GetComponent <Transform> ().gameObject.SetActive(false); text_nozzle_temp.GetComponent <Transform> ().gameObject.SetActive(false); text_bed_temp.GetComponent <Transform> ().gameObject.SetActive(false); if (GcodeRenderManager.GetInstance().GetInfo().isParsing) { panel_content.SetActive(true); //show render progress float progress = GcodeRenderManager.GetInstance().GetInfo().parseProgress; text_print_progress.text = "Rendering : " + (((int)(progress * 1000)) / 10.0f).ToString("0.0") + "%"; image_print_progress.fillAmount = progress; } else { panel_content.SetActive(false); } break; case StageManager.Stage_Enum.Gcode_Send: { panel_content.SetActive(true); //widget : invisible btn_stop.GetComponent <Transform> ().gameObject.SetActive(true); text_nozzle.GetComponent <Transform> ().gameObject.SetActive(true); text_bed.GetComponent <Transform> ().gameObject.SetActive(true); text_nozzle_temp.GetComponent <Transform> ().gameObject.SetActive(true); text_bed_temp.GetComponent <Transform> ().gameObject.SetActive(true); //temp float temp_cur_bed = GcodeSenderManager.GetInstance().GetInfo().temp_cur_bed; float temp_tar_bed = GcodeSenderManager.GetInstance().GetInfo().temp_target_bed; float temp_cur_nozzle = GcodeSenderManager.GetInstance().GetInfo().temp_cur_nozzle; float temp_tar_nozzle = GcodeSenderManager.GetInstance().GetInfo().temp_target_nozzle; text_bed_temp.text = Math.Round(temp_cur_bed) + "/" + temp_tar_bed + "°C"; text_nozzle_temp.text = Math.Round(temp_cur_nozzle) + "/" + temp_tar_nozzle + "°C"; //progress float progress = GcodeSenderManager.GetInstance().GetInfo().progress; text_print_progress.text = "Waiting : " + (((int)(progress * 1000)) / 10.0f).ToString("0.0") + "%"; image_print_progress.fillAmount = progress; if (GcodeSenderManager.GetInstance().GetInfo().sending_GcodeFile) { btn_pause.interactable = true; btn_stop.interactable = true; btn_pause.GetComponentInChildren <Text> ().text = "PAUSE"; img_pause_icon.sprite = Resources.Load("Images/Pause-Icon", typeof(Sprite)) as Sprite; } else { btn_pause.interactable = true; btn_stop.interactable = true; btn_pause.GetComponentInChildren <Text> ().text = "START"; img_pause_icon.sprite = Resources.Load("Images/START-Icon", typeof(Sprite)) as Sprite; } } break; } }
void Update() { //dropdown GcodeRenderManager.ColorScheme colorScheme = GcodeRenderManager.GetInstance().GetCurColorScheme(); if (colorScheme == GcodeRenderManager.ColorScheme.Material) { dropdown.value = 0; } else if (colorScheme == GcodeRenderManager.ColorScheme.Line_Type) { dropdown.value = 1; } //image if (colorScheme == GcodeRenderManager.ColorScheme.Material) { image_WALL_INNER.enabled = false; image_WALL_OUTER.enabled = false; image_SKIN.enabled = false; image_SKIRT.enabled = false; image_SUPPORT.enabled = false; image_FILL.enabled = false; image_Travel.enabled = false; image_TopLayer.enabled = false; } else if (colorScheme == GcodeRenderManager.ColorScheme.Line_Type) { image_WALL_INNER.enabled = true; image_WALL_OUTER.enabled = true; image_SKIN.enabled = true; image_SKIRT.enabled = true; image_SUPPORT.enabled = true; image_FILL.enabled = true; image_Travel.enabled = true; image_TopLayer.enabled = true; } //toggle toggle_Show_Shell.isOn = GcodeRenderManager.GetInstance().IsGcodeTypeShow(GcodeType.WALL_OUTER) && GcodeRenderManager.GetInstance().IsGcodeTypeShow(GcodeType.WALL_INNER) && GcodeRenderManager.GetInstance().IsGcodeTypeShow(GcodeType.SKIN); toggle_Skirt_Brim.isOn = GcodeRenderManager.GetInstance().IsGcodeTypeShow(GcodeType.SKIRT); toggle_Support_Raft.isOn = GcodeRenderManager.GetInstance().IsGcodeTypeShow(GcodeType.SUPPORT); toggle_Infill.isOn = GcodeRenderManager.GetInstance().IsGcodeTypeShow(GcodeType.FILL); toggle_Travels.isOn = GcodeRenderManager.GetInstance().IsGcodeTypeShow(GcodeType.Travel); toggle_Top_Layer.isOn = GcodeRenderManager.GetInstance().GetActive_Top_Layer(); //btn_arrow switch (StageManager.GetCurStage()) { case StageManager.Stage_Enum.Idle: case StageManager.Stage_Enum.Load_Model: case StageManager.Stage_Enum.Gcode_Create: case StageManager.Stage_Enum.Gcode_Send: btn_arrow.GetComponent <Button> ().gameObject.SetActive(false); break; case StageManager.Stage_Enum.Gcode_Render: if (GcodeRenderManager.GetInstance().GetInfo().isRendered) { btn_arrow.GetComponent <Button> ().gameObject.SetActive(true); } else { btn_arrow.GetComponent <Button> ().gameObject.SetActive(false); } break; } //panel_colorScheme panel_colorScheme.GetComponent <Transform> ().gameObject.SetActive(btn_arrow.GetComponent <Button> ().gameObject.activeInHierarchy); }
void Awake() { GcodeRenderManager.GetInstance().AddListener(this); GcodeSenderManager.GetInstance().AddListener(this); }
/*************** GcodeCreateManager.Listener: callback ***************/ //on sub thread public void OnGcodeCreated(GcodeCreateBean gcodeBean) { Debug.Log("@@ OnGcodeCreated" + "\n"); GcodeRenderManager.GetInstance().StartParseGcodeFile(gcodeBean.gcodePath); }
void Update() { switch (StageManager.GetCurStage()) { case StageManager.Stage_Enum.Idle: case StageManager.Stage_Enum.Load_Model: panel_content.SetActive(true); break; case StageManager.Stage_Enum.Gcode_Create: //render gcode is following, so do not set apart ‘creating’ from ‘created’ panel_content.SetActive(false); break; case StageManager.Stage_Enum.Gcode_Render: if (GcodeRenderManager.GetInstance().GetInfo().isParsing) { //rendering panel_content.SetActive(false); } else { //rendered panel_content.SetActive(true); } break; case StageManager.Stage_Enum.Gcode_Send: panel_content.SetActive(false); break; } //material if (ConfigManager.GetInstance().IsMaterial_PLA()) { dropdown_materials.value = 0; } else if (ConfigManager.GetInstance().IsMaterial_ABS()) { dropdown_materials.value = 1; } // else if (ConfigManager.GetInstance ().IsMaterial_Custom ()) { // dropdown_materials.value = 2; // } //adhesion if (ConfigManager.GetInstance().IsAdhesion_skirt()) { dropdown_adhesion.value = 0; } else if (ConfigManager.GetInstance().IsAdhesion_brim()) { dropdown_adhesion.value = 1; } else if (ConfigManager.GetInstance().IsAdhesion_raft()) { dropdown_adhesion.value = 2; } else if (ConfigManager.GetInstance().IsAdhesion_none()) { dropdown_adhesion.value = 3; } //support if (ConfigManager.GetInstance().IsSupport_buildplate()) { dropdown_support.value = 0; } else if (ConfigManager.GetInstance().IsSupport_everywhere()) { dropdown_support.value = 1; } else if (ConfigManager.GetInstance().IsSupport_none()) { dropdown_support.value = 2; } //profile if (ConfigManager.GetInstance().myBean_fastPrint.selected) { btn_fastPrint.interactable = false; btn_fastPrint.GetComponentInChildren <Text>().color = _textBlue; btn_normalQuality.interactable = true; btn_normalQuality.GetComponentInChildren <Text>().color = _textBlack; btn_highQuality.interactable = true; btn_highQuality.GetComponentInChildren <Text>().color = _textBlack; dropdown_customProfiles.GetComponentInChildren <Text>().color = _textBlack; } else if (ConfigManager.GetInstance().myBean_normalQuality.selected) { btn_fastPrint.interactable = true; btn_fastPrint.GetComponentInChildren <Text>().color = _textBlack; btn_normalQuality.interactable = false; btn_normalQuality.GetComponentInChildren <Text>().color = _textBlue; btn_highQuality.interactable = true; btn_highQuality.GetComponentInChildren <Text>().color = _textBlack; dropdown_customProfiles.GetComponentInChildren <Text>().color = _textBlack; } else if (ConfigManager.GetInstance().myBean_highQuality.selected) { btn_fastPrint.interactable = true; btn_fastPrint.GetComponentInChildren <Text>().color = _textBlack; btn_normalQuality.interactable = true; btn_normalQuality.GetComponentInChildren <Text>().color = _textBlack; btn_highQuality.interactable = false; btn_highQuality.GetComponentInChildren <Text>().color = _textBlue; dropdown_customProfiles.GetComponentInChildren <Text>().color = _textBlack; } else { //select custom profile btn_fastPrint.interactable = true; btn_fastPrint.GetComponentInChildren <Text>().color = _textBlack; btn_normalQuality.interactable = true; btn_normalQuality.GetComponentInChildren <Text>().color = _textBlack; btn_highQuality.interactable = true; btn_highQuality.GetComponentInChildren <Text>().color = _textBlack; dropdown_customProfiles.GetComponentInChildren <Text>().color = _textBlue; for (int i = 0; i < ConfigManager.GetInstance().GetCustomMyBeanList().Count; i++) { if (ConfigManager.GetInstance().GetCustomMyBeanList()[i].selected) { dropdown_customProfiles.value = i; break; } } } updateDropdown(); }