コード例 #1
0
    public void OnModelManager_ParseModelError()
    {
        Debug.LogError("OnModelManager_ParseModelError" + "\n");
        StageManager.SetStage_Idle();

        AlertMananger.GetInstance().ShowAlertMsg("Unable to open the file.");
    }
コード例 #2
0
    void onClick_connect()
    {
        if (PortConnectManager.GetInstance().IsConnected())
        {
            AlertMananger.GetInstance().ShowConfirmDialog("Disconnect", "Are you sure you want to disconnect? The printing will fail if you disconnect when printing.", this);
            return;
        }

        if (PortConnectManager.GetInstance().IsConnecting())
        {
            AlertMananger.GetInstance().ShowToast("Connecting, wait a minute.");
            return;
        }

        if (PortConnectManager.GetAllPortNames().Count == 0)
        {
            Debug.LogWarning("No port found" + "\n");
            AlertMananger.GetInstance().ShowToast("Please connect the printer to your computer using the provided USB cable.");
            return;
        }

        if (dropdown_port.value >= PortConnectManager.GetAllPortNames().Count)
        {
            AlertMananger.GetInstance().ShowToast("Selelct a port first.");
            return;
        }

        //try to connect
        _loadingMsgId = AlertMananger.GetLoadingMsgId();
        AlertMananger.GetInstance().ShowAlertLoading("Connecting...", _loadingMsgId);

        string portName = PortConnectManager.GetAllPortNames()[dropdown_port.value];

        PortConnectManager.GetInstance().Connect(portName);
    }
コード例 #3
0
    private void onClick_export()
    {
        if (StageManager.GetStageList().Contains(StageManager.Stage_Enum.Gcode_Render) &&
            GcodeRenderManager.GetInstance().GetInfo().isRendered&&
            StageManager.GetCurStage() != StageManager.Stage_Enum.Gcode_Send)
        {
            if (GcodeRenderManager.GetInstance().IsInBounds())
            {
                string path        = ModelManager.GetInstance().GetInfo().modelPath;
                string defaultName = System.IO.Path.GetFileNameWithoutExtension(path);
                string exportPath  = FileDialogManager.GetInstance().ShowFileSaveDialog_Gcode(defaultName);

                if (string.IsNullOrEmpty(exportPath) || exportPath.Trim().Length == 0)
                {
                    Debug.LogWarning("Gcode export is empty");
                }
                else
                {
                    string originPath = GcodeCreateManager.GetInstance().curGcodeBean.gcodePath;
                    startSubThreadToExportGcode(originPath, exportPath);
                }
            }
            else
            {
                AlertMananger.GetInstance().ShowAlertMsg("Unable to print. The model goes beyond the work area.");
            }
        }
    }
コード例 #4
0
 public static AlertMananger GetInstance()
 {
     if (_INSTANCE == null)
     {
         _INSTANCE = new AlertMananger();
     }
     return(_INSTANCE);
 }
コード例 #5
0
    /*************** preview ***************/
    void onClick_preview()
    {
        if (ModelManager.GetInstance().GetModel() == null)
        {
            AlertMananger.GetInstance().ShowToast("Please open a file to preview.");
            return;
        }

        if (!ModelManager.GetInstance().GetInfo().printable)
        {
            AlertMananger.GetInstance().ShowToast("Please move, scale or rotate the model so that it's within the build volume.");
            return;
        }

        if (!ConfigManager.GetInstance().GetSelectedMyBean().IsValuesAvailable())
        {
            AlertMananger.GetInstance().ShowToast("Invalid configuration. Please check.");
            GameObject.Find("panel_configDisplay").GetComponent <ControlConfigDisplay>().ShowConfigDisplayPanelAnima();
            return;
        }

        Vector3 size = ModelManager.GetInstance().GetModel().GetCurDataSize();

        if (size.x < 2 && size.y < 2 && size.z < 2)
        {
            AlertMananger.GetInstance().ShowToast("Model is too tiny to print.");
            return;
        }

        //model is too thin to print
        //todo change content of alert msg
        if (ModelManager.GetInstance().GetRenderOperateBean().size.z < ConfigManager.GetInstance().GetSelectedMyBean().bean.overrides.layer_height.default_value)
        {
            AlertMananger.GetInstance().ShowAlertMsg("The thickness of model is less than 1 layer. Modify model or decrease the value of ‘Layer Height’.");
            return;
        }

        string stlFilepath        = ModelManager.GetInstance().SaveModelAsStlFile();
        string configJsonFilePath = Application.streamingAssetsPath + "/CrossPlatform/CuraEngine/Config/" + "output.def.json";

        ConfigManager.GetInstance().GetSelectedMyBean().ArchiveForPrint(configJsonFilePath);

        if (StageManager.GetStageList().Contains(StageManager.Stage_Enum.Gcode_Render))
        {
            if (!GcodeCreateManager.GetInstance().NeedSlice(stlFilepath, configJsonFilePath))
            {
                AlertMananger.GetInstance().ShowToast("You are already in Preview.");
                return;
            }
        }

        GcodeRenderManager.GetInstance().Destroy();
        GcodeCreateManager.GetInstance().StartSubThread_CreateGcode(stlFilepath, configJsonFilePath);
    }
