Enabling a tool to be active from the start

I am trying to enable the Reference Line tool on viewer initialization/start without having to click on it to activate it.

I was able to enable the reference line tool in root folder\modes\longitudinal\src\initToolGroups.js by moving the reference line code from disabled section to enabled section → enabled: [{ toolName: toolNames.ReferenceLines }],

But this option just enables the reference line button to be visible not activated.

What i tried:

Moving the reference line tool to active section → same result, button visible but function not activated
Moving the reference line tool to passive section → same result, button visible but function not activated

This is the file and the locations that I modified:

const tools = {
    active: [
      {
        toolName: toolNames.WindowLevel,
        bindings: [{ mouseButton: Enums.MouseBindings.Primary }],
      },
      {
        toolName: toolNames.Pan,
        bindings: [{ mouseButton: Enums.MouseBindings.Auxiliary }],
      },
      {
        toolName: toolNames.Zoom,
        bindings: [{ mouseButton: Enums.MouseBindings.Secondary }],
      },
      { toolName: toolNames.StackScrollMouseWheel, bindings: [] },
      //{ toolName: toolNames.ReferenceLines, bindings: [] },   ->  tried inserting here but failed, same result as enabled section
    ],
    passive: [
      { toolName: toolNames.Length },
      {
        toolName: toolNames.ArrowAnnotate,
        configuration: {
          getTextCallback: (callback, eventDetails) =>
            commandsManager.runCommand('arrowTextCallback', {
              callback,
              eventDetails,
            }),

          changeTextCallback: (data, eventDetails, callback) =>
            commandsManager.runCommand('arrowTextCallback', {
              callback,
              data,
              eventDetails,
            }),
        },
      },
      { toolName: toolNames.Bidirectional },
      { toolName: toolNames.DragProbe },
      { toolName: toolNames.EllipticalROI },
      { toolName: toolNames.CircleROI },
      { toolName: toolNames.RectangleROI },
      { toolName: toolNames.StackScroll },
      { toolName: toolNames.Angle },
      { toolName: toolNames.CobbAngle },
      { toolName: toolNames.PlanarFreehandROI },
      { toolName: toolNames.Magnify },
      { toolName: toolNames.SegmentationDisplay },
      { toolName: toolNames.CalibrationLine },
      // { toolName: toolNames.ReferenceLines },  ->   tried inserting here but failed, same result as enabled section
    ],
    enabled: [{ toolName: toolNames.ImageOverlayViewer }],
    //enabled: [{ toolName: toolNames.ReferenceLines }],
  };

What i am wondering is due to lack of documentation on how to enable or disable tools from start, am i using this wrong or is this a bug and under active section it should be activated?

Steps to Reproduce

  1. Download Ohif Viewer 3.8 beta 25
  2. Modify \modes\longitudinal\src\initToolGroups.js so that reference lines are under active or passive
  3. Build for production with yarn install, yarn run build
  4. Nothing happens the result is always the same “Reference Lines” button is visible but never active from the start

I had the same question.
After a little bit of playing around I found out that which ever tool has the [{ mouseButton: Enums.MouseBindings.Primary }] binding property will be the default tool used when opening a basic viewer.
Any changes to the toolName on line 17 in the file: \modes\longitudinal\src\initToolGroups.js will affect the default tool in basic viewer respectively.

Hope this saves someone a bit of time :slight_smile:

Reference lines don’t move. If you want to drag them, you need to use the crosshair tool.
See an example here

https://www.cornerstonejs.org/live-examples/crosshairs

and here

https://www.cornerstonejs.org/live-examples/referencelines