
# IPCB_ComponentPainterView interface

A preview panel that displays a single PCB component (footprint) in 2D or 3D.

```csharp
public interface IPCB_ComponentPainterView
```

**Namespace:** PCB · **Assembly:** Altium.SDK.Interfaces

## Remarks

[`IPCB_ServerInterface.CreateComponentPainter`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_ServerInterface.md#createcomponentpainter) creates a new preview. The preview draws the component on a board of its own ([`GetDummyBoard`](#getdummyboard)), not on an open PCB document.

The preview uses one of two views. The DirectX view shows the component in 3D (or in 2D after [`SetDirectXMode`](#setdirectxmode)); it is used only when DirectX can be used. Otherwise the preview uses a standard 2D view. A button on the panel lets the user switch between 2D and 3D.

[`SetCamera`](#setcamera), [`SetCameraAngle`](#setcameraangle), [`SetViewRect`](#setviewrect), [`SetVisibleLayer`](#setvisiblelayer), [`SetAllLayersVisibilityState`](#setalllayersvisibilitystate), [`KeyDown`](#keydown), [`RefreshView`](#refreshview) and [`ClearGraphicalObjects`](#cleargraphicalobjects) act on the DirectX view only and do nothing in the standard 2D view. [`SetVariantOption`](#setvariantoption) acts on the standard 2D view only.

## Methods

| Method | Returns | Description |
| --- | --- | --- |
| [ClearGraphicalObjects](#cleargraphicalobjects) | `void` | Removes all graphical objects from the DirectX view of the preview. |
| [ConfigView](#configview) | `void` | Configures the preview from a string of named parameters. |
| [GetDummyBoard](#getdummyboard) | [IPCB_Board](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Board.md) | Returns the board on which the preview places the component it displays. |
| [KeyDown](#keydown) | `void` | Passes a key press to the DirectX view of the preview, so that a host form can forward keyboard input to it. |
| [RefreshView](#refreshview) | `void` | Redraws the DirectX view of the preview. |
| [SetAllLayersVisibilityState](#setalllayersvisibilitystate) | `void` | Shows or hides all layers in the DirectX view of the preview. |
| [SetCamera](#setcamera) | `void` | Aims the camera of the DirectX view at a rectangle of the preview's board. |
| [SetCameraAngle](#setcameraangle) | `void` | Sets the camera of the DirectX view from a point to look at, a rotation and a zoom factor. |
| [SetComponentByHandle](#setcomponentbyhandle) | `void` | Displays a placed component in the preview. |
| [SetComponentByHandle_1](#setcomponentbyhandle_1) | `void` | Displays a library component (footprint) in the preview. |
| [SetComponentByPath](#setcomponentbypath) | `void` | Loads a footprint from a library file and displays it in the preview. |
| [SetDirectXMode](#setdirectxmode) | `void` | Switches the preview to the DirectX view in 2D. |
| [SetVariantOption](#setvariantoption) | `void` | Applies a variant option to the component displayed in the standard 2D view. |
| [SetViewRect](#setviewrect) | `void` | Centers the DirectX view of the preview on a rectangle of the preview's board and resets the camera rotation. |
| [SetVisibleLayer](#setvisiblelayer) | `void` | Shows or hides a layer in the DirectX view of the preview. |

### ClearGraphicalObjects

Removes all graphical objects from the DirectX view of the preview.

```csharp
void ClearGraphicalObjects();
```

**Returns:** nothing (`void`)

### ConfigView

Configures the preview from a string of named parameters.

```csharp
void ConfigView(string argParameters);
```

| Parameter | Type | Passing | Description |
| --- | --- | --- | --- |
| `argParameters` | `string` | value | The parameters, as name and value pairs. |

**Returns:** nothing (`void`)

`2DOnly=True` switches the preview to the standard 2D view and hides the 2D/3D button; `3DOnly=True` switches it to the DirectX view, when DirectX can be used, and hides the button. A value of `False` shows the button again without switching. When `2DOnly` is given, `3DOnly` is ignored. In the DirectX view, `CameraYaw`, `CameraPitch` and `CameraRoll` set the camera rotation, in degrees; angles that are not given keep their current values.

### GetDummyBoard

Returns the board on which the preview places the component it displays.

```csharp
IPCB_Board GetDummyBoard();
```

**Returns:** [IPCB_Board](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Board.md)

Extension method of `IPCB_ComponentPainterViewHelper` (`using PCB;`).

The board belongs to the preview; it is not an open PCB document.

### KeyDown

Passes a key press to the DirectX view of the preview, so that a host form can forward keyboard input to it.

```csharp
void KeyDown(ref ushort argKey, TShiftStateSet argShift);
void KeyDown(ref ushort argKey, ITransportSet argShift);
```

| Parameter | Type | Passing | Description |
| --- | --- | --- | --- |
| `argKey` | `ushort` | ref | The key that was pressed; the preview can change it. |
| `argShift` | [TShiftStateSet](https://altiumdeveloper.github.io/ad-sdk-docs/reference/dxp/TShiftStateSet.md) | value | The state of the modifier keys. |

**Returns:** nothing (`void`)

The first overload is an extension method of `IPCB_ComponentPainterViewHelper` (`using PCB;`) with typed parameters; the second is declared by the interface.

### RefreshView

Redraws the DirectX view of the preview.

```csharp
void RefreshView();
```

**Returns:** nothing (`void`)

### SetAllLayersVisibilityState

Shows or hides all layers in the DirectX view of the preview.

```csharp
void SetAllLayersVisibilityState(bool argVisible);
```

| Parameter | Type | Passing | Description |
| --- | --- | --- | --- |
| `argVisible` | `bool` | value | True to show all layers, false to hide them. |

**Returns:** nothing (`void`)

### SetCamera

Aims the camera of the DirectX view at a rectangle of the preview's board.

```csharp
void SetCamera(int argLowX, int argLowY, int argHighX, int argHighY);
```

| Parameter | Type | Passing | Description |
| --- | --- | --- | --- |
| `argLowX` | `int` | value | The left edge of the rectangle, in internal units (10,000 per mil). |
| `argLowY` | `int` | value | The bottom edge of the rectangle, in internal units (10,000 per mil). |
| `argHighX` | `int` | value | The right edge of the rectangle, in internal units (10,000 per mil). |
| `argHighY` | `int` | value | The top edge of the rectangle, in internal units (10,000 per mil). |

**Returns:** nothing (`void`)

### SetCameraAngle

Sets the camera of the DirectX view from a point to look at, a rotation and a zoom factor.

```csharp
void SetCameraAngle(double argLookAtX, double argLookAtY, double argLookAtZ, double argRotationX, double argRotationY, double argRotationZ, double argRotationW, double argZoomMultiplier);
```

| Parameter | Type | Passing | Description |
| --- | --- | --- | --- |
| `argLookAtX` | `double` | value | The X coordinate of the point the camera looks at. |
| `argLookAtY` | `double` | value | The Y coordinate of the point the camera looks at. |
| `argLookAtZ` | `double` | value | The Z coordinate of the point the camera looks at. |
| `argRotationX` | `double` | value | The X component of the camera rotation, a quaternion. |
| `argRotationY` | `double` | value | The Y component of the camera rotation, a quaternion. |
| `argRotationZ` | `double` | value | The Z component of the camera rotation, a quaternion. |
| `argRotationW` | `double` | value | The W component of the camera rotation, a quaternion. |
| `argZoomMultiplier` | `double` | value | The zoom factor. |

**Returns:** nothing (`void`)

### SetComponentByHandle

Displays a placed component in the preview.

```csharp
void SetComponentByHandle(IPCB_Component argComponent);
void SetComponentByHandle(object argComponent);
```

| Parameter | Type | Passing | Description |
| --- | --- | --- | --- |
| `argComponent` | [IPCB_Component](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Component.md) | value | The component to display. |

**Returns:** nothing (`void`)

The first overload is an extension method of `IPCB_ComponentPainterViewHelper` (`using PCB;`) with typed parameters; the second is declared by the interface.

The preview displays copies of the component's primitives and of its designator, placed on the preview's own board; the component itself is not changed. The copies replace the component displayed before.

### SetComponentByHandle_1

Displays a library component (footprint) in the preview.

```csharp
void SetComponentByHandle_1(IPCB_LibComponent argComponent);
void SetComponentByHandle_1(object argComponent);
```

| Parameter | Type | Passing | Description |
| --- | --- | --- | --- |
| `argComponent` | [IPCB_LibComponent](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LibComponent.md) | value | The footprint to display. |

**Returns:** nothing (`void`)

The first overload is an extension method of `IPCB_ComponentPainterViewHelper` (`using PCB;`) with typed parameters; the second is declared by the interface.

The preview displays a copy of the footprint, which replaces the component displayed before; the footprint itself is not changed. Passing null does nothing.

### SetComponentByPath

Loads a footprint from a library file and displays it in the preview.

```csharp
void SetComponentByPath(string argPattern, string argLibraryPath);
```

| Parameter | Type | Passing | Description |
| --- | --- | --- | --- |
| `argPattern` | `string` | value | The name of the footprint in the library. |
| `argLibraryPath` | `string` | value | The path of the library file that contains the footprint. |

**Returns:** nothing (`void`)

The footprint replaces the component displayed before.

### SetDirectXMode

Switches the preview to the DirectX view in 2D.

```csharp
void SetDirectXMode();
```

**Returns:** nothing (`void`)

The preview recreates its view and hides and disables the 2D/3D button. When DirectX cannot be used, the preview keeps the standard 2D view.

### SetVariantOption

Applies a variant option to the component displayed in the standard 2D view.

```csharp
void SetVariantOption(IVariantOption argVariantOption);
void SetVariantOption(object argVariantOption);
```

| Parameter | Type | Passing | Description |
| --- | --- | --- | --- |
| `argVariantOption` | [IVariantOption](https://altiumdeveloper.github.io/ad-sdk-docs/reference/edp/IVariantOption.md) | value | The variant option to apply. |

**Returns:** nothing (`void`)

The first overload is an extension method of `IPCB_ComponentPainterViewHelper` (`using PCB;`) with typed parameters; the second is declared by the interface.

The standard 2D view draws the component with the variant option's PCB display settings, such as the struck-through designator, the cross or mesh graphics and the variant text. The DirectX view ignores the variant option.

### SetViewRect

Centers the DirectX view of the preview on a rectangle of the preview's board and resets the camera rotation.

```csharp
void SetViewRect(int argLowX, int argLowY, int argHighX, int argHighY);
```

| Parameter | Type | Passing | Description |
| --- | --- | --- | --- |
| `argLowX` | `int` | value | The left edge of the rectangle, in internal units (10,000 per mil). |
| `argLowY` | `int` | value | The bottom edge of the rectangle, in internal units (10,000 per mil). |
| `argHighX` | `int` | value | The right edge of the rectangle, in internal units (10,000 per mil). |
| `argHighY` | `int` | value | The top edge of the rectangle, in internal units (10,000 per mil). |

**Returns:** nothing (`void`)

### SetVisibleLayer

Shows or hides a layer in the DirectX view of the preview.

```csharp
void SetVisibleLayer(V7_LayerBase argLayer, bool argbState);
void SetVisibleLayer(IV7_Layer argLayer, bool argbState);
```

| Parameter | Type | Passing | Description |
| --- | --- | --- | --- |
| `argLayer` | [V7_LayerBase](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/V7_LayerBase.md) | value | The layer. |
| `argbState` | `bool` | value | True to show the layer, false to hide it. |

**Returns:** nothing (`void`)

The first overload is an extension method of `IPCB_ComponentPainterViewHelper` (`using PCB;`) with typed parameters; the second is declared by the interface.

## Returned by

[IPCB_ServerInterface.CreateComponentPainter](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_ServerInterface.md#createcomponentpainter)
