// ===============================================================
    // DICOM Loading:

    /*! Starts loading the given DICOM, if available.
     * \note If slice is negative, this loads the entire volume!
     * \return true if loading process is started, false if the loader is currently busy. */
    public bool startLoading(DICOMSeries toLoad, int slice = 0)
    {
        if (!isBusy && toLoad != null)
        {
            // Lock:
            isBusy = true;

            seriesToLoad = toLoad;
            sliceToLoad  = slice;
            ThreadUtil t = new ThreadUtil(load, loadCallback);
            t.Run();

            // Let event system know what we're currently doing:
            PatientEventSystem.triggerEvent(PatientEventSystem.Event.LOADING_AddLoadingJob,
                                            "Loading DICOM series " + toLoad.seriesUID);

            if (slice >= 0)
            {
                PatientEventSystem.triggerEvent(PatientEventSystem.Event.DICOM_StartLoadingSlice);
            }
            else
            {
                PatientEventSystem.triggerEvent(PatientEventSystem.Event.DICOM_StartLoadingVolume);
            }

            return(true);
        }
        else
        {
            return(false);
        }
    }
Beispiel #2
0
    public Patient( PatientMeta meta )
        : base(meta)
    {
        PatientEventSystem.stopListening (PatientEventSystem.Event.PATIENT_FinishedLoading, finishedLoading);	// if we were listening already, stop
        PatientEventSystem.startListening (PatientEventSystem.Event.PATIENT_FinishedLoading, finishedLoading);
        PatientEventSystem.startListening (PatientEventSystem.Event.PATIENT_Closed, closePatient);

        ThreadUtil t = new ThreadUtil(this.PatientLoaderWorker, this.PatientLoaderCallback);
        t.Run();
    }
Beispiel #3
0
    /*! This methode starts the loading of a .blend file
     * \param pathToMeshJson path to a .blend file */
    public void LoadFile(string pathToMeshJson)
    {
        //Check if mesh.json exists
        if (!File.Exists(pathToMeshJson))
        {
            Debug.LogWarning("Could not load mesh from: " + pathToMeshJson + ", file not found.");
            return;
        }

        // Read mesh.json
        string fileContent = "";
        string line;

        System.IO.StreamReader file = new System.IO.StreamReader(pathToMeshJson);
        while ((line = file.ReadLine()) != null)
        {
            fileContent += line;
        }
        file.Close();
        meshJson = JsonMapper.ToObject <MeshJson>(fileContent);
        if (meshJson == null)
        {
            Debug.LogWarning("Error while parsing mesh.json");
            return;
        }
        Patient currentPatient = Patient.getLoadedPatient();
        string  path           = currentPatient.path + "/" + meshJson.pathToBlendFile;

        //Loading blend file
        if (File.Exists(path))
        {
            // Let loading screen know what we're currently doing:
            PatientEventSystem.triggerEvent(PatientEventSystem.Event.LOADING_AddLoadingJob, "Mesh");
            this.RemoveMesh();
            this.Path = path;
            MeshGameObjectContainers = new List <GameObject>();

            // Reset scale, rotation, position:
            meshNode.transform.localScale           = new Vector3(0.007f, 0.007f, 0.007f);
            meshNode.transform.parent.localScale    = new Vector3(1.0f, 1.0f, 1.0f);
            meshNode.transform.parent.localRotation = Quaternion.identity;
            //meshNode.transform.parent.Rotate (90, 0, 0);
            meshNode.transform.parent.GetComponent <ModelRotator>().setTargetOrientation(Quaternion.Euler(90, 0, 0));

            ThreadUtil t = new ThreadUtil(this.LoadFileWorker, this.LoadFileCallback);
            t.Run();
        }
        else
        {
            Debug.LogWarning("Could not load mesh from: '" + path + "', file not found.");
        }
    }
    // ===============================================================
    // Directory parsing:

    /*! Starts searching the given path for DICOMs.
     * \return true if loading process is started, false if the loader is currently busy. */
    public bool setDirectory(string path)
    {
        if (!isBusy)
        {
            // Lock:
            isBusy = true;

            directoryToLoad = path;
            ThreadUtil t = new ThreadUtil(parseDirectory, parseDirectoryCallback);
            t.Run();

            // Let event system know what we're currently doing:
            PatientEventSystem.triggerEvent(PatientEventSystem.Event.LOADING_AddLoadingJob,
                                            "DICOM directory parsing");

            return(true);
        }
        else
        {
            return(false);
        }
    }
Beispiel #5
0
    private void showHTML(Patient.AdditionalInformation info)
    {
        rawImageObj.SetActive(false);
        html = info.content;
        //The width of the viewport (can be resized)
        int widthOfViewport = (int)viewPort.GetComponent <RectTransform>().rect.width - 17;

        //int widthOfStretchedRawImage = (int)rawImageObj.GetComponent<RawImage>().rectTransform.rect.width;
        widthOfViewport = Math.Max(1, widthOfViewport); //prevent widthOfStrechedRawImage to be less then 1
        int widthBody = findBodyWidth(info.content);

        //If body with in html file is taller the space in the viewport, the body width attribute in html file is set to widthOfStretchedRawImage
        if (widthBody > widthOfViewport)
        {
            html = rewriteBodyWidth(info.content, widthOfViewport);
        }

        ThreadUtil t = new ThreadUtil(this.showHTMLWorker, this.showHTMLCallback);

        t.Run();

        return;
    }
Beispiel #6
0
    // ===============================================================
    // DICOM Loading:

    /*! Starts loading the given DICOM, if available.
     * \note If slice is negative, this loads the entire volume!
     * \return true if loading process is started, false if the loader is currently busy. */
    public bool startLoading(DICOMSeries toLoad, int slice = 0)
    {
        if (!isBusy && toLoad != null)
        {
            // Lock:
            isBusy = true;

            seriesToLoad = toLoad;
            sliceToLoad  = slice;
            ThreadUtil t = new ThreadUtil(load, loadCallback);
            t.Run();

            // Let event system know what we're currently doing:
            PatientEventSystem.triggerEvent(PatientEventSystem.Event.LOADING_AddLoadingJob,
                                            "DICOM directory parsing");

            return(true);
        }
        else
        {
            return(false);
        }
    }