"""
This is a demonstration file to explain how to
use a macro.

#. Go to *Tools/Macro Player* to start the Macro Player;
#. Select the macro *DemoMacroCreateDatasetAndROI*;
#. Execute the macro.

:author: ORS Team
:contact: http://theobjects.com
:email: info@theobjects.com
:organization: Object Research Systems (ORS), Inc.
:address: 760 St-Paul West, suite 101, Montréal, Québec, Canada, H3C 1M4
:copyright: Object Research Systems (ORS), Inc. All rights reserved 2020.
:date: Sep 29 2017 09:46
:dragonflyVersion: 3.1.0.307 (D)
:UUID: 45ecd7b1a51c11e78db5448a5b5d70c0
"""

__version__ = '1.0.0'

# Action log Fri Sep 29 09:50:12 2017

# Macro name: DemoMacroCreateDatasetAndROI

# ********** BEGIN MACRO ********** #
"""
Initialization of a dataset

:name: Create an empty Channel
:execution: execute

:param title: title of the dataset
:type title: str
:param dataType: data type. 0: unsigned byte; 2: unsigned short; 4: unsigned int; 6: float.
:type dataType: int
:param sizeX: X size
:type sizeX: int
:param sizeY: Y size
:type sizeY: int
:param sizeZ: Z size
:type sizeZ: int
:param sizeT: T size
:type sizeT: int
:param spacingX: X spacing (in meters)
:type spacingX: float
:param spacingY: Y spacing (in meters)
:type spacingY: float
:param spacingZ: Z spacing (in meters)
:type spacingZ: float
:param offset: 
:type offset: float
:param slope: 
:type slope: float
:param addNoise: if True, noise will be added
:type addNoise: bool
:param gaussian: if True, the added noise will have a gaussian distribution
:type gaussian: bool
:param noiseStdDev: noise standard deviation
:type noiseStdDev: float
:param noiseRatio: ratio of noise
:type noiseRatio: float
:param initValue: initial value put in each voxel
:type initValue: float
:param progress: id of a progress object
:type progress: str

:return output: Created dataset
:rtype output: ORSModel.ors.Channel
:rcount output: 1
"""

# ----- BEGIN INPUT ARGUMENT DEFINITION ----- #
title = 'aChannel'

dataType = 0

sizeX = 100

sizeY = 100

sizeZ = 5

sizeT = 1

spacingX = 1e-06

spacingY = 1e-06

spacingZ = 1e-06

offset = 0.0

slope = 1.0

addNoise = False

gaussian = False

noiseStdDev = 100.0

noiseRatio = 0.5

initValue = 0.0

progress = '645930729863071452CxvProgress'

# ----- END INPUT ARGUMENT DEFINITION ----- #
# Interface method
output = OrsQtEmptyLoader.createChannel(title=title,
                                        dataType=dataType,
                                        sizeX=sizeX,
                                        sizeY=sizeY,
                                        sizeZ=sizeZ,
                                        sizeT=sizeT,
                                        spacingX=spacingX,
                                        spacingY=spacingY,
                                        spacingZ=spacingZ,
                                        offset=offset,
                                        slope=slope,
                                        addNoise=addNoise,
                                        gaussian=gaussian,
                                        noiseStdDev=noiseStdDev,
                                        noiseRatio=noiseRatio,
                                        initValue=initValue,
                                        progress=progress)

# ----- BEGIN RETURNED VALUES DEFINITION ----- #
# output = orsObj('6459307294815751CxvChannel')

# ----- END RETURNED VALUES DEFINITION ----- #
# ********** END MACRO ********** #

# ********** BEGIN MACRO ********** #
"""
Publish the dataset.

:name: Publish the dataset
:execution: execute

:param output: an object
:type output: ORSModel.ors.Managed
"""

# Interface method
ManagedHelper.publish(anObject=output)

# ********** END MACRO ********** #

# ********** BEGIN MACRO ********** #
"""
Initialization of a ROI from the shape of a dataset

:name: Create an empty ROI
:execution: execute

:param output: reference shape of the new ROI
:type output: ORSModel.ors.StructuredGrid
:param title_2: title of the new ROI
:type title_2: str
:param ROIColor: color of the new ROI
:type ROIColor: ORSModel.ors.Color

:return output_2: created ROI
:rtype output_2: ORSModel.ors.ROI
"""

