Exemplo n.º 1
0
    void Start()
    {
        Edge1    = gameObject.transform.Find("Edge (1)").GetComponent <LineRenderer> ();
        Edge2    = gameObject.transform.Find("Edge (2)").GetComponent <LineRenderer> ();
        Edge3    = gameObject.transform.Find("Edge (3)").GetComponent <LineRenderer> ();
        Edge4    = gameObject.transform.Find("Edge (4)").GetComponent <LineRenderer> ();
        Edge5    = gameObject.transform.Find("Edge (5)").GetComponent <LineRenderer> ();
        Edge6    = gameObject.transform.Find("Edge (6)").GetComponent <LineRenderer> ();
        Edge7    = gameObject.transform.Find("Edge (7)").GetComponent <LineRenderer> ();
        Edge8    = gameObject.transform.Find("Edge (8)").GetComponent <LineRenderer> ();
        Edge9    = gameObject.transform.Find("Edge (9)").GetComponent <LineRenderer> ();
        Edge10   = gameObject.transform.Find("Edge (10)").GetComponent <LineRenderer> ();
        Edge11   = gameObject.transform.Find("Edge (11)").GetComponent <LineRenderer> ();
        Edge12   = gameObject.transform.Find("Edge (12)").GetComponent <LineRenderer> ();
        RectXMin = gameObject.transform.Find("RectXMin").GetComponent <LineRenderer> ();
        RectXMax = gameObject.transform.Find("RectXMax").GetComponent <LineRenderer> ();
        RectYMin = gameObject.transform.Find("RectYMin").GetComponent <LineRenderer> ();
        RectYMax = gameObject.transform.Find("RectYMax").GetComponent <LineRenderer> ();

        if (!listeningToEvents)
        {
            PatientEventSystem.startListening(PatientEventSystem.Event.DICOM_NewLoaded, eventNewDICOM);
            PatientEventSystem.startListening(PatientEventSystem.Event.PATIENT_Closed, patientClosed);
            listeningToEvents = true;                   // Don't call startListening again when disabling and re-enabling this object.
        }

        // In case a DICOM is already loaded:
        eventNewDICOM();
    }
    // ===============================================================
    // 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);
        }
    }
    // ===============================================================
    // Update loop:
    public void Update()
    {
        if (newDirectoryParsed)
        {
            PatientEventSystem.triggerEvent(PatientEventSystem.Event.DICOM_NewList);
            newDirectoryParsed = false;

            // Let loading screen know what we're currently doing:
            PatientEventSystem.triggerEvent(PatientEventSystem.Event.LOADING_RemoveLoadingJob,
                                            "DICOM directory parsing");
        }
        if (newDICOMLoaded)
        {
            newDICOMLoaded = false;
            if (newlyLoadedDICOM != null)
            {
                if (newlyLoadedDICOM.dimensions == 2)
                {
                    currentDICOM = newlyLoadedDICOM as DICOM2D;
                    // Let Listeners know that we've loaded a new DICOM:
                    PatientEventSystem.triggerEvent(PatientEventSystem.Event.DICOM_NewLoadedSlice, currentDICOM);
                }
                else
                {
                    currentDICOMVolume = newlyLoadedDICOM as DICOM3D;
                    // Let Listeners know that we've loaded a new DICOM:
                    PatientEventSystem.triggerEvent(PatientEventSystem.Event.DICOM_NewLoadedVolume, currentDICOMVolume);
                }
            }
        }
    }
Exemplo n.º 4
0
    void removeLoadingJob(object obj)
    {
        if (!LoadingScreenWidget.activeSelf)
        {
            return;
        }

        string msg = obj as string;

        if (msg != null)
        {
            if (activeJobs.Contains(msg))
            {
                activeJobs.Remove(msg);
            }
        }
        updateInfo();

        // If all jobs have finished, close loading screen:
        if (activeJobs.Count <= 0)
        {
            LoadingScreenWidget.SetActive(false);
            // Let others know that loading is considered finished:
            // (TODO: maybe move this elsewhere?
            PatientEventSystem.triggerEvent(PatientEventSystem.Event.PATIENT_FinishedLoading);
        }
    }
