#
# QCad
# (c) Q Solutions 1998
#
#
#
#
# Global Data structures
#
# Note Main edit windows will have own global array
# associated with the window.
# This data will be initialized from global arrays
#

# SC	- Schematic capture data
# PCB	- PCB Layout data
# PE	- Part editor
# GBL 	- Global to all systems
# FLOW	- Flow Chart Editor mode of the Schematic Capture
#

proc initSystemData {} {

	global GBL SCH PCB PE FLOW ColourMap Help
	array set GBL {

		File,Revision		0
		-background			#C0C0C0
		-closeenough 		5
		-cursor 			dotbox
		AppName				QSCad
		FilePath			Files
		BitmapPath			{Library /usr/local/lib/QSCad/Bitmaps ~/PartsLibrary Bitmaps .}
		LibraryPath			{Library /usr/local/lib/QSCad/Lib ~/PartsLibrary Flow .}
		SubPath				{. Base Conn Passive Micro TTL CMOS Analog Mech Misc Flow PWR Page}
		ButtonFont			{Clean 8 bold}
		Grid,Colour			Black
		Grid,DotSize 		3
		Grid,Mode			Dots
		Grid,On				1
		Grid,Size			100
		Grid,Step			50
		Grid,RelStep		50
		Grid,Type			None
		Cursor,Type			Small

		Zoom				0
		Zoom,Step			2
		Zoom,Limit			1
		Zoom,Correct		0

		Scale				1
		RelScale			1
		Scale,Step			1.5
		TieDot,Size			5
		TieDot,Filled		{Filled}

		TypeList			{Decor Outline Pad Track Anchor Pin RefDes PartRef Copper Net Connection TieDot}
		LayerList			{All Silk Top Bottom Internal}
		ScaleList				{1 2 3 4 5}
		HoleList			{0 1 6 7 8 9 10}
		WidthList			{1 2 4 8 12 12.5 13 25 50 75 100 120 150 300 500 1000}
		GridList			{Not Dots Lines Points}
		CursorList			{Small Full None}
		StepList			{200 100 50 25 12.5 10 6.25 5 3.125 2 1.5625 1 0.5}
	
		Sheet				Sheet1

		edit,RubberBand		1
		edit,Sheet			Sheet1
		edit,Gate			1
		edit,CurrentItem 	0
		edit,CurrentGate 	0
		edit,CurrentType 	Visual
		edit,CurrentName 	{}
		edit,objID			{}
		edit,objType		{}
		edit,objItem		{}
		edit,Connected		1
		edit,filled			0
		edit,Layer			All
		Mode,Create			line
		edit,Type			Outline
		def,Break			0
		edit,Break			0

		ColourMode			ByType
		Print,Mode			color
		Page,Sizes			{{A4 21 * 29.7}}
		Page,Orientation	{Landscape}
		Page,Width			{21}
		Page,Height			{29}
		Page,LeftMargin		{1}
		Page,TopMargin		{1}
		Page,Units			{c}
		Page,OList			{Landscape Portrait}
		Page,SList			{Fit 1:1 2:1 3:1 4:1 1:2 1:3 1:4}
		Page,Scale			Fit
	}

	set Display {
		Copper		SlateGrey 	{} 		0 		{Helvetica 10 normal}
		Decor		White		White	3		{Helvetica 18 normal}
		PartRef		Black		{}		1		{Helvetica 14 italic}
		RefDes		Black		Black	1		{Helvetica 14 bold}
		Text		Black		Black	1		{Helvetica 14 normal}
		TieDot		Blue		Yellow	2		{}
		Connection	Yellow		Yellow	5		{}
		Pin			White		White	3		{Helvetica 14 bold}
		Anchor		#c09000		#c09000	1		{}
		Pad			#e0e000		#e0e000	1		{Helvetic 14 bold}
		Outline		Blue		Blue	3		{Helvetica 14 normal}
		Net			White		White	1		{}
		Track		Blue		Blue	25		{}
		Via			Red			Red		13		{}

		All			White		White	1		{Helvetica 24 normal}
		Silk		White		White	2		{Helvetica 24 normal}
		Top			Red			Red		1		{Helvetica 12 normal}
		Bottom		Green		Green 	1		{Helvetica 12 normal}
		Internal	Pink		Pink	1		{Helvetica 10 normal}
		Unknown		Black		Black	2		{Helvetica 8 normal}
	}

	array set ColourMap { 
		White		{0 0 0 setrgbcolor}
	}


	foreach {type fg bg w f} $Display {
		set GBL($type,fill) $fg
		set GBL($type,outline) $bg
		set GBL($type,width) $w
		set GBL($type,font) $f
	}
	foreach l $GBL(TypeList) {
		set GBL(prn,Type,$l) 1
	}
	foreach l $GBL(LayerList) {
		set GBL(prn,Layer,$l) 1
	}

	
	array set SCH {
		Window,width		1000
		Window,height		600

		Route,fill			Black
		Route,width			12
		Route,outline		{}

		Canvas,width		4000
		Canvas,height		3000
		Connection,width	2
		Outline,width		2

		Grid,Size			100
		Grid,Step			5
		Grid,On				1
		Scale				3
		Mode,Create			Connection
	}

	array set FLOW {
		Window,width		600
		Window,height		800

		Route,fill			Black
		Route,width			12
		Route,outline		{}

		Canvas,width		4000
		Canvas,height		3000
		Connection,width	2
		Outline,width		2

		Grid,Size			100
		Grid,Step			5
		Grid,On				1
		Scale				5
		Mode,Create			Connection
	}

	array set PCB {
		-background			Black
		Window,width		800
		Window,height		600
		Grid,Colour			White
		ColourMode			ByLayer
		Unknown,fill		White
		Unknown,outline		White
		Unknown,width		2	
		Unknown,font		{Helvetica 50 normal}

		Canvas,width		1200
		Canvas,height		800

		edit,CurrentType 	Decal
		Mode,Create			Net
		edit,Type			Net
		edit,Layer			Bottom


		Scale				1
		Scale,Step			2
		Grid,RelStep		25
		Page,Scale			1:1
	}

	array set PE {
		Window,width		400
		Window,height		600
		-closeenough 		2
		Canvas,width		16000
		Canvas,height		14000
		Grid,Size			50
		Grid,Step			25
		Grid,On				1
		Grid,DotSize		0.5
		Scale				1

		Part,Revision		0
		Part,Gates	 		{}
		Part,GatePins		{}
		Part,Scale			128
		Part,Decals			{}
	}
	defaultBindings
	catch {uplevel #0 {unset Help} }
	global Help
	set file [fileFind $GBL(LibraryPath) $GBL(AppName) .hlp]
	if {  [file exists $file] } {  
		set f [open $file r]
		array set Help [read $f]
		close $f
	}
}