# ----- BEGIN INPUT ARGUMENT DEFINITION ----- #
title_2 = 'aROI'

ROIColor = orsColor(0.16470588235294117, 0.21568627450980393, 0.9098039215686274, 1.0)

# ----- END INPUT ARGUMENT DEFINITION ----- #
# Interface method
output_2 = OrsVolumeROITools.createEmptyROIFromStructuredGrid(structuredGrid=output,
                                                              title=title_2,
                                                              ROIColor=ROIColor)

# ----- BEGIN RETURNED VALUES DEFINITION ----- #
# output_2 = orsObj('130960729447901312CxvVolume_ROI')

# ----- END RETURNED VALUES DEFINITION ----- #
# ********** END MACRO ********** #

# ********** BEGIN MACRO ********** #
"""
Publish the ROI.

:name: Publish the ROI
:execution: execute

:param output_2: an object
:type output_2: ORSModel.ors.Managed
"""

# Interface method
ManagedHelper.publish(anObject=output_2)

# ********** END MACRO ********** #

# ********** BEGIN MACRO ********** #
"""
Painting a big circle in the ROI

:name: Draw outer circle
:execution: execute

:param output_2: the ROI to paint
:type output_2: ORSModel.ors.ROI
:param boundedPlane_9: the drawing bounded plane
:type boundedPlane_9: ORSModel.ors.Rectangle
:param worldPos_9: the world position of the voxel at the center of the circle
:type worldPos_9: ORSModel.ors.Vector3
:param brushSize_9: the brush radius size in world coordinate
:type brushSize_9: float
:param t_9: the time step index of the ROI
:type t_9: int
:param remove_9: indicating whether the voxel index should be added or removed from the ROI
:type remove_9: bool
"""

# ----- BEGIN INPUT ARGUMENT DEFINITION ----- #
boundedPlane_9 = orsRect(orsVect(-2.5644388148704157e-05, -1.8095275327870483e-06, 2e-06), orsVect(1.0, 0.0, 0.0), 0.00015017136319092595, 1.173213774929109e-07, orsVect(0.0, 1.0, 0.0), 0.00010273646817205645, 1.172790732557722e-07)

worldPos_9 = orsVect(5.167039961912413e-05, 4.779952045440459e-05, 2e-06)

brushSize_9 = 3.628966856076736e-05

t_9 = 0

remove_9 = False

# ----- END INPUT ARGUMENT DEFINITION ----- #
# Interface method
OrsVolumeROIPainter.drawCircle(aROI=output_2,
                               boundedPlane=boundedPlane_9,
                               worldPos=worldPos_9,
                               brushSize=brushSize_9,
                               t=t_9,
                               remove=remove_9)

# ********** END MACRO ********** #

# ********** BEGIN MACRO ********** #
"""
Erasing the middle potion of the circle

:name: Remove middle portion of the circle
:execution: execute

:param output_2: the ROI to paint
:type output_2: ORSModel.ors.ROI
:param boundedPlane_11: the drawing bounded plane
:type boundedPlane_11: ORSModel.ors.Rectangle
:param worldPos_11: the world position of the voxel at the center of the circle
:type worldPos_11: ORSModel.ors.Vector3
:param brushSize_11: the brush radius size in world coordinate
:type brushSize_11: float
:param t_11: the time step index of the ROI
:type t_11: int
:param remove_11: indicating whether the voxel index should be added or removed from the ROI
:type remove_11: bool
"""

# ----- BEGIN INPUT ARGUMENT DEFINITION ----- #
boundedPlane_11 = orsRect(orsVect(-2.5644388148704157e-05, -1.8095275327870483e-06, 2e-06), orsVect(1.0, 0.0, 0.0), 0.00015017136319092595, 1.173213774929109e-07, orsVect(0.0, 1.0, 0.0), 0.00010273646817205645, 1.172790732557722e-07)

worldPos_11 = orsVect(5.577664783137601e-05, 4.9206869333473856e-05, 2e-06)

brushSize_11 = 2.645516838079941e-05

t_11 = 0

remove_11 = True

# ----- END INPUT ARGUMENT DEFINITION ----- #
# Interface method
OrsVolumeROIPainter.drawCircle(aROI=output_2,
                               boundedPlane=boundedPlane_11,
                               worldPos=worldPos_11,
                               brushSize=brushSize_11,
                               t=t_11,
                               remove=remove_11)

# ********** END MACRO ********** #