Exemplo n.º 5
0
 void OnDisable()
 {
     // Unregister myself - no longer receive events (until the next OnEnable() call):
     PatientEventSystem.stopListening(PatientEventSystem.Event.DICOM_NewLoadedVolume, eventDisplayCurrentDicom);
     PatientEventSystem.stopListening(PatientEventSystem.Event.PATIENT_Closed, eventClear);
     PatientEventSystem.stopListening(PatientEventSystem.Event.DICOM_CloseVolume, eventClear);
 }
Exemplo n.º 6
0
 void Start()
 {
     PatientEventSystem.startListening(PatientEventSystem.Event.PATIENT_StartLoading, eventStartLoadingMesh);
     PatientEventSystem.startListening(PatientEventSystem.Event.MESH_LoadedSingle, eventFinishLoadingMesh);
     PatientEventSystem.startListening(PatientEventSystem.Event.PATIENT_FinishedLoading, eventFinishLoadingAllMeshes);
     PatientEventSystem.startListening(PatientEventSystem.Event.PATIENT_Closed, eventPatientClosed);
 }
Exemplo n.º 7
0
    // Use this for initialization
    void OnEnable()
    {
        tabButton.SetActive(false);
        rawImageObj.SetActive(false);

        text = textObj.GetComponent <Text>();
        string msg = bold("Patient Information");

        msg      += "\n\nNo patient loaded.";
        text.text = msg;

        PatientEventSystem.startListening(PatientEventSystem.Event.PATIENT_Loaded, eventNewPatientLoaded);
        PatientEventSystem.startListening(PatientEventSystem.Event.PATIENT_Closed, eventPatientClosed);

        Patient loadedPatient = Patient.getLoadedPatient();

        Debug.Log("Loaded patient: " + loadedPatient);
        if (loadedPatient != null)
        {
            eventNewPatientLoaded(loadedPatient);
        }
        else
        {
            eventPatientClosed();
        }
    }
Exemplo n.º 8
0
 public void closePatient()
 {
     Patient.close();
     PatientEventSystem.triggerEvent(PatientEventSystem.Event.PATIENT_Closed);
     layoutSystem.closeAllWidgets();
     closePatientButton.SetActive(false);
     savePatientButton.SetActive(false);
     PatientSelector.SetActive(true);
 }
Exemplo n.º 9
0
 void OnDisable()
 {
     // Unregister myself - no longer receive events (until the next OnEnable() call):
     PatientEventSystem.stopListening(PatientEventSystem.Event.DICOM_NewList, eventNewDicomList);
     PatientEventSystem.stopListening(PatientEventSystem.Event.DICOM_StartLoading, eventHideDICOM);
     PatientEventSystem.stopListening(PatientEventSystem.Event.DICOM_NewLoaded, eventDisplayCurrentDicom);
     PatientEventSystem.stopListening(PatientEventSystem.Event.DICOM_AllCleared, eventClear);
     PatientEventSystem.stopListening(PatientEventSystem.Event.PATIENT_Closed, eventClear);
 }
Exemplo n.º 10
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();
    }
Exemplo n.º 11
0
 void OnEnable()
 {
     // Register event callbacks for all DICOM events:
     PatientEventSystem.startListening(PatientEventSystem.Event.DICOM_NewLoadedVolume, eventDisplayCurrentDicom);
     PatientEventSystem.startListening(PatientEventSystem.Event.PATIENT_Closed, eventClear);
     PatientEventSystem.startListening(PatientEventSystem.Event.DICOM_CloseVolume, eventClear);
     eventClear();
     //eventDisplayCurrentDicom ();
     buildMesh();
 }
