Source for file Smith.php
Documentation is available at Smith.php
* Description: Smith Series
* @copyright (c) 1995-2010 by Steema Software SL. All Rights Reserved. <info@steema.com>
* @link http://www.steema.com
public function Smith($c= null) {
$this->getYValues()->name = Language::getString("SmithReactance");
//$this->setCircleBackColor(Color::getEmpty());
* Defines pen to draw SmithSeries Chart.
if ($this->pen == null) {
* Defines pen to draw SmithSeries Chart.
if ($this->pointer == null) {
* Specifies the text used to display together with axis labels around a
* Smith circle series.<br>
* Default value: ImagSymbol is a lowercase "i" letter.
return $this->imagSymbol;
* Specifies the text used to display together with axis labels around a
* Smith circle series.<br>
* Default value: ImagSymbol is a lowercase "i" letter.
* Defines Brush to fill Chart.
for ( $t = 0; $t <= $numValues; $t++ ) {
$this->add(6.5 * $t / $numValues, ($t * $r->Random() + 3.8) / $numValues);
* Defines Pen to draw CCircles of the Smith Series.<br>
* xCircle (reactance circle) pen. <br>
* Read CCirclePen to obtain the TChartPen object that represents the color
* and style of the CCircles of the Smith Series.<br>
* Use CCirclePen to change the color or style.
* Defines Pen to draw RCircles of the Smith Series.<br>
* rCircle (resistance circle) pen. <br>
* Read RCirclePen to obtain the Pen object that represents the color and
* style of the RCircles of the Smith Series.<br>
* Use RCirclePen to change the color or style.
* Defines Pen to draw external Circle of the Smith Series.<br>
* Resistance = 0 rCircle pen (biggest circle). <br>
* Read CirclePen to obtain the Pen object that represents the color and
* style of the external circle of the Smith Series.<br>
* Use CirclePen to change the color or style.
if ($this->circlePen == null) {
private $DEFAULTX = Array (0, 0.1, 0.3, 0.5, 0.8, 1, 1.5, 2, 3, 5, 7, 10);
$Shows/hides $the $static $finalant $reactance $labels.<br>
* When set to true, constant reactance labels are shown.
return $this->getVertAxis()->getLabels()->getVisible();
$Shows/hides $the $static $finalant $reactance $labels.<br>
* When set to true, constant reactance labels are shown.
$Shows/hides $the $static $finalant $resistance $labels.<br>
* When set to true constant resistance labels are shown.
$Shows/hides $the $static $finalant $resistance $labels.<br>
* When set to true constant resistance labels are shown.
private function drawXCircleGrid() {
for ( $t = 0; $t <= 11; $t++ ) {
private $DEFAULTR = Array(0, 0.2, 0.5, 1, 2, 5, 10);
private function drawRCircleGrid() {
for ( $t = 0; $t <= 6; $t++ ) {
private function drawAxis() {
$this->drawXCircleGrid();
$this->chart->getGraphics3D()->unClip();
$this->drawRCircleGrid();
private function drawCircle() {
$g = $this->chart->getGraphics3D();
$g->getBrush()->setVisible(false);
$g->getBrush()->setVisible(true);
$g->getBrush()->setSolid(true);
for ( $t = 0; $t < $this->chart->getSeriesCount(); $t++ ) {
$s = $this->chart->getSeries($t);
if ($s->getActive() && ($s instanceof Smith)) {
$r = $this->chart->getChartRect();
$r->grow( - $this->chart->getGraphics3D()->textWidth("360"),
- $this->chart->getGraphics3D()->getFontHeight() + 2);
$this->chart->setChartRect($r);
for ( $tt = 0; $tt < $this->chart->getSeriesCount(); $tt++ ) {
$ss = $this->chart->getSeries($tt);
if ($ss->getActive() && ($ss instanceof Smith)) {
if ($this->chart->getAxes()->getVisible() &&
$this->chart->getAxes()->getDrawBehind()) {
protected function draw() {
if ($this->pointer->getVisible()) {
$this->pointer->prepareCanvas($this->chart->getGraphics3D(), $tmpColor);
* Called internally. Draws the "ValueIndex" point of the Series.
$p = $this->zToPos($this->vxValues->getValue($valueIndex),
$this->vyValues->getValue($valueIndex));
$this->linePrepareCanvas($valueIndex);
$this->chart->getGraphics3D()->moveTo($p, $this->getStartZ()); // <-- first point
if (($p->x != $this->oldX) || ($p->y != $this->oldY)) {
private function getXCircleLabel($reactance) {
return $reactance . $this->imagSymbol;
private function linePrepareCanvas($valueIndex) {
$g = $this->chart->getGraphics3D();
if ($this->getPen()->getVisible()) {
$g->getPen()->setColor(($valueIndex == - 1) ? $this->getColor() :
$g->getPen()->setVisible(false);
parent::prepareForGallery($isEnabled);
$this->chart->getAspect()->setChart3DPercent(5);
$this->chart->getAxes()->getRight()->getLabels()->setVisible(false);
$this->chart->getAxes()->getTop()->getLabels()->setVisible(false);
$this->chart->getAspect()->setOrthogonal(false);
$this->chart->getAspect()->setElevation(360);
$this->chart->getAspect()->setZoom(90);
if ($this->pointer != null) {
$this->pointer->setChart($c);
if (($this->chart != null) && $this->Beans->isDesignTime()) {
$this->chart->getAspect()->setView3D(false);
* The pixel Screen Horizontal coordinate of the ValueIndex Series
* This coordinate is calculated using the Series associated Horizontal Axis.
return $this->zToPos($this->vxValues->getValue($valueIndex),
$this->vyValues->getValue($valueIndex))->x;
* The pixel Screen Vertical coordinate of the ValueIndex Series
* This coordinate is calculated using the Series associated Vertical Axis.
return $this->zToPos($this->vxValues->getValue($valueIndex),
$this->vyValues->getValue($valueIndex))->y;
* The ValueIndex of the "clicked" point in the Series.<br>
if ($this->chart != null) {
$p = $this->chart->getGraphics3D()->calculate2DPosition($x, $y, $this->getStartZ());
$result = parent::clicked($x, $y);
if ($this->pointer->getVisible()) {
if (($this->abs($this->calcXPos($t) - $x) < $this->pointer->getHorizSize()) &&
($this->abs($this->calcYPos($t) - $y) < $this->pointer->getVertSize())) {
private function drawRCircleLabel($rVal, $x, $y) {
$this->chart->getGraphics3D()->setTextAlign($tmpStringAlignment->CENTER);
$this->chart->getGraphics3D()->textOut($x, $y, $this->getEndZ(), $rVal);
private function drawRCircle($value, $z, $showLabel) {
// Circles are always right aligned
if ($showLabel) { // 5.02 ( if $RLabels)
$this->drawRCircleLabel($value,
private function drawXCircleLabel($xVal, $x, $y) {
$tmpHeight = $this->chart->getGraphics3D()->getFontHeight();
$tmpSt = $this->getXCircleLabel($xVal);
if (($angle == 0) || ($angle == 180)) {
if (($angle > 0) && ($angle < 180)) {
if (($angle == 90) || ($angle == 270)) {
$this->chart->getGraphics3D()->setTextAlign($tmpStringAlignment->CENTER);
$this->chart->getGraphics3D()->setTextAlign((($angle > 90) &&
$tmpStringAlignment->FAR :
$tmpStringAlignment->NEAR);
$tmpWidth = $this->chart->getGraphics3D()->textWidth("0") / 2;
} else if ($angle == 180) {
$this->chart->getGraphics3D()->textOut($x, $y, $this->getEndZ(), $tmpSt);
private function drawXCircle($value, $z, $showLabel) {
$p4 = $this->zToPos(0, $value); // Endpos
$this->drawXCircleLabel($value, $p4->x, $p4->y);
$p3 = $this->zToPos(100, $value); // Startpos
// ellipse bounding points
$p2->y = $p1->y - 2 * $halfYSize;
// TODO $this->chart->getGraphics3D()->clipEllipse($this->getCircleRect());
if ((!$this->chart->getAspect()->getView3D()) ||
$this->chart->getAspect()->getOrthogonal()) {
$this->chart->getGraphics3D()->arc($p1->x, $p2->y, $p2->x, $p1->y, 0, 360);
$p4 = $this->zToPos(0, - $value); // Endpos
if ((!$this->chart->getAspect()->getView3D()) ||
$this->chart->getAspect()->getOrthogonal()) {
$this->chart->getGraphics3D()->arc($p1->x, $p2->y + 2 * $halfYSize, $p2->x,
$p1->y + 2 * $halfYSize, 0, 360);
// TODO $this->chart->getGraphics3D()->unClip();
$this->drawXCircleLabel( - $value, $p4->x, $p4->y);
/* special case ) reactance is zero */
$this->chart->getGraphics3D()->line($p1->x, $p1->y, $p2->x, $p1->y, $this->getMiddleZ());
$this->drawXCircleLabel(0, $p1->x, $p1->y);
// Position to impendance
// (ZRe,ZIm)=(1+gamma)/(1-gamma)
private function posToZ($x, $y) {
$norm2 = ($gRe * $gRe) + ($gIm * $gIm);
$invDen = 1 / ($norm2 - 2 * $gRe + 1);
return new PointDouble((1 - $norm2) * $invDen, 2 * $gIm * $invDen);
// impendance to Position
private function zToPos($resist, $react) {
$norm2 = ($resist * $resist) + ($react * $react);
$invDen = 1 / ($norm2 + 2 * $resist + 1);
$gRe = ($norm2 - 1) * $invDen;
$gIm = 2 * $react * $invDen;
|