Skip to content

Commit

Permalink
rename: toolGroup tools property to toolOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
sedghi authored and swederik committed Mar 22, 2022
1 parent cc0cc79 commit c59bd03
Show file tree
Hide file tree
Showing 13 changed files with 39 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default function keyDown(evt) {
)

toolGroups.forEach((toolGroup) => {
if (Object.keys(toolGroup.tools).includes(activeTool.name)) {
if (Object.keys(toolGroup.toolOptions).includes(activeTool.name)) {
toolGroup.resetViewportsCursor({ name: activeTool.name })
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default function keyUp(evt) {
resetModifierKey()

toolGroups.forEach((toolGroup) => {
if (Object.keys(toolGroup.tools).includes(activeTool.name)) {
if (Object.keys(toolGroup.toolOptions).includes(activeTool.name)) {
toolGroup.resetViewportsCursor({ name: activeTool.name })
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ export default function customCallbackHandler(
let activeTool
for (let i = 0; i < toolGroups.length; i++) {
const toolGroup = toolGroups[i]
const toolGroupToolNames = Object.keys(toolGroup.tools)
const toolGroupToolNames = Object.keys(toolGroup.toolOptions)

for (let j = 0; j < toolGroupToolNames.length; j++) {
const toolName = toolGroupToolNames[j]
const tool = toolGroup.tools[toolName]
const tool = toolGroup.toolOptions[toolName]
// TODO: Should be getter
const toolInstance = toolGroup._toolInstances[toolName]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ export default function getActiveToolForMouseEvent(evt) {

for (let i = 0; i < toolGroups.length; i++) {
const toolGroup = toolGroups[i]
const toolGroupToolNames = Object.keys(toolGroup.tools)
const toolGroupToolNames = Object.keys(toolGroup.toolOptions)

for (let j = 0; j < toolGroupToolNames.length; j++) {
const toolName = toolGroupToolNames[j]
const tool = toolGroup.tools[toolName]
const tool = toolGroup.toolOptions[toolName]

// tool has binding that matches the mouse button, if mouseEvent is undefined
// it uses the primary button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ export default function getToolsWithModesForMouseEvent(

for (let i = 0; i < toolGroups.length; i++) {
const toolGroup = toolGroups[i]
const toolGroupToolNames = Object.keys(toolGroup.tools)
const toolGroupToolNames = Object.keys(toolGroup.toolOptions)

for (let j = 0; j < toolGroupToolNames.length; j++) {
const toolName = toolGroupToolNames[j]
const tool = toolGroup.tools[toolName]
const tool = toolGroup.toolOptions[toolName]

// tool has binding that matches the mouse button
const correctBinding =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default interface IToolGroup {
_toolInstances: Record<string, any>
id: string
viewports: Array<Types.IViewportUID>
tools: Record<string, any>
toolOptions: Record<string, any>
//
getToolInstance: { (toolName: string): any }
addTool: { (toolName: string, toolConfiguration?: any): void }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function createToolGroup(toolGroupId: string): IToolGroup | undefined {
_toolInstances: {}, // tool instances
id: toolGroupId,
viewports: [],
tools: {}, // tools modes etc.
toolOptions: {}, // tools modes etc.
//
getToolInstance: function (toolName) {
const toolInstance = this._toolInstances[toolName]
Expand All @@ -39,7 +39,7 @@ function createToolGroup(toolGroupId: string): IToolGroup | undefined {
addTool: function (toolName, toolConfiguration = {}) {
const toolDefinition = state.tools[toolName]
const hasToolName = typeof toolName !== 'undefined' && toolName !== ''
const localToolInstance = this.tools[toolName]
const localToolInstance = this.toolOptions[toolName]

if (!hasToolName) {
console.warn(
Expand Down Expand Up @@ -136,7 +136,7 @@ function createToolGroup(toolGroupId: string): IToolGroup | undefined {
}

// Would only need this for sanity check if not instantiating/hydrating
// const tool = this.tools[toolName];
// const tool = this.toolOptions[toolName];
const toolModeOptionsWithMode = Object.assign(
{
bindings: [],
Expand All @@ -147,7 +147,7 @@ function createToolGroup(toolGroupId: string): IToolGroup | undefined {
}
)

this.tools[toolName] = toolModeOptionsWithMode
this.toolOptions[toolName] = toolModeOptionsWithMode
this._toolInstances[toolName].mode = Active

// reset the mouse cursor if tool has left click binding
Expand All @@ -169,7 +169,7 @@ function createToolGroup(toolGroupId: string): IToolGroup | undefined {
}

// Would only need this for sanity check if not instantiating/hydrating
// const tool = this.tools[toolName];
// const tool = this.toolOptions[toolName];
const toolModeOptionsWithMode = Object.assign(
{
bindings: [],
Expand All @@ -180,7 +180,7 @@ function createToolGroup(toolGroupId: string): IToolGroup | undefined {
}
)

this.tools[toolName] = toolModeOptionsWithMode
this.toolOptions[toolName] = toolModeOptionsWithMode
this._toolInstances[toolName].mode = Passive
this.refreshViewports()
},
Expand All @@ -197,7 +197,7 @@ function createToolGroup(toolGroupId: string): IToolGroup | undefined {
}

// Would only need this for sanity check if not instantiating/hydrating
// const tool = this.tools[toolName];
// const tool = this.toolOptions[toolName];
const toolModeOptionsWithMode = Object.assign(
{
bindings: [],
Expand All @@ -208,7 +208,7 @@ function createToolGroup(toolGroupId: string): IToolGroup | undefined {
}
)

this.tools[toolName] = toolModeOptionsWithMode
this.toolOptions[toolName] = toolModeOptionsWithMode
this._toolInstances[toolName].mode = Enabled
this.refreshViewports()
},
Expand All @@ -224,7 +224,7 @@ function createToolGroup(toolGroupId: string): IToolGroup | undefined {
}

// Would only need this for sanity check if not instantiating/hydrating
// const tool = this.tools[toolName];
// const tool = this.toolOptions[toolName];
const toolModeOptionsWithMode = Object.assign(
{
bindings: [],
Expand All @@ -234,13 +234,13 @@ function createToolGroup(toolGroupId: string): IToolGroup | undefined {
mode: Disabled,
}
)
this.tools[toolName] = toolModeOptionsWithMode
this.toolOptions[toolName] = toolModeOptionsWithMode
this._toolInstances[toolName].mode = Disabled
this.refreshViewports()
},
getActivePrimaryButtonTools() {
return Object.keys(this.tools).find((toolName) => {
const toolModeOptions = this.tools[toolName]
return Object.keys(this.toolOptions).find((toolName) => {
const toolModeOptions = this.toolOptions[toolName]
return (
toolModeOptions.mode === Active &&
this.isPrimaryButtonBinding(toolModeOptions)
Expand Down
8 changes: 4 additions & 4 deletions packages/cornerstone-tools/src/tools/CrosshairsTool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ export default class CrosshairsTool extends BaseAnnotationTool {
sceneUID,
viewportUID
)
const groupTools = toolGroups[0]?.tools
const groupTools = toolGroups[0]?.toolOptions
const mode = groupTools[this.name]?.mode

// We don't want this annotation tool to render or be interactive unless its
Expand Down Expand Up @@ -258,7 +258,7 @@ export default class CrosshairsTool extends BaseAnnotationTool {
sceneUID,
viewportUID
)
const groupTools = toolGroups[0]?.tools
const groupTools = toolGroups[0]?.toolOptions
const mode = groupTools[this.name]?.mode

// We don't want this annotation tool to render or be interactive unless its
Expand All @@ -272,7 +272,7 @@ export default class CrosshairsTool extends BaseAnnotationTool {
let isCrosshairsActive = false
for (let i = 0; i < toolGroups.length; ++i) {
const toolGroup = toolGroups[i]
const tool = toolGroup.tools['Crosshairs']
const tool = toolGroup.toolOptions['Crosshairs']

if (tool.mode === 'Active') {
isCrosshairsActive = true
Expand Down Expand Up @@ -348,7 +348,7 @@ export default class CrosshairsTool extends BaseAnnotationTool {
let isCrosshairsActive = false
for (let i = 0; i < toolGroups.length; ++i) {
const toolGroup = toolGroups[i]
const tool = toolGroup.tools['Crosshairs']
const tool = toolGroup.toolOptions['Crosshairs']

if (tool.mode === 'Active') {
isCrosshairsActive = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ export default class RectangleRoiThresholdTool extends RectangleRoiTool {
shadow: true,
preventHandleOutsideImage: false,
},
strategies: {},
defaultStrategy: '',
})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import {
getBoundingBoxAroundShape,
} from '../../../util/segmentation'
import { Point3 } from '../../../types'
import { ImageVolume, Types } from '@ohif/cornerstone-render'
import { ImageVolume } from '@ohif/cornerstone-render'
import { IEnabledElement } from '@ohif/cornerstone-render/src/types'

type EraseOperationData = {
points: [Point3, Point3, Point3, Point3]
Expand All @@ -13,7 +14,7 @@ type EraseOperationData = {
}

type FillRectangleEvent = {
enabledElement: Types.IEnabledElement
enabledElement: IEnabledElement
}

/**
Expand Down Expand Up @@ -78,7 +79,7 @@ function eraseRectangle(
*/
export function eraseInsideRectangle(
evt: FillRectangleEvent,
operationData: OperationData
operationData: EraseOperationData
): void {
eraseRectangle(evt, operationData, true)
}
Expand All @@ -92,7 +93,7 @@ export function eraseInsideRectangle(
*/
export function eraseOutsideRectangle(
evt: FillRectangleEvent,
operationData: OperationData
operationData: EraseOperationData
): void {
eraseRectangle(evt, operationData, false)
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import {
IEnabledElement,
} from '@ohif/cornerstone-render/src/types'
import {
fillInsideShape,
getBoundingBoxAroundShape,
} from '../../../util/segmentation'
import { Point3 } from '../../../types'
import { ImageVolume, Types } from '@ohif/cornerstone-render'
import { ImageVolume } from '@ohif/cornerstone-render'

type OperationData = {
points: [Point3, Point3, Point3, Point3]
Expand All @@ -14,7 +17,7 @@ type OperationData = {
}

type FillRectangleEvent = {
enabledElement: Types.IEnabledElement
enabledElement: IEnabledElement
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ export default function getToolsWithModesForElement(

for (let i = 0; i < toolGroups.length; i++) {
const toolGroup = toolGroups[i]
const toolGroupToolNames = Object.keys(toolGroup.tools)
const toolGroupToolNames = Object.keys(toolGroup.toolOptions)

for (let j = 0; j < toolGroupToolNames.length; j++) {
const toolName = toolGroupToolNames[j]
const tool = toolGroup.tools[toolName]
const tool = toolGroup.toolOptions[toolName]

if (modesFilter.includes(tool.mode)) {
const toolInstance = toolGroup._toolInstances[toolName]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ export default function filterViewportsWithToolEnabled(viewports, toolName) {
* @returns {boolean} True if the tool is enabled, passive or active in the `toolGroup`.
*/
function _toolGroupHasActiveEnabledOrPassiveTool(toolGroup, toolName) {
const { tools } = toolGroup
const tool = tools[toolName]
const { toolOptions } = toolGroup
const tool = toolOptions[toolName]

if (!tool) {
return false
Expand Down

0 comments on commit c59bd03

Please sign in to comment.