Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test schematics + data to review changes in rect3ddiagram.cpp #19

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 102 additions & 0 deletions testsuite/GUI_rect3ddiagram_prj/img_diff.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# copyright by ldpgh @ 2016

import sys
import numpy as np
import cv2

# For automation - means non-interactive ...
# change shw(...., timeout=0, ..) to a value other than 0


# rect3ddiagram ... ca. position and size to evaluate
ref_name="qucs_rect3ddiagram_0.0.9.PNG"
tst_name="qucs_rect3ddiagram_0.0.19.PNG"
x0=20
y0=370
ww=520
hh=270

# waveform color definition for inRange() filter
blue_min=np.array([112,148,148])
blue_max=np.array([125,255,255])

try:
if sys.argv[1]:
print("WARNING testmode for PASS using tst_name=ref_name=%s" % (ref_name))
tst_name=ref_name
except:
pass

def img_filt_low_coord(img):
x_min=len(img[0])
y_min=len(img)
# performance issue in numpy, if accessing small arrays (Pixel px, px[0])
# in the loop center very often
l_img=img.tolist()
for yy in range(len(img)):
for xx in range(len(l_img[yy])):
px=l_img[yy][xx]
# mit mask=cv2.bitwise_and() test px=array([0, 0, 0], dtype=uint8)
# oder array([255, 0, 0], dtype=uint8)
if px[0] > 128:
if xx<x_min:
x_min=xx
if yy<y_min:
y_min=yy
return y_min, x_min

def img_filt(img):
global blue_min, blue_max
# convert image to HSV color style for inRange() operation
img_hsv=cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
# define blue color range for filter operation
img_msk=cv2.inRange(img_hsv, blue_min, blue_max)
# Bitwise-AND the mask and image ... returns [0,0,0] or [255,0,0]
retimg=cv2.bitwise_and(img, img, mask=img_msk)
return retimg

def shw(img, timeout=0, title="image"):
cv2.imshow(title, img)
cv2.waitKey(timeout)
# cv2.destroyAllWindows()

def check_pixel_is_set(img):
limg=img.tolist()
for xx in limg:
for px in xx:
if px[0] is not 0:
return True
return False

# load images
img_ref=cv2.imread(ref_name)
img_tst=cv2.imread(tst_name)

# extract blue pixel, keep image size unchanged for later offset correction
img_ref=img_filt(img_ref)
img_tst=img_filt(img_tst)

# find most top and most left pixel position in predefined diagram region only
img_ref_y_min, img_ref_x_min=img_filt_low_coord(img_ref[y0:y0+hh, x0:x0+ww])
img_tst_y_min, img_tst_x_min=img_filt_low_coord(img_tst[y0:y0+hh, x0:x0+ww])

# calculate the offset between the blue waveforms in the images
dy=img_tst_y_min-img_ref_y_min
dx=img_tst_x_min-img_ref_x_min

# final cut-out for the comparison including offset correction of tst-image
img_ref=img_ref[y0:y0+hh, x0:x0+ww]
img_tst=img_tst[y0+dy:y0+dy+hh, x0+dx:x0+dx+ww]

# show the input images
shw(img_ref, title="ref")
shw(img_tst, title="tst")
# show the compare results
shw(img_tst-img_ref, title="tst-ref")
shw(img_ref-img_tst, title="ref-tst")
shw(img_ref^img_tst, title="ref^tst") #, timeout=0)

