<commit_before>// Annotation widget toggles annotation visibility and also shows the drawing tools.
// Each view will need its own widget.
// I am less happy about this than the right click menu implementation.
// It would be nice to expand the drawing tools on hover, but
// the toggle for annotation visibiity naturally suggests
// the same state should show drawing tool palette.

// Todo:
// - Make an object out of it to support two views.
// - Change behavior of text widget to first drag an arrow when created.
// - eliminate polyLine verticies when they are dragged ontop of another vert.
//   or maybe the delete key.

function AnnotationWidget (viewer) {
  var self = this; // trick to set methods in callbacks.
  this.Viewer = viewer;
  viewer.AnnotationWidget = this;

  if ( ! MOBILE_DEVICE) {
    // We need unique names for the HTML elements.
    this.Widget = $('<table>').appendTo('body')
      .css({
        'opacity': '0.6',
        'position': 'absolute',
        'height': '28px',
        'bottom' : '5px',
        'right' : '20px',
        'z-index': '1'});;

    viewer.AddGuiObject(this.Widget, "Bottom", 5, "Right", 312);

    var row = $('<tr>').appendTo(this.Widget)
    var cell = $('<td>').appendTo(row)
    this.VisibilityButton = $('<img>').appendTo(cell)
      .css({
        'opacity': '0.6',
        'border-radius': '5px'})
      .attr('type','image')
      .attr('src',"/webgl-viewer/static/pencil3.png")
      .click(function(){self.ToggleVisibility();});

    this.ToolsTable = $('<td>').appendTo(row)
      .hide()
      .css({
        'opacity': '0.6',
        'width': '182',
        'border-radius': '5px'});

    $('<img>').appendTo(this.ToolsTable)
      .css({'height': '28px'})
      .attr('type','image')
      .attr('src',"/webgl-viewer/static/Text.gif")
      .click(function(){self.NewText();});
    $('<img>').appendTo(this.ToolsTable)
      .css({'height': '28px'})
      .attr('type','image')
      .attr('src',"/webgl-viewer/static/Circle.gif")
      .click(function(){self.NewCircle();});
    $('<img>').appendTo(this.ToolsTable)
      .css({'height': '28px'})
      .attr('type','image')
      .attr('src',"/webgl-viewer/static/FreeForm.gif")
      .click(function(){self.NewPolyline();});
    $('<img>').appendTo(this.ToolsTable)
      .css({'height': '28px'})
      .attr('type','image')
      .attr('src',"/webgl-viewer/static/Pencil-icon.jpg")
      .click(function(){self.NewPencil();});
    $('<img>').appendTo(this.ToolsTable)
      .css({'height': '28px'})
      .attr('type','image')
      .attr('src',"/webgl-viewer/static/select_lasso.png")
      .click(function(){self.NewLasso();});
    $('<img>').appendTo(this.ToolsTable)
      .css({'height': '28px'})
      .attr('type','image')
      .attr('src',"/webgl-viewer/static/arrowWidget.png")
      .click(function(){self.NewArrowStamp();});
  }
}

AnnotationWidget.prototype.SetVisibility = function(visibility) {
  if (this.Viewer.GetAnnotationVisibility() == visibility) {
    return;
  }
  if (this.VisibilityButton) {
    if (visibility == ANNOTATION_OFF) {
      this.VisibilityButton.attr('src',"/webgl-viewer/static/pencil3.png")
      this.ToolsTable.fadeOut();
    } else if (visibility == ANNOTATION_NO_TEXT) {
      this.VisibilityButton.attr('src',"/webgl-viewer/static/pencil3Flip.png")
      this.ToolsTable.fadeIn();
    } else {
      this.VisibilityButton.attr('src',"/webgl-viewer/static/pencil3Up.png")
    }
  }

  this.Viewer.SetAnnotationVisibility(visibility);

  eventuallyRender();
}

AnnotationWidget.prototype.GetVisibility = function() {
  return this.Viewer.GetAnnotationVisibility();
}<commit_msg>Widget icons were not showing up<commit_after>// Annotation widget toggles annotation visibility and also shows the drawing tools.
// Each view will need its own widget.
// I am less happy about this than the right click menu implementation.
// It would be nice to expand the drawing tools on hover, but
// the toggle for annotation visibiity naturally suggests
// the same state should show drawing tool palette.