Exemplo n.º 12
0
    void OnEnable()
    {
        // Register event callbacks for MESH events:
        PatientEventSystem.startListening(PatientEventSystem.Event.MESH_LoadedSingle, meshLoaded);
        PatientEventSystem.startListening(PatientEventSystem.Event.PATIENT_Closed, patientClosed);

        mMeshLoader = GameObject.Find("GlobalScript").GetComponent <MeshLoader>();

        activate();
    }
Exemplo n.º 13
0
    void setView(int index, bool animate = true)
    {
        Patient p = Patient.getLoadedPatient();

        if (p != null)
        {
            if (p.getViewCount() == 0)
            {
                viewNameText.text = "No views configured.";
            }
            else
            {
                View view = p.getView(index);
                if (view != null)
                {
                    viewNameText.text  = (index + 1).ToString();
                    viewNameText.text += ": ";
                    viewNameText.text += view.name;

                    if (animate)
                    {
                        // Slowly zoom and rotate towards the target:
                        meshViewerScaleNode.GetComponent <ModelZoomer> ().setTargetZoom(view.scale, 0.8f);
                        meshViewerRotationNode.GetComponent <ModelRotator> ().setTargetOrientation(view.orientation, 0.8f);
                    }
                    else
                    {
                        meshViewerScaleNode.GetComponent <ModelZoomer> ().setTargetZoom(view.scale);
                        meshViewerRotationNode.GetComponent <ModelRotator> ().setTargetOrientation(view.orientation);
                    }

                    foreach (KeyValuePair <string, double> entry in view.opacities)
                    {
                        setMeshOpacity(entry.Key, (float)entry.Value);
                    }

                    currentViewIndex = index;
                }
            }

            PatientEventSystem.triggerEvent(PatientEventSystem.Event.MESH_Opacity_Changed);

            updateViewCount();

            if (p.getViewCount() > 0)
            {
                deleteButton.interactable = true;
            }
            else
            {
                deleteButton.interactable = false;
            }
        }
    }
Exemplo n.º 14
0
 void OnEnable()
 {
     // Register event callbacks for all DICOM events:
     PatientEventSystem.startListening(PatientEventSystem.Event.DICOM_NewList, eventNewDicomList);
     PatientEventSystem.startListening(PatientEventSystem.Event.DICOM_StartLoading, eventHideDICOM);
     PatientEventSystem.startListening(PatientEventSystem.Event.DICOM_NewLoaded, eventDisplayCurrentDicom);
     PatientEventSystem.startListening(PatientEventSystem.Event.DICOM_AllCleared, eventClear);
     PatientEventSystem.startListening(PatientEventSystem.Event.PATIENT_Closed, eventClear);
     eventClear();
     eventNewDicomList();
     //eventDisplayCurrentDicom ();
 }
Exemplo n.º 15
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.");
        }
    }
Exemplo n.º 16
0
    void OnEnable()
    {
        // Register event callbacks for MESH events:
        PatientEventSystem.startListening(PatientEventSystem.Event.MESH_LoadedAll, createContent);
        PatientEventSystem.startListening(PatientEventSystem.Event.PATIENT_Closed, clearContent);

        mMeshLoader = GameObject.Find("GlobalScript").GetComponent <MeshLoader>();
        defaultLine.SetActive(false);
        if (mMeshLoader.MeshGameObjectContainers.Count != 0)
        {
            createContent();
        }
    }
Exemplo n.º 17
0
    // Use this for initialization
    void Start()
    {
        // Get the text components to be modified later:
        //mTextLoadingProcess = TextLoadingProcess.GetComponent<Text> ();
        mTextPatientName = TextPatientName.GetComponent <Text> ();

        // Start listening to events which are called during the loading process:
        PatientEventSystem.startListening(PatientEventSystem.Event.PATIENT_StartLoading,
                                          loadingStarted);
        PatientEventSystem.startListening(PatientEventSystem.Event.LOADING_AddLoadingJob,
                                          addLoadingJob);
        PatientEventSystem.startListening(PatientEventSystem.Event.LOADING_RemoveLoadingJob,
                                          removeLoadingJob);
    }
