#VRML V2.0 utf8								
# Data set view for use in 3D model-view-controller group 
# Kurt A. Fisher fisherka@csolutions.net  beginner level VRML coder
# 12/2003

# Controls scaling and on/off toggle to show a dataset of plotted objects
#  Use with: 
#       Model-Data -  SO_proto.wrl 			# model
#       Dataset_view_proto.wrl			# data view controller - this file 
#       Controller     -   Controller_proto.wrl   		# coordinates display of data and axes 
#                               	-   Axes_ctrl_proto.wrl		# axes object  

PROTO DATA_SET [ 
	exposedField MFString	dataName		[ "Dataset 1" ]			# data object name 
	exposedField SFInt32	showData 		0				# 0=yes show dataset; 1=do not display dataset
	exposedField SFVec3f	scaleDataObjects 	1.000 1.000 1.000		#  change the scale of the objects in the world 
	exposedField MFString	dataURL			[ "data_Data_blank.wrl" ]			# path and filename of object data file to plot 
] {

# Syntax - startup file for dataURL should be "data_Data_blank.wrl" for CosmoPlayer compatability 

# BEGIN PLOT OBJECTS 
# Two-fold rotation of world to normal galactic presentation - looking down postive polar x axis x=0 deg to -x axis x=180 deg
DEF firstWorldRotationX Transform { 
	rotation 1.0 0.0 0.0 -1.571 # first rotation of world around x-axis
	children [

DEF secondWorldRotationZ Transform { 
	rotation 0.0 0.0 1.0 -1.571 # second rotation of world around z-axis
	children [

# OnOff Toggle Show Data 
Switch { 
	whichChoice IS showData
	choice [ 

		Group { 
			children [ 

# Plot the data version 0: show the data 
DEF Plot_objects Transform  {
	translation 	0.00 0.00 0.00
#  CHANGE SCALE OF PLOTTED OBJECTS IN THIS LINE  
	scale 		IS scaleDataObjects 
	children [ 
		DEF PlotObjects_Inline Inline { 
#  Path and filename to data objects is reset in script 
#  Syntax - this statement is retained to provide CosmoPlayer compatability 
			url IS dataURL
		} 
	] # end children
} # end Transform Group Plot_objects 
# END PLOTTED OBJECTS 

	] # end children secondWorldRotationZ - around Z axis 
} # end Transform firstWorldRotationZ around Z axis 

	] # end children firstWorldRotationX - around X axis 
} # end Transform firstWorldRotationX around X axis 

			] # children
		} # end Group Show the data 

# Plot the data version 0: show the data 
#  NULL OPTION GROUP - NO OBJECT
	# version 5: Null group  
		Group { 
			children [ ] # children
		} # end Group do not show the data Null group 

	] # end choice
} # end Switch 


# BEGIN PASS DATA FROM EXPOSED FIELDS IN PROTOTYPE TO OBJECT INSTANCE 
DEF tmp_dataFilename Text { string IS dataURL }

#  BEGIN BEHAVIORS OF OBJECT

#  INITIALIZATION SCRIPT 
DEF get_Initialize Script {
#   Pass object variables as input variables for these functions  
field SFNode LabelNode USE tmp_dataFilename 			# label array string
directOutput TRUE
  url [ 
	"javascript:
	 function initialize (  ) {

//  Note all arrays received from VRML are 0 based, while ECMA javascript arrays are 1 based

//  Syntax -  initialize variable for CosmoPlayer compatability - Cosmo wants array hard-initialized 
string_changed = new MFString() 

//           Set url string 
		string_changed[0] = LabelNode.string[0] ;

	  }"
      ] # end url 
#  Make events for function output 
eventOut MFString string_changed                     # label string
 } # end Script 
# Route function results back to object 
ROUTE get_Initialize.string_changed TO PlotObjects_Inline.set_url                                           # set the label string 
# End routers initialization script 

}  # END OF DATA_SET PROTOTYPE 

