Eyeon:Script/Reference/Applications/Fuse/Classes/Input/RectangleControl

From VFXPedia

Jump to: navigation, search

Contents


RectangleControl

Description

The RectangleControl is an inscreen preview control which displays a simple rectangle. The RectangleControl is added to an Input by adding the INPID_PreviewControl attribute to the AddInput function's attribute table.


If you use the RCD_LockAspect attribute below, then the width and height are both determined by the same input, and no PC_ControlGroup is needed. Otherwise, a seperate input is needed for both the width and height Both inputs should use the same PC_ControlGroup attribute. The input with the attribute PC_ControlID = 0 will determine the width, and the one with PC_ControlID = 1 will determine the height of the Rectangle. Both inputs should have the INPID_PreviewControl set to "RectangleControl".

A slider set to PC_ControlID = 2 can optionally be used to determine the radius of the corners.


Attributes

RCP_Center input: specifies which input is used to set the position of the rectangle control. Typically this is an OffsetControl
RCP_Angle input : specifies which input is used to set the angle of the rectangle control. Typically this will be a ScrewControl.
RCD_LockAspect numeric : If this attribute is set to 1.0 the rectangle control will use the same value for the width and height.
RCD_SetX numeric : A numeric value used to set the position of the rectangle on the X axis.
RCD_SetY numeric : A numeric value used to set the position of the rectangle on the Y axis.


.


Example

The Create function below shows a rectangle control associated with seperate width, height and radius sliders

function Create()
	InCenter = self:AddInput("Center", "Center", {
		LINKID_DataType = "Point",
		INPID_InputControl = "OffsetControl",
		INPID_PreviewControl = "CrosshairControl",
		})
	
	InWidth = self:AddInput("Width", "Width", {
		LINKID_DataType = "Number",
		INPID_InputControl = "SliderControl",
		INPID_PreviewControl = "RectangleControl",
		PC_ControlGroup = 1.0,
		PC_ControlID = 0,
		INP_MaxScale = 2,
		INP_Default = 1.0,
		})
	
	InHeight = self:AddInput("Height", "Height", {
		LINKID_DataType = "Number",
		INPID_InputControl = "SliderControl",
		INPID_PreviewControl = "RectangleControl",
		PC_ControlGroup = 1.0,
		PC_ControlID = 1,
		INP_MaxScale = 2,
		INP_Default = 1.0,
		})
	
	InRadius = self:AddInput("Corner Radius", "CornerRadius", {
		LINKID_DataType = "Number",
		INPID_InputControl = "SliderControl",
		INPID_PreviewControl = "RectangleControl",
		PC_ControlGroup = 1.0,
		PC_ControlID = 2,
		INP_MaxScale = 0.2,
		INP_Default = 0.0,
		})
 
	InAngle = self:AddInput("Angle", "Angle", {
		LINKID_DataType = "Number",
		INPID_InputControl = "ScrewControl",
		INPID_PreviewControl = "AngleControl",
		INP_MinScale =   0.0,
		INP_MaxScale = 360.0,
		INP_Default = 0.0,
		ACP_Center = InCenter,
		})
 
	InWidth:SetAttrs({
		RCP_Center = InCenter,
		RCP_Angle = InAngle,
		})	
	
	InImage = self:AddInput("Input", "Input", {
		LINKID_DataType = "Image",
		LINK_Main = 1,
		})
 
	OutImage = self:AddOutput("Output", "Output", {
		LINKID_DataType = "Image",
		LINK_Main = 1,
		})				
		
end


Tips for RectangleControl (edit)

In addition to RCP_Center and RCP_Angle there is also RCP_Axis which needs to point to the input control that defines the center of rotation for the rectangular overlay. In many standard tools, this is an OffsetControl labeled "Pivot".

The transform fuse example that ships with Fusion doesn't completely recreate the rectangle overlay of the regular transform tool. By using RCP_Angle and RCP_Axis, the overlay is transformed correctly. However, the preview controls for angle and pivot don't move along with the rectangle. This needs to be implemented manually:

  • Turn on INP_DoNotifyChanged for the input control that is linked to RCP_Center.
  • In the NotifyChanged event handler, set two attributes for both your angle and pivot preview controls (i.e. the inputs linked to RCP_Angle and RCP_Axis): PCD_OffsetX and PCD_OffsetY will shift the preview controls in the viewer and need to be updated with the current position of the center control (minus 0.5 to account for it's default resting position in the middle of the image).

If you want to use separate sliders for X and Y size, keep in mind that PC_Visible (to show/hide the preview widget) also has to be set for both inputs. Otherwise you'll only hide the width or height part of your preview control.