Exemplo n.º 18
0
    void Start()
    {
        // Register event callbacks for all Patient events:
        PatientEventSystem.startListening(PatientEventSystem.Event.PATIENT_FinishedLoading, patientLoaded);
        PatientEventSystem.startListening(PatientEventSystem.Event.PATIENT_Closed, patientClosed);

        InputDeviceManager.instance.setLeftControllerTouchpadIconCentral(ToolSelectSprite);

        foreach (Transform child in transform)
        {
            child.gameObject.SetActive(false);
        }
        updateAvailableTools();
    }
Exemplo n.º 19
0
    // Use this for initialization
    void Start()
    {
        // Get the scroll view defined for the widget:
        mScrollView = transform.Find("Background/Scroll View").gameObject;
        // Disable the default button:
        defaultPatientButton = mScrollView.transform.Find("Viewport/Content/ButtonPatient").gameObject;
        defaultPatientButton.SetActive(false);

        PatientEventSystem.startListening(
            PatientEventSystem.Event.PATIENT_NewPatientDirectoryFound,
            addPatientEntry
            );

        PatientDirectoryLoader.setPath("../Patients/");
    }
Exemplo n.º 20
0
    void OnEnable()
    {
        PatientEventSystem.startListening(PatientEventSystem.Event.DICOM_CloseVolume, eventDicomClosed);
        PatientEventSystem.startListening(PatientEventSystem.Event.DICOM_NewLoadedVolume, eventNewDicom);
        PatientEventSystem.startListening(PatientEventSystem.Event.DICOM_StartLoadingVolume, eventLoadingStarted);

        // If a DICOM is already loaded, display the transfer function and histogram:
        if (DICOMLoader.instance.currentDICOMVolume != null)
        {
            eventNewDicom();
        }
        else
        {
            eventDicomClosed();
        }
    }
Exemplo n.º 21
0
    /*! Starts processing the new path, by searching the subfolders for patients. */
    public static void setPath(string newPath)
    {
        //Debug.Log( "Current working directory:\n" + Directory.GetCurrentDirectory() );

        if (!Directory.Exists(newPath))
        {
            throw (new System.Exception("Invalid path given: " + newPath));
        }

        // While parsing a directory, don't start parsing another one:
        if (!currentlyLoading)
        {
            currentlyLoading = true;

            // remove previously found patient entries:
            mPatientEntries.Clear();

            currentPath = newPath;

            Debug.Log("Looking for Patients in:\n" + currentPath);

            string[] folders = Directory.GetDirectories(currentPath);

            foreach (string folder in folders)
            {
                // Attempt to load the directorie's contents as a patient:
                PatientMeta newPatient = PatientMeta.createFromFolder(folder);
                if (newPatient != null)
                {
                    mPatientEntries.Add(newPatient);

                    // Let listeners know there's a new patient entry by firing an event:
                    PatientEventSystem.triggerEvent(
                        PatientEventSystem.Event.PATIENT_NewPatientDirectoryFound
                        );
                }
            }

            // Done parsing, unlock:
            currentlyLoading = false;
        }
    }
Exemplo n.º 22
0
    // Update is called once per frame
    void Update()
    {
        if (loaded)
        {
            StartCoroutine("LoadFileExecute");
            unityMeshes = new List <List <UnityMesh> >();
            loaded      = false;
            Path        = "";
        }
        if (triggerEvent)
        {
            blenderObjects = new List <BlenderObjectBlock>();
            meshJson       = null;
            triggerEvent   = false;

            // Let loading screen know what we're currently doing:
            PatientEventSystem.triggerEvent(PatientEventSystem.Event.LOADING_RemoveLoadingJob, "Mesh");
            PatientEventSystem.triggerEvent(PatientEventSystem.Event.MESH_LoadedAll);
        }
    }
Exemplo n.º 23
0
    private void PatientLoaderCallback(object sender, RunWorkerCompletedEventArgs e)
    {
        //BackgroundWorker worker = sender as BackgroundWorker;
        if (e.Cancelled)
        {
            Debug.Log("[Patient.cs] Patient Loading cancelled"); //Not implemented in worker yet
        }
        else if (e.Error != null)
        {
            Debug.LogError("[Patient.cs] Error while loading the patient");
        }
        else
        {
            loadedPatient = this;

            // Let other widgets know the patient information is now available:
            PatientEventSystem.triggerEvent(PatientEventSystem.Event.PATIENT_Loaded, this);
        }
        return;
    }
Exemplo n.º 24
0
    public static void loadPatient(int index)
    {
        if (loadingLock)
        {
            Debug.LogWarning("[PatientDirectoryLoader.cs] Loading aborted. Still loading other patient");
            return;
        }

        loadingLock = true;
        if (index >= 0 && index < mPatientEntries.Count)
        {
            entry = mPatientEntries[index];

            PatientEventSystem.triggerEvent(PatientEventSystem.Event.PATIENT_StartLoading, entry);

            new Patient(entry);
        }
        else
        {
            throw (new System.Exception("Could not find patient with index " + index.ToString()));
        }
    }
    // ===============================================================
    // 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);
        }
    }
Exemplo n.º 26
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);
        }
    }
Exemplo n.º 27
0
    // Use this for initialization
    void Start()
    {
        PatientEventSystem.startListening(
            PatientEventSystem.Event.PATIENT_NewPatientDirectoryFound,
            addPatientEntry
            );

        PatientEventSystem.startListening(
            PatientEventSystem.Event.PATIENT_FinishedLoading,
            loadedPatient
            );

        // Start loading the patient directory:
        PatientDirectoryLoader.setPath("../Patients/");

        // Activate all the objects:
        sphere.SetActive(true);
        sphereEmitters.SetActive(true);

        // Start the animations of the objects, and set their normalized time to 1 (the end)
        sphereEmitters.GetComponent <Animator> ().Play("EnableSphereEmitters", -1, 1f);
        sphere.GetComponent <Animator> ().Play("EnableSphere", -1, 1f);
    }
Exemplo n.º 28
0
        public void OnEnable()
        {
            layoutSystem = new LayoutSystem();

            indicatorLeft.SetActive(false);
            indicatorRight.SetActive(false);
            statusBar.SetActive(true);

            Transform tf = statusBar.transform.Find("ButtonClose");

            if (tf != null)
            {
                closePatientButton = tf.gameObject;
                closePatientButton.GetComponent <Button> ().onClick.AddListener(() => closePatient());
                closePatientButton.SetActive(false);
            }
            else
            {
                Debug.LogWarning("ButtonClose not found on Status Bar!");
            }

            tf = statusBar.transform.Find("ButtonSave");
            if (tf != null)
            {
                savePatientButton = tf.gameObject;
                savePatientButton.GetComponent <Button> ().onClick.AddListener(() => savePatient());
                savePatientButton.SetActive(false);
            }
            else
            {
                Debug.LogWarning("ButtonSave not found on Status Bar!");
            }

            PatientEventSystem.startListening(PatientEventSystem.Event.PATIENT_FinishedLoading, patientLoaded);
            //PatientEventSystem.startListening (PatientEventSystem.Event.PATIENT_Closed, hidePatientDefaultUI );
        }
Exemplo n.º 29
0
 void OnDisable()
 {
     // Unregister myself:
     PatientEventSystem.stopListening(PatientEventSystem.Event.PATIENT_Closed, RemoveMesh);
 }
Exemplo n.º 30
0
 void OnEnable()
 {
     // Register event callbacks:
     PatientEventSystem.startListening(PatientEventSystem.Event.PATIENT_Closed, RemoveMesh);
 }