if check_pixel_is_set(img_tst-img_ref):
print("FAILED")
else:
print("PASS")
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<Qucs Schematic 0.0.9>
<Properties>
<View=380,-9,1024,546,1.02019,0,0>
<Grid=10,10,1>
<DataSet=rect3ddiagram_1x_diode_dblswp_qucs.dat>
<DataDisplay=rect3ddiagram_1x_diode_dblswp_qucs.dpl>
<OpenDisplay=0>
</Properties>
<Symbol>
</Symbol>
<Components>
<.SW SW2 1 430 40 0 51 0 0 "SW1" 1 "lin" 0 "Rr1" 1 "0.01" 1 "0.1" 1 "5" 1>
<IProbe Pr1 1 660 130 -26 16 0 0>
<R R2 1 730 130 -26 15 0 0 "0.1" 1 "26.85" 0 "0.0" 0 "0.0" 0 "26.85" 0 "european" 0>
<R R1 1 800 130 -26 15 0 0 "Rr1" 1 "26.85" 0 "0.0" 0 "0.0" 0 "26.85" 0 "european" 0>
<Vdc V1 1 590 170 18 -26 0 1 "Vdc" 1>
<GND * 1 590 200 0 0 0 0>
<.SW SW1 1 430 240 0 51 0 0 "DC1" 1 "lin" 0 "Vdc" 1 "0" 1 "2" 1 "200" 1>
<.DC DC1 1 430 440 0 44 0 0 "26.85" 0 "0.001" 0 "1 pA" 0 "1 uV" 0 "no" 0 "150" 0 "no" 0 "none" 0 "CroutLU" 0>
<GND * 1 870 190 0 0 0 0>
<Diode D_1N4148_1 1 870 160 7 -69 0 1 "222p" 1 "1.65" 1 "4p" 0 "0.333" 0 "0.7" 0 "0.5" 0 "0" 0 "0" 0 "2" 0 "68.6m" 0 "5.76n" 0 "0" 0 "0" 0 "1" 0 "1" 0 "75" 0 "22u" 1 "26.85" 0 "3.0" 0 "1.11" 0 "0.0" 0 "0.0" 0 "0.0" 0 "0.0" 0 "0.0" 0 "0.0" 0 "26.85" 0>
</Components>
<Wires>
<690 130 700 130 "" 0 0 0 "">
<760 130 770 130 "" 0 0 0 "">
<590 130 630 130 "" 0 0 0 "">
<590 130 590 140 "" 0 0 0 "">
<830 130 870 130 "" 0 0 0 "">
</Wires>
<Diagrams>
<Rect3D 606 495 340 265 3 #c0c0c0 1 00 1 0 0.5 2 1 0 0.02 0.109 1 -0.54829 2 6.63119 337 0 225 "" "" "">
<"Pr1.I" #ff0000 0 3 0 0 1>
</Rect3D>
</Diagrams>
<Paintings>
<Text 670 40 12 #000000 0 "Changed Diode:Ibv=22u to prevent warnings\nfrom Qucsator v0.0.9 simulation">
</Paintings>
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<Qucs Schematic 0.0.9>
<Properties>
<View=570,231,1280,952,0.793343,0,0>
<Grid=10,10,1>
<DataSet=rect3ddiagram_1x_small_000_test_sch.dat>
<DataDisplay=rect3ddiagram_1x_small_000_test_sch.dpl>
<OpenDisplay=0>
</Properties>
<Symbol>
</Symbol>
<Components>
<.SW SW1 1 620 280 0 51 0 0 "DC1" 1 "lin" 0 "VSW1" 1 "0" 1 "3.14159" 1 "5" 1>
<.SW SW2 1 850 280 0 51 0 0 "SW1" 1 "lin" 0 "VSW2" 1 "1" 1 "10" 1 "5" 1>
<.DC DC1 1 1080 280 0 42 0 0 "26.85" 0 "0.001" 0 "1 pA" 0 "1 uV" 0 "no" 0 "150" 0 "no" 0 "none" 0 "CroutLU" 0>
<GND * 1 1180 410 0 0 0 0>
<R R1 1 1180 380 15 -26 0 1 "1" 1 "26.85" 0 "0.0" 0 "0.0" 0 "26.85" 0 "european" 0>
<GND * 1 1140 410 0 0 0 0>
<Vdc V1 1 1140 380 -62 -26 1 1 "VV1" 1>
<Eqn Eqn1 5 1020 430 -33 16 0 0 "VV1=sin(VSW1)*VSW2" 1 "yes" 0>
</Components>
<Wires>
<1140 350 1180 350 "VR" 1140 330 23 "">
</Wires>
<Diagrams>
<Rect3D 640 912 575 415 3 #c0c0c0 1 00 1 0 0.2 3.2 1 0 2 10.9 1 -1 12 11 0 0 0 "X: VSW1" "Y: VSW2" "">
<"VR.V" #0000ff 0 3 0 0 1>
</Rect3D>
</Diagrams>
<Paintings>
</Paintings>
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<Qucs Schematic 0.0.9>
<Properties>
<View=390,231,1112,892,0.865355,0,0>
<Grid=10,10,1>
<DataSet=rect3ddiagram_1x_small_test_sch.dat>
<DataDisplay=rect3ddiagram_1x_small_test_sch.dpl>
<OpenDisplay=0>
</Properties>
<Symbol>
</Symbol>
<Components>
<.DC DC1 1 440 280 0 42 0 0 "26.85" 0 "0.001" 0 "1 pA" 0 "1 uV" 0 "no" 0 "150" 0 "no" 0 "none" 0 "CroutLU" 0>
<GND * 1 540 410 0 0 0 0>
<R R1 1 540 380 15 -26 0 1 "1" 1 "26.85" 0 "0.0" 0 "0.0" 0 "26.85" 0 "european" 0>
<GND * 1 500 410 0 0 0 0>
<Vdc V1 1 500 380 -62 -26 1 1 "VV1" 1>
<Eqn Eqn1 5 470 450 -33 16 0 0 "VV1=sin(VSW1)*VSW2" 1 "yes" 0>
<.SW SW1 1 620 280 0 51 0 0 "DC1" 1 "lin" 0 "VSW1" 1 "0" 1 "3.14159" 1 "5" 1>
<.SW SW2 1 850 280 0 51 0 0 "SW1" 1 "lin" 0 "VSW2" 1 "1" 1 "10" 1 "5" 1>
</Components>
<Wires>
<500 350 540 350 "VR" 500 330 23 "">
</Wires>
<Diagrams>
<Rect3D 440 852 575 415 3 #c0c0c0 1 00 1 0 0.2 3.2 1 0 2 10.9 1 -1 2 11 315 3 225 "X: VSW1" "Y: VSW2" "">
<"VR.V" #0000ff 0 3 0 0 1>
</Rect3D>
</Diagrams>
<Paintings>
</Paintings>
35 changes: 35 additions & 0 deletions testsuite/GUI_rect3ddiagram_prj/rect3ddiagram_1x_test_sch.sch
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<Qucs Schematic 0.0.9>
<Properties>
<View=550,191,1473,932,0.711809,0,0>
<Grid=10,10,1>
<DataSet=rect3ddiagram_1x_test_sch.dat>
<DataDisplay=rect3ddiagram_1x_test_sch.dpl>
<OpenDisplay=0>
</Properties>
<Symbol>
</Symbol>
<Components>
<.DC DC1 1 600 240 0 43 0 0 "26.85" 0 "0.001" 0 "1 pA" 0 "1 uV" 0 "no" 0 "150" 0 "no" 0 "none" 0 "CroutLU" 0>
<GND * 1 700 510 0 0 0 0>
<R R1 1 700 480 15 -26 0 1 "1" 1 "26.85" 0 "0.0" 0 "0.0" 0 "26.85" 0 "european" 0>
<GND * 1 660 510 0 0 0 0>
<Vdc V1 1 660 480 -62 -26 1 1 "VV1" 1>
<.SW SW1 1 770 240 0 51 0 0 "DC1" 1 "lin" 1 "VSW1" 1 "0" 1 "3.14159" 1 "5" 1>
<.SW SW2 1 1000 240 0 51 0 0 "SW1" 1 "lin" 1 "VSW2" 1 "1" 1 "10" 1 "5" 1>
<Eqn Eqn1 1 630 330 -33 16 0 0 "VV1=sin(VSW1)*VSW2" 1 "yes" 0>
</Components>
<Wires>
<700 430 700 450 "" 0 0 0 "">
<660 430 700 430 "VR" 630 410 23 "">
<660 430 660 450 "" 0 0 0 "">
</Wires>
<Diagrams>
<Rect3D 600 892 560 419 3 #c0c0c0 1 00 1 0 0.2 3.2 1 0 2 10.9 1 -1 2 11 315 3 225 "X: VSW1" "Y: VSW2" "">
<"VR.V" #0000ff 0 3 0 0 1>
</Rect3D>
<Tab 1230 838 203 592 3 #c0c0c0 1 00 1 0 1 1 1 0 1 1 1 0 1 25 315 0 225 "" "" "">
<"VR.V" #0000ff 0 3 1 0 0>
</Tab>
</Diagrams>
<Paintings>
</Paintings>
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<Qucs Schematic 0.0.9>
<Properties>
<View=318,176,1387,1223,0.546323,0,0>
<Grid=10,10,1>
<DataSet=rect3ddiagram_1x_waves3x_4sweeps_test_sch.dat>
<DataDisplay=rect3ddiagram_1x_waves3x_4sweeps_test_sch.dpl>
<OpenDisplay=0>
</Properties>
<Symbol>
</Symbol>
<Components>
<Eqn Eqn3 1 800 230 -33 16 0 0 "VV3=(1.5-3*sin(VSW1))*VSW2*VSW3*VSW4" 1 "yes" 0>
<Eqn Eqn2 1 610 250 -33 16 0 0 "VV2=(3.5*sin(VSW1)-1.5)*VSW2*VSW3*VSW4" 1 "yes" 0>
<Eqn Eqn1 1 450 270 -33 16 0 0 "VV1=sin(VSW1)*VSW2*VSW3*VSW4" 1 "yes" 0>
<.DC DC1 1 1120 250 0 44 0 0 "26.85" 0 "0.001" 0 "1 pA" 0 "1 uV" 0 "no" 0 "150" 0 "no" 0 "none" 0 "CroutLU" 0>
<.SW SW1 1 1120 330 0 51 0 0 "DC1" 1 "lin" 0 "VSW1" 1 "0" 1 "3.14159" 1 "25" 1>
<.SW SW2 1 1120 540 0 51 0 0 "SW1" 1 "lin" 0 "VSW2" 1 "1" 1 "10" 1 "15" 1>
<.SW SW3 1 1120 750 0 51 0 0 "SW2" 1 "lin" 0 "VSW3" 1 "1" 1 "3" 1 "3" 1>
<.SW SW4 1 1120 960 0 51 0 0 "SW3" 1 "lin" 0 "VSW4" 1 "-0.5" 1 "2.5" 1 "3" 1>
<GND * 1 650 420 0 0 0 0>
<GND * 1 610 420 0 0 0 0>
<R R2 1 650 410 15 -26 0 1 "1" 1 "26.85" 0 "0.0" 0 "0.0" 0 "26.85" 0 "european" 0>
<Vdc V2 1 610 410 -62 -26 1 1 "VV2" 1>
<GND * 1 900 430 0 0 0 0>
<R R3 1 900 400 15 -26 0 1 "1" 1 "26.85" 0 "0.0" 0 "0.0" 0 "26.85" 0 "european" 0>
<GND * 1 860 430 0 0 0 0>
<Vdc V3 1 860 400 -62 -26 1 1 "VV3" 1>
<GND * 1 460 420 0 0 0 0>
<GND * 1 420 420 0 0 0 0>
<R R1 1 460 410 15 -26 0 1 "1" 1 "26.85" 0 "0.0" 0 "0.0" 0 "26.85" 0 "european" 0>
<Vdc V1 1 420 410 -62 -26 1 1 "VV1" 1>
</Components>
<Wires>
<650 360 650 380 "" 0 0 0 "">
<610 360 650 360 "VR2" 560 350 0 "">
<610 360 610 380 "" 0 0 0 "">
<900 350 900 370 "" 0 0 0 "">
<860 350 900 350 "VR3" 910 330 23 "">
<860 350 860 370 "" 0 0 0 "">
<610 420 610 440 "" 0 0 0 "">
<650 420 650 440 "" 0 0 0 "">
<460 360 460 380 "" 0 0 0 "">
<420 360 460 360 "VR" 470 350 23 "">
<420 360 420 380 "" 0 0 0 "">
<420 420 420 440 "" 0 0 0 "">
<460 420 460 440 "" 0 0 0 "">
</Wires>
<Diagrams>
<Rect3D 367 1151 646 710 3 #c0c0c0 1 00 1 0 0.2 3.2 1 0 2 10.9 1 -20 5 25 315 3 225 "X: VSW1" "Y: VSW2" "">
<"VR.V" #0000ff 0 3 0 0 1>
<"VR2.V" #ff0000 0 3 0 0 1>
<"VR3.V" #00aa00 0 3 0 0 1>
</Rect3D>
</Diagrams>
<Paintings>
</Paintings>
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<Qucs Schematic 0.0.9>
<Properties>
<View=327,201,1302,1031,0.673846,0,0>
<Grid=10,10,1>
<DataSet=rect3ddiagram_1x_waves3x_test_sch.dat>
<DataDisplay=rect3ddiagram_1x_waves3x_test_sch.dpl>
<OpenDisplay=0>
</Properties>
<Symbol>
</Symbol>
<Components>
<.DC DC1 1 1040 250 0 42 0 0 "26.85" 0 "0.001" 0 "1 pA" 0 "1 uV" 0 "no" 0 "150" 0 "no" 0 "none" 0 "CroutLU" 0>
<.SW SW1 1 1040 350 0 51 0 0 "DC1" 1 "lin" 1 "VSW1" 1 "0" 1 "3.14159" 1 "25" 1>
<.SW SW2 1 1040 610 0 51 0 0 "SW1" 1 "lin" 1 "VSW2" 1 "1" 1 "10" 1 "15" 1>
<Eqn Eqn3 1 750 260 -33 16 0 0 "VV3=(1.5-3*sin(VSW1))*VSW2" 1 "yes" 0>
<Eqn Eqn2 1 570 280 -33 16 0 0 "VV2=(3.5*sin(VSW1)-1.5)*VSW2" 1 "yes" 0>
<Eqn Eqn1 1 410 300 -33 16 0 0 "VV1=sin(VSW1)*VSW2" 1 "yes" 0>
<GND * 1 470 460 0 0 0 0>
<R R1 1 470 430 15 -26 0 1 "1" 1 "26.85" 0 "0.0" 0 "0.0" 0 "26.85" 0 "european" 0>
<GND * 1 430 460 0 0 0 0>
<Vdc V1 1 430 430 -62 -26 1 1 "VV1" 1>
<GND * 1 650 460 0 0 0 0>
<R R2 1 650 430 15 -26 0 1 "1" 1 "26.85" 0 "0.0" 0 "0.0" 0 "26.85" 0 "european" 0>
<GND * 1 610 460 0 0 0 0>
<Vdc V2 1 610 430 -62 -26 1 1 "VV2" 1>
<GND * 1 860 460 0 0 0 0>
<R R3 1 860 430 15 -26 0 1 "1" 1 "26.85" 0 "0.0" 0 "0.0" 0 "26.85" 0 "european" 0>
<GND * 1 820 460 0 0 0 0>
<Vdc V3 1 820 430 -62 -26 1 1 "VV3" 1>
</Components>
<Wires>
<470 380 470 400 "" 0 0 0 "">
<430 380 470 380 "VR" 400 370 23 "">
<430 380 430 400 "" 0 0 0 "">
<650 380 650 400 "" 0 0 0 "">
<610 380 650 380 "VR2" 570 370 0 "">
<610 380 610 400 "" 0 0 0 "">
<860 380 860 400 "" 0 0 0 "">
<820 380 860 380 "VR3" 780 370 23 "">
<820 380 820 400 "" 0 0 0 "">
</Wires>
<Diagrams>
<Rect3D 367 991 566 504 3 #c0c0c0 1 00 1 0 0.2 3.2 1 0 2 10.9 1 -20 5 25 315 3 225 "X: VSW1" "Y: VSW2" "">
<"VR.V" #0000ff 0 3 0 0 1>
<"VR2.V" #ff0000 0 3 0 0 1>
<"VR3.V" #00aa00 0 3 0 0 1>
</Rect3D>
</Diagrams>
<Paintings>
</Paintings>
Loading