include <dimensions.scad>
use <case.scad>
use <bottom.scad>
use <slider.scad>
use <side.scad>
use <middle.scad>
use <back.scad>
use <divider.scad>
use <bottom_strengthening.scad>

module case_slider(){
	angle = asin(slidelift/slidelength);
//echo("#### ANGLE ", angle);
	translate([0, 0, caseheight-lidheight-slideheight]) {
		rotate([-angle, 0, 0]) {
			slider();
		}
	}

	translate([slidethick + play/2, 0, 0]) {
		rotate([-angle, 0, 0]) {
			case();
		}
	}

	translate([casewidth+slidethick+play, 0, caseheight-lidheight-slideheight]) {
		rotate([-angle, 0, 0]) {
			slider();
		}
	}
}

// bottom
translate([0, 0, -plythick]) {
	bottom();
}

// left side
side();

// right side
translate([casespace+plythick, 0, 0]) {
	side();
}

// front case drawers
for (i=[0:4]) {
	translate([plythick, casedepth, 10+110*i]) {
		case_slider();
	}
}

// top
translate([0, 0, sideheight]) {
	bottom();
}

// back for front cases / middle divider
translate([plythick, casedepth, 0]) {
	middle();
}

// back for assembly
translate([0, casedepth + plythick + casespace, 0]) {
	back();
}

// back for side cases / divider
translate([bottomwidth-fullcasedepth-plythick, casedepth+plythick, 0]) {
	divider();
}

// side case drawers
translate([bottomwidth-handledepth, casedepth+plythick, 0]) {
	rotate([0, 0, 90]) {
		for (i=[0:4]) {
			translate([0, casedepth, 10+110*i]) {
				case_slider();
			}
		}
	}
}

// bottom strengthening for wheels
translate([0, 0, - plythick*2]) {
	bottom_strengthening();
}

//echo("#### shelf usefulness? ", bottomwidth - fullcasedepth - plythick);

// wielen zijn 73
echo("#### Total height: ", sideheight + plythick*3 + 73);
