Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create visualization graph #1011

Merged
merged 57 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from 40 commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
164d7f9
add a blank
YukaUU Jun 10, 2024
fe4eee4
Merge branch 'yukaUU_GSoC_db_Mark_add_centerPosition_and_Zoom' into y…
YukaUU Jun 13, 2024
a2d41a9
Add log at Toolbar and logAnnotation callback
YukaUU Jun 16, 2024
fc7ba17
add log side menu
YukaUU Jun 30, 2024
91c0996
Added opening/closing of side menu/ header
YukaUU Jul 2, 2024
c2e0231
add log annotation icon
YukaUU Jul 3, 2024
d9b78d5
draft pull request
YukaUU Jul 6, 2024
a1f8279
add sideMenu on right
YukaUU Jul 6, 2024
08ed4f3
add collapsiblelist in Log Panel
YukaUU Jul 6, 2024
a154cbb
add collapsible list on right side menu
YukaUU Jul 7, 2024
50f70a0
add collapsiblelist in Log Panel
YukaUU Jul 7, 2024
78026e7
add layers on log panel using $UI.layers,$UI.layers.list
YukaUU Jul 8, 2024
71c3d13
add original component
YukaUU Jul 9, 2024
0fd78db
logの情報を取り出す
YukaUU Jul 13, 2024
144f139
change function fetchMark : logAnnotaiton
YukaUU Jul 13, 2024
20038b6
add loadingLog function
YukaUU Jul 13, 2024
4013f34
add visualizationLayerItems in dataloader
YukaUU Jul 14, 2024
3d8ef72
create graph in log panel
YukaUU Jul 15, 2024
7ff366e
add data calculate
YukaUU Jul 15, 2024
c05437c
create graph
YukaUU Jul 15, 2024
431550c
fix from log to visualization in subtool
YukaUU Jul 15, 2024
3b0f51b
fix id: 'visualization_panel'
YukaUU Jul 15, 2024
1d78faa
fix:visualizationSideMenu
YukaUU Jul 15, 2024
15e43e1
fix id and $UI.visualizationList (CollapsibleList )
YukaUU Jul 15, 2024
7ef73f6
fix visualizationlist
YukaUU Jul 15, 2024
84650dc
fix side menu size
YukaUU Jul 15, 2024
bc73fef
fix titleVisualization
YukaUU Jul 15, 2024
3c71ed3
fix createVisualizationViewer
YukaUU Jul 15, 2024
d919cb8
fix VisualizationViewer (is logsViewer instance)
YukaUU Jul 15, 2024
ffd169a
fix $UI.visualizatiomViewer
YukaUU Jul 15, 2024
48b84a8
fix id overvisuzalization
YukaUU Jul 15, 2024
302db07
fix css , js pass
YukaUU Jul 15, 2024
da45fb2
delete addHumanItem in visualizationviewer.js
YukaUU Jul 15, 2024
be6e49d
fix comment
YukaUU Jul 15, 2024
2bc6ec9
add comment
YukaUU Jul 15, 2024
4d9c558
delete console.log
YukaUU Jul 15, 2024
9b9f79e
fix dataloader and $D
YukaUU Jul 15, 2024
ced2289
add comment
YukaUU Jul 15, 2024
5d0604c
fix comments
YukaUU Jul 16, 2024
88d1846
delete graph in info page
YukaUU Jul 16, 2024
10a8801
change name from states to viewerStates
YukaUU Jul 18, 2024
29e4a08
fix
YukaUU Jul 18, 2024
67c0196
add zooming in each annotation at Multi mode
YukaUU Jul 18, 2024
467755e
ad zoom data each annotation
YukaUU Jul 18, 2024
7204c13
add viewerStates in each annotation at multi mode
YukaUU Jul 18, 2024
277397e
add viewerStates in each annotation at multi mode
YukaUU Jul 18, 2024
17e6f80
fix Multi mode on the pencil tool seems to save all annotations
YukaUU Jul 18, 2024
037c693
fix error This line has a length of 148. Maximum allowed is 125
YukaUU Jul 18, 2024
27c7fd3
delete viewerStates ( previuos commit :added viewerStates each annota…
YukaUU Jul 18, 2024
e748f61
fix visualization panel using $D.visualizations.geometries.features
YukaUU Jul 18, 2024
a093930
fix small bug
YukaUU Jul 18, 2024
4e6f480
remove viewerStates:image
YukaUU Jul 18, 2024
0076c4d
fix point viewerStates
YukaUU Jul 19, 2024
591a265
fix small bug
YukaUU Jul 20, 2024
eb64052
Remove unused code from viewer.html
YukaUU Jul 20, 2024
179d08a
delete unused code
YukaUU Jul 20, 2024
01ffbd9
fix comment in visualizationviewer
YukaUU Jul 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ The toolbar is in the top-left of the main content window. Use the toolbar butto
| ![](https://fonts.gstatic.com/s/i/materialicons/bug_report/v4/24px.svg) | Bug Report | Report a bug or give feedback. |
| ![](https://fonts.gstatic.com/s/i/materialicons/camera_enhance/v4/24px.svg) | Slide Capture | Click to take a screenshot of the slide and annotations on it. |
| ![](https://fonts.gstatic.com/s/i/materialicons/help/v4/24px.svg) | Tutorial | Click to view a guided tour of the viewer tools. |

| ![](https://fonts.gstatic.com/s/i/materialicons/auto_graph/v4/24px.svg) | Visualization | Click to view visualizations of annotations. |

## Toolbar Shortcuts

Expand Down
18 changes: 15 additions & 3 deletions apps/viewer/dataloaders.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,27 @@ function layersLoader() {
console.error(error);
});
}

// visualization
function visualization() {
$CAMIC.store.findMark($D.params.slideId).then(function(layers) {
$D.visualizations = [...layers.map(covertToVisualization)];
visualizationLayerItems($D.visualizations);
}).catch(function(error) {
// overlayers schema
$UI.message.addError('Loading Logs is Error');
console.error(error);
});
}

var checkCoreIsReady = setInterval(function() {
if ($UI.layersViewer && $UI.layersViewerMinor) {
if ($UI.layersViewer && $UI.layersViewerMinor && $UI.visualizatiomViewer) {
clearInterval(checkCoreIsReady);
loadingHumanOverlayers();
loadingRulerOverlayers();
loadingHeatmapOverlayers();
loadingComputerOverlayers();
visualization();
}
}, 500);
}


173 changes: 164 additions & 9 deletions apps/viewer/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ function initialize() {
}
}, 100);
}

