function object_drawing_functions(obj)
if strcmp(obj.obj_type, 'voltage_source')
draw_a_voltage_source(obj);
end
if strcmp(obj.obj_type, 'current_source')
draw_a_current_source(obj);
end
if strcmp(obj.obj_type, 'resistor')
draw_a_resistor(obj);
end
if strcmp(obj.obj_type, 'capacitor')
draw_a_capacitor(obj);
end
if strcmp(obj.obj_type, 'inductor')
draw_an_inductor(obj);
end
if strcmp(obj.obj_type, 'diode')
draw_a_diode(obj);
end
if strcmp(obj.obj_type, 'sampled_voltage')
draw_a_sampled_voltage(obj);
end
if strcmp(obj.obj_type, 'sampled_current')
draw_a_sampled_current(obj);
end
if strcmp(obj.obj_type, 'thin_wire')
draw_a_thin_wire(obj);
end
if strcmp(obj.obj_type, 'sampled_electric_field')
draw_a_sampled_electric_field(obj);
end
if strcmp(obj.obj_type, 'sampled_magnetic_field')
draw_a_sampled_magnetic_field(obj);
end
if strcmp(obj.obj_type, 'axis_outside_domain')
draw_axis_outside_domain(obj);
end
if strcmp(obj.obj_type, 'axis_at_origin')
draw_axis_at_origin(obj);
end
%===================================================================
function draw_a_current_source(obj)
ix = obj.min_x; iy = obj.min_y; iz = obj.min_z;
ax = obj.max_x; ay = obj.max_y; az = obj.max_z;
switch (obj.direction)
case ('xn')
vx = [ax ix]; vy = 0.5*[(iy+ay) (iy+ay)]; vz = 0.5*[(iz+az) (iz+az)];
len = ax - ix;
ir = len/20;
[v1, f1] = a_line([ix ix+0.2*len], vy, vz, ir);
[v2, f2] = a_line([ix+0.8*len ax], vy, vz, ir);
if ((az-iz)<(ay-iy)) dn = 'z'; else dn = 'y'; end
cx = (vx(1)+vx(2))/2;
cy = (vy(1)+vy(2))/2;
cz = (vz(1)+vz(2))/2;
[v3, f3] = a_circle(cx, cy, cz, len*0.3, dn, ir);
[v4, f4] = a_vector([cx+len/10 cx-len/10], [cy cy], [cz cz], len/16, len/8, 0.5);
case ('xp')
vx = [ix ax]; vy = 0.5*[(iy+ay) (iy+ay)]; vz = 0.5*[(iz+az) (iz+az)];
len = ax - ix;
ir = len/20;
[v1, f1] = a_line([ix ix+0.2*len], vy, vz, ir);
[v2, f2] = a_line([ix+0.8*len ax], vy, vz, ir);
if ((az-iz)<(ay-iy)) dn = 'z'; else dn = 'y'; end
cx = (vx(1)+vx(2))/2;
cy = (vy(1)+vy(2))/2;
cz = (vz(1)+vz(2))/2;
[v3, f3] = a_circle(cx, cy, cz, len*0.3, dn, ir);
[v4, f4] = a_vector([cx-len/10 cx+len/10], [cy cy], [cz cz], len/16, len/8, 0.5);
case ('yn')
vx = 0.5*[(ix+ax) (ix+ax)]; vy = [ay iy]; vz = 0.5*[(iz+az) (iz+az)];
len = ay - iy;
ir = len/20;
[v1, f1] = a_line(vx, [iy iy+0.2*len], vz, ir);
[v2, f2] = a_line(vx, [iy+0.8*len ay], vz, ir);
if ((ax-ix)<(az-iz)) dn = 'x'; else dn = 'z'; end
cx = (vx(1)+vx(2))/2;
cy = (vy(1)+vy(2))/2;
cz = (vz(1)+vz(2))/2;
[v3, f3] = a_circle(cx, cy, cz, len*0.3, dn, ir);
[v4, f4] = a_vector([cx cx],[cy+len/10 cy-len/10], [cz cz], len/16, len/8, 0.5);
case ('yp')
vx = 0.5*[(ix+ax) (ix+ax)]; vy = [iy ay]; vz = 0.5*[(iz+az) (iz+az)];
len = ay - iy;
ir = len/20;
[v1, f1] = a_line(vx, [iy iy+0.2*len], vz, ir);
[v2, f2] = a_line(vx, [iy+0.8*len ay], vz, ir);
if ((ax-ix)<(az-iz)) dn = 'x'; else dn = 'z'; end
cx = (vx(1)+vx(2))/2;
cy = (vy(1)+vy(2))/2;
cz = (vz(1)+vz(2))/2;
[v3, f3] = a_circle(cx, cy, cz, len*0.3, dn, ir);
[v4, f4] = a_vector([cx cx],[cy-len/10 cy+len/10], [cz cz], len/16, len/8, 0.5);
case ('zn')
vx = 0.5*[(ix+ax) (ix+ax)]; vy = 0.5*[(iy+ay) (iy+ay)]; vz = [az iz];
len = az - iz;
ir = len/20;
[v1, f1] = a_line(vx, vy, [iz iz+0.2*len], ir);
[v2, f2] = a_line(vx, vy, [iz+0.8*len az], ir);
if ((ax-ix)<(ay-iy)) dn = 'x'; else dn = 'y'; end
cx = (vx(1)+vx(2))/2;
cy = (vy(1)+vy(2))/2;
cz = (vz(1)+vz(2))/2;
[v3, f3] = a_circle(cx, cy, cz, len*0.3, dn, ir);
[v4, f4] = a_vector([cx cx], [cy cy], [cz+len/10 cz-len/10], len/16, len/8, 0.5);
case ('zp')
vx = 0.5*[(ix+ax) (ix+ax)]; vy = 0.5*[(iy+ay) (iy+ay)]; vz = [iz az];
len = az - iz;
ir = len/20;
[v1, f1] = a_line(vx, vy, [iz iz+0.2*len], ir);
[v2, f2] = a_line(vx, vy, [iz+0.8*len az], ir);
if ((ax-ix)<(ay-iy)) dn = 'x'; else dn = 'y'; end
cx = (vx(1)+vx(2))/2;
cy = (vy(1)+vy(2))/2;
cz = (vz(1)+vz(2))/2;
[v3, f3] = a_circle(cx, cy, cz, len*0.3, dn, ir);
[v4, f4] = a_vector([cx cx], [cy cy], [cz-len/10 cz+len/10], len/16, len/8, 0.5);
end
v = [v1; v2; v3; v4];
f = f1;
f = [f; max(max(f)) + f2];
f = [f; max(max(f)) + f3];
f = [f; max(max(f)) + f4];
patch('Vertices',v,'Faces',f,'facecolor','m', ...
'facealpha',1,'edgecolor','none');
% draw boundaries
v = [0 0 0; 1 0 0; 1 1 0; 0 1 0; 0 0 1; 1 0 1; 1 1 1; 0 1 1];
vx = v(:,1) * (ax - ix) + ix;
vy = v(:,2) * (ay - iy) + iy;
vz = v(:,3) * (az - iz) + iz;
f = [1 2 6 5; 2 3 7 6; 3 4 8 7; 4 1 5 8; 1 2 3 4; 5 6 7 8];
patch('Vertices',[vx vy vz],'Faces',f,'facecolor','none','LineWidth',1, ...
'facealpha',0.3,'edgecolor','m','linestyle','-');
% show label
text(ix,iy,iz,obj.obj_id,'VerticalAlignment','bottom', ...
'BackgroundColor','w','edgecolor','m','fontsize',12);
%===================================================================
function draw_a_voltage_source(obj)
ix = obj.min_x; iy = obj.min_y; iz = obj.min_z;
ax = obj.max_x; ay = obj.max_y; az = obj.max_z;
switch (obj.direction)
case ('xn')
vx = [ax ix]; vy = 0.5*[(iy+ay) (iy+ay)]; vz = 0.5*[(iz+az) (iz+az)];
len = ax - ix;
ir = len/30;
[v1, f1] = a_line([ix ix+0.2*len], vy, vz, ir);
[v2, f2] = a_line([ix+0.8*len ax], vy, vz, ir);
if ((az-iz)<(ay-iy)) dn = 'z'; else dn = 'y'; end
cx = (vx(1)+vx(2))/2;
cy = (vy(1)+vy(2))/2;
cz = (vz(1)+vz(2))/2;
[v3, f3] = a_circle(cx, cy, cz, len*0.3, dn, ir);
[v4, f4] = a_plus(cx-len/10, cy, cz, len/5, dn, ir);
[v5, f5] = a_minus(cx+len/10, cy, cz, len/5, dn, ir, 'x');
case ('xp')
vx = [ix ax]; vy = 0.5*[(iy+ay) (iy+ay)]; vz = 0.5*[(iz+az) (iz+az)];
len = ax - ix;
ir = len/30;
[v1, f1] = a_line([ix ix+0.2*len], vy, vz, ir);
[v2, f2] = a_line([ix+0.8*len ax], vy, vz, ir);
if ((az-iz)<(ay-iy)) dn = 'z'; else dn = 'y'; end
cx = (vx(1)+vx(2))/2;
cy = (vy(1)+vy(2))/2;
cz = (vz(1)+vz(2))/2;
[v3, f3] = a_circle(cx, cy, cz, len*0.3, dn, ir);
[v4, f4] = a_plus(cx+len/10, cy, cz, len/5, dn, ir);
[v5, f5] = a_minus(cx-len/10, cy, cz, len/5, dn, ir, 'x');
case ('yn')
vx = 0.5*[(ix+ax) (ix+ax)]; vy = [ay iy]; vz = 0.5*[(iz+az) (iz+az)];
len = ay - iy;
ir = len/30;
[v1, f1] = a_line(vx, [iy iy+0.2*len], vz, ir);
[v2, f2] = a_line(vx, [iy+0.8*len ay], vz, ir);
if ((ax-ix)<(az-iz)) dn = 'x'; else dn = 'z'; end
cx = (vx(1)+vx(2))/2;
cy = (vy(1)+vy(2))/2;
cz = (vz(1)+vz(2))/2;
[v3, f3] = a_circle(cx, cy, cz, len*0.3, dn, ir);
[v4, f4] = a_plus(cx, cy-len/10, cz, len/5, dn, ir);
[v5, f5] = a_minus(cx, cy+len/10, cz, len/5, dn, ir, 'y');
case ('yp')
vx = 0.5*[(ix+ax) (ix+ax)]; vy = [iy ay]; vz = 0.5*[(iz+az) (iz+az)];
len = ay - iy;
ir = len/30;
[v1, f1] = a_line(vx, [iy iy+0.2*len], vz, ir);
[v2, f2] = a_line(vx, [iy+0.8*len ay], vz, ir);
if ((ax-ix)<(az-iz)) dn = 'x'; else dn = 'z'; end
cx = (vx(1)+vx(2))/2;
cy = (vy(1)+vy(2))/2;
cz = (vz(1)+vz(2))/2;
[v3, f3] = a_circle(cx, cy, cz, len*0.3, dn, ir);
[v4, f4] = a_plus(cx, cy+len/10, cz, len/5, dn, ir);
[v5, f5] = a_minus(cx, cy-len/10, cz, len/5, dn, ir, 'y');
case ('zn')
vx = 0.5*[(ix+ax) (ix+ax)]; vy = 0.5*[(iy+ay) (iy+ay)]; vz = [az iz];
len = az - iz;
ir = len/30;
[v1, f1] = a_line(vx, vy, [iz iz+0.2*len], ir);
[v2, f2] = a_line(