package rec.simulate.widgets.wm;

import java.util.*;
import java.awt.*;
import rec.util.*;
import rec.sys.*;
import rec.core.widgets.*;
import rec.geo.*;
import rec.simulate.*;
import rec.simulate.widgets.*;

public class WMSimGearTrain extends WSimGearTrain
{
    public WMSimGearTrain(WSimGear[] gears, WSimGearTrain[] trains, 
			  WSimGear newGear, boolean singleCircles){
	super (gears,trains,newGear,singleCircles);
    }
    
    public String load(WMSimulatorRegistryBase reg){
	String output = "";

	for (int i = 0; i < numGears(); i++){
	    for(int j = 0; j < m_gearMeshes[i].length; j++){

		if(m_gearMeshes[i][j] > i){

		    String gearName = "Gear" + getId() + "X" + i + "X" + j;
		    
		    output += "Dim " + gearName + " as WMConstraint\n";
		    
		    output += "Set " + gearName 
			+ " = doc.NewConstraint(\"gear\")\n";
		    
		    GPoint center1 = reg.convert( m_gears[i].getCenter() );
		    GPoint center2 = reg.convert(m_gears[m_gearMeshes[i][j]]
						 .getCenter() );

		    output += "Set "+ gearName + ".Point(1).Body = " 
			+ m_gears[i].getName() + "\n";
		    output += "Set "+ gearName + ".Point(2).Body = " 
			+ m_gears[m_gearMeshes[i][j]].getName() + "\n";
		}
	    }
	}
		
	return output;
    }
}
