# Complex Measurement (Legacy)

This code snippet shows how to trigger the measurement of a whole gauge hierarchy and retrieve the results using the legacy EasyGauge API.

## C++

```cpp
#include <eVision/EasyGauge/Legacy/ERectangleGauge.h>
```

```cpp
using namespace eVision;
using namespace eVision::Legacy;
// Image constructor
EImageBW8 srcImage;
// EWorldShape constructor
EWorldShape worldShape;
// Load the EWorldShape together with its daughters
worldShape.Load("myWorldShape.gge", true);
// Retrieve the number of worldShape's daughters
int numDaughters = worldShape.GetNumDaughters();
// ...
// Trigger the measurement of all the
// gauges attached to the EWorldShape
worldShape.Process(&srcImage, true);
// Retrieve the measurement result of
// the first daughter (a rectangle gauge)
Legacy::ERectangleGauge* rectangleGauge = (Legacy::ERectangleGauge*)worldShape.GetDaughter(0);
float sizeX = rectangleGauge->GetMeasuredRectangle().GetSizeX();
// Retrieve the measurement result of a
// daughter gauge called "myCircleGauge1"
Legacy::ECircleGauge* circleGauge = (Legacy::ECircleGauge*)worldShape.GetShapeNamed("myCircleGauge1");
EPoint center = circleGauge->GetMeasuredCircle().GetCenter();
```

## C#

```cs
using eVision;
using Legacy = eVision.Legacy;
```

```cs
// Image constructor
EImageBW8 srcImage = new EImageBW8();
// EWorldShape constructor
Legacy.EWorldShape worldShape = new Legacy.EWorldShape();
// Load the EWorldShape together with its daughters
worldShape.Load("myWorldShape.gge", true);
// Retrieve the number of worldShape's daughters
uint numDaughters = worldShape.NumDaughters;
// ...
// Trigger the measurement of all the
// gauges attached to the EWorldShape
worldShape.Process(srcImage, true);
// Retrieve the measurement result of
// the first daughter (a rectangle gauge)
Legacy.ERectangleGauge rectangleGauge = (Legacy.ERectangleGauge)worldShape.GetDaughter(0);
float sizeX = rectangleGauge.MeasuredRectangle.SizeX;
// Retrieve the measurement result of a
// daughter gauge called "myCircleGauge1"
Legacy.ECircleGauge circleGauge = (Legacy.ECircleGauge)worldShape.GetShapeNamed("myCircleGauge1");
EPoint center = circleGauge.MeasuredCircle.Center;
```

## Python

```py
import eVision
import eVision.Legacy as Legacy
from typing import cast
# Image constructor
src_image = eVision.EImageBW8()
# EWorldShape constructor
world_shape = Legacy.EWorldShape()
# Load the EWorldShape together with its daughters
world_shape.Load("myWorldShape.gge", True)
# Retrieve the number of world_shape's daughters
numDaughters = world_shape.NumDaughters
# ...
# Trigger the measurement of all the
# gauges attached to the EWorldShape
world_shape.Process(src_image, True)
# Retrieve the measurement result of
# the first daughter (a rectangle gauge)
rectangle_gauge = cast(Legacy.ERectangleGauge, world_shape.GetDaughter(0))
sizeX = rectangle_gauge.MeasuredRectangle.SizeX
# Retrieve the measurement result of a
# daughter gauge called "myCircleGauge1"
circle_gauge = cast(Legacy.ECircleGauge, world_shape.GetShapeNamed("myCircleGauge1"))
center = circle_gauge.MeasuredCircle.Center
```
