1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-14 13:30:48 +03:00

0023493: Incorrect QAGetPixelColor usage

Usage of QAGetPixelColor were checked and corrected.

Using simple comparison instead of regexp.

Improved usage of command vreadpixel for standard colors.

Command QAGetPixelColor was dropped from TKQADraw.

Procedures "checkcolor" and auxiliary "checkpoint" were moved to DrawResources/TestCommands.tcl

Some test cases using "checkcolor" for picking line color were simplified.

Procedures checkcolor and checkpoint were changed to handle situation when pixel is out of view.

Removed unnecessary use of command "vaspects -setwidth" in tests.

Revert -setwidth change in test bugs/vis/bug23525
This commit is contained in:
ski
2014-12-11 16:47:12 +03:00
committed by bugmaster
parent a4bb1420ca
commit ccadc126ba
56 changed files with 356 additions and 932 deletions

View File

@@ -2026,3 +2026,145 @@ proc _testgrid_process_jobs {worker {nb_ok 0}} {
}
catch {tpool::suspend $worker}
}
help checkcolor {
Check pixel color.
Use: checkcolor x y red green blue
x y - pixel coordinates
red green blue - expected pixel color (values from 0 to 1)
Function check color with tolerance (5x5 area)
}
# Procedure to check color using command vreadpixel with tolerance
proc checkcolor { coord_x coord_y rd_get gr_get bl_get } {
puts "Coordinate x = $coord_x"
puts "Coordinate y = $coord_y"
puts "RED color of RGB is $rd_get"
puts "GREEN color of RGB is $gr_get"
puts "BLUE color of RGB is $bl_get"
if { $coord_x <= 1 || $coord_y <= 1 } {
puts "Error : minimal coordinate is x = 2, y = 2. But we have x = $coord_x y = $coord_y"
return -1
}
set color ""
catch { [set color "[vreadpixel ${coord_x} ${coord_y} rgb]"] }
if {"$color" == ""} {
puts "Error : Pixel coordinates (${position_x}; ${position_y}) are out of view"
}
set rd [lindex $color 0]
set gr [lindex $color 1]
set bl [lindex $color 2]
set rd_int [expr int($rd * 1.e+05)]
set gr_int [expr int($gr * 1.e+05)]
set bl_int [expr int($bl * 1.e+05)]
set rd_ch [expr int($rd_get * 1.e+05)]
set gr_ch [expr int($gr_get * 1.e+05)]
set bl_ch [expr int($bl_get * 1.e+05)]
if { $rd_ch != 0 } {
set tol_rd [expr abs($rd_ch - $rd_int)/$rd_ch]
} else {
set tol_rd $rd_int
}
if { $gr_ch != 0 } {
set tol_gr [expr abs($gr_ch - $gr_int)/$gr_ch]
} else {
set tol_gr $gr_int
}
if { $bl_ch != 0 } {
set tol_bl [expr abs($bl_ch - $bl_int)/$bl_ch]
} else {
set tol_bl $bl_int
}
set status 0
if { $tol_rd > 0.2 } {
puts "Warning : RED light of additive color model RGB is invalid"
set status 1
}
if { $tol_gr > 0.2 } {
puts "Warning : GREEN light of additive color model RGB is invalid"
set status 1
}
if { $tol_bl > 0.2 } {
puts "Warning : BLUE light of additive color model RGB is invalid"
set status 1
}
if { $status != 0 } {
puts "Warning : Colors of default coordinate are not equal"
}
global stat
if { $tol_rd > 0.2 || $tol_gr > 0.2 || $tol_bl > 0.2 } {
set info [_checkpoint $coord_x $coord_y $rd_ch $gr_ch $bl_ch]
set stat [lindex $info end]
if { ${stat} != 1 } {
puts "Error : Colors are not equal in default coordinate and in the near coordinates too"
return $stat
} else {
puts "Point with valid color was found"
return $stat
}
} else {
set stat 1
}
}
# Procedure to check color in the point near default coordinate
proc _checkpoint {coord_x coord_y rd_ch gr_ch bl_ch} {
set x_start [expr ${coord_x} - 2]
set y_start [expr ${coord_y} - 2]
set mistake 0
set i 0
while { $mistake != 1 && $i <= 5 } {
set j 0
while { $mistake != 1 && $j <= 5 } {
set position_x [expr ${x_start} + $j]
set position_y [expr ${y_start} + $i]
puts $position_x
puts $position_y
set color ""
catch { [set color "[vreadpixel ${position_x} ${position_y} rgb]"] }
if {"$color" == ""} {
puts "Warning : Pixel coordinates (${position_x}; ${position_y}) are out of view"
incr j
continue
}
set rd [lindex $color 0]
set gr [lindex $color 1]
set bl [lindex $color 2]
set rd_int [expr int($rd * 1.e+05)]
set gr_int [expr int($gr * 1.e+05)]
set bl_int [expr int($bl * 1.e+05)]
if { $rd_ch != 0 } {
set tol_rd [expr abs($rd_ch - $rd_int)/$rd_ch]
} else {
set tol_rd $rd_int
}
if { $gr_ch != 0 } {
set tol_gr [expr abs($gr_ch - $gr_int)/$gr_ch]
} else {
set tol_gr $gr_int
}
if { $bl_ch != 0 } {
set tol_bl [expr abs($bl_ch - $bl_int)/$bl_ch]
} else {
set tol_bl $bl_int
}
if { $tol_rd > 0.2 || $tol_gr > 0.2 || $tol_bl > 0.2 } {
puts "Warning : Point with true color was not found near default coordinates"
set mistake 0
} else {
set mistake 1
}
incr j
}
incr i
}
return $mistake
}