

function meu:define_ui()
	local ref = self.ref
	local ui = self.ui
	local bu
	local ix,iy = 1,1
	local SY = 1
	local DY = .2

	local SXS = 4
	local SYS = SY * 2

--	self:set_tab_key( "Art" )
	--iy = self:add_exploitation_start_stop(	{ix,iy,		7,SY},	true, true )

--	self:add_ui_exploitation_window(	{ix,iy,			7,5}	)
--	iy = iy + 5 + DY

--	self:add_trig_method(	{ix+2,iy,		4,SY},	"FULLSCREEN", 	ga,			"force_fullscreen"	):set_color_back( "restart" )
--	iy = iy + SY + SY/2

--	self:add_slider(		{ix,iy,			8,SY},	"Volume", 		self,		"volume",	.8,	0,1	)
--	iy = iy + SY + DY

--	self:add_slider(		{ix,iy,			8,SY},	"Flatland_offset_X", 	aaa.ref.draw_focus_offset_x	):set_min_max( 0, 4000 )
--	iy = iy + SY + DY

	ix,iy = 9,1
	self:add_selector(		{ix,iy,			8,SY},	"Detection"		)
		:set_item_text( 1, "NO", "Detection", "Simulation", "Direct" )
		:set_target_lua( self, "s_detection" )
		--:set_nb( 3 )
	--	:set_value( 2 )
	iy = iy + SY
	
	local pres = self.presence
	for i = 1,self.detection_nb do
		local s = 8/self.detection_nb
		self:add_slider(	{ix+s*(i-1),iy,		s,SY},	"Cov Max"..i,	pres[i],	"coverage_max",	0,	0,.5 	)
		self:add_slider(	{ix+s*(i-1),iy+SY,	s,SY},	"Cov "..i,		pres[i],	"cov",			0,	0,1 	)
		self:add_slider(	{ix+s*(i-1),iy+SY*2,s,SY},	"Accum "..i,	pres[i],	"accum",		0,	0,1 	)
	--	:set_draw_min(false)	--todo works but not the right way ? solve later
	end
	iy = iy + SY*3

end


function meu:init()
	local ref = self.ref
--	local bdd = self:get_layer_bdd(1)
--	ref.temp	= param.get_ref( bdd, "received_number_last" )
	self.s_fullscreen_needed = 0
	self.s_init = 0
	--self:print( "init s_init "..self.s_init )
	-- if not aaa.pc.is_maa() then
	-- 	ga:set_ui_on_screen(1)
	-- 	ga:force_fullscreen()
	-- end

	self.presence = {}
	self.detection_nb = 1
	for i = 1,self.detection_nb do
		local pre = {}
		pre.ref_bdd = self:get_layer_bdd(i)
		pre.ref_cov = param.get_ref( pre.ref_bdd, "out_coverage" )
		pre.ref_cov_max = param.get_ref( pre.ref_bdd, "coverage_max" )
		self.presence[i] = pre
	end
end

function meu:update_ui()
	local ui = self.ui

--	self:update_ui_exploitation_start_stop()
end

--todo ?
function meu:configure()
-- 	local host_id = aaa.net.get_host_id()
-- 	if inside( host_id, 211, 215 ) then
-- 	else
-- --		aaa.net.set_active(true)
-- 	end
end

function meu:get_circle_cov( i )
	local pre = self.presence[i]
	return pre.cov
end
function meu:get_circle_accum( i )
	local pre = self.presence[i]
	return pre.accum
end
function meu:set_circle_accum( i, accum )
	local pre = self.presence[i]
	pre.accum = accum
end
function meu:update()
	local ref = self.ref
	local b_onsite = not aaa.pc.is_maa()	
	self:set_ui_slot_at_start( 3 )

	local dt = aaa.time.dt

	local pres = self.presence
	for i=1,self.detection_nb do
		local pre = pres[i]
		if inside( self.s_detection, 2, 3 ) then
			if self.s_detection==2 then
				param.set( pre.ref_cov_max, pre.coverage_max )
				self:update_then_draw( pre.ref_bdd )
				pre.cov = param.get( pre.ref_cov )
			end
			local cov = pre.cov
			pre.accum = clamp_01( pre.accum + ((cov>.05) and (cov*.5) or -1) * dt )
		end
	end
	
--	self:update_exploitation_window()
	if self.s_detection~=1 then
		local def = meu:get_circle_accum( 1 )
		local m = self:get_meu_by_name_cached( "Obj3DLatex_1" )
		m:set_bu_value( "f1", def )
	end
end

