@@ -288,31 +288,25 @@ ExecutionVisualizer.prototype.render = function() {
288288 }
289289
290290 myViz . editAnnotationMode = false ;
291- myViz . allAnnotationBubbles = [ ] ;
292291
293292 if ( this . allowEditAnnotations ) {
294293 var ab = this . domRoot . find ( '#annotateBtn' ) ;
295294
296295 ab . click ( function ( ) {
297296 if ( myViz . editAnnotationMode ) {
298297 ab . html ( '(rendering ...)' ) ;
299- $ . each ( myViz . allAnnotationBubbles , function ( i , e ) {
300- e . enterViewMode ( ) ;
301- } ) ;
298+ myViz . enterViewAnnotationsMode ( ) ;
302299
303300 myViz . domRoot . find ( "#jmpFirstInstr,#jmpLastInstr,#jmpStepBack,#jmpStepFwd,#executionSlider" ) . show ( ) ;
304301 ab . html ( 'Annotate this step' ) ;
305302 }
306303 else {
307304 ab . html ( '(rendering ...)' ) ;
308- $ . each ( myViz . allAnnotationBubbles , function ( i , e ) {
309- e . enterEditMode ( ) ;
310- } ) ;
305+ myViz . enterEditAnnotationsMode ( ) ;
311306
312307 myViz . domRoot . find ( "#jmpFirstInstr,#jmpLastInstr,#jmpStepBack,#jmpStepFwd,#executionSlider" ) . hide ( ) ;
313308 ab . html ( 'Done annotating' ) ;
314309 }
315- myViz . editAnnotationMode = ! myViz . editAnnotationMode ;
316310 } ) ;
317311 }
318312 else {
@@ -435,6 +429,79 @@ ExecutionVisualizer.prototype.render = function() {
435429 this . hasRendered = true ;
436430}
437431
432+ ExecutionVisualizer . prototype . enterViewAnnotationsMode = function ( ) {
433+ this . editAnnotationMode = false ;
434+
435+ // TODO: grab all annotations bubbles from current trace entry
436+ /*
437+ $.each(myViz.allAnnotationBubbles, function(i, e) {
438+ e.enterViewMode();
439+ });
440+ */
441+ }
442+
443+ ExecutionVisualizer . prototype . enterEditAnnotationsMode = function ( ) {
444+ // TODO: check for memory leaks!!!
445+
446+ this . editAnnotationMode = true ;
447+
448+ var myViz = this ;
449+
450+ var codelineIDs = [ ] ;
451+ $ . each ( this . domRoot . find ( '#pyCodeOutput .cod' ) , function ( i , e ) {
452+ codelineIDs . push ( $ ( e ) . attr ( 'id' ) ) ;
453+ } ) ;
454+
455+ var heapObjectIDs = [ ] ;
456+ $ . each ( this . domRoot . find ( '.heapObject' ) , function ( i , e ) {
457+ heapObjectIDs . push ( $ ( e ) . attr ( 'id' ) ) ;
458+ } ) ;
459+
460+ var variableIDs = [ ] ;
461+ $ . each ( this . domRoot . find ( '.variableTr' ) , function ( i , e ) {
462+ variableIDs . push ( $ ( e ) . attr ( 'id' ) ) ;
463+ } ) ;
464+
465+ var frameIDs = [ ] ;
466+ $ . each ( this . domRoot . find ( '.stackFrame' ) , function ( i , e ) {
467+ frameIDs . push ( $ ( e ) . attr ( 'id' ) ) ;
468+ } ) ;
469+
470+
471+ var allAnnotationBubbles = [ ] ;
472+
473+ $ . each ( codelineIDs , function ( i , e ) {
474+ allAnnotationBubbles . push ( new AnnotationBubble ( myViz , 'codeline' , e ) ) ;
475+ } ) ;
476+
477+ $ . each ( heapObjectIDs , function ( i , e ) {
478+ allAnnotationBubbles . push ( new AnnotationBubble ( myViz , 'object' , e ) ) ;
479+ } ) ;
480+
481+ $ . each ( variableIDs , function ( i , e ) {
482+ allAnnotationBubbles . push ( new AnnotationBubble ( myViz , 'variable' , e ) ) ;
483+ } ) ;
484+
485+ $ . each ( frameIDs , function ( i , e ) {
486+ allAnnotationBubbles . push ( new AnnotationBubble ( myViz , 'frame' , e ) ) ;
487+ } ) ;
488+
489+ //this.allAnnotationBubbles = allAnnotationBubbles;
490+
491+ // TODO: this is badly placed ...
492+ this . domRoot . find ( '#pyCodeOutputDiv' ) . scroll ( function ( ) {
493+ $ . each ( allAnnotationBubbles , function ( i , e ) {
494+ if ( e . type == 'codeline' ) {
495+ e . redrawCodelineBubble ( ) ;
496+ }
497+ } ) ;
498+ } ) ;
499+
500+ $ . each ( allAnnotationBubbles , function ( i , e ) {
501+ e . enterEditMode ( ) ;
502+ } ) ;
503+ }
504+
438505
439506// find the previous/next breakpoint to c or return -1 if it doesn't exist
440507ExecutionVisualizer . prototype . findPrevBreakpoint = function ( ) {
@@ -1875,6 +1942,7 @@ ExecutionVisualizer.prototype.renderDataStructures = function() {
18751942 globalVarTable
18761943 . enter ( )
18771944 . append ( 'tr' )
1945+ . attr ( 'class' , 'variableTr' )
18781946 . attr ( 'id' , function ( d , i ) {
18791947 return myViz . generateID ( varnameToCssID ( 'global__' + d + '_tr' ) ) ; // make globally unique (within the page)
18801948 } ) ;
@@ -2025,6 +2093,7 @@ ExecutionVisualizer.prototype.renderDataStructures = function() {
20252093 stackVarTable
20262094 . enter ( )
20272095 . append ( 'tr' )
2096+ . attr ( 'class' , 'variableTr' )
20282097 . attr ( 'id' , function ( d , i ) {
20292098 return myViz . generateID ( varnameToCssID ( d . frame . unique_hash + '__' + d . varname + '_tr' ) ) ; // make globally unique (within the page)
20302099 } ) ;
@@ -2400,7 +2469,9 @@ function createSpeechBubble(domID, my, at, htmlContent, isInput) {
24002469// (as determined by the 'type' param)
24012470//
24022471// domID is the ID of the element to attach to (without the leading '#' sign)
2403- function AnnotationBubble ( type , domID ) {
2472+ function AnnotationBubble ( parentViz , type , domID ) {
2473+ this . parentViz = parentViz ;
2474+
24042475 this . domID = domID ;
24052476 this . hashID = '#' + domID ;
24062477
0 commit comments