Changeset 37256
- Timestamp:
- 2023-02-03T00:08:09+13:00 (15 months ago)
- Location:
- gs3-installations/mars/trunk/sites/mars/collect/amc-essentia
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
gs3-installations/mars/trunk/sites/mars/collect/amc-essentia/etc/collectionConfig.xml
r37254 r37256 736 736 <hr/> 737 737 <div style="float: right"> 738 <span class="display-view-modes" onclick="hideAVChart();">Hide AV Chart</span> 738 <span id="hide-av-chart-rtab" class="display-view-modes" style="display: inline-block;" onclick="hideAVChart();">Hide AV Chart</span> 739 <br/> 740 <span id="clear-user-av-chart-rtab" class="display-view-modes" style="display: inline-block;" onclick="clearRecordedUserAVChart();">Clear AV Chart</span> 739 741 </div> 740 742 … … 744 746 cursor: url(<xsl:value-of select="$library_name"/>/sites/<xsl:value-of select="$site_name"/>/collect/<xsl:value-of select="$collName"/>/images/crosshair-cursor-black32.png) 16 16, crosshair 745 747 } 746 .record-cursor { 748 749 .record-cursor-NeededToTriggerResourceLoad { 747 750 cursor: url(<xsl:value-of select="$library_name"/>/sites/<xsl:value-of select="$site_name"/>/collect/<xsl:value-of select="$collName"/>/images/crosshair-cursor-red32.png) 16 16, crosshair 748 751 } … … 879 882 </span> 880 883 <input onclick="return preSubmit(this.form);" type="submit" value="Make Arousal-Valence Recommendation"/> 881 <div id="makeRecommendationFrom-AV" style="font-style: italics; font-size: 90%; ">884 <div id="makeRecommendationFrom-AV" style="font-style: italics; font-size: 90%; display: none;"> <!-- **** --> 882 885 <xsl:text> </xsl:text> 886 </div> 887 <div id="overall-personal-bias" style="font-style: italics; font-size: 90%;"> 888 Personal Bias (Arousal,Valence): No user recordings currently made 883 889 </div> 884 890 </div> -
gs3-installations/mars/trunk/sites/mars/collect/amc-essentia/js/av_document.js
r37254 r37256 386 386 } 387 387 displayClampedCurrentTimeAndAV(); 388 389 if (isRecordingUserAV) { 390 appendRecordedUserAVVals(); 391 } 388 392 }); 389 393 … … 538 542 } 539 543 544 var hasExistingUserRecording = false; 545 540 546 var isRecordingUserAV = false; 547 548 var recordedUserArousalVal = 0; 549 var recordedUserValenceVal = 0; 550 var recordedUserCanvasX = 0; 551 var recordedUserCanvasY = 0; 552 553 var recordedAVs = { 554 predArousal: [], 555 predValence: [], 556 userArousal: [], 557 userValence: [], 558 diffArousal: [], 559 diffValence: [], 560 561 canvasX: [], 562 canvasY: [] 563 564 }; 565 566 function resetRecordedAVs() { 567 recordedAVs.predArousal = []; 568 recordedAVs.predValence = []; 569 recordedAVs.userArousal = []; 570 recordedAVs.userValence = []; 571 recordedAVs.diffArousal = []; 572 recordedAVs.diffValence = []; 573 574 recordedAVs.canvasX = []; 575 recordedAVs.canvasY = []; 576 } 577 578 function appendRecordedUserAVVals() 579 { 580 var current_time = wavesurfer.getCurrentTime(); 581 582 // Predicted AV vals 583 var pred_arousal_val = parseFloat($('#arousal-val').text()); 584 var pred_valence_val = parseFloat($('#valence-val').text()); 585 586 var user_arousal_val = recordedUserArousalVal; 587 var user_valence_val = recordedUserValenceVal; 588 589 var diff_arousal_val = pred_arousal_val - user_arousal_val; 590 var diff_valence_val = pred_valence_val - user_valence_val; 591 592 recordedAVs.predArousal.push(pred_arousal_val); 593 recordedAVs.predValence.push(pred_valence_val); 594 595 recordedAVs.userArousal.push(user_arousal_val); 596 recordedAVs.userValence.push(user_valence_val); 597 598 recordedAVs.diffArousal.push(diff_arousal_val); 599 recordedAVs.diffValence.push(diff_valence_val); 600 601 recordedAVs.canvasX.push(recordedUserCanvasX); 602 recordedAVs.canvasY.push(recordedUserCanvasY); 603 604 605 var av_canvas = document.getElementById("av-chart-canvas-unlabeled"); 606 var av_context = av_canvas.getContext("2d"); 607 608 av_context.fillStyle = "rgba(190,0,0,0.05)"; 609 //av_context.fillStyle = "rgba(130,0,0,0.1)"; 610 //av_context.fillStyle = "rgba(78,196,108,0.1)"; 611 av_context.beginPath(); 612 av_context.arc(recordedUserCanvasX, recordedUserCanvasY, 5, 0, 2 * Math.PI); 613 av_context.fill(); 614 615 } 616 617 function displayPersonalBias(overall_personal_bias_rec) 618 { 619 var bias_arousal_2dp = overall_personal_bias_rec['bias-arousal'].toFixed(2); 620 var bias_valence_2dp = overall_personal_bias_rec['bias-valence'].toFixed(2); 621 622 $('#overall-personal-bias') 623 .html("Personal Bias (Arousal,Valence):" 624 + " (" 625 + bias_arousal_2dp 626 + "," 627 + bias_valence_2dp 628 + ")"); 629 630 } 631 632 function clearRecordedUserAVChart() 633 { 634 var doc_storage_key = gs.cgiParams.c + "." + gs.cgiParams.d; 635 636 var doc_personal_bias_arousal = 0.0; 637 var doc_personal_bias_valence = 0.0; 638 639 var recordedAVs_str = window.localStorage.getItem(doc_storage_key); 640 if (recordedAVs_str) { 641 recordedAVs = JSON.parse(recordedAVs_str); 642 643 doc_personal_bias_arousal = recordedAVs.personalBiasArousal; 644 doc_personal_bias_valence = recordedAVs.personalBiasValence; 645 646 } 647 648 window.localStorage.removeItem(doc_storage_key); 649 650 var overall_personal_bias_key = "mars.overall-personal-bias"; 651 652 var overall_personal_bias_rec_str = window.localStorage.getItem(overall_personal_bias_key); 653 654 var overall_personal_bias_rec; 655 if (overall_personal_bias_rec_str) { 656 overall_personal_bias_rec = JSON.parse(overall_personal_bias_rec_str); 657 658 overall_personal_bias_rec['bias-arousal'] -= doc_personal_bias_arousal; 659 overall_personal_bias_rec['bias-valence'] -= doc_personal_bias_valence; 660 } 661 662 window.localStorage.setItem(overall_personal_bias_key, JSON.stringify(overall_personal_bias_rec)); 663 664 displayPersonalBias(overall_personal_bias_rec); 665 666 667 // Now proceed to visually clear the av-chart-canvas 668 var av_canvas = document.getElementById("av-chart-canvas-unlabeled"); 669 var av_context = av_canvas.getContext("2d"); 670 av_context.clearRect(0, 0, av_canvas.width, av_canvas.height); 671 672 resetRecordedAVs(); 673 hasExistingUserRecording = false; 674 } 675 676 function renderRecordedUserAVVals() 677 { 678 679 var doc_storage_key = gs.cgiParams.c + "." + gs.cgiParams.d; 680 681 var recordedAVs_str = window.localStorage.getItem(doc_storage_key); 682 if (recordedAVs_str) { 683 recordedAVs = JSON.parse(recordedAVs_str); 684 685 var av_canvas = document.getElementById("av-chart-canvas-unlabeled"); 686 var av_context = av_canvas.getContext("2d"); 687 688 var num_canvas_coords = recordedAVs.canvasX.length; 689 690 for (var i=0; i<num_canvas_coords; i++) { 691 692 var canvas_x = recordedAVs.canvasX[i]; 693 var canvas_y = recordedAVs.canvasY[i]; 694 695 av_context.fillStyle = "rgba(190,0,0,0.05)"; 696 //av_context.fillStyle = "rgba(130,0,0,0.1)"; 697 //av_context.fillStyle = "rgba(78,196,108,0.1)"; 698 av_context.beginPath(); 699 av_context.arc(canvas_x, canvas_y, 5, 0, 2 * Math.PI); 700 av_context.fill(); 701 } 702 703 hasExistingUserRecording = true; 704 } 705 else { 706 hasExistingUserRecording = false; 707 } 708 709 } 541 710 542 711 function crsc_popup_close($elem) … … 555 724 556 725 av_context.clearRect(0, 0, av_canvas.width, av_canvas.height); 726 resetRecordedAVs(); 727 hasExistingUserRecording = false; 557 728 558 729 crsc_popup_close($(this)); … … 583 754 console.log("Saving to your browser RecordingUserAV"); 584 755 crsc_popup_close($(this)); 756 757 var num_av_vals = recordedAVs.userArousal.length; 758 759 var doc_personal_bias_arousal = 0; 760 var doc_personal_bias_valence = 0; 761 762 for (var i=0; i<num_av_vals; i++) { 763 doc_personal_bias_arousal += recordedAVs.diffArousal[i]; 764 doc_personal_bias_valence += recordedAVs.diffValence[i]; 765 } 766 767 doc_personal_bias_arousal /= num_av_vals; 768 doc_personal_bias_valence /= num_av_vals; 769 770 recordedAVs.personalBiasArousal = doc_personal_bias_arousal; 771 recordedAVs.personalBiasValence = doc_personal_bias_valence; 772 773 var doc_storage_key = gs.cgiParams.c + "." + gs.cgiParams.d; 774 window.localStorage.setItem(doc_storage_key,JSON.stringify(recordedAVs)); 775 776 var overall_personal_bias_key = "mars.overall-personal-bias"; 777 778 var overall_personal_bias_rec_str = window.localStorage.getItem(overall_personal_bias_key); 779 780 var overall_personal_bias_rec; 781 if (overall_personal_bias_rec_str) { 782 overall_personal_bias_rec = JSON.parse(overall_personal_bias_rec_str); 783 784 } 785 else { 786 overall_personal_bias_rec = { 'bias-arousal': 0.0, 'bias-valence': 0.0 }; 787 } 788 789 overall_personal_bias_rec['bias-arousal'] += doc_personal_bias_arousal; 790 overall_personal_bias_rec['bias-valence'] += doc_personal_bias_valence; 791 792 window.localStorage.setItem(overall_personal_bias_key, JSON.stringify(overall_personal_bias_rec)); 793 displayPersonalBias(overall_personal_bias_rec); 794 795 hasExistingUserRecording = true; 585 796 } 586 797 … … 589 800 function av_chart_record_click(elem,event) 590 801 { 591 if (isRecordingUserAV == false) { 592 isRecordingUserAV = true; 593 594 if (!wavesurfer.backend.isPaused()) { 595 console.log("Starting recording user's AV values"); 596 AVSeekTo(0); 802 if (hasExistingUserRecording) { 803 return; 804 } 805 806 var av_chart_position_info = get_av_chart_unlabeled_position_info(elem,event); 807 808 var av_inside = av_chart_position_info.av_inside; 809 if (av_inside) { 810 recordedUserValenceVal = av_chart_position_info.valence_val; 811 recordedUserArousalVal = av_chart_position_info.arousal_val; 812 813 recordedUserCanvasX = av_chart_position_info.canvas_x; 814 recordedUserCanvasY = av_chart_position_info.canvas_y; 815 816 817 if (isRecordingUserAV == false) { 818 isRecordingUserAV = true; 819 820 if (!wavesurfer.backend.isPaused()) { 821 console.log("Starting recording user's AV values"); 822 AVSeekTo(0); 823 } 824 else { 825 console.log("Resuming recording user's AV values"); 826 } 827 AVPlay() 597 828 } 598 829 else { 599 console.log("Resuming recording user's AV values"); 600 } 601 AVPlay() 602 } 603 else { 604 AVEnsurePaused(); 605 // Have stopped recording 606 // => Store recorded values into LocalStorage 607 isRecordingUserAV = false; 608 609 610 CancelResumeSaveConfirm('Customised AV Recording', 'Would you like to save this AV Recording?', 611 'Cancel and Start Over', 'Resume Recording', "Save", 612 crsc_popup_cancel_callback, crsc_popup_resume_callback, crsc_popup_save_callback 613 ); 614 830 AVEnsurePaused(); 831 // Have stopped recording 832 // => Store recorded values into LocalStorage 833 isRecordingUserAV = false; 834 835 836 CancelResumeSaveConfirm('Customised AV Recording', 'Would you like to save this AV Recording?', 837 'Cancel and Start Over', 'Resume Recording', "Save", 838 crsc_popup_cancel_callback, crsc_popup_resume_callback, crsc_popup_save_callback 839 ); 840 } 615 841 } 616 842 } … … 676 902 $('#av-chart-img-unlabeled').hide(); 677 903 $('#av-chart-canvas-unlabeled').hide(); 904 $('#clear-user-av-chart-rtab').hide(); 678 905 $('#av-chart-img').show(); 679 906 $('#av-chart-canvas').show(); … … 710 937 711 938 $('#hide-av-chart').hide(); 939 $('#clear-user-av-chart-rtab').hide(); 712 940 $('#show-av-chart').show(); 713 941 … … 788 1016 $('#av-chart-img-unlabeled').show(); 789 1017 $('#av-chart-canvas-unlabeled').show(); 790 1018 $('#clear-user-av-chart-rtab').show(); 1019 791 1020 $('#start-av-recommendation').hide(); 792 1021 $('#start-av-recording').show(); … … 822 1051 // Here they are ordered to match x,y 823 1052 824 function av_to_canvas_xy (valenceVal, arousalVal, circ_x_org,circ_y_org,circ_radius)1053 function av_to_canvas_xy__UNTESTED(valenceVal, arousalVal, circ_x_org,circ_y_org,circ_radius) 825 1054 { 826 1055 //var canvasX = (valenceVal * circ_radius) - circ_x_org; // effectively "times -1" … … 832 1061 } 833 1062 1063 function get_av_chart_unlabeled_position_info(elem,event) 1064 { 1065 var circ_x_org = 183; 1066 var circ_y_org = 194; 1067 var circ_radius = 130; 1068 1069 var av_rec = mouse_xy_to_av(elem,event,circ_x_org,circ_y_org,circ_radius); 1070 1071 var valence_val = av_rec.valence; 1072 var arousal_val = av_rec.arousal; 1073 var av_radius = av_rec.avRadius; 1074 1075 var av_inside = (av_radius <= 1.0); 1076 1077 var return_rec = { 'av_inside': av_inside }; 1078 1079 if (av_inside) { 1080 return_rec.arousal_val = arousal_val; 1081 return_rec.valence_val = valence_val; 1082 1083 var canvas_x = event.pageX - $(elem).offset().left; 1084 var canvas_y = event.pageY - $(elem).offset().top; 1085 1086 return_rec.canvas_x = canvas_x; 1087 return_rec.canvas_y = canvas_y; 1088 } 1089 1090 return return_rec; 1091 } 834 1092 835 1093 $(document).ready(function() { … … 850 1108 loginToRecord(); 851 1109 } 852 1110 1111 renderRecordedUserAVVals(); 853 1112 } 854 1113 … … 865 1124 866 1125 initPlayerVisual(); 1126 1127 var overall_personal_bias_key = "mars.overall-personal-bias"; 1128 var overall_personal_bias_rec_str = window.localStorage.getItem(overall_personal_bias_key); 1129 1130 var overall_personal_bias_rec; 1131 if (overall_personal_bias_rec_str) { 1132 overall_personal_bias_rec = JSON.parse(overall_personal_bias_rec_str); 1133 displayPersonalBias(overall_personal_bias_rec); 1134 } 867 1135 868 1136 $('#av-chart-img').on("click",function(event) { … … 884 1152 885 1153 if (recAVInside) { 1154 886 1155 var roundedA = Math.round(recArousalVal * 100) / 100 887 1156 var roundedV = Math.round(recValenceVal * 100) / 100 … … 913 1182 914 1183 var prevRecAVInside = true; 915 1184 1185 $('#av-chart-img-unlabeled').on("mouseover",function(event) { 1186 //console.log("**** mouseenter") 1187 var av_chart_position_info = get_av_chart_unlabeled_position_info(this,event); 1188 1189 var av_inside = av_chart_position_info.av_inside; 1190 1191 if (av_inside) { 1192 //console.log("**** inside") 1193 1194 // crosshairs on 1195 var crosshair_record_url = gs.variables.collImagesURL + "/crosshair-cursor-red32.png"; 1196 $('#av-chart-img-unlabeled').css("cursor","url('"+crosshair_record_url+"') 16 16, crosshair"); 1197 } 1198 else { 1199 // revert 1200 $('#av-chart-img-unlabeled').css("cursor","default"); 1201 } 1202 }); 1203 1204 916 1205 $('#av-chart-img-unlabeled').on("mousemove",function(event) { 917 1206 /* 918 1207 var circ_x_org = 183; 919 1208 var circ_y_org = 194; … … 927 1216 928 1217 var recAVInside = (avRadius <= 1.0); 929 1218 */ 1219 1220 var av_chart_position_info = get_av_chart_unlabeled_position_info(this,event); 1221 1222 var recValenceVal = av_chart_position_info.valence_val; 1223 var recArousalVal = av_chart_position_info.arousal_val; 1224 var recAVInside = av_chart_position_info.av_inside; 1225 930 1226 if (recAVInside) { 1227 931 1228 var roundedA = Math.round(recArousalVal * 100) / 100 932 1229 var roundedV = Math.round(recValenceVal * 100) / 100 … … 941 1238 //var canvas_y = xy_rec.canvasY; 942 1239 943 var canvas_x = event.pageX - $(this).offset().left; 944 var canvas_y = event.pageY - $(this).offset().top; 945 946 console.log("canvas x,y = " + canvas_x + " , " + canvas_y); 1240 //var canvas_x = event.pageX - $(this).offset().left; 1241 //var canvas_y = event.pageY - $(this).offset().top; 1242 1243 var canvas_x = av_chart_position_info.canvas_x; 1244 var canvas_y = av_chart_position_info.canvas_y; 1245 1246 //console.log("**** canvas x,y = " + canvas_x + " , " + canvas_y); 947 1247 948 var av_canvas = document.getElementById("av-chart-canvas-unlabeled"); 949 var av_context = av_canvas.getContext("2d"); 950 951 av_context.fillStyle = "rgba(190,0,0,0.1)"; 952 //av_context.fillStyle = "rgba(130,0,0,0.1)"; 953 //av_context.fillStyle = "rgba(78,196,108,0.1)"; 954 av_context.beginPath(); 955 av_context.arc(canvas_x, canvas_y, 5, 0, 2 * Math.PI); 956 av_context.fill(); 957 } 958 959 if (recAVInside != prevRecAVInside) { 960 if (recAVInside) { 961 // crosshairs on 962 var crosshair_record_url = gs.variables.collImagesURL + "/crosshair-cursor-red32.png"; 963 $('#av-chart-img-unlabeled').css("cursor","url('"+crosshair_record_url+"') 16 16, crosshair"); 964 } 965 else { 966 // revert 967 $('#av-chart-img-unlabeled').css("cursor","default"); 1248 recordedUserArousalVal = recArousalVal; 1249 recordedUserValenceVal = recValenceVal; 1250 1251 recordedUserCanvasX = canvas_x; 1252 recordedUserCanvasY = canvas_y; 1253 1254 } 1255 1256 if (hasExistingUserRecording) { 1257 $('#av-chart-img-unlabeled').css("cursor","default"); 1258 } 1259 else { 1260 if (recAVInside != prevRecAVInside) { 1261 if (recAVInside) { 1262 // crosshairs on 1263 var crosshair_record_url = gs.variables.collImagesURL + "/crosshair-cursor-red32.png"; 1264 $('#av-chart-img-unlabeled').css("cursor","url('"+crosshair_record_url+"') 16 16, crosshair"); 1265 } 1266 else { 1267 // revert 1268 $('#av-chart-img-unlabeled').css("cursor","default"); 1269 } 968 1270 } 969 1271 }
Note:
See TracChangeset
for help on using the changeset viewer.