// Todo:
// - Make an object out of it to support two views.
// - Change behavior of text widget to first drag an arrow when created.
// - eliminate polyLine verticies when they are dragged ontop of another vert.
//   or maybe the delete key.

function AnnotationWidget (viewer) {
  var self = this; // trick to set methods in callbacks.
  this.Viewer = viewer;
  viewer.AnnotationWidget = this;

  if ( ! MOBILE_DEVICE) {
    // We need unique names for the HTML elements.
    this.Widget = $('<table>').appendTo('body')
      .css({
        'opacity': '0.6',
        'position': 'absolute',
        'height': '28px',
        'bottom' : '5px',
        'right' : '20px',
        'z-index': '1'});;

    viewer.AddGuiObject(this.Widget, "Bottom", 5, "Right", 312);

    var row = $('<tr>').appendTo(this.Widget)
    var cell = $('<td>').appendTo(row)
    this.VisibilityButton = $('<img>').appendTo(cell)
      .css({
        'opacity': '0.6',
        'border-radius': '5px'})
      .attr('type','image')
      .attr('src',"/webgl-viewer/static/pencil3.png")
      .click(function(){self.ToggleVisibility();});

    this.ToolsTable = $('<td>').appendTo(row)
      .hide()
      .css({
        'opacity': '0.6',
        'width': '182',
        'border-radius': '5px'});

    $('<img>').appendTo(this.ToolsTable)
      .css({'height': '28px'})
      .attr('type','image')
      .attr('src',"/webgl-viewer/static/Text.gif")
      .click(function(){self.NewText();});
    $('<img>').appendTo(this.ToolsTable)
      .css({'height': '28px'})
      .attr('type','image')
      .attr('src',"/webgl-viewer/static/Circle.gif")
      .click(function(){self.NewCircle();});
    $('<img>').appendTo(this.ToolsTable)
      .css({'height': '28px'})
      .attr('type','image')
      .attr('src',"/webgl-viewer/static/FreeForm.gif")
      .click(function(){self.NewPolyline();});
    $('<img>').appendTo(this.ToolsTable)
      .css({'height': '28px'})
      .attr('type','image')
      .attr('src',"/webgl-viewer/static/Pencil-icon.jpg")
      .click(function(){self.NewPencil();});
    $('<img>').appendTo(this.ToolsTable)
      .css({'height': '28px'})
      .attr('type','image')
      .attr('src',"/webgl-viewer/static/select_lasso.png")
      .click(function(){self.NewLasso();});
    $('<img>').appendTo(this.ToolsTable)
      .css({'height': '28px'})
      .attr('type','image')
      .attr('src',"/webgl-viewer/static/arrowWidget.png")
      .click(function(){self.NewArrowStamp();});
  }
}

AnnotationWidget.prototype.SetVisibility = function(visibility) {
  if (this.Viewer.GetAnnotationVisibility() == visibility) {
    return;
  }
  if (this.VisibilityButton) {
    if (visibility == ANNOTATION_OFF) {
      this.VisibilityButton.attr('src',"/webgl-viewer/static/pencil3.png")
      this.ToolsTable.fadeOut();
    } else if (visibility == ANNOTATION_NO_TEXT) {
      this.VisibilityButton.attr('src',"/webgl-viewer/static/pencil3Flip.png")
      this.ToolsTable.fadeIn();
    } else {
      this.VisibilityButton.attr('src',"/webgl-viewer/static/pencil3Up.png")
      this.ToolsTable.fadeIn();
    }
  }

  this.Viewer.SetAnnotationVisibility(visibility);

  eventuallyRender();
}

AnnotationWidget.prototype.GetVisibility = function() {
  return this.Viewer.GetAnnotationVisibility();
}
{'fraction_non_alphanumeric': 0.18915974397385266, 'fraction_numerical': 0.010077624948930955, 'mean_word_length': 3.165626772546795, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5268105', 'n_tokens_mistral': 2454, 'n_tokens_neox': 2394, 'n_words': 470}