/**
 * Track object. Represents a track on the Mars surface.
 * A track is identified by a name and a path (a set of connected lines).
 */
function Track_setName(name) {
	this.name=name;
}

function Track_getName(name) {
	return this.name;
}

/**
 * Stores a new line (first point)
 */
function Track_startLine(p) {
	this.lines.push(new Line(p,p));
	
}

/**
 * Terminates current line.
 */
function Track_endLine(p) {
	var line=this.lines[this.lines.length-1];
	line.p2=p;
	return line;

}

/**
 * Terminates current line.
 */
function Track_removeLastLine(p) {
	if(this.lines.length>0)
		this.lines.pop();
}

function Track_initProfile(allprofile) {
	this.profile=new Profile(allprofile);
	Martian.slider.setMaximum(this.profile.getWalkLength()-1);
}

function Track_initMartian(mode) {
	this.martian=new Martian(mode,this,this.objName+'.martian');
}


function Track(name,lines,objName) {
	this.objName=objName;
	this.profile=null;
	this.martian=null;
	this.name=name;
	if(lines)
		this.lines=lines;
	else
		this.lines=new Array();
}

Track.prototype.setName=Track_setName;
Track.prototype.getName=Track_getName;
Track.prototype.startLine=Track_startLine;
Track.prototype.endLine=Track_endLine;
Track.prototype.removeLastLine=Track_removeLastLine;
Track.prototype.initProfile=Track_initProfile;
Track.prototype.initMartian=Track_initMartian;
