ModuleService.js 12.2 KB
var ATLAS_ANATOMY = 'Atlas Anatomy';
var CLINICAL_ILLUSTRATION = 'Clinical Illustrations';
var CLINICAL_ANIMATION = 'Clinical Animations';
var OpenedModuleItemList = [];
var ModDetail = [];
var moduleData;
var modName;

var moduleDataObj = {};
moduleDataObj.AAData = [];

moduleDataObj.DAData = [];
moduleDataObj.CIData = [];
moduleDataObj.CAData = [];
moduleDataObj.ThreeDData = [];

AIA.service('ModuleService', function ($http, DataService) {
    return {
        loadModuleDataBasedOnModuleName: function (moduleName) {
            var jsonPath;

            modName = moduleName;

            //debugger;
            if (moduleName == ATLAS_ANATOMY) {
                jsonPath = '~/../content/data/json/aa/aa_dat_contentlist.json';


            }
            else if (moduleName == CLINICAL_ANIMATION) {
                //to do, in next phase of project
                jsonPath = '~/../content/data/json/ca/ca_dat_contentlist.json';
            }
            else if (moduleName == CLINICAL_ILLUSTRATION) {
                //to do, in next phase of project
                jsonPath = '~/../content/data/json/ci/ci_dat_contentlist.json';
            }

            return $http.get(jsonPath, function (response) {

                moduleData = new jinqJs()
                                  .from(response.data.root.Item)
                                  .select();

                return moduleData;
            });
        },

        GetOpenedTileData: function (id, moduleJson) {

            if (modName == ATLAS_ANATOMY) {
                var AADataForSelectedItem = [];

                var title = id;

                var selectedTileData = new jinqJs()
                                 .from(moduleJson.data.root.Item)
                                 .where("_Title == " + title)
                                  .select();

                AADataForSelectedItem.push(selectedTileData[0]._ImageId);
                AADataForSelectedItem.push(selectedTileData[0]._BodyRegion);
                AADataForSelectedItem.push(selectedTileData[0]._BodySystem);
                AADataForSelectedItem.push(selectedTileData[0]._ImageName);
                AADataForSelectedItem.push(selectedTileData[0]._ImageType);
                AADataForSelectedItem.push(selectedTileData[0]._TileImageName);
                AADataForSelectedItem.push(selectedTileData[0]._Title);

                AADataForSelectedItem.push("ViewOrientation: " + selectedTileData[0]._ViewOrientation);

                return AADataForSelectedItem;

            }

        },

        getPinDataForImage: function (imageName) {

            var pindataFileNamePart1 = imageName.replace("aa_img_", "");
            var pinFileNamePart2 = pindataFileNamePart1.replace(".jpg", "");

            var pinDatajsonPath = '~/../content/data/json/aa/aa_pindata/aa_dat_pindata_' + pinFileNamePart2 + '.json';


            return $http.get(pinDatajsonPath, function (response) {

                var pinData = new jinqJs()
                                  .from(response.data.Root.Item)
                                  .select();

                return pinData;
            });

        },

        getTermTextDataForPin: function (moduleName) {

            var jsonPath;
            if (moduleName == ATLAS_ANATOMY) {
                jsonPath = '~/../content/data/json/aa/aa_dat_term.json';

            }

            return $http.get(jsonPath, function (response) {
                var termdata = new jinqJs()
                                  .from(response.data.Terms.Term)
                                  .select();
                // alert(pinData.Root.Item);
                return termdata;
            });

        },

        getTermTextDataForAAImage: function (imageId) {


            var jsonPath = '~/../content/data/json/aa/aa_pinterm/aa_dat_pinterm_' + imageId + '.json';


            return $http.get(jsonPath, function (response) {

                return response;
            });

        },

        getData: function (param) {


            var jsonPath = '~/../content/data/json/aa/aa_pinterm/aa_dat_pinterm_' + param + '.json';



        },

        getModuleData: function (moduleName) {
            if (moduleName == "ATLAS_ANATOMY")
                return moduleDataObj.AAData;
            else if (moduleName == "DISSECTIBLE_ANATOMY")
                return moduleDataObj.DAData;
            else if (moduleName == "CLINICAL_ILLUSTRATIONS")
                return moduleDataObj.CIData;
            else if (moduleName == "CLINICAL_ANIMATIONS")
                return moduleDataObj.CAData;
            else if (moduleName == "THREE_D_ANATOMY")
                return moduleDataObj.ThreeDData;
            
        },

        setModuleData: function (windowData, windowId, SlideNo) {

            if (windowData.mType == "THREE_D_ANATOMY") {
                moduleDataObj.ThreeDData.push({
                    slideId: SlideNo,
                    currentWindowId: windowId,
                    mType: windowData.mType,
                    threeDData:windowData.threeDData,
                    containsCapturedContent: windowData.containsCapturedContent,
                    anatomyTitle: windowData.windowTitle,
                    scrollPosition: windowData.scrollPosition,
                    imageId: windowData.imageId,
                    maximised: windowData.maximised,
                    minimised: windowData.minimised,
                    id: windowData.id,
                    position: windowData.position,
                    size: windowData.size,
                    contextMenu: windowData.contextMenu,
                    contentPath: windowData.contentPath
                });
            }
            else if (windowData.mType == "CLINICAL_ANIMATIONS") {
                moduleDataObj.CAData.push({
                    slideId: SlideNo,
                    currentWindowId: windowId,
                    mType: windowData.mType,
                    containsCapturedContent: windowData.containsCapturedContent,
                    textVisible: windowData.textVisible,
                    anatomyTitle: windowData.windowTitle,
                    horizontalScroll: windowData.scrollFlvPosition.horizontal + 'px',
                    verticalScroll: windowData.scrollFlvPosition.vertical + 'px',
                    imageId: windowData.imageId,
                    maximised: windowData.maximised,
                    minimised: windowData.minimised,
                    id: windowData.id,
                    position: windowData.position,
                    size: windowData.size,
                    contextMenu: windowData.contextMenu
                });
            }
            else if (windowData.mType == "CLINICAL_ILLUSTRATIONS") {
                moduleDataObj.CIData.push({
                    slideId: SlideNo,
                    currentWindowId: windowId,
                    mType: windowData.mType,
                    containsCapturedContent: windowData.containsCapturedContent,
                    textVisible: windowData.textVisible,
                    anatomyTitle: windowData.windowTitle,
                    horizontalScroll: windowData.scrollPosition.horizontal + 'px',
                    verticalScroll: windowData.scrollPosition.vertical + 'px',
                    imageId: windowData.imageId,
                    maximised: windowData.maximised,
                    minimised: windowData.minimised,
                    id: windowData.id,
                    position: windowData.position,
                    size: windowData.size,
                    contextMenu: windowData.contextMenu,
                    annotationData: windowData.annotationData
                });
            }
            else if (windowData.mType == "ATLAS_ANATOMY") {
                moduleDataObj.AAData.push({
                    slideId:SlideNo,
                    currentWindowId: windowId,
                    mType: windowData.mType,
                    anatomyTitle: windowData.windowTitle,
                    selectedPinTermId: windowData.selectedStructureID,
                    selectedPins: windowData.selectedPins,
                    selectedBodysystemId: windowData.bodySystemId,
                    hideAnnotations: windowData.hideCallOuts,
                    horizontalScroll: windowData.scrollPosition.horizontal + 'px',
                    verticalScroll: windowData.scrollPosition.vertical + 'px',
                    zoomLevel: windowData.scaleIndex,
                    showSelectedPins: windowData.showSelectedPins,
                    hideAllPins: windowData.hideAllPins,
                    showAllPins:windowData.showAllPins,
                    selectedCallouts: windowData.selectedCallouts,
                    imageId: windowData.imageId,
                    maximised: windowData.maximised,
                    minimised: windowData.minimised,
                    annotationData:windowData.annotationData,
                    id:windowData.id,
                    position: windowData.position,
                    size: windowData.size,
                    contextMenu:windowData.contextMenu
                });
            }
            else if (windowData.mType == "DISSECTIBLE_ANATOMY") {
                moduleDataObj.DAData.push({
                    slideId: SlideNo,
                    currentWindowId: windowId,
                    currentBodyViewId: windowData.id,
                    windowTitle: windowData.windowTitle,
                    skinId: windowData.skinId,
                    isModestyOn: windowData.isModestyOn,
                    size: windowData.size,
                    position: windowData.position,
                    layerNumber: windowData.layerNumber,
                    zoom: windowData.zoom,

                    maximised: windowData.maximised,
                    highlightOptionsSelectedId: windowData.highlightOptionsSelectedId,
                    selectedStructureId: windowData.selectedStructureId,
                    isModuleLoaded: windowData.isModuleLoaded,
                    isTopToolBarVisible: windowData.isTopToolBarVisible,
                    transparencyValue: windowData.transparencyValue,
                    imageId: windowData.imageId,
                    containsCapturedContent: windowData.containsCapturedContent,
                    layerNumberTransparency: windowData.layerNumberTransparency,
                    isTitleBarVisible: windowData.isTitleBarVisible,
                    clickedTermList: windowData.clickedTermList,
                    isResizeLock: windowData.isResizeLock,
                    mode: windowData.mode,
                    isLeftToolBarVisible: windowData.isLeftToolBarVisible,
                    contentDescriptorId: windowData.contentDescriptorId,
                    bodySystemTermList: windowData.bodySystemTermList,
                    isTransparent: windowData.isTransparent,
                    windowListId: windowData.windowListId,
                    canvasVScrollX: windowData.canvasVScrollX,
                    canvasHScrollX: windowData.canvasHScrollX,
                    callOuts: windowData.callOuts,
                    mType: windowData.mType,

                    isCallOutVisible: windowData.isCallOutVisible,

                    minimised: windowData.minimised,
                    annotationData: windowData.annotationData,

                    transparencyBounds: windowData.transparencyBounds

                });
            }
            

        },

        ClearWinData: function () {

            moduleDataObj.DAData = [];
            moduleDataObj.AAData = [];
            moduleDataObj.CIData = [];
            moduleDataObj.CAData = [];
            moduleDataObj.ThreeDData = [];
            
        },
        ClearWinDataByModule: function (moduleName) {
            if (moduleName == "ATLAS_ANATOMY")
            {
                moduleDataObj.AAData = [];
            }
            else if (moduleName == "DISSECTIBLE_ANATOMY")
            {
                moduleDataObj.DAData = [];
            }
            else if (moduleName == "CLINICAL_ILLUSTRATIONS")
            {
                moduleDataObj.CIData = [];
            }
            else if (moduleName == "CLINICAL_ANIMATIONS")
            {
                moduleDataObj.CAData = [];
            }
            else if (moduleName == "THREE_D_ANATOMY")
            {
                moduleDataObj.ThreeDData = [];
            }

        },



    };
});