<?xml version = "1.0" encoding = "UTF-8"?>
<!-- style sheet OFF -->
<!--
    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    #
    # Copyright (C) 2003-2011 Open Microscopy Environment
    #       Massachusetts Institute of Technology,
    #       National Institutes of Health,
    #       University of Dundee,
    #       University of Wisconsin at Madison
    #
    # This work is licensed under the
    #       Creative Commons Attribution 3.0 Unported License.
    # To view a copy of this license, visit
    #       http://creativecommons.org/licenses/by/3.0/
    # or send a letter to
    #       Creative Commons, 444 Castro Street, Suite 900,
    #       Mountain View, California, 94041, USA.
    # For attribution instructions, visit
    #       http://www.openmicroscopy.org/info/attribution
    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-->
<!--
	#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	# Written by:  Andrew J Patterson 
	#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-->
<xsd:schema xmlns = "http://www.openmicroscopy.org/Schemas/ROI/2011-06"
	targetNamespace = "http://www.openmicroscopy.org/Schemas/ROI/2011-06"
	xmlns:OME = "http://www.openmicroscopy.org/Schemas/OME/2011-06"
	xmlns:BIN="http://www.openmicroscopy.org/Schemas/BinaryFile/2011-06" 
	xmlns:SA="http://www.openmicroscopy.org/Schemas/SA/2011-06" 
	xmlns:xsd = "http://www.w3.org/2001/XMLSchema"
	version = "1"
	elementFormDefault = "qualified">

	<xsd:import namespace="http://www.openmicroscopy.org/Schemas/OME/2011-06" schemaLocation="http://www.openmicroscopy.org/Schemas/OME/2011-06/ome.xsd"/>
	<xsd:import namespace="http://www.openmicroscopy.org/Schemas/BinaryFile/2011-06" schemaLocation="http://www.openmicroscopy.org/Schemas/BinaryFile/2011-06/BinaryFile.xsd"/>
	<xsd:import namespace="http://www.openmicroscopy.org/Schemas/SA/2011-06" schemaLocation="http://www.openmicroscopy.org/Schemas/SA/2011-06/SA.xsd"/>

	<xsd:element name="ROI"> <!-- top level definition -->
		<xsd:annotation>
			<xsd:documentation>
				A four dimensional 'Region of Interest'.
				If they are not used, and the Image has more than one plane,
				the entire set of planes is assumed to be included in the ROI.
				Multiple ROIs may be specified.
			</xsd:documentation>
		</xsd:annotation>
		<xsd:complexType>
			<xsd:sequence>
				<xsd:choice minOccurs="1" maxOccurs="1">
					<xsd:element name="Union" minOccurs="1" maxOccurs="1">
						<xsd:complexType>
							<xsd:sequence>
								<xsd:element ref="Shape" minOccurs="1" maxOccurs="unbounded"/>
							</xsd:sequence>
						</xsd:complexType>
					</xsd:element>
				</xsd:choice>
				<xsd:element ref="SA:AnnotationRef" minOccurs="0" maxOccurs="unbounded"/>
				<xsd:element name="Description" minOccurs="0" maxOccurs="1">
					<xsd:annotation>
						<xsd:documentation>
							A description for the ROI. [plane text multi-line string]
						</xsd:documentation>
					</xsd:annotation>
					<xsd:simpleType>
						<xsd:restriction base="xsd:string">
							<xsd:whiteSpace value="preserve"/>
						</xsd:restriction>
					</xsd:simpleType>
				</xsd:element>
			</xsd:sequence>
			<xsd:attribute name="ID" use="required" type="ROIID"/>
			<xsd:attribute name="Name" use="optional" type="xsd:string">
				<xsd:annotation>
					<xsd:documentation>
						The Name identifies the ROI to the user. [plane text string]
					</xsd:documentation>
				</xsd:annotation>
			</xsd:attribute>
			<xsd:attribute name="Namespace" use="optional" type="xsd:anyURI"></xsd:attribute>
		</xsd:complexType>
	</xsd:element>
	
	<xsd:element name="Shape"> <!-- top level definition -->
		<xsd:annotation>
			<xsd:appinfo>abstract-proprietary</xsd:appinfo>
			<xsd:documentation>
				The shape element contains a single specific ROI shape and links 
				that to any channels, and a timepoint and a z-section. It also 
				records any transform applied to the ROI shape.
			</xsd:documentation>
		</xsd:annotation>
		<xsd:complexType>
			<xsd:sequence>
				<xsd:choice minOccurs="1" maxOccurs="1">
					<xsd:element ref="Line" minOccurs="1" maxOccurs="1"/>
					<xsd:element ref="Rectangle" minOccurs="1" maxOccurs="1"/>
					<xsd:element ref="Mask" minOccurs="1" maxOccurs="1"/>
					<xsd:element ref="Ellipse" minOccurs="1" maxOccurs="1"/>
					<xsd:element ref="Point" minOccurs="1" maxOccurs="1"/>
					<xsd:element ref="Polyline" minOccurs="1" maxOccurs="1"/>
					<xsd:element ref="Path" minOccurs="1" maxOccurs="1"/>
					<xsd:element ref="Text" minOccurs="1" maxOccurs="1"/>
				</xsd:choice>
				<xsd:element name="Description" minOccurs="0" maxOccurs="1">
					<xsd:annotation>
						<xsd:documentation>
							A description for the ROI. [plane text multi-line string]
						</xsd:documentation>
					</xsd:annotation>
					<xsd:simpleType>
						<xsd:restriction base="xsd:string">
							<xsd:whiteSpace value="preserve"/>
						</xsd:restriction>
					</xsd:simpleType>
				</xsd:element>
			</xsd:sequence>
			<xsd:attribute name="Name" use="optional" type="xsd:string">
				<xsd:annotation>
					<xsd:documentation>
						The Name identifies the Shape to the user. [plane text string]
					</xsd:documentation>
				</xsd:annotation>		
			</xsd:attribute>
			<xsd:attribute name="Fill" use="optional" type="xsd:int">
				<xsd:annotation>
					<xsd:documentation>
						The colour of the fill - encoded as RGBA
						The value "-2147483648" is #FFFFFFFF so solid white (it is a signed 32 bit value)
					</xsd:documentation>
				</xsd:annotation>
			</xsd:attribute>
			<xsd:attribute name="FillRule" use="optional">
				<xsd:simpleType>
					<xsd:annotation>
						<xsd:documentation>
							The rule used to decide which parts of the shape to
							fill. [enumeration]
						</xsd:documentation>
					</xsd:annotation>
					<xsd:restriction base="xsd:string">
						<xsd:enumeration value="EvenOdd"/>
						<xsd:enumeration value="NonZero"/>
					</xsd:restriction>
				</xsd:simpleType>
			</xsd:attribute>
			<xsd:attribute name="Stroke" use="optional" type="xsd:int">
				<xsd:annotation>
					<xsd:documentation>
						The colour of the stroke  - encoded as RGBA
						The value "-2147483648" is #FFFFFFFF so solid white (it is a signed 32 bit value)
					</xsd:documentation>
				</xsd:annotation>
			</xsd:attribute>
			<xsd:attribute name="StrokeWidth" use="optional" type="xsd:float">
				<xsd:annotation>
					<xsd:documentation>
						The width of the stroke [units pixels]
					</xsd:documentation>
				</xsd:annotation>
			</xsd:attribute>
			<xsd:attribute name="StrokeDashArray" use="optional" type="xsd:string">
				<xsd:annotation>
					<xsd:documentation>
						e.g. "none", "10 20 30 10"
					</xsd:documentation>
				</xsd:annotation>
			</xsd:attribute>
			<xsd:attribute name="LineCap" use="optional">
				<xsd:simpleType>
					<xsd:annotation>
						<xsd:documentation>
							The shape of the end of the line. [enumeration]
						</xsd:documentation>
					</xsd:annotation>
					<xsd:restriction base="xsd:string">
						<xsd:enumeration value="Butt"/>
						<xsd:enumeration value="Line"/>
						<xsd:enumeration value="Square"/>
					</xsd:restriction>
				</xsd:simpleType>
			</xsd:attribute>
			<xsd:attribute name="MarkerStart" use="optional" type="Marker"/>
			<xsd:attribute name="MarkerEnd" use="optional" type="Marker"/>
			<xsd:attribute name="Label" use="optional" type="xsd:string"/>
			<xsd:attribute name="FontFamily" use="optional">
				<xsd:simpleType>
					<xsd:annotation>
						<xsd:documentation>
							The font family used to draw the text. [enumeration]
							Note: these values are all lower case so they match 
							the standard HTML/CSS values. "fantasy" has been
							included for completeness we do not recommended it's
							regular use.
						</xsd:documentation>
					</xsd:annotation>
					<xsd:restriction base="xsd:string">
						<xsd:enumeration value="serif"/>
						<xsd:enumeration value="sans-serif"/>
						<xsd:enumeration value="cursive"/>
						<xsd:enumeration value="fantasy"/>
						<xsd:enumeration value="monospace"/>
					</xsd:restriction>
				</xsd:simpleType>
			</xsd:attribute>
			<xsd:attribute name="FontSize" use="optional" type="OME:NonNegativeInt">
				<xsd:annotation>
					<xsd:documentation>
						Size of the font [units points]
					</xsd:documentation>
				</xsd:annotation>
			</xsd:attribute>
			<xsd:attribute name="FontStyle" use="optional">
				<xsd:simpleType>
					<xsd:annotation>
						<xsd:documentation>
							The style and weight applied to the text.  [enumeration]
							This is a simplified combination of the HTML/CSS 
							attributes font-style AND font-weight.
						</xsd:documentation>
					</xsd:annotation>
					<xsd:restriction base="xsd:string">
						<xsd:enumeration value="Bold"/>
						<xsd:enumeration value="BoldItalic"/>
						<xsd:enumeration value="Italic"/>
						<xsd:enumeration value="Normal"/>
					</xsd:restriction>
				</xsd:simpleType>
			</xsd:attribute>
			<xsd:attribute name="ID" use="required" type="ShapeID"/>
			<xsd:attribute name="TheZ" use="optional" type="OME:NonNegativeInt">
				<xsd:annotation>
					<xsd:documentation>
						The z-section the ROI applies to. If not specified then 
						the ROI applies to all the z-sections of the image. [units:none]
						This is numbered from 0.
					</xsd:documentation>
				</xsd:annotation>
			</xsd:attribute>
			<xsd:attribute name="TheT" use="optional" type="OME:NonNegativeInt">
				<xsd:annotation>
					<xsd:documentation>
						The timepoint the ROI applies to. If not specified then 
						the ROI applies to all the timepoints of the image. [units:none]
						This is numbered from 0.
					</xsd:documentation>
				</xsd:annotation>
			</xsd:attribute>
			<xsd:attribute name="TheC" use="optional" type="OME:NonNegativeInt">
				<xsd:annotation>
					<xsd:documentation>
						The channel the ROI applies to. If not specified then 
						the ROI applies to all the channels of the image. [units:none]
						This is numbered from 0.
					</xsd:documentation>
				</xsd:annotation>
			</xsd:attribute>
			<xsd:attribute name="Transform" use="optional" type="xsd:string">
				<xsd:annotation>
					<xsd:documentation>
						This is a matrix used to transform the the shape.
						It is a string of 6 numbers "a, b, c, d, e, f" that
						represent the 3 by 3 matrix.
						--       --
						| a, c, e |
						| b, d, f |
						| 0, 0, 1 |
						--       --
					</xsd:documentation>
				</xsd:annotation>
			</xsd:attribute>
		</xsd:complexType>
	</xsd:element>

	<xsd:element name="Rectangle"> <!-- top level definition -->
		<xsd:annotation>
			<xsd:documentation>
				A simple rectangle object. If rotation is required apply a 
				transformation at the Shape level.
			</xsd:documentation>
		</xsd:annotation>
		<xsd:complexType>
					<xsd:attribute name="X" use="required" type="xsd:float">
						<xsd:annotation>
							<xsd:documentation>
								The X value of the left edge or the rectangle. [units pixels]
							</xsd:documentation>
						</xsd:annotation>
					</xsd:attribute>
					<xsd:attribute name="Y" use="required" type="xsd:float">
						<xsd:annotation>
							<xsd:documentation>
								The y value of the top edge or the rectangle. [units pixels]
							</xsd:documentation>
						</xsd:annotation>
					</xsd:attribute>
					<xsd:attribute name="Width" use="required" type="xsd:float">
						<xsd:annotation>
							<xsd:documentation>
								The width of the rectangle. [units pixels]
							</xsd:documentation>
						</xsd:annotation>
					</xsd:attribute>
					<xsd:attribute name="Height" use="required" type="xsd:float">
						<xsd:annotation>
							<xsd:documentation>
								The height of the rectangle. [units pixels]
							</xsd:documentation>
						</xsd:annotation>
					</xsd:attribute>
		</xsd:complexType>
	</xsd:element>
	
	<xsd:element name="Mask"> <!-- top level definition -->
		<xsd:annotation>
			<xsd:documentation>
				The Mask ROI shape is a link to a BIN:BinData object that is 
				a BIT mask drawn on top of the image as an ROI. It is applied 
				at the same scale, pixel to pixel, as the Image the ROI is 
				applied to, unless a transform is applied at the shape level.
			</xsd:documentation>
		</xsd:annotation>
		<xsd:complexType>
			<xsd:sequence>
				<xsd:element ref="BIN:BinData" minOccurs="1" maxOccurs="unbounded"/>
			</xsd:sequence>
			<xsd:attribute name="X" use="required" type="xsd:float">
				<xsd:annotation>
					<xsd:documentation> 
						The X coordinate of the left side of the image. [units pixels]
					</xsd:documentation>
				</xsd:annotation>
			</xsd:attribute>
			<xsd:attribute name="Y" use="required" type="xsd:float">
				<xsd:annotation>
					<xsd:documentation>
						The Y coordinate of the top side of the image. [units pixels]
					</xsd:documentation>
				</xsd:annotation>
			</xsd:attribute>
			<xsd:attribute name="Width" use="required" type="xsd:float">
				<xsd:annotation>
					<xsd:documentation>
						The width of the mask. [units pixels]
					</xsd:documentation>
				</xsd:annotation>
			</xsd:attribute>
			<xsd:attribute name="Height" use="required" type="xsd:float">
				<xsd:annotation>
					<xsd:documentation> 
						The height of the mask. [units pixels]
					</xsd:documentation>
				</xsd:annotation>
			</xsd:attribute>
		</xsd:complexType>
	</xsd:element>

	<xsd:element name="Point"> <!-- top level definition -->
		<xsd:complexType>
					<xsd:attribute name="X" use="required" type="xsd:float">
						<xsd:annotation>
							<xsd:documentation>
								The X coordinate of the point. [units pixels]
							</xsd:documentation>
						</xsd:annotation>
					</xsd:attribute>
					<xsd:attribute name="Y" use="required" type="xsd:float">
						<xsd:annotation>
							<xsd:documentation>
								The Y coordinate of the point. [units pixels]
							</xsd:documentation>
						</xsd:annotation>
					</xsd:attribute>
		</xsd:complexType>
	</xsd:element>
	
	<xsd:element name="Ellipse"> <!-- top level definition -->
		<xsd:annotation>
			<xsd:documentation>
				A simple ellipse object. If rotation is required apply a 
				transformation at the Shape level.
			</xsd:documentation>
		</xsd:annotation>		
		<xsd:complexType>
					<xsd:attribute name="X" use="required" type="xsd:float">
						<xsd:annotation>
							<xsd:documentation>
								The X coordinate of the center of the ellipse. [units pixels]
							</xsd:documentation>
						</xsd:annotation>
					</xsd:attribute>
					<xsd:attribute name="Y" use="required" type="xsd:float">
						<xsd:annotation>
							<xsd:documentation>
								The Y coordinate of the center of the ellipse. [units pixels]
							</xsd:documentation>
						</xsd:annotation>
					</xsd:attribute>
					<xsd:attribute name="RadiusX" use="required" type="xsd:float">
						<xsd:annotation>
							<xsd:documentation>
								The horizontal radius of the ellipse. [units pixels]
							</xsd:documentation>
						</xsd:annotation>
					</xsd:attribute>
					<xsd:attribute name="RadiusY" use="required" type="xsd:float">
						<xsd:annotation>
							<xsd:documentation>
								The vertical radius of the ellipse. [units pixels]
							</xsd:documentation>
						</xsd:annotation>
					</xsd:attribute>
		</xsd:complexType>
	</xsd:element>
	
	<xsd:element name="Line"> <!-- top level definition -->
		<xsd:annotation>
			<xsd:documentation>
				A straight line defined by it's end points.
			</xsd:documentation>
		</xsd:annotation>
		<xsd:complexType>
					<xsd:attribute name="X1" use="required" type="xsd:float">
						<xsd:annotation>
							<xsd:documentation>
								The X coordinate of the start of the line. [units pixels]
							</xsd:documentation>
						</xsd:annotation>
					</xsd:attribute>
					<xsd:attribute name="Y1" use="required" type="xsd:float">
						<xsd:annotation>
							<xsd:documentation>
								The Y coordinate of the start of the line. [units pixels]
							</xsd:documentation>
						</xsd:annotation>
					</xsd:attribute>
					<xsd:attribute name="X2" use="required" type="xsd:float">
						<xsd:annotation>
							<xsd:documentation>
								The X coordinate of the end of the line. [units pixels]
							</xsd:documentation>
						</xsd:annotation>
					</xsd:attribute>
					<xsd:attribute name="Y2" use="required" type="xsd:float">
						<xsd:annotation>
							<xsd:documentation>
								The Y coordinate of the end of the line. [units pixels]
							</xsd:documentation>
						</xsd:annotation>
					</xsd:attribute>
		</xsd:complexType>
	</xsd:element>
	
	<xsd:element name="Polyline"> <!-- top level definition -->
		<xsd:annotation>
			<xsd:documentation>
				NOTE: Polyline and Path are DEPRECATED as they are due to be 
				replaced in the next major release to provide support for 
				3-dimensional objects. see http://www.openmicroscopy.org/site/support/file-formats/working-with-ome-xml/roi
				
				The Polyline defines open and closed shapes formed of straight 
				lines. Note: Polyline uses counterclockwise winding (this is the 
				default OpenGL behavior)
			</xsd:documentation>
		</xsd:annotation>		
		<xsd:complexType>
					<xsd:attribute name="Points" use="required" type="xsd:string">
						<xsd:annotation>
							<xsd:documentation>
								The points of the polyline are defined as a list 
								of comma separated x,y coordinates seperated by 
								spaces like "x1,y1 x2,y2 x3,y3" e.g. "0,0 1,2 3,5"
							</xsd:documentation>
						</xsd:annotation>
					</xsd:attribute>
					<xsd:attribute name="Closed" use="optional" type="xsd:boolean" default="false">
						<xsd:annotation>
							<xsd:documentation>
								Indicates if the shape is closed with an extra 
								line form the end point back to the start point. [flag]
							</xsd:documentation>
						</xsd:annotation>
					</xsd:attribute>
		</xsd:complexType>
	</xsd:element>
		
	<xsd:element name="Path"> <!-- top level definition -->
		<xsd:annotation>
			<xsd:documentation>
				NOTE: Polyline and Path are DEPRECATED as they are due to be 
				replaced in the next major release to provide support for 
				3-dimensional objects. see http://www.openmicroscopy.org/site/support/file-formats/working-with-ome-xml/roi
				
				A path is a complex shape that can consists of straight and 
				curved sections. It is defined as a collection of drawing 
				commands.
			</xsd:documentation>
		</xsd:annotation>
		<xsd:complexType>
					<xsd:attribute name="Definition" use="required" type="xsd:string">
						<xsd:annotation>
							<xsd:documentation>
								The commands are listed in the string separated by spaces.
								The following commands are available:
								
								M = moveto (absolute)
								L = lineto (absolute)
								H = horizontal lineto (absolute)
								V = vertical lineto (absolute)
								C = curveto (absolute)
								S = smooth curveto (absolute)
								Q = quadratic Bezier curve (absolute)
								T = smooth quadratic Bezier curveto (absolute)
								A = elliptical Arc (absolute)
								Z = closepath
								
								m = moveto (relative)
								l = lineto (relative)
								h = horizontal lineto (relative)
								v = vertical lineto (relative)
								c = curveto (relative)
								s = smooth curveto (relative)
								q = quadratic Bezier curve (relative)
								t = smooth quadratic Bezier curveto (relative)
								a = elliptical Arc (relative)
								z = closepath
							</xsd:documentation>
						</xsd:annotation>
					</xsd:attribute>
		</xsd:complexType>
	</xsd:element>
	
	<xsd:element name="Text"> <!-- top level definition -->
		<xsd:annotation>
			<xsd:documentation>
				The text annotation. Any transformation should be applied at the 
				shape level.
			</xsd:documentation>
		</xsd:annotation>
		<xsd:complexType>
					<xsd:sequence>
						<xsd:element name="Value">
							<xsd:annotation>
								<xsd:documentation>
									The string of characters to display. 
									White space should be preserved.
								</xsd:documentation>
							</xsd:annotation>
							<xsd:simpleType>
								<xsd:restriction base="xsd:string">
									<xsd:whiteSpace value="preserve"/>
								</xsd:restriction>
							</xsd:simpleType>
						</xsd:element>
					</xsd:sequence>
					<xsd:attribute name="X" use="required" type="xsd:float">
						<xsd:annotation>
							<xsd:documentation>
								This defines the X coordinate of the current 
								text position of the first character in the 
								string. [units pixels]
							</xsd:documentation>
						</xsd:annotation>
					</xsd:attribute>
					<xsd:attribute name="Y" use="required" type="xsd:float">
						<xsd:annotation>
							<xsd:documentation>
								This defines the X coordinate of the current 
								text position of the first character in the 
								string. [units pixels]
							</xsd:documentation>
						</xsd:annotation>
					</xsd:attribute>
		</xsd:complexType>
	</xsd:element>

	<xsd:element name="ROIRef"> <!-- top level definition -->
		<xsd:complexType>
			<xsd:complexContent>
				<xsd:extension base="OME:Reference">
					<xsd:attribute name="ID" use="required" type="ROIID"/>
				</xsd:extension>
			</xsd:complexContent>
		</xsd:complexType>
	</xsd:element>

	<xsd:simpleType name="ROIID"> <!-- top level definition -->
		<xsd:restriction base="OME:LSID">
			<xsd:pattern value="(urn:lsid:([\w\-\.]+\.[\w\-\.]+)+:ROI:\S+)|(ROI:\S+)"/>
		</xsd:restriction>
	</xsd:simpleType>
	
	<xsd:simpleType name="ShapeID"> <!-- top level definition -->
		<xsd:restriction base="OME:LSID">
			<xsd:pattern value="(urn:lsid:([\w\-\.]+\.[\w\-\.]+)+:Shape:\S+)|(Shape:\S+)"/>
		</xsd:restriction>
	</xsd:simpleType>
	
	<xsd:simpleType name="Marker"> <!-- top level definition -->
		<xsd:annotation>
			<xsd:documentation>
				Shape of marker on the end of a line. [enumeration]
			</xsd:documentation>
		</xsd:annotation>
		<xsd:restriction base="xsd:string">
			<xsd:enumeration value="Arrow"/>
			<xsd:enumeration value="Circle"/>
			<xsd:enumeration value="Square"/>
		</xsd:restriction>
	</xsd:simpleType>
	
</xsd:schema>