コード例 #6
0
    public void OnSendStoped()
    {
        Debug.Log("OnSendStoped" + "\n");
        AlertMananger.GetInstance().ShowAlertMsg("Printing stoped. Please do NOT touch the heated bed and nozzle.");

        //hack
        if (ConfigManager.GetInstance().GetSelectedMyBean().bean.name == "customize")
        {
            ConfigManager.GetInstance().GetSelectedMyBean().writable = true;
        }
    }
コード例 #7
0
    /*************** GcodeSenderManager.Listener call back ***************/
    public void OnSendStarted()
    {
        Debug.Log("OnSendStarted" + "\n");
        AlertMananger.GetInstance().ShowToast("Before printing starts, it will take a few minutes to heat the heated bed and extruder.");

        //hack
        if (ConfigManager.GetInstance().GetSelectedMyBean().bean.name == "customize")
        {
            ConfigManager.GetInstance().GetSelectedMyBean().writable = false;
        }
    }
コード例 #8
0
    private void doExportGcode(object obj)
    {
        List <string> list       = (List <string>)obj;
        string        originPath = list[0];
        string        exportPath = list[1];

        _loadingMsgId = AlertMananger.GetLoadingMsgId();
        AlertMananger.GetInstance().ShowAlertLoading("Exporting...", _loadingMsgId);
        //todo: may exception occured
        Debug.Log("Gcode export: " + originPath + "--->" + exportPath + "\n");
        File.Copy(originPath, exportPath, true);

        AlertMananger.GetInstance().DismissAlertLoading(_loadingMsgId);
        AlertMananger.GetInstance().ShowToast("Successfully export gcode.");
    }
コード例 #9
0
    //on main thread
    public void OnModelManager_RenderModelSucceed()
    {
        Debug.Log("OnModelManager_RenderModelSucceed" + "\n");

        if (ModelManager.GetInstance().GetModel() == null)
        {
            //todo: parse exception, then alert user
            Debug.LogError("Model3d is null");
            return;
        }

        //3.set material of shellCube children
        ModelManager.GetInstance().SetPrintable(true);

        //4.add model to scence
        //rotate print space to front
        Transform transform = GameObject.Find("Print_cube").transform;

        transform.localEulerAngles = Vector3.zero;
        ModelManager.GetInstance().GetModel().renderedModel.shellCube.transform.parent = transform;
        ModelManager.GetInstance().SetModelInitialLocalPosition();

        //5.update shellCubeOriginLocalScale
        //Attention: must do it, use to scale stl model. must do it after parentCube be added into go_printCube
        ModelManager.GetInstance().GetModel().renderedModel.shellCubeOriginLocalScale = ModelManager.GetInstance().GetModel().renderedModel.shellCube.transform.localScale;

        if (ModelManager.GetInstance().GetModel() != null)
        {
            //slider
            slider_scale.value    = ModelManager.GetInstance().GetRenderOperateBean().scale;
            slider_scale.minValue = ModelManager.GetInstance().GetScaleRange().x;
            slider_scale.maxValue = ModelManager.GetInstance().GetScaleRange().y;
        }

        Vector3 size = ModelManager.GetInstance().GetCurDataSize();
        float   min  = 10.0f;

        if (Mathf.Max(size.x, size.y, size.z) < min)
        {
            AlertMananger.GetInstance().ShowAlertMsg("Model is too tiny to see, scale first");
        }
    }
コード例 #10
0
 public void OnGcodeParseFailed()
 {
     Debug.Log("OnGcodeParseFailed" + "\n");
     AlertMananger.GetInstance().ShowAlertMsg("Unable to generate G-code for this model.");
 }
コード例 #11
0
 public void OnPortOpenFailed(string portName, string reason)
 {
     AlertMananger.GetInstance().ShowAlertMsg("Failed to connect. The port may be used by another software.");
     AlertMananger.GetInstance().DismissAlertLoading(_loadingMsgId);
 }
コード例 #12
0
 public void OnPortError(string portName, string errorMsg)
 {
     AlertMananger.GetInstance().ShowAlertMsg("Error occurs." + "\n" + errorMsg);
 }
コード例 #13
0
 public void OnPortPullOut(string portName)
 {
     AlertMananger.GetInstance().ShowToast("Cable disconnected.");
 }
コード例 #14
0
 public void OnPortConnectTimeOut(string portName)
 {
     AlertMananger.GetInstance().DismissAlertLoading(_loadingMsgId);
     AlertMananger.GetInstance().ShowAlertMsg("Connection timeout, try again.");
 }
コード例 #15
0
 public void OnPortDisconnect(string portName)
 {
     AlertMananger.GetInstance().DismissAlertLoading(_loadingMsgId);
     AlertMananger.GetInstance().ShowToast("Disconnected from " + "\"" + portName + "\"");
 }
コード例 #16
0
 public void OnModelManager_ParseModelSucceed()
 {
     Debug.Log("OnModelManager_ParseModelSucceed" + "\n");
     AlertMananger.GetInstance().ShowToast("Loading file succeed.");
 }
コード例 #17
0
 /*************** ModelManager call back ***************/
 public void OnModelManager_ParseModelStarted()
 {
     Debug.Log("OnModelManager_ParseModelStarted" + "\n");
     StageManager.SetStage_Load_Model();
     AlertMananger.GetInstance().ShowToast("Start loading.");
 }
コード例 #18
0
 void onClick_stop()
 {
     AlertMananger.GetInstance().ShowConfirmDialog("Printing", "Are you sure you want to stop? The printing cannot resume if you stop now.", this);
 }