 
   destroyImage: (img_id) ->
 
+  setMark: ->
+    #TODO state machine is getting messy
+    if @state is "asteroidTool" or "whatKind"  
+      @tool.mark.set 'detection', @getAsteroidDetection()
+    else if @state is "artifactTool"
+      @tool.mark.set 'detection', @getArtifactDetection()
+    else
+      debugger  
+      console.log("Error: marking tool not specified")   
 
   setState: (newState) ->
     if @state

    'change input[name="classifier-type"]': (e) ->

      if e.currentTarget.value == 'asteroid' 
        asteroid_detection= 
          type: "asteroid" 
          frame: @currentFrame.seqNumber
          
        @setState 'asteroidTool change'
        @tool.mark.set 'detection', asteroid_detection
        
      else if  e.currentTarget.value == 'artifact'
        art_detection = 
          type: "artifact" 
          frame:   @currentFrame.seqNumber
          subType: @artifactSubtype
        @setState 'artifactTool'
        @tool.mark.set 'detection', art_detection
        
      else
        console.log("Error: unknown classifier-type")

    'change input[name="selected-artifact"]': =>
     
      #TODO why do I need to place locate  selectedArtifactRadios in elements. 
      # it shoudl be added go  the object scope
      # @artifactSubtype = selectedArtifactRadios.filter(':checked').val() 

    'click button[name="delete"]': ->
      @tool.mark.destroy()

      exit: ->
        @el.find('.artifact-classifier').hide() 

  getAsteroidDetection: =>
    asteroid_detection= 
      type: "asteroid" 
      frame: @currentFrame.seqNumber
    asteroid_detection

  getArtifactDetection: =>
    art_detection = 
        type: "artifact" 
        frame:   @currentFrame.seqNumber
        subType: @artifactSubtype
    art_detection



  #ToDo move to model 
class ImageSet