// setting core functionalities
function initCore() {
// start initial
Expand Down Expand Up @@ -179,6 +178,7 @@ function initCore() {
$D.pages.table = '../../../';
}

console.log($D);
try {
const slideQuery = {};
slideQuery.id = $D.params.slideId;
Expand Down Expand Up @@ -222,8 +222,8 @@ function initCore() {
}
// for support QUIP 2.0
const data = Array.isArray(e.data) ? e.data[e.data.selected] : e.data;
const type = data.provenance.analysis.source;

const type = data.provenance.analysis.source;
let body;
let attributes;
let warning = null;
Expand Down Expand Up @@ -668,6 +668,17 @@ async function initUIcomponents() {
value: 'slCap',
callback: captureSlide,
});

// visualization panel
subToolsOpt.push({
name: 'visualization',
icon: 'auto_graph', // material icons' name
title: 'visualization',
value: 'visualization',
type: 'btn',
callback: visualization,
});

subToolsOpt.push({
name: 'tutorial',
icon: 'help',
Expand Down Expand Up @@ -737,10 +748,15 @@ async function initUIcomponents() {
callback: toggleSideMenu,
});

const loading = `<div class="cover" style="z-index: 500;"><div class="block"><span>loading layers...</span><div class="bar"></div></div></div>`;
$UI.layersSideMenu.addContent(loading);
// TODO add layer viewer

$UI.visualizationSideMenu = new SideMenu({
id: 'visualization_panel',
width: 250,
contentPadding: 5,
position: 'right',
height: '45vh',
// , isOpen:true
callback: toggleSideMenu,
});

/* annotation popup */
$UI.annotPopup = new PopupPanel({
Expand Down Expand Up @@ -850,7 +866,6 @@ async function initUIcomponents() {
// const minorViewerData = $D.overlayers.map((d) => {
// return {item: d, isShow: false};
// });

$UI.AssistantViewer = new Assistant({
id: 'ml_assistant',
viewer: $CAMIC.viewer,
Expand Down Expand Up @@ -881,7 +896,26 @@ async function initUIcomponents() {
callback.bind('minor'),
rootCallback.bind('minor'),
);

// create UI and set data
// $UI.VisualizationViewer = createVisualizationViewer(
// 'overvisuzalization',
// null,
// callback.bind('main'),
// rootCallback.bind('main'),
// );
// // create UI and set data - minor
// $UI.visualizatiomViewerMinor = createVisualizationViewer(
// 'overvisuzalizationMinor',
// null,
// callback.bind('minor'),
// rootCallback.bind('minor'),
// );
$UI.visualizatiomViewer = createVisualizationViewer(
'overvisuzalization',
null,
callback.bind('main'),
rootCallback.bind('main'),
);
// TODO move to add layers
// if ($D.params.states && $D.params.states.l) {
// $D.params.states.l.forEach((id) =>
Expand All @@ -908,13 +942,43 @@ async function initUIcomponents() {
// console.log(e);
},
});

$UI.visualizationList = new CollapsibleList({
id: 'visualizationlist',
list: [
{
id: 'visualizationlist',
title: 'Human:Draw Annotation',
content: 'No Template Loaded', // $UI.annotOptPanel.elt
// isExpand:true
},
// {
// id: 'heatMap',
// title: 'HeatMap',
// content: 'No Template Loaded', // $UI.algOptPanel.elt,
// },
],
changeCallBack: function(e) {
// console.log(e);
},
});
$UI.layersSideMenu.clearContent();
// add to layers side menu
const title = document.createElement('div');
title.classList.add('item_head');
title.textContent = 'Layers Manager';

$UI.layersSideMenu.addContent(title);
// add to log side menu
const titleVisualization = document.createElement('div');
titleVisualization.classList.add('item_head');
titleVisualization.textContent = 'Visualization Panel';
// add CSS
titleVisualization.style.color = '#365f9c';
titleVisualization.style.fontSize = '20px';
titleVisualization.style.backgroundColor = 'rgba(220, 220, 220, 1)';
titleVisualization.style.marginTop = '28px';

$UI.visualizationSideMenu.addContent(titleVisualization);

// loading status
$UI.loadStatus = document.createElement('div');
Expand Down Expand Up @@ -954,6 +1018,16 @@ async function initUIcomponents() {
$UI.layersList.elt.parentNode.removeChild($UI.layersList.elt);
closeMinorControlPanel();
$UI.layersSideMenu.addContent($UI.layersList.elt);

// visualization
$UI.visualizationList.clearContent('visualizationlist');
$UI.visualizationList.addContent('visualizationlist', $UI.visualizatiomViewer.elt);
// $UI.visualizationList.clearContent('heatMap');
// $UI.visualizationList.addContent('heatMap', $UI.visualizatiomViewerMinor.elt);

$UI.visualizationList.elt.parentNode.removeChild($UI.visualizationList.elt);
closeMinorControlPanel();
$UI.visualizationSideMenu.addContent($UI.visualizationList.elt);
}
}, 300);

Expand Down Expand Up @@ -1320,6 +1394,31 @@ function createLayerViewer(id, viewerData, callback, rootCallback) {
return layersViewer;
}

// function createVisualizationViewer(id, viewerData, callback, rootCallback) {
// const visualizatiomViewer = new LayersViewer({
// id: id,
// data: viewerData,
// removeCallback: removeCallback,
// locationCallback: locationCallback,
// callback: callback,
// rootCallback: rootCallback,

// });
// visualizatiomViewer.elt.parentNode.removeChild(visualizatiomViewer.elt);
// return visualizatiomViewer;
// }
function createVisualizationViewer(id, viewerData, callback, rootCallback) {
const visualizatiomViewer = new VisualizationViewer({
id: id,
data: viewerData,
removeCallback: removeCallback,
locationCallback: locationCallback,
callback: callback,
rootCallback: rootCallback,
});
visualizatiomViewer.elt.parentNode.removeChild(visualizatiomViewer.elt);
return visualizatiomViewer;
}
// create lay panel for side-by-side control
function createLayPanelControl() {
$UI.layCtrlbar = document.createElement('div');
Expand Down Expand Up @@ -1438,6 +1537,7 @@ function addHumanLayerItems() {
}, mainViewerItems);

$UI.layersViewer.addHumanItems(mainViewerItems);
// $UI.visualizatiomViewer.addHumanItems(mainViewerItems);

// minor viewer minorViewer
const minorViewerItems = {
Expand Down Expand Up @@ -1478,7 +1578,11 @@ function addHumanLayerItems() {
}, minorViewerItems);

$UI.layersViewerMinor.addHumanItems(minorViewerItems);
// $UI.visualizatiomViewerMinor.addHumanItems(minorViewerItems);
}
// function addLogItems(){

// }
function openLoadStatus(text) {
const txt = $UI.loadStatus.querySelector('.text');
txt.textContent = `Loading ${text}`;
Expand All @@ -1497,6 +1601,8 @@ function addRulerLayerItems(data) {
});
$UI.layersViewer.addItems(mainViewerData, 'ruler');
$UI.layersViewerMinor.addItems(minorViewerData, 'ruler');
// $UI.visualizatiomViewer.addItems(mainViewerData, 'ruler');
// $UI.visualizatiomViewerMinor.addItems(minorViewerData, 'ruler');
}

function addComputerLayerItems(data) {
Expand All @@ -1509,6 +1615,8 @@ function addComputerLayerItems(data) {
});
$UI.layersViewer.addItems(mainViewerData, 'segmentation');
$UI.layersViewerMinor.addItems(minorViewerData, 'segmentation');
// $UI.visualizatiomViewer.addItems(mainViewerData, 'segmentation');
// $UI.visualizatiomViewerMinor.addItems(minorViewerData, 'segmentation');
}

function addHeatmapLayerItems(data) {
Expand All @@ -1521,6 +1629,53 @@ function addHeatmapLayerItems(data) {
});
$UI.layersViewer.addItems(mainViewerData, 'heatmap');
$UI.layersViewerMinor.addItems(minorViewerData, 'heatmap');
// $UI.visualizatiomViewer.addItems(mainViewerData, 'heatmap');
// $UI.visualizatiomViewerMinor.addItems(minorViewerData, 'heatmap');
}

function visualizationLayerItems(data) {
var initialZommingData = [];

// Get initial data
$D.visualizations.map((d) => {
if (d.states) {
for (let i = 0; i < d.geometries.features.length; i++) {
initialZommingData.push(roundToSecondDecimalPlace(d.states.zoom));
}
}
});
let result = countOccurrences(initialZommingData);

$UI.visualizatiomViewer.visualization('myChart', result);
}

// Function to round to decimal places
function roundToSecondDecimalPlace(num) {
return Math.round(num * 100) / 100;
}

function countOccurrences(arr) {
// Create objects for counting
let countMap = {};

// Count each element in the array
arr.forEach(function(value) {
if (countMap[value] === undefined) {
countMap[value] = 1;
} else {
countMap[value]++;
}
});

// Convert the result to a 2-dimensional array
let result = [];
for (let key in countMap) {
if (countMap.hasOwnProperty(key)) {
result.push([parseFloat(key), countMap[key]]);
}
};

return result;
}

// const mainViewerData = $D.overlayers.map((d) => {
Expand Down
16 changes: 16 additions & 0 deletions apps/viewer/uicallbacks.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,9 @@ function toolsOff() {
case 'download_selection':
downloadSelectionOff();
break;
case 'log':
$UI.visualizationSideMenu.close();
break;
}
}

Expand Down Expand Up @@ -2736,6 +2739,19 @@ async function captureSlide() {
$UI.layersSideMenu.close();
}

/* Log annotaiton */
let isSidemenuOpen = true;

function visualization() {
if (isSidemenuOpen == true) {
$UI.visualizationSideMenu.open();
isSidemenuOpen = false;
} else {
$UI.visualizationSideMenu.close();
isSidemenuOpen = true;
};
}

function downloadSlideCapture(combiningCanvas) {
const imageData = combiningCanvas.toDataURL('image/jpeg');
const downloadLink = document.createElement('a');
Expand Down
Loading
Loading