miek / inspectrum

Radio signal analyser
GNU General Public License v3.0
2.04k stars 263 forks source link

Color SigMF Annotations #195

Closed jacobagilbert closed 2 years ago

jacobagilbert commented 2 years ago

Adds the ability to color SigMF using the information in the core:comment annotation SigMF field. If the string in this field is a valid QColor QString (see: https://doc.qt.io/qt-5/qcolor.html#setNamedColor), either a SVG named color or a supported hexadecimal color specification (including alpha) it can be used to set the color of the annotation. This has many uses, and does not require any libsigmf changes. There is also a checkbox to disable custom colors (reverts to white).

image

{
  ...
  "annotations": [
    {
      "core:sample_start": 3383600,
      "core:sample_count": 197312,
      "core:freq_upper_edge": 201379186,
      "core:freq_lower_edge": 200727361,
      "core:description": "UNKNOWN",
      "core:comment": "#55ffffff"
    },
    {
      "core:sample_start": 7327744,
      "core:sample_count": 397312,
      "core:freq_upper_edge": 198540829,
      "core:freq_lower_edge": 197964200,
      "core:description": "VALID",
      "core:comment": "lightgreen"
    },
    {
      "core:sample_start": 5327744,
      "core:sample_count": 897312,
      "core:freq_upper_edge": 195540829,
      "core:freq_lower_edge": 194964200,
      "core:description": "ERROR",
      "core:comment": "palevioletred"
    },
    ...
  ]
}

Closes #189 (as this MR includes it... ill leave that open in case you just want it and not this one).

jacobagilbert commented 2 years ago

This is a potential abuse of the core:comment field... if this is the type of behavior that you like @miek we could discuss expanding this to provide control over line width, fill, text, etc via a dedicated inspectrum.sigmf-ext.md extension. This is more complicated as libsigmf would need to be updated for that extension, but I can probably make that happen.

jacobagilbert commented 2 years ago

New plan is to add a presentation.sigmf-ext.md extension to more cleanly handle this, and to support it within libsigmf directly. This should not be merged, so I am going to close it.

For now its still on the main branch of my fork of inspectrum if anyone would like to try it.