Skip to content

Commit

Permalink
Fixing coordinate frame when changing video size
Browse files Browse the repository at this point in the history
  • Loading branch information
marcus-oscarsson committed May 2, 2018
1 parent 3343fa3 commit f1b73a8
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 11 deletions.
1 change: 0 additions & 1 deletion mxcube3/routes/beamlineutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ def get_beam_info():
# the correct beam posiition
width, height, scale = streaming.video_size()
position = beam_info.get_beam_position()
position = position[0] * scale, position[1] * scale
beam_info_dict["position"] = position

return beam_info_dict
Expand Down
3 changes: 2 additions & 1 deletion mxcube3/ui/actions/sampleview.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ export function setVideoSize(width, height) {
width: json.imageWidth,
height: json.imageHeight,
pixelsPerMm: json.pixelsPerMm,
beamPosition: json.position
beamPosition: json.position,
sourceScale: json.scale
});
});
}
Expand Down
11 changes: 6 additions & 5 deletions mxcube3/ui/components/SampleView/SampleImage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -334,11 +334,11 @@ export default class SampleImage extends React.Component {
}
}

drawCanvas(imageRatio) {
drawCanvas(imageRatio, sourceScale) {
// Getting the size of screen
const { width, height } = this.props;
const w = width * imageRatio;
const h = height * imageRatio;
const w = width * imageRatio / sourceScale;
const h = height * imageRatio / sourceScale;
// Set the size of the original html Canvas
const canvasWindow = document.getElementById('canvas');
canvasWindow.width = w;
Expand Down Expand Up @@ -726,9 +726,10 @@ export default class SampleImage extends React.Component {
points,
lines,
grids,
pixelsPerMm
pixelsPerMm,
sourceScale
} = nextProps;
this.drawCanvas(imageRatio);
this.drawCanvas(imageRatio, sourceScale);
this.canvas.add(...makeImageOverlay(
imageRatio,
pixelsPerMm,
Expand Down
5 changes: 3 additions & 2 deletions mxcube3/ui/containers/SampleViewContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import config from 'guiConfig';
class SampleViewContainer extends Component {

render() {
const { imageRatio, motorSteps } = this.props.sampleViewState;
const { sourceScale, imageRatio, motorSteps } = this.props.sampleViewState;
const { sendMotorPosition, setStepSize, sendStopMotor } = this.props.sampleViewActions;
const sampleID = this.props.current.sampleID;
const [points, lines, grids] = [{}, {}, {}];
Expand Down Expand Up @@ -90,7 +90,7 @@ class SampleViewContainer extends Component {
sampleID={sampleID}
sampleData={this.props.sampleList[sampleID]}
defaultParameters={this.props.defaultParameters}
imageRatio={imageRatio}
imageRatio={imageRatio * sourceScale}
workflows={this.props.workflows}
savedPointId={this.props.sampleViewState.savedPointId}
groupFolder={this.props.groupFolder}
Expand All @@ -100,6 +100,7 @@ class SampleViewContainer extends Component {
sampleActions={this.props.sampleViewActions}
{...this.props.sampleViewState}
{...this.props.beamline}
imageRatio={imageRatio * sourceScale}
contextMenuVisible={this.props.contextMenu.show}
shapes={this.props.shapes}
points={points}
Expand Down
7 changes: 5 additions & 2 deletions mxcube3/ui/reducers/sampleview.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const initialState = {
autoScale: true,
imageRatio: 0,
pixelsPerMm: [0, 0],
sourceScale: 1,
motorSteps: {
focusStep: 0.1,
phiStep: 90,
Expand Down Expand Up @@ -98,7 +99,8 @@ export default (state = initialState, action) => {
width: action.width,
height: action.height,
pixelsPerMm: action.pixelsPerMm,
beamPosition: action.beamPosition
beamPosition: action.beamPosition,
sourceScale: action.sourceScale
};
}
case 'CENTRING_CLICKS_LEFT': {
Expand Down Expand Up @@ -221,7 +223,8 @@ export default (state = initialState, action) => {
beamSize: { x: action.data.beamInfo.size_x, y: action.data.beamInfo.size_y },
phaseList: action.data.phaseList,
currentPhase: action.data.currentPhase,
pixelsPerMm: action.data.Camera.pixelsPerMm
pixelsPerMm: action.data.Camera.pixelsPerMm,
sourceScale: action.data.Camera.scale
};
}
default:
Expand Down

0 comments on commit f1b73a8

Please sign in to comment.