puts "================"
puts "OCC1629"
puts "OCC2707"
puts "================"
puts ""
#######################################################################################
# Viewer is always updated on closing local contexts
#######################################################################################

box b1 10 10 10
box b2 50 50 50 10 10 10
vinit
vdisplay b1 b2
vfit

# box b2
set x1 321
set y1 120

set x2 336
set y2 145

set x3 367
set y3 144

# box b1
set x4 44
set y4 314

set x5 72
set y5 314

set Selection_R 0.8
set Selection_G 0.8
set Selection_B 0.8

#QASetChoiceMode EDGE ON
vselmode 2 1 -local

set BeforeNbSelected [vnbselected]

vselect 0 0 1

vselect ${x1} ${y1} 1
vselect ${x2} ${y2} 1 
vselect ${x3} ${y3} 1
vselect ${x4} ${y4} 1
vselect ${x5} ${y5} 1

set AfterNbSelected [vnbselected]

checkcolor ${x1} ${y1} ${Selection_R} ${Selection_G} ${Selection_B}
checkcolor ${x2} ${y2} ${Selection_R} ${Selection_G} ${Selection_B}
checkcolor ${x3} ${y3} ${Selection_R} ${Selection_G} ${Selection_B}
checkcolor ${x4} ${y4} ${Selection_R} ${Selection_G} ${Selection_B}
checkcolor ${x5} ${y5} ${Selection_R} ${Selection_G} ${Selection_B}

if {${BeforeNbSelected} == 0} {
    puts "OCC1629: OK (case 6: before selection)"
} else {
    puts "OCC1629: Error (case 6: before selection)"
}

if {${AfterNbSelected} == 5} {
    puts "OCC1629: OK (case 7: after selection)"
} else {
    puts "OCC1629: Error (case 7: after selection)"
}

vselmode 0 1

#
puts "NOTES:"
puts ""
puts "Viewer is not updated on closing local context,"
puts "but we can not check it by automatic test!"
puts ""
puts "5 edges must be selected on the viewer,"
puts "but must be CloseNbSelected = 0 !"
puts ""
#

set CloseNbSelected [vnbselected]

checkcolor ${x1} ${y1} 1 1 0
checkcolor ${x2} ${y2} 1 1 0
checkcolor ${x3} ${y3} 1 1 0
checkcolor ${x4} ${y4} 1 1 0
checkcolor ${x5} ${y5} 1 1 0

if {${CloseNbSelected} == 0} {
    puts "OCC1629: OK (case 13: after close local context)"
} else {
    puts "OCC1629: Error (case 13: after close local context)"
}

checkview -screenshot -3d -path ${imagedir}/${test_image}.png
