make profile coordinates modifieable in panel

This commit is contained in:
m-schuetz 2017-07-19 18:13:58 +02:00
parent 470ba25cbd
commit d9cd3d382f
3 changed files with 84 additions and 1 deletions

View File

@ -93,6 +93,10 @@ Potree.utils = class{
}
return x1 + x2;
};
static removeCommas(str){
return str.replace(/,/g, "");
}
/**
* create worker from a string

View File

@ -780,3 +780,13 @@ label:hover{
width: 100%
}
.invalid_value{
color: #e05e5e;
}
//[contenteditable]:focus {
// outline: 1px solid red;
// outline-radius: 2px;
//}

View File

@ -1122,7 +1122,76 @@ function initMeasurementDetails(){
update(){
let elCoordiantesContainer = this.elContent.find(".coordinates_table_container");
elCoordiantesContainer.empty();
elCoordiantesContainer.append(createCoordinatesTable(this.measurement));
let coordinatesTable = createCoordinatesTable(this.measurement);
let validate = input => {
return !isNaN(Number(input));
};
let cells = coordinatesTable.find("td");
cells.attr("contenteditable", "true");
cells = cells.toArray();
for(let i = 0; i < cells.length; i++){
let cell = cells[i];
let measure = this.measurement;
let updateCallback = this._update;
let assignValue = () => {
let text = Potree.utils.removeCommas($(cell).html());
let num = Number(text);
if(!isNaN(num)){
$(cell).removeClass("invalid_value");
measure.removeEventListener("marker_moved", updateCallback);
let index = parseInt(i / 3);
let coordinateComponent = i % 3;
let position = measure.points[index].clone();
if(coordinateComponent === 0){
position.x = num;
} else if(coordinateComponent === 1){
position.y = num;
} else if(coordinateComponent === 2){
position.z = num;
}
measure.setPosition(index, position);
measure.addEventListener("marker_moved", updateCallback);
}else{
$(cell).addClass("invalid_value");
}
};
$(cell).on("keypress", (e) => {
if(e.which === 13){
assignValue();
return false;
}
});
$(cell).focusout(() => assignValue());
$(cell).on("input", function(e){
let text = Potree.utils.removeCommas($(this).html());
let num = Number(text);
if(!isNaN(num)){
$(this).removeClass("invalid_value");
}else{
$(this).addClass("invalid_value");
}
});
}
elCoordiantesContainer.append(coordinatesTable);
}
download(){