Commit 255f316e authored by Laurent Claustre's avatar Laurent Claustre

Merge branch 'issue_fixes2' into 'master'

last_but_not_least

See merge request !13
parents cfdfa3d9 b89f205b
Pipeline #19142 passed with stages
in 2 minutes and 2 seconds
......@@ -131,7 +131,7 @@ export function setLockCrosshair(state) {
export function setOptions(options) {
return (dispatch,getState) => {
const state = getState()
fetch(config.base_url+'/'+state.bpmState.client_id+'/api/set_options', {
return fetch(config.base_url+'/'+state.bpmState.client_id+'/api/set_options', {
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
......@@ -166,3 +166,11 @@ export function updateMin(value) {
export function updateMax(value) {
return { type: "UPDATE_MAX", value }
}
export function setProfileType(value) {
return (dispatch, getState) => {
const state = getState()
dispatch({ type: "PROFILE_TYPE", value})
dispatch(setOptions({ profile_type: value}))
}
}
......@@ -2,7 +2,7 @@ import React from 'react';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import {setBeamMark,setROIMark,setPrevROIMark,setROI,updateDimensions} from '../actions/canvas.js'
import {updateBackground,setCrosshair} from '../actions/video.js'
import {updateBackground,setCrosshair,refreshImage} from '../actions/video.js'
import {setImgDisplay,setLiveChecked} from '../actions/options.js'
......@@ -125,7 +125,9 @@ class Canvas extends React.Component {
if(e != undefined){
if((this.props.beam_markX != e.nativeEvent.offsetX*this.props.imageMaxWidth/this.props.windowWidth || this.props.beam_markY != e.nativeEvent.offsetY*this.props.imageMaxHeight/this.props.windowHeight) && !this.props.lockCrosshair){
this.props.setBeamMark(Math.round(e.nativeEvent.offsetX*this.props.imageMaxWidth/this.props.windowWidth),Math.round(e.nativeEvent.offsetY*this.props.imageMaxHeight/this.props.windowHeight)).then(() => {
this.props.setCrosshair()
this.props.setCrosshair().then(() => {
if (!this.props.liveCheckedBool) this.props.refreshImage()
})
})
}
}
......@@ -188,6 +190,7 @@ function mapStateToProps(state) {
activeBkgnd: state.video.activeBkgnd,
temperatureCheckedBool:state.video.temperatureCheckedBool,
client_id: state.bpmState.client_id,
liveCheckedBool: state.options.liveCheckedBool,
};
}
......@@ -202,6 +205,7 @@ function mapDispatchToProps(dispatch) {
updateBackground: bindActionCreators(updateBackground,dispatch),
setImgDisplay:bindActionCreators(setImgDisplay,dispatch),
setLiveChecked:bindActionCreators(setLiveChecked,dispatch),
refreshImage: bindActionCreators(refreshImage, dispatch),
};
}
......
......@@ -16,6 +16,8 @@ class Options extends React.Component {
this.textStateCalib_y = this.textStateCalib_y.bind(this);
this.initSocket()
this.localUpdate = false
}
initSocket() {
......@@ -39,26 +41,39 @@ class Options extends React.Component {
}
componentDidUpdate(prevProps) {
if (prevProps.exposureTimeValue != this.props.exposureTimeValue) {
this.props.textEnterSampling(1/(this.props.exposureTimeValue+(1.000001*this.props.minLatencyTime)));
if (prevProps.exposureTimeValue !== this.props.exposureTimeValue && !this.localUpdate) {
if (!this.props.exposureTimeValue) return
this.localUpdate = true
this.props.textEnterSampling((1/(this.props.exposureTimeValue+(1.000001*this.props.minLatencyTime))));
setTimeout(() => this.localUpdate = false, 0)
}
if (prevProps.samplingRateValue !== this.props.samplingRateValue && !this.localUpdate) {
if (!this.props.samplingRateValue) return
this.localUpdate = true
this.props.textEnterExposure((1/(this.props.samplingRateValue))-(1.00001*this.props.minLatencyTime))
setTimeout(() => this.localUpdate = false, 0)
}
}
textStateExposure(evt){
const val = parseFloat(evt.target.value)
if (evt.target.value > -0.0001){ // if >0, can't write "0,xxx" because of the first 0
this.props.textEnterExposure(parseFloat(evt.target.value));
this.props.textEnterExposure(isNaN(val) ? '' : val);
} else {
this.props.textEmptyExposure();
}
}
textStateSampling(evt){
if(evt.target.value > -0.0001 && evt.target.value<=(1.0/this.props.exposureTimeValue)){
this.props.textEnterSampling(parseFloat(evt.target.value));
} else {
this.props.textEmptySampling();
}
const val = parseFloat(evt.target.value)
if(evt.target.value > -0.0001){
this.props.textEnterSampling(isNaN(val) ? '' : val);
} //else {
// this.props.textEmptySampling();
// }
}
textStateCalib_x(evt) {
......
import React from 'react';
import { Container,Row,Col,Dropdown,Button,DropdownButton,ButtonGroup,FormCheck,DropdownItem,OverlayTrigger,Tooltip,SplitButton,Form } from 'react-bootstrap';
import { Container,Row,Col,Dropdown,Button,DropdownButton,ButtonGroup,FormCheck,DropdownItem,OverlayTrigger,Tooltip,SplitButton,Form,ToggleButton,ToggleButtonGroup } from 'react-bootstrap';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import {linearClicked,logarithmicClicked,autoscaleChecked,temperatureChecked,updateBackground,setRoi,setRotation,setFlip, setCrosshair, setLockCrosshair, setOptions,updateMin,updateMax} from '../actions/video.js'
import {linearClicked,logarithmicClicked,autoscaleChecked,temperatureChecked,updateBackground,setRoi,setRotation,setFlip, setCrosshair, setLockCrosshair, setOptions,updateMin,updateMax,setProfileType } from '../actions/video.js'
import {resetRoi, getStatus, profileSize, updateDimensions,setBeamMark,setBeamMarkDone } from '../actions/canvas.js'
import {setImgDisplay,setLiveChecked} from '../actions/options.js'
import Canvas from '../components/canvas.js'
......@@ -19,6 +19,7 @@ class Video extends React.Component {
this.updateMin = this.updateMin.bind(this);
this.updateMax = this.updateMax.bind(this);
this.saveMinMax = this.saveMinMax.bind(this);
this.resetMinMax = this.resetMinMax.bind(this);
this.graph_profilX = undefined;
this.graph_profilY = undefined;
......@@ -172,7 +173,13 @@ class Video extends React.Component {
}
saveMinMax() {
this.props.setOptions({ min_max: this.props.min_max })
this.props.setOptions({ min_max: this.props.min_max }).then(() => {
this.props.getStatus(window.innerWidth, window.innerHeight)
})
}
resetMinMax() {
this.props.setOptions({ min_max: [0,0] })
}
render() {
......@@ -200,6 +207,10 @@ class Video extends React.Component {
<Tooltip id="tooltip">Click here to show / hide image profiles</Tooltip>
);
const profileType = (
<Tooltip id="tooltip">Show profiles for beam or crosshair position</Tooltip>
);
const ready = this.props.acqStatus == 'Ready';
return (
......@@ -246,7 +257,10 @@ class Video extends React.Component {
<Form.Control type="number" value={this.props.min_max[1]} onChange={this.updateMax} />
</Col>
</Form.Group>
<Button onClick={this.saveMinMax}>Apply</Button>
<ButtonGroup>
<Button onClick={this.saveMinMax}>Apply</Button>
<Button onClick={this.resetMinMax}>Reset</Button>
</ButtonGroup>
</Container>
</DropdownButton>
</OverlayTrigger>
......@@ -271,6 +285,17 @@ class Video extends React.Component {
<OverlayTrigger placement="top" overlay={profiles}>
<Button onClick={this.toggleHideProfile.bind(this)} variant={this.props.profileSize.x?'primary':'secondary'}>Profiles</Button>
</OverlayTrigger>
<OverlayTrigger placement="top" overlay={profileType}>
<ToggleButtonGroup type="radio" name="profileType" value={this.props.profileType} onChange={this.props.setProfileType} className="ml-1">
<ToggleButton type="radio" value="beam">
Beam
</ToggleButton>
<ToggleButton type="radio" value="crosshair">
Crosshair
</ToggleButton>
</ToggleButtonGroup>
</OverlayTrigger>
</Col>
</Row>
......@@ -321,7 +346,8 @@ function mapStateToProps(state) {
calib_y: state.options.calib_y,
temperatureCheckedBool: state.video.temperatureCheckedBool,
autoscaleCheckedBool: state.video.autoscaleCheckedBool,
min_max: state.video.min_max
min_max: state.video.min_max,
profileType: state.video.profileType,
};
}
......@@ -348,6 +374,7 @@ function mapDispatchToProps(dispatch) {
setOptions:bindActionCreators(setOptions,dispatch),
updateMin:bindActionCreators(updateMin,dispatch),
updateMax:bindActionCreators(updateMax,dispatch),
setProfileType: bindActionCreators(setProfileType, dispatch),
};
}
......
......@@ -11,6 +11,7 @@ const initialState = {
rotation: 0,
flip: [false, false],
min_max: [0, 65536],
profileType: 'beam',
};
......@@ -24,9 +25,9 @@ export default function video(state = initialState, action) {
const crosshair = action.status.beam_mark_x && action.status.beam_mark_y;
if(action.status.background===true){
alert('A background is already set, you can reset it by clicking on the \'Bkgnd\' button')
return Object.assign({}, state, {backgroundstate: 0, activeBkgnd:true, activeROIServer: action.status.roi, rotation: action.status.rotation, flip: action.status.flip, selectedLut: action.status.lut_method, temperatureCheckedBool: action.status.color_map, autoscaleCheckedBool: action.status.autoscale, activeCrosshair: crosshair, min_max: action.status.min_max})
return Object.assign({}, state, {backgroundstate: 0, activeBkgnd:true, activeROIServer: action.status.roi, rotation: action.status.rotation, flip: action.status.flip, selectedLut: action.status.lut_method, temperatureCheckedBool: action.status.color_map, autoscaleCheckedBool: action.status.autoscale, activeCrosshair: crosshair, min_max: action.status.min_max,profileType: action.status.profile_type})
} else {
return Object.assign({}, state, { activeROIServer: action.status.roi, rotation: action.status.rotation, flip: action.status.flip, selectedLut: action.status.lut_method, temperatureCheckedBool: action.status.color_map, autoscaleCheckedBool: action.status.autoscale, activeCrosshair: crosshair, min_max: action.status.min_max})
return Object.assign({}, state, { activeROIServer: action.status.roi, rotation: action.status.rotation, flip: action.status.flip, selectedLut: action.status.lut_method, temperatureCheckedBool: action.status.color_map, autoscaleCheckedBool: action.status.autoscale, activeCrosshair: crosshair, min_max: action.status.min_max, profileType: action.status.profile_type})
}
}
......@@ -115,6 +116,11 @@ export default function video(state = initialState, action) {
return Object.assign({}, state, {min_max: [state.min_max[0], action.value]})
}
case 'PROFILE_TYPE':
{
return Object.assign({}, state, { profileType: action.value })
}
default:
return state
}
......
This diff is collapsed.
......@@ -239,6 +239,7 @@ class BVWebserver:
"max_latency_time": self.cameras_running[camera][0].valid_ranges[3],
"rotation": 0 if self.cameras_running[camera][0].image_rotation == 'NONE' else int(self.cameras_running[camera][0].image_rotation),
"flip": (bool(self.cameras_running[camera][0].image_flip[0]), bool(self.cameras_running[camera][0].image_flip[1])),
"profile_type": "beam" if self.cameras_running[camera][1].return_bpm_profiles else "crosshair"
}
return reply
......@@ -309,6 +310,12 @@ class BVWebserver:
self.cameras_running[camera][1].min_max = [int(mm[0]), int(mm[1])]
return { "message": "min_max updated"}
if "profile_type" in bottle.request.json:
beam = bottle.request.json["profile_type"] == "beam"
print("profile_type", bottle.request.json["profile_type"], beam)
self.cameras_running[camera][1].return_bpm_profiles = beam
return { "message": "profile_type set"}
def refresh_image(self, camera):
self.parse_bvdata(camera, self.cameras_running[camera][1].bvdata)
......@@ -370,7 +377,6 @@ class BVWebserver:
x = int(bottle.request.query.x)
y = int(bottle.request.query.y)
self.cameras_running[camera][1].beammark = ([x, y])
self.cameras_running[camera][1].return_bpm_profiles = True if x == 0 and y == 0 else False
def getintensity(self, camera):
x = int(bottle.request.query.x); y = int(bottle.request.query.y)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment