RequestOutPutPlotElementPlotFunctionNodeClass.php 4.67 KB
<?php

require_once("RequestOutPutPlotElementPlotFunctionNodeClass.php");


class RequestOutPutPlotElementPlotFunctionNodeClass extends RequestOutputPlotElementNodeClass
{
    const REQUESTOUTPUTPLOTELEMENT_PLOTFUNCTION_NAME = "plotFunction";
    const PLOT_FUNCTION_ABSCISSE =  "abscisse";
    const PLOT_FUNCTION_SCALE_ABSCISSE = "scale_abscisse";
    const PLOT_FUNCTION_SCALE_ORDONNEE = "scale_ordonnee";
    const PLOT_FUNCTION_PARAMS_NB_POINTS = "param_nb_points";
    const PLOT_FUNCTION_TYPE = "type";
    const PLOT_FUNCTION_TIMEAXIS_ID = "xaxis_id1";
    const PLOT_FUNCTION_YAXIS_ID = "y-left";
    const PLOT_FUNCTION_DIGITALAXIS_ID = "xaxis_id";
    const PLOT_FUNCTION_FFT = "FFT";
    const PLOT_FUNCTION_DFT = "DFT";
    const PLOT_FUNCTION_IHERITS = "Inherits";
    const PLOT_FUNCTION_FREQUNECY = "Frequency";
    const PLOT_FUNCTION_PERIOD = "Period";

    public function __construct()
    {
        parent::__construct(RequestOutPutPlotElementPlotFunctionNodeClass::REQUESTOUTPUTPLOTELEMENT_PLOTFUNCTION_NAME, true, false, false, false, false, true);
        //create x axis
        $this->getAxes()->addDigitalAxis(RequestOutputPlotAxisTypeEnum::XAXIS, REQUESTOUTPUTPLOTELEMENTXY_XAXISID);
        //force color axis creation
        $this->getAxes()->getColorAxis();
    }

    public function getTimeAxis()
    {
        $timeAxis = $this->getAxes()->getTimeAxis();
        $timeAxis->setId(RequestOutPutPlotElementPlotFunctionNodeClass::PLOT_FUNCTION_TIMEAXIS_ID);
        return $timeAxis;
    }

    /**
     * Check if the function to apply is Fourier
     */
    public static function isFourier($value)
    {
        return $value == RequestOutPutPlotElementPlotFunctionNodeClass::PLOT_FUNCTION_FFT
            || $value == RequestOutPutPlotElementPlotFunctionNodeClass::PLOT_FUNCTION_DFT;
    }

    /**
     * Get a label to assoiciated with getAbscisse type when using Fourier
     */
    public static function getTextLegend($abscisse)
    {
        return $abscisse ===  RequestOutPutPlotElementPlotFunctionNodeClass::PLOT_FUNCTION_FREQUNECY ? "Freq, Hz" : "Period, S";
    }

    public function getXAxis()
    {
        return $this->getAxes()->getDigitalAxis(RequestOutputPlotAxisTypeEnum::XAXIS, REQUESTOUTPUTPLOTELEMENTXY_XAXISID);
    }

    public function addYAxis($id)
    {
        return $this->getAxes()->addDigitalAxis(RequestOutputPlotAxisTypeEnum::YAXIS, $id);
    }

    public function getYAxis($id)
    {
        return $this->getAxes()->getDigitalAxis(RequestOutputPlotAxisTypeEnum::YAXIS, $id);
    }

    public function getZAxis()
    {
        return $this->getAxes()->getColorAxis();
    }

    public function loadFromNode($xmlNode)
    {
        parent::loadFromNode($xmlNode);
    }

    /**
     * Set Abscisse
     */
    public function setAbscisse($abscisse)
    {
        $this->setAttribute(RequestOutPutPlotElementPlotFunctionNodeClass::PLOT_FUNCTION_ABSCISSE, $abscisse);
    }

    /**
     * Get Abscisse
     */
    public function getAbscisse()
    {
        $this->getAttribute(RequestOutPutPlotElementPlotFunctionNodeClass::PLOT_FUNCTION_ABSCISSE);
    }

    /**
     * Set Type
     */
    public function setType($type)
    {
        $this->setAttribute(RequestOutPutPlotElementPlotFunctionNodeClass::PLOT_FUNCTION_TYPE, $type);
    }

    /**
     * Get Type
     */
    public function getType()
    {
        $this->getAttribute(RequestOutPutPlotElementPlotFunctionNodeClass::PLOT_FUNCTION_TYPE);
    }

    /**
     * Set Scale Abscisse
     */
    public function setScaleAbscisse($scale_abscisse)
    {
        $this->setAttribute(RequestOutPutPlotElementPlotFunctionNodeClass::PLOT_FUNCTION_SCALE_ABSCISSE, $scale_abscisse);
    }

    /**
     * Get Scale Abscisse
     */
    public function getScaleAbscisse()
    {
        $this->getAttribute(RequestOutPutPlotElementPlotFunctionNodeClass::PLOT_FUNCTION_SCALE_ABSCISSE);
    }

    /**
     * Set Scale Ordonnée
     */
    public function setScaleOrdonnee($scale_ordonnee)
    {
        $this->setAttribute(RequestOutPutPlotElementPlotFunctionNodeClass::PLOT_FUNCTION_SCALE_ORDONNEE, $scale_ordonnee);
    }

    /**
     * Get Scale Ordonnée
     */
    public function getScaleOrdonnee()
    {
        $this->getAttribute(RequestOutPutPlotElementPlotFunctionNodeClass::PLOT_FUNCTION_SCALE_ORDONNEE);
    }

    /*
     * Set Param's  nb points for FFT
     
    public function setParamsNbPoints($nb)
    {
        $this->setAttribute(RequestOutPutPlotElementPlotFunctionNodeClass::PLOT_FUNCTION_PARAMS_NB_POINTS, $nb);
    }

     
      GET Param's  nb points for FFT
     
    public function getParamsNbPoints()
    {
        $this->getAttribute(RequestOutPutPlotElementPlotFunctionNodeClass::PLOT_FUNCTION_PARAMS_NB_POINTS);
    }*/
}