Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/cine black images #761

Merged
merged 21 commits into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion common/reviews/api/tools.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,7 @@ type CinePlayContext = {
get numScrollSteps(): number;
get currentStepIndex(): number;
get frameTimeVectorEnabled(): boolean;
tries?: number;
scroll(delta: number): void;
};

Expand Down Expand Up @@ -3182,7 +3183,6 @@ interface IVolumeViewport extends IViewport {
// (undocumented)
useCPURendering: boolean;
worldToCanvas: (worldPos: Point3) => Point2;

}

// @public (undocumented)
Expand Down Expand Up @@ -3761,6 +3761,7 @@ type PlayClipOptions = {
loop?: boolean;
dynamicCineEnabled?: boolean;
frameTimeVectorSpeedMultiplier?: number;
waitForRendered?: number;
};

declare namespace point {
Expand Down
1 change: 1 addition & 0 deletions packages/adapters/rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export default {
],
plugins: [
resolve({
preferBuiltins: true,
browser: true
}),
commonjs(),
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/RenderingEngine/StackViewport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2151,6 +2151,7 @@ class StackViewport extends Viewport implements IStackViewport {
// Update the state of the viewport to the new imageIdIndex;
this.currentImageIdIndex = imageIdIndex;
this.hasPixelSpacing = true;
this.viewportStatus = ViewportStatus.PRE_RENDER;

// Todo: trigger an event to allow applications to hook into START of loading state
// Currently we use loadHandlerManagers for this
Expand Down
5 changes: 3 additions & 2 deletions packages/tools/src/types/CINETypes.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Types } from '@cornerstonejs/core';

type PlayClipOptions = {
framesPerSecond?: number;
frameTimeVector?: number[];
reverse?: boolean;
loop?: boolean;
dynamicCineEnabled?: boolean;
frameTimeVectorSpeedMultiplier?: number;
// How many items to wait for. Set to 0 to play immediately
wayfarer3130 marked this conversation as resolved.
Show resolved Hide resolved
waitForRendered?: number;
};

interface ToolData {
Expand All @@ -26,6 +26,7 @@ type CinePlayContext = {
get numScrollSteps(): number;
get currentStepIndex(): number;
get frameTimeVectorEnabled(): boolean;
tries?: number;
scroll(delta: number): void;
};

Expand Down
19 changes: 17 additions & 2 deletions packages/tools/src/utilities/cine/playClip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
VolumeViewport,
cache,
BaseVolumeViewport,
Enums,
} from '@cornerstonejs/core';

import { Types } from '@cornerstonejs/core';
Expand All @@ -14,6 +15,7 @@ import { addToolState, getToolState } from './state';
import { CINETypes } from '../../types';
import scroll from '../scroll';

const { ViewportStatus } = Enums;
const { triggerEvent } = csUtils;

const debounced = true;
Expand Down Expand Up @@ -315,7 +317,8 @@ function _getVolumeFromViewport(viewport): Types.IImageVolume {
}

function _createStackViewportCinePlayContext(
viewport: StackViewport
viewport: StackViewport,
waitForRendered: number
): CINETypes.CinePlayContext {
const imageIds = viewport.getImageIds();

Expand All @@ -330,7 +333,16 @@ function _createStackViewportCinePlayContext(
// It is always in acquired orientation
return true;
},
tries: 0,
scroll(delta: number): void {
if (
this.tries <= waitForRendered &&
wayfarer3130 marked this conversation as resolved.
Show resolved Hide resolved
viewport.viewportStatus !== ViewportStatus.RENDERED
) {
this.tries++;
return;
}
this.tries = 0;
scroll(viewport, { delta, debounceLoading: debounced });
},
};
Expand Down Expand Up @@ -419,7 +431,10 @@ function _createCinePlayContext(
playClipOptions: CINETypes.PlayClipOptions
): CINETypes.CinePlayContext {
if (viewport instanceof StackViewport) {
return _createStackViewportCinePlayContext(viewport);
return _createStackViewportCinePlayContext(
viewport,
playClipOptions.waitForRendered ?? 30
);
}

if (viewport instanceof VolumeViewport) {
Expand Down