viewof draw_controls = {
const element = html`
<div id="draw-controls" style="display: inline-block; user-select: none;"></div>`;
d3.select(element)
.style('padding-right', '25px')
.selectAll('div')
.data(['Draw Lasso'])
.join('span')
.on('click', function(d){
if (d3.select(this).text() == 'Draw Lasso'){
d3.select('#lasso').style('display', 'none')
d3.select('#Draw-Lasso')
.text('Cancel Lasso')
.style('color', 'red')
d3.select('#lasso_layer')
.style('display', 'block')
mutable drawn_polygon = []
mutable save_lasso = false
d3.select('#Name-Lasso').node().value = default_name_lasso
}
else if (d3.select(this).text() == 'Cancel Lasso'){
// switch cancel-lasso button back to a draw-lasso button
d3.select('#Draw-Lasso')
.text('Draw Lasso')
.style('color', default_draw_text_color)
// turn off name lasso input
d3.select('#Name-Lasso')
.style('display', 'none')
// turn off save lasso button
d3.select('#Save-Lasso')
.style('display', 'none')
// turn off color_picker
d3.select('#Color-Picker')
.style('display', 'none')
// turn off lasso_layer
d3.select('#lasso_layer')
.style('display', 'none')
mutable drawn_polygon = []
// set to not saving lasso
mutable save_lasso = false
}
})
.style('min-width', '200px')
.style('max-width', '200px')
.style('margin-right', '10px')
.text('Draw Lasso')
.style('font-weight', '550px')
.style("font-family", "sans-serif")
.style("font-size", "16")
.style("text-anchor", "end")
.style('font-weight', 'bold')
.style('color', d => d === ini_draw_state ? 'blue': default_draw_text_color) // 808080
// .attr('id', d => d.replace(' ', '-'))
.attr('id', 'Draw-Lasso')
// Name Lasso
//////////////////////
d3.select(element)
.append('input')
.attr('value', default_name_lasso)
.style('width', '100px')
.style('height', '12px')
.style('margin-right', '10px')
.style('display', 'none')
.attr('id', 'Name-Lasso')
// d3.select(element)
// .html("<div> ${viewof color_picker} </div>")
// d3.select('#Color-Picker')
// .style(
// // Color Lasso
// //////////////////////
// d3.select(element)
// .append('input')
// .attr('value', default_color_lasso)
// .style('width', '100px')
// .style('height', '12px')
// .style('margin-right', '10px')
// .style('display', 'none')
// .attr('id', 'Color-Lasso')
// Save Lasso
////////////////////////////
d3.select(element)
.style('padding-right', '25px')
.selectAll('div')
.data(['Save Lasso'])
.join('span')
.on('click', function(d){
// Save Lasso Button
// switch back to a draw-lasso button
d3.select('#Draw-Lasso')
.text('Draw Lasso')
.style('color', default_draw_text_color)
// turn off name lasso input
d3.select('#Name-Lasso')
.style('display', 'none')
// turn off save lasso button after pressing save lasso
d3.select('#Save-Lasso')
.style('display', 'none')
// turn off lasso_layer
d3.select('#lasso_layer')
.style('display', 'none')
element.dispatchEvent(new CustomEvent("input"));
mutable save_lasso = true
// console.log('save_lasso', save_lasso)
// hack to get the save_lasso variable back to false
// setting this in Python casuses it to no longer be an
// updatable value
setTimeout(() => {
mutable save_lasso = false
// console.log('something!!!!')
}, 100);
mutable saved_lasso_name = d3.select('#Name-Lasso').node().value
// // this causes updating issues with Observable
// // update saved_poygon
// mutable saved_polygon = drawn_polygon
// turn off color_picker
d3.select('#Color-Picker')
.style('display', 'none')
})
.style('min-width', '200px')
.style('max-width', '200px')
.style('margin-right', '10px')
.text('Save Lasso')
.style('display', 'none')
.style('font-weight', '550px')
.style("font-family", "sans-serif")
.style("font-size", "16")
.style("text-anchor", "end")
.style('font-weight', 'bold')
.style('color', d => d === ini_draw_state ? 'blue': default_draw_text_color) // 808080
// .attr('id', d => d.replace(' ', '-'))
.attr('id', 'Save-Lasso')
// Delete Lasso
////////////////////////////
d3.select(element)
.style('padding-right', '25px')
.selectAll('div')
.data(['Delete Lasso'])
.join('span')
.on('click', function(d){
console.log('delete lasso')
mutable delete_lasso = true
// hack to get the save_lasso variable back to false
// setting this in Python casuses it to no longer be an
// updatable value
setTimeout(() => {
mutable delete_lasso = false
// console.log('something!!!!')
}, 100);
})
.style('min-width', '200px')
.style('max-width', '200px')
.style('margin-right', '10px')
.text('Delete Lasso')
.style('display', 'none')
.style('font-weight', '550px')
.style("font-family", "sans-serif")
.style("font-size", "16")
.style("text-anchor", "end")
.style('font-weight', 'bold')
.style('color', 'red')
.attr('id', 'Delete-Lasso')
element.value = ini_draw_state
element.dispatchEvent(new CustomEvent("input"))
return element
}