ohif-viewer/Packages/ohif-viewerbase/client/lib/classes
2017-02-23 14:01:16 -03:00
..
metadata Bug Fix: Only first frame of multiframe images is being rendered. 2017-01-29 22:11:18 -02:00
ImageSet.js Initial work on Nucleus parity merge 2017-01-29 22:11:17 -02:00
LayoutManager.js Allowing follow-up number to be controlled by configuration 2017-02-23 14:01:16 -03:00
OHIFError.js Initial work on Nucleus parity merge 2017-01-29 22:11:17 -02:00
README.md README.md file for important objects in ohif-viewerbase lib/classes/ folder 2017-02-01 15:35:49 -02:00
ResizeViewportManager.js Provinding a new fitToWindow option for resizing viewports 2017-02-01 16:32:11 -02:00
StackImagePositionOffsetSynchronizer.js jslint 2017-02-08 21:10:01 -02:00
TypeSafeCollection.js Extending capabilities of "findBy" method from TypeSafeCollection to search an ordered dataset as needed by hanging-protocols package. 2017-01-29 22:11:17 -02:00

Table of contents

In this document, some important objects are described. In the files there are comments that can help better undestand methods and properties.

The Resize Viewport Manager object

This object has multiple functions to manage window resize event. It relocates Dialogs, resizes viewport elements and scrollbars and some other UI components such as Study and Series Quick Switch, when available.

Usage

It's only necessary to bind handleResize function to the window resize event as follows. The ohif:viewerbase package needs to be imported by the referring code as well.

import { Viewerbase } from 'meteor/ohif:viewerbase';

const ResizeViewportManager = new Viewerbase.ResizeViewportManager();
window.addEventListener('resize', ResizeViewportManager.handleResize.bind(ResizeViewportManager));

An example os its usage can be found in ohif-viewerbase/client/components/viewer/viewerMain/viewerMain.js.

The Image Set object

An object that represents a list of images that are associated by any arbitrary criteria being thus content agnostic. Besides the main attributes (images and uid) it allows additional attributes to be appended to it (currently indiscriminately, but this should be changed).

Usage

ImageSet constructor requires an array of SOP instances like in the example below. It's necessary to import ohif:viewerbase.

import { Viewerbase } from 'meteor/ohif:viewerbase';

const imageSet = new Viewerbase.ImageSet(sopInstances);

imageSet.setAttributes({
    displaySetInstanceUid: imageSet.uid,
    seriesInstanceUid: seriesData.seriesInstanceUid,
    seriesNumber: seriesData.seriesNumber,
    seriesDescription: seriesData.seriesDescription,
    numImageFrames: instances.length,
    frameRate: instance.getRawValue('x00181063'),
    modality: seriesData.modality,
    isMultiFrame: isMultiFrame(instance)
});

// Sort instances by InstanceNumber (0020,0013)
imageSet.sortBy((a, b) => {
    return (parseInt(a.getRawValue('x00200013', 0)) || 0) - (parseInt(b.getRawValue('x00200013', 0)) || 0);
});

Each SOP instance in this example is an instance of OHIFInstanceMetadata object, which is a specialization of InstanceMetadata. To read more about the Metadata API click here.

The Layout Manager object

Objects of this class are responsible for creating, organizing and maintaining (manage) viewport rendering. It creates a grid, positioning viewports accordingly to it's configuration keeping all viewports data (in viewportData property) for easy access from other components. It support many layout configurations and some of them were fully tested: 1x1, 1x2, 1x3, 2x1, 2x2, 2x3, 3x1, 3x2, 3x3. Other configurations may work as well. Finally it provides some useful functions to move through viewports and zoom it.

Usage

In order to use LayoutManager the ohif:viewerbase package needs to be imported by the referring code and instantiated as follows. An example os its usage is in ohif-viewerbase/client/components/viewer/viewerMain/viewerMain.js.

import { Viewerbase } from 'meteor/ohif:viewerbase';

// Get an array of studies object. This function needs to be implemented, it does not exist.
const studies = getArrayOfStudiesObjects();
const parentElement = document.getElementById('layoutManagerTarget');
const LayoutManager = new Viewerbase.LayoutManager(parentElement, studies);

The default configuration is 1x1, and to change it just set layoutProps and call updateViewports to update the layout as follows.

import { Viewerbase } from 'meteor/ohif:viewerbase';

// Get an array of studies object. This function needs to be implemented, it does not exist.
const studies = getArrayOfStudiesObjects();
const parentElement = document.getElementById('layoutManagerTarget');
const LayoutManager = new LayoutManager(parentElement, studies);

// Set the layout proprerties to 2x2 layout
LayoutManager.layoutProps = {
    rows: 2,
    columns: 2
};

// It will render four viewports: two in each row.
LayoutManager.updateViewports();

The layoutManagerTarget element will have a new class layout-2-2 (to allow further styling) and it's inner content will a new div#imageViewerViewports that has four inner elements like the following (some elements and attributes were removed for example purpose):

<div class="viewportContainer active" style="height:50%; width:50%;">
    <div class="removable">
        <div class="imageViewerViewport">
            <canvas></canvas>
        </div>
        <div class="imageViewerViewportOverlay"></div>
        <div class="imageViewerLoadingIndicator"></div>
        <div class="imageViewerErrorLoadingIndicator"></div>
        <div class="viewportOrientationMarkers"></div>
    </div>
</div>

Each of this div.viewportContainer will have some classes to help CSS specific styling accordingly to the element's position in the grid: top, middle and bottom. This classes are added by viewer/components/gridLayout/ component in ohif-viewerbase package.

The Type Safe Collections

With the introduction of the new Study Metadata API in which study metadata is represented by class hierarchies (using prototype-based inheritance), the usage of standard Minimongo collections as a central client-side storage for this data became no longer an option. Standard Mongo and Minimongo collections internally flatten data (in other words, data gets serialized) before storage hence no functions or prototype chains are preserved. In that scenario, when an object is restored (fetched), what is returned is actually a flattened copy of the original object with no functions or prototype (it's no longer an instance of it's original class). As an attempt to overcome this limitation a new type of collection was intruduced: the TypeSafeCollection.

The TypeSafeCollection is a simple list-like collection which tries to implement an API similar but not compatible with Mongo's API. It supports basic features like search by attribute map and ID, retrieval by index, sorting of result sets, insertion, removal and reactive operations but, unlike Mongo's API, it (still) lacks support to advanced functionality like complex search criterea or flexible sorting options.

Usage

In order to use TypeSafeCollection the ohif:viewerbase package needs to be imported by the referring code and instantiated as follows.

Basic usage:

import { Viewerbase } from 'meteor/ohif:viewerbase';

const users = new Viewerbase.TypeSafeCollection();
let id = users.insert({
    data: {
        name: 'John Doe',
        age: 45
    },
    getName() {
        return this.data.name;
    }
});