示例#1
0
文件: Estimate.cs 项目: pre078/ApsimX
        /// <summary>Initializes a new instance of the <see cref="Estimate"/> class.</summary>
        /// <param name="parent">The parent model</param>
        /// <param name="Type">The type of estimate</param>
        /// <param name="soilstate">The state of the soil</param>
        /// <param name="uptakeModels">A list of models that do uptake.</param>
        public Estimate(IModel parent, CalcType Type, SoilState soilstate, List <IModel> uptakeModels)
        {
            Values = new List <CropUptakes>();

            Parent = parent;
            foreach (IUptake crop in uptakeModels)
            {
                List <ZoneWaterAndN> uptake;
                if (Type == CalcType.Water)
                {
                    uptake = crop.GetSWUptakes(soilstate);
                }
                else
                {
                    uptake = crop.GetNUptakes(soilstate);
                }

                if (uptake != null)
                {
                    CropUptakes Uptake = new CropUptakes();
                    Uptake.Crop  = crop;
                    Uptake.Zones = uptake;
                    Values.Add(Uptake);
                }
            }
        }
示例#2
0
        /// <summary>
        /// Gets the max number of points element and the number.
        /// </summary>
        /// <param name="doc"></param>
        /// <param name="type"></param>
        /// <param name="onlyCurrentView"></param>
        /// <returns></returns>
        public static (Element, int) GetMaxElement(this Document doc, CalcType type, bool onlyCurrentView = false)
        {
            var elms   = doc.Checkout(onlyCurrentView);
            var maxElm = default(Element);
            var maxNum = int.MinValue;
            var num    = 0;

            foreach (var elm in elms)
            {
                switch (type)
                {
                case CalcType.FaceNum:
                    num = elm.GetFaces().Count;
                    break;

                case CalcType.FacePointNum:
                    num = elm.GetFacePoints().Count;
                    break;

                case CalcType.SolidPointNum:
                    num = elm.GetSolidPoints().Count;
                    break;
                }

                if (num <= maxNum)
                {
                    continue;
                }

                maxNum = num;
                maxElm = elm;
            }

            return(maxElm, maxNum);
        }
示例#3
0
        private bool VerifyForm(CalcType selectedType)
        {
            if (selectedType == CalcType.Singleton && string.IsNullOrEmpty(textInputOne.Text))
            {
                this.ShowPopup("It won't work!", "You must enter an (x) value for Singleton.");
                return(false);
            }
            else if (selectedType == CalcType.Gamma && string.IsNullOrEmpty(textInputOne.Text) && string.IsNullOrEmpty(textInputTwo.Text))
            {
                this.ShowPopup("It won't work!", "You must enter an (x,a) and (x,b) value for Gamma.");
                return(false);
            }
            else if (selectedType == CalcType.L && string.IsNullOrEmpty(textInputOne.Text) && string.IsNullOrEmpty(textInputTwo.Text))
            {
                this.ShowPopup("It won't work!", "You must enter an (x,a) and (x,b) value for L.");
                return(false);
            }
            else if (selectedType == CalcType.T && string.IsNullOrEmpty(textInputOne.Text) && string.IsNullOrEmpty(textInputTwo.Text) && string.IsNullOrEmpty(textInputThree.Text))
            {
                this.ShowPopup("It won't work!", "You must enter an (x,a), (x,b) and (x,c) value for t.");
                return(false);
            }

            return(true);
        }
    protected internal override void NodeGUI()
    {
        GUILayout.BeginHorizontal();
        GUILayout.BeginVertical();
        GUILayout.Label("Val1:" + (float)m_Value1 + " Val2:" + (float)m_Value2);


        GUILayout.EndVertical();
        GUILayout.BeginVertical();
        if (Outputs[0] != null)
        {
            Outputs [0].DisplayLayout();
        }

        GUILayout.EndVertical();
        GUILayout.EndHorizontal();

#if UNITY_EDITOR
        type = (CalcType)UnityEditor.EditorGUILayout.EnumPopup(new GUIContent("Calculation Type", "The type of calculation performed on Input 1 and Input 2"), type);
#else
        GUILayout.Label(new GUIContent("Calculation Type: " + type.ToString(), "The type of calculation performed on Input 1 and Input 2"));
#endif

        if (GUI.changed)
        {
            NodeEditor.RecalculateFrom(this);
        }
    }
示例#5
0
 public Var8x(VarType typeID, string name, CalcType calcType = Var8x.CalcType.Calc8x)
 {
     sigArray = SIGSTRING[(int)calcType].ToByteArray();
     if (calcType != CalcType.Calc85)
     {
         fsigArray = new byte[3] {
             0x1A, 0x0A, 0x00
         };
     }
     else
     {
         fsigArray = new byte[3] {
             0x1A, 0x0C, 0x00
         };
     }
     flag1 = new byte[2] {
         0x0D, 0x00
     };
     comment      = "Merthsoft TokenIDE";
     commentArray = new byte[42];
     this.name    = name;
     varNameArray = new byte[8];
     varID        = typeID;
     archFlag     = 0;
     Calc         = calcType;
 }
示例#6
0
 public Var(VarType varType, string code, string defaultValue = null)
 {
     CalcType     = new CalcType(ClassType.Undef);
     VarType      = varType;
     Code         = code;
     DefaultValue = defaultValue;
 }
示例#7
0
 public CalcTypeControl(CalcType calcType)
 {
     InitializeComponent();
     _calcType = calcType;
     lbCalcTypeName.Content  = _calcType.TypeName;
     imgCalcTypeImage.Source = new BitmapImage(new Uri(_calcType.ImageName, UriKind.Relative));
 }
示例#8
0
        }                                              // Вид платежа

        public Calculator(double creditAmount, double creditRate, int creditPeriod, CalcType selectCalcType)
        {
            CreditAmount     = creditAmount;
            CreditRateYear   = creditRate;
            CreditPeriod     = creditPeriod;
            SelectedCalcType = selectCalcType;
        }
示例#9
0
	public override void NodeGUI () 
	{
		GUILayout.BeginHorizontal ();
		GUILayout.BeginVertical ();

		if (Inputs [0].connection != null)
			GUILayout.Label (Inputs [0].name);
		else
			Input1Val = RTEditorGUI.FloatField (GUIContent.none, Input1Val);
		InputKnob (0);
		// --
		if (Inputs [1].connection != null)
			GUILayout.Label (Inputs [1].name);
		else
			Input2Val = RTEditorGUI.FloatField (GUIContent.none, Input2Val);
		InputKnob (1);

		GUILayout.EndVertical ();
		GUILayout.BeginVertical ();

		Outputs [0].DisplayLayout ();

		GUILayout.EndVertical ();
		GUILayout.EndHorizontal ();

#if UNITY_EDITOR
		type = (CalcType)UnityEditor.EditorGUILayout.EnumPopup (new GUIContent ("Calculation Type", "The type of calculation performed on Input 1 and Input 2"), type);
#else
		GUILayout.Label (new GUIContent ("Calculation Type: " + type.ToString (), "The type of calculation performed on Input 1 and Input 2"));
#endif

		if (GUI.changed)
			NodeEditor.RecalculateFrom (this);
	}
示例#10
0
 public PriceChannel(ISeries input, int length, CalcType calcType, IncludeLast includeLast, BarData barData = BarData.Close)
     : base(input)
 {
     this.length      = length;
     this.barData     = barData;
     this.calcType    = calcType;
     this.includeLast = includeLast;
     this.Init();
 }
示例#11
0
文件: PC.cs 项目: ForTrade/OpenQuant
 public PC(ISeries series, int length, BarData barData, CalcType calcType, UseLast useLast)
     : base(series)
 {
     this.length = length;
     this.barData = barData;
     this.calcType = calcType;
     this.useLast = useLast;
     this.Name = "PriceChannel";
 }
示例#12
0
文件: PC.cs 项目: zjtan1992/OpenQuant
 public PC(ISeries series, int length, BarData barData, CalcType calcType, UseLast useLast)
     : base(series)
 {
     this.length   = length;
     this.barData  = barData;
     this.calcType = calcType;
     this.useLast  = useLast;
     this.Name     = "PriceChannel";
 }
示例#13
0
    public override void DrawNodePropertyEditor()
    {
#if UNITY_EDITOR
        m_Type = (CalcType)UnityEditor.EditorGUILayout.EnumPopup(new GUIContent("Type", "The type of calculation performed on Input 1 "), m_Type);
#else
        GUILayout.Label(new GUIContent("Calculation Type: " + type.ToString(), "The type of calculation performed on Input 1 and Input 2"));
#endif

        m_Value1.SliderLabel(this, "Value1");
    }
示例#14
0
 public ICalcInterFace CerateCalcIntance(CalcType calcType)
 {
     ICalcInterFace CalcInterFace = null;
     switch (calcType)
     {
         case CalcType.Add: CalcInterFace = new Add(); break;
         case CalcType.Subtract: CalcInterFace = new Subtract(); break;
         default: break;
     }
     return CalcInterFace;
 }
示例#15
0
 public CalculationNode()
 {
     windowTitle    = "Calculation Node";
     inputNodeRects = new Rect[variableNames.Length];
     pastCalcType   = calcType;
     for (int i = 0; i < inputNodeRects.Length; i++)
     {
         inputNodes.Add(null);
     }
     inputType = new InputType[] { InputType.Node, InputType.Node };
 }
示例#16
0
        public int Calc(CalcType calcType)
        {
            switch (calcType)
            {
            case CalcType.Add: return(Add());

            case CalcType.Subtract: return(Subtract());

            default: return(0);
            }
        }
示例#17
0
        /// <summary>
        ///     Gets the element set that filter the max number of points.
        /// </summary>
        /// <param name="doc"></param>
        /// <param name="maxNum"></param>
        /// <param name="moreThan"></param>
        /// <param name="type"></param>
        /// <param name="viewId"></param>
        /// <returns></returns>
        public static List <Element> GetElementList(this Document doc, CalcType type, int maxNum, bool moreThan,
                                                    ElementId viewId)
        {
            if (doc == null)
            {
                throw new ArgumentNullException(nameof(doc));
            }

            if (viewId == null)
            {
                throw new ArgumentNullException(nameof(viewId));
            }

            var elms    = doc.Checkout(FilterType.Instance, viewId);
            var results = new List <Element>();

            foreach (var elm in elms)
            {
                int num;

                switch (type)
                {
                case CalcType.FaceNum:
                    num = elm.GetFaceList().Count;
                    break;

                case CalcType.FacePointNum:
                    num = elm.GetFacePointList().Count;
                    break;

                case CalcType.SolidPointNum:
                    num = elm.GetSolidPointList().Count;
                    break;

                default:
                    throw new ArgumentOutOfRangeException(nameof(type), type, null);
                }

                if (moreThan && num <= maxNum)
                {
                    continue;
                }

                if (!moreThan && num > maxNum)
                {
                    continue;
                }

                results.Add(elm);
            }

            return(results);
        }
        public int EaseOut(CCounter counter, int startPoint, int endPoint, CalcType type)
        {
            StartPoint   = startPoint;
            EndPoint     = endPoint;
            Sa           = EndPoint - StartPoint;
            TimeMs       = (int)counter.n終了値;
            Type         = type;
            CounterValue = counter.n現在の値;

            switch (Type)
            {
            case CalcType.Quadratic:     //Quadratic
                CounterValue /= TimeMs;
                Value         = -Sa * CounterValue * (CounterValue - 2) + StartPoint;
                break;

            case CalcType.Cubic:     //Cubic
                CounterValue /= TimeMs;
                CounterValue--;
                Value = Sa * (CounterValue * CounterValue * CounterValue + 1) + StartPoint;
                break;

            case CalcType.Quartic:     //Quartic
                CounterValue /= TimeMs;
                CounterValue--;
                Value = -Sa * (CounterValue * CounterValue * CounterValue * CounterValue - 1) + StartPoint;
                break;

            case CalcType.Quintic:     //Quintic
                CounterValue /= TimeMs;
                CounterValue--;
                Value = Sa * (CounterValue * CounterValue * CounterValue * CounterValue * CounterValue + 1) + StartPoint;
                break;

            case CalcType.Sinusoidal:     //Sinusoidal
                Value = Sa * Math.Sin(CounterValue / TimeMs * (Math.PI / 2)) + StartPoint;
                break;

            case CalcType.Exponential:     //Exponential
                Value = Sa * (-Math.Pow(2, -10 * CounterValue / TimeMs) + 1) + StartPoint;
                break;

            case CalcType.Circular:     //Circular
                CounterValue /= TimeMs;
                CounterValue--;
                Value = Sa * Math.Sqrt(1 - CounterValue * CounterValue) + StartPoint;
                break;
            }

            return((int)Value);
        }
示例#19
0
        public static int Calc(CalcType onType, int oprend1, int oprend2)
        {
            switch (onType)
            {
            case CalcType.Add: return(oprend1 + oprend2);

            case CalcType.Minus: return(oprend1 - oprend2);

            case CalcType.Multiply: return(oprend1 * oprend2);

            case CalcType.Divide: return(oprend1 / oprend2);
            }
            return(0);
        }
        public static int EaseOut(CCounter counter, int StartPoint, int EndPoint, CalcType type)
        {
            int    Sa           = EndPoint - StartPoint;
            int    TimeMs       = counter.n終了値;
            double CounterValue = counter.n現在の値;

            double Value;

            switch (type)
            {
            case CalcType.Quadratic:     //Quadratic
                CounterValue /= TimeMs;
                Value         = -Sa * CounterValue * (CounterValue - 2) + StartPoint;
                break;

            case CalcType.Cubic:     //Cubic
                CounterValue /= TimeMs;
                CounterValue--;
                Value = Sa * (CounterValue * CounterValue * CounterValue + 1) + StartPoint;
                break;

            case CalcType.Quartic:     //Quartic
                CounterValue /= TimeMs;
                CounterValue--;
                Value = -Sa * (CounterValue * CounterValue * CounterValue * CounterValue - 1) + StartPoint;
                break;

            case CalcType.Quintic:     //Quintic
                CounterValue /= TimeMs;
                CounterValue--;
                Value = Sa * (CounterValue * CounterValue * CounterValue * CounterValue * CounterValue + 1) + StartPoint;
                break;

            case CalcType.Sinusoidal:     //Sinusoidal
                Value = Sa * Math.Sin(CounterValue / TimeMs * (Math.PI / 2)) + StartPoint;
                break;

            case CalcType.Exponential:     //Exponential
                Value = Sa * (-Math.Pow(2, -10 * CounterValue / TimeMs) + 1) + StartPoint;
                break;

            default:     //Circular
                CounterValue /= TimeMs;
                CounterValue--;
                Value = Sa * Math.Sqrt(1 - CounterValue * CounterValue) + StartPoint;
                break;
            }

            return((int)Value);
        }
示例#21
0
        enum CalcType { Add, Min, Mul, Div }                         // enum으로 연산자를 결정

        static int Calc(CalcType opType, int operand1, int operand2) // 2번 메소드
        {
            switch (opType)
            {
            case CalcType.Add: return(operand1 + operand2);

            case CalcType.Min: return(operand1 - operand2);

            case CalcType.Mul: return(operand1 * operand2);

            case CalcType.Div: return(operand1 / operand2);
            }
            return(0);
        }
示例#22
0
        private static int Calc(CalcType opType, int operand1, int operand2)
        {
            switch (opType)
            {
            case CalcType.Add: return(operand1 + operand2);

            case CalcType.Minus: return(operand1 - operand2);

            case CalcType.Multiplay: return(operand1 * operand2);

            case CalcType.Divide: return(operand1 / operand2);
            }

            return(0);
        }
示例#23
0
        /// <summary>
        /// Starts full calculation proccess.
        /// </summary>
        /// <param name="message">String to be printed through the UI.</param>
        /// <param name="warning">Warning Enum to display to the user.</param>
        /// <param name="passCount">The desired number of completed paystubs.</param>
        public static Tuple <List <Paystub>, Tuple <decimal, decimal, decimal>, Tuple <decimal, decimal> > BeginCalc(Message message, WarningMessage warning, List <Paystub> paystubs, decimal accuracy, int passCount = 1)
        {
            int completePaystubs = 0;

            decimal averagePercentage = 0;
            decimal percentAccuracy   = 0;
            decimal outputRatio       = 0;
            bool    paystubRatio      = true;
            bool    accuracyOutput    = true;

            Decision = CalculationDecision(paystubs);

            // Maybe add a name to the paystub collection??
            message(Decision.ToString());

            Tuple <decimal, int> calcPercentageOutput = CalculatePercentage(paystubs);

            averagePercentage = calcPercentageOutput.Item1;
            completePaystubs  = calcPercentageOutput.Item2;

            SetPercentage(paystubs, averagePercentage);
            Tuple <bool, decimal> checkCompleteOutput = CheckCompletedPaystubRatio(paystubs, passCount, completePaystubs);

            paystubRatio = checkCompleteOutput.Item1;
            outputRatio  = checkCompleteOutput.Item2;

            if (Decision == CalcType.CalcGross)
            {
                Paystub.GrossFromPercentageList(paystubs);
            }
            else if (Decision == CalcType.CalcNet)
            {
                Paystub.NetFromPercentageList(paystubs);
            }

            Tuple <bool, decimal> checkPercentOutput = CheckPercentageAccuracy(paystubs, accuracy);

            accuracyOutput  = checkPercentOutput.Item1;
            percentAccuracy = checkPercentOutput.Item2;

            warning(CheckWarning(paystubRatio, accuracyOutput));

            Tuple <decimal, decimal> calcAccuracy = Tuple.Create(percentAccuracy, outputRatio);

            Tuple <decimal, decimal, decimal> averagesOut = RunAverages(paystubs);

            return(Tuple.Create(paystubs, averagesOut, calcAccuracy));
        }
示例#24
0
    public override void DrawNode()
    {
        GUILayout.BeginHorizontal();
        GUILayout.BeginVertical();

        if (inputs [0].connection != null)
        {
            GUILayout.Label(inputs [0].name);
        }
        else
        {
            Input1Val = EditorGUILayout.FloatField(Input1Val);
        }
        if (Event.current.type == EventType.Repaint)
        {
            inputs [0].SetRect(GUILayoutUtility.GetLastRect());
        }
        // --
        if (inputs [1].connection != null)
        {
            GUILayout.Label(inputs [1].name);
        }
        else
        {
            Input2Val = EditorGUILayout.FloatField(Input2Val);
        }
        if (Event.current.type == EventType.Repaint)
        {
            inputs [1].SetRect(GUILayoutUtility.GetLastRect());
        }

        GUILayout.EndVertical();
        GUILayout.BeginVertical();

        outputs [0].DisplayLayout();
        // We take that this time, because it has a GuiStyle to aligned to the right :)

        GUILayout.EndVertical();
        GUILayout.EndHorizontal();

        type = (CalcType)EditorGUILayout.EnumPopup(new GUIContent("Calculation Type", "The type of calculation performed on Input 1 and Input 2"), type);

        if (GUI.changed)
        {
            Node_Editor.editor.RecalculateFrom(this);
        }
    }
示例#25
0
        private double Calc(DeviceCollection devices, string propertyName, CalcType calcType)
        {
            Calculator c = new Calculator(calcType);

            foreach (IDevice device in devices)
            {
                IData last = device.DeviceDataManager.Last;
                Debug.Assert(last != null);

                object obj = ReflectionHelper.GetPropertyValue(last, propertyName);
                double val = Convert.ToDouble(obj);

                c.Add(val);
            }

            return(c.Calc());
        }
示例#26
0
        /// <summary>
        ///     Gets the max number of points element and the number.
        /// </summary>
        /// <param name="doc"></param>
        /// <param name="type"></param>
        /// <param name="viewId"></param>
        /// <returns></returns>
        public static (Element, int) GetMaxElementPair(this Document doc, CalcType type, ElementId viewId)
        {
            if (doc == null)
            {
                throw new ArgumentNullException(nameof(doc));
            }

            if (viewId == null)
            {
                throw new ArgumentNullException(nameof(viewId));
            }

            var elms   = doc.Checkout(FilterType.Instance, viewId);
            var maxElm = default(Element);
            var maxNum = int.MinValue;
            var num    = 0;

            foreach (var elm in elms)
            {
                switch (type)
                {
                case CalcType.FaceNum:
                    num = elm.GetFaceList().Count;
                    break;

                case CalcType.FacePointNum:
                    num = elm.GetFacePointList().Count;
                    break;

                case CalcType.SolidPointNum:
                    num = elm.GetSolidPointList().Count;
                    break;
                }

                if (num <= maxNum)
                {
                    continue;
                }

                maxNum = num;
                maxElm = elm;
            }

            return(maxElm, maxNum);
        }
示例#27
0
        public void GetJob(IPAddress address, int port)
        {
            using (TcpClient client = new TcpClient())
            {
                client.Connect(address, port);

                BinaryWriter writer = new BinaryWriter(client.GetStream());
                writer.Write((byte)RequestOpcode.JobRequest);
                writer.Write(id.ToByteArray());

                BinaryReader reader = new BinaryReader(client.GetStream());

                int charsToCalcFromServer = reader.ReadInt32();
                if (charsToCalcFromServer > 0)
                {
                    type        = CalcType.ExactlyAsSpecified;
                    charsToCalc = charsToCalcFromServer;
                }
                else if (charsToCalcFromServer < 0)
                {
                    type        = CalcType.LessThanSpecified;
                    charsToCalc = -charsToCalcFromServer;
                }
                else if (charsToCalcFromServer == 0)
                {
                    // Hash already found
                    IsFinished = true;
                    Console.WriteLine("No more jobs availible, stopping");
                    return;
                }

                prefix = reader.ReadString();

                var hashLength = reader.ReadInt32();
                desiredHash = reader.ReadBytes(hashLength);
            }

            string stars = string.Empty;

            for (int i = 0; i < charsToCalc; i++)
            {
                stars += "*";
            }
            Console.WriteLine($"Got job! {prefix}{stars}");
        }
示例#28
0
        public static double Value(ISeries input, int index, int length, CalcType calcType, IncludeLast includeLast, BarData barData = BarData.Close)
        {
            int _index = index - length + 1;

            if (_index < 0)
            {
                return(double.NaN);
            }

            if (calcType == CalcType.Max)
            {
                double max = double.MinValue;
                for (int i = _index; i < index; ++i)
                {
                    max = Math.Max(max, input[i, barData]);
                }
                if (IncludeLast.Yes == includeLast)
                {
                    max = Math.Max(max, input[index, barData]);
                }
                if (max == double.MinValue)
                {
                    return(double.NaN);
                }
                return(max);
            }
            else
            {
                double min = double.MaxValue;
                for (int i = _index; i < index; ++i)
                {
                    min = Math.Min(min, input[i, barData]);
                }
                if (IncludeLast.Yes == includeLast)
                {
                    min = Math.Min(min, input[index, barData]);
                }
                if (min == double.MaxValue)
                {
                    return(double.NaN);
                }
                return(min);
            }
        }
示例#29
0
    public override void NodeGUI()
    {
        GUILayout.BeginHorizontal();
        GUILayout.BeginVertical();

        if (Inputs [0].connection != null)
        {
            GUILayout.Label(Inputs [0].name);
        }
        else
        {
            Input1Val = RTEditorGUI.FloatField(GUIContent.none, Input1Val);
        }
        InputKnob(0);
        // --
        if (Inputs [1].connection != null)
        {
            GUILayout.Label(Inputs [1].name);
        }
        else
        {
            Input2Val = RTEditorGUI.FloatField(GUIContent.none, Input2Val);
        }
        InputKnob(1);

        GUILayout.EndVertical();
        GUILayout.BeginVertical();

        Outputs [0].DisplayLayout();

        GUILayout.EndVertical();
        GUILayout.EndHorizontal();

#if UNITY_EDITOR
        type = (CalcType)UnityEditor.EditorGUILayout.EnumPopup(new GUIContent("Calculation Type", "The type of calculation performed on Input 1 and Input 2"), type);
#else
        GUILayout.Label(new GUIContent("Calculation Type: " + type.ToString(), "The type of calculation performed on Input 1 and Input 2"));
#endif

        if (GUI.changed)
        {
            NodeEditor.RecalculateFrom(this);
        }
    }
示例#30
0
        /// <summary>
        /// Gets the element set that filter the max number of points.
        /// </summary>
        /// <param name="doc"></param>
        /// <param name="maxNum"></param>
        /// <param name="moreThan"></param>
        /// <param name="type"></param>
        /// <param name="onlyCurrentView"></param>
        /// <returns></returns>
        public static List <Element> GetElementList(this Document doc, CalcType type, int maxNum, bool moreThan, bool onlyCurrentView = false)
        {
            if (doc == null)
            {
                throw new ArgumentNullException(nameof(doc));
            }

            var elms    = doc.Checkout(onlyCurrentView);
            var results = new List <Element>();
            var num     = 0;

            foreach (var elm in elms)
            {
                switch (type)
                {
                case CalcType.FaceNum:
                    num = elm.GetFaceList().Count;
                    break;

                case CalcType.FacePointNum:
                    num = elm.GetFacePointList().Count;
                    break;

                case CalcType.SolidPointNum:
                    num = elm.GetSolidPointList().Count;
                    break;
                }

                if (moreThan && num <= maxNum)
                {
                    continue;
                }

                if (!moreThan && num > maxNum)
                {
                    continue;
                }

                results.Add(elm);
            }

            return(results);
        }
示例#31
0
    public override void NodeGUI()
    {
        GUILayout.BeginHorizontal();
        GUILayout.BeginVertical();

        if (Inputs [0].connection != null)
        {
            GUILayout.Label(Inputs [0].name);
        }
        else
        {
            Input1Val = (GameObject)GUIExt.ObjectField(Input1Val, this);
        }
        InputKnob(0);
        // --
        if (Inputs [1].connection != null)
        {
            GUILayout.Label(Inputs [1].name);
        }
        else
        {
            Input2Val = (GameObject)GUIExt.ObjectField(Input2Val, this);
        }
        InputKnob(1);

        objectMaterial = (Material)UnityEditor.EditorGUILayout.ObjectField(objectMaterial, typeof(Material));

        GUILayout.EndVertical();
        GUILayout.BeginVertical();

        Outputs [0].DisplayLayout();

        GUILayout.EndVertical();
        GUILayout.EndHorizontal();

        type = (CalcType)UnityEditor.EditorGUILayout.EnumPopup(
            new GUIContent("CSG Operation", "The type of calculation performed on Input 1 and Input 2"), type);

        if (GUI.changed)
        {
            NodeEditor.RecalculateFrom(this);
        }
    }
示例#32
0
        public override void NodeGUI()
        {
            GUILayout.BeginHorizontal();
            GUILayout.BeginVertical();

            // First input
            if (input1Knob.connected())
            {
                GUILayout.Label(input1Knob.name);
            }
            else
            {
                Input1Val = RTEditorGUI.FloatField(GUIContent.none, Input1Val);
            }
            input1Knob.SetPosition();

            // Second input
            if (input2Knob.connected())
            {
                GUILayout.Label(input2Knob.name);
            }
            else
            {
                Input2Val = RTEditorGUI.FloatField(GUIContent.none, Input2Val);
            }
            input2Knob.SetPosition();

            GUILayout.EndVertical();
            GUILayout.BeginVertical();

            // Output
            outputKnob.DisplayLayout();

            GUILayout.EndVertical();
            GUILayout.EndHorizontal();

            type = (CalcType)RTEditorGUI.EnumPopup(new GUIContent("Calculation Type", "The type of calculation performed on Input 1 and Input 2"), type);

            if (GUI.changed)
            {
                NodeEditor.curNodeCanvas.OnNodeChange(this);
            }
        }
示例#33
0
文件: Estimate.cs 项目: hol353/ApsimX
        /// <summary>Initializes a new instance of the <see cref="Estimate"/> class.</summary>
        /// <param name="parent">The parent model</param>
        /// <param name="Type">The type of estimate</param>
        /// <param name="soilstate">The state of the soil</param>
        /// <param name="uptakeModels">A list of models that do uptake.</param>
        public Estimate(IModel parent, CalcType Type, SoilState soilstate, List<IModel> uptakeModels)
        {
            Values = new List<CropUptakes>();

            Parent = parent;
            foreach (IUptake crop in uptakeModels)
            {
                List<ZoneWaterAndN> uptake;
                if (Type == CalcType.Water)
                    uptake = crop.GetSWUptakes(soilstate);
                else
                    uptake = crop.GetNUptakes(soilstate);

                if (uptake != null)
                {
                    CropUptakes Uptake = new CropUptakes();
                    Uptake.Crop = crop;
                    Uptake.Zones = uptake;
                    Values.Add(Uptake);
                }
            }
        }
示例#34
0
    public override void NodeGUI()
    {
        GUILayout.BeginHorizontal ();
        GUILayout.BeginVertical ();

        if (Inputs [0].connection != null)
            GUILayout.Label (Inputs [0].name);
        #if UNITY_EDITOR
        else
            Input1Val = UnityEditor.EditorGUILayout.FloatField (Input1Val);
        #endif
        PlaceGUIInputKnobHere(0);
        // --
        if (Inputs [1].connection != null)
            GUILayout.Label (Inputs [1].name);
        #if UNITY_EDITOR
        else
            Input2Val = UnityEditor.EditorGUILayout.FloatField (Input2Val);
        #endif
        PlaceGUIInputKnobHere(1);

        GUILayout.EndVertical ();
        GUILayout.BeginVertical ();

        Outputs [0].DisplayLayout ();
        // We take that this time, because it has a GuiStyle to aligned to the right :)

        GUILayout.EndVertical ();
        GUILayout.EndHorizontal ();

        type = (CalcType)UnityEditor.EditorGUILayout.EnumPopup (new GUIContent ("Calculation Type", "The type of calculation performed on Input 1 and Input 2"), type);

        if (GUI.changed)
            NodeEditor.RecalculateFrom (this);
    }
示例#35
0
文件: Calc.cs 项目: hkiaipc/C3
 /// <summary>
 /// 
 /// </summary>
 /// <param name="calcType"></param>
 public Calculator(CalcType calcType)
 {
     this.CalcType = calcType;
 }
示例#36
0
        private double Run(string val1, string val2, CalcType type)
        {
            double dVal1, dVal2, result = 0;
            if (!double.TryParse(val1, out dVal1))
            {
                throw new InvalidCastException("引数1を数値に変換出来ません。");
            }
            if (!double.TryParse(val2, out dVal2))
            {
                throw new InvalidCastException("引数2を数値に変換出来ません。");
            }

            switch (type)
            {
                case CalcType.plus:
                    result = dVal1 + dVal2;
                    break;
            }
            return result;
        }
示例#37
0
    public override void NodeGUI()
    {
        GUILayout.BeginHorizontal ();
        GUILayout.BeginVertical ();

        if (Inputs [0].connection != null)
            GUILayout.Label (Inputs [0].name);
        else
            Input1Val = GUIExt.FloatField (Input1Val, this);
        InputKnob (0);
        // --
        if (Inputs [1].connection != null)
            GUILayout.Label (Inputs [1].name);
        else
            Input2Val = GUIExt.FloatField (Input2Val, this);
        InputKnob (1);

        GUILayout.EndVertical ();
        GUILayout.BeginVertical ();

        Outputs [0].DisplayLayout ();

        GUILayout.EndVertical ();
        GUILayout.EndHorizontal ();

        type = (CalcType)UnityEditor.EditorGUILayout.EnumPopup (new GUIContent ("Calculation Type", "The type of calculation performed on Input 1 and Input 2"), type);

        if (GUI.changed)
            NodeEditor.RecalculateFrom (this);
    }
示例#38
0
        private double Calc(DeviceCollection devices, string propertyName, CalcType calcType)
        {
            Calculator c = new Calculator(calcType);

            foreach (IDevice device in devices)
            {
                IData last = device.DeviceDataManager.Last;
                Debug.Assert(last != null);

                object obj = ReflectionHelper.GetPropertyValue(last, propertyName);
                double val = Convert.ToDouble(obj);

                c.Add(val);
            }

            return c.Calc();
        }
示例#39
0
		/// -------------------------------------------------------------------------------------------
		/// <summary>
		/// To find the width of the image.
		/// </summary>
		/// <returns> </returns>
		/// -------------------------------------------------------------------------------------------
		public static string CalcDimension(string fromPath, ref string imgDimension, CalcType calcType)
		{
			double retValue = 0.0;
			try
			{
				if (File.Exists(fromPath))
				{
					Image fullimage = Image.FromFile(fromPath);
					double height = fullimage.Height;
					double width = fullimage.Width;
					fullimage.Dispose();

					if (calcType == CalcType.Width)
					{
						retValue = width / height * double.Parse(imgDimension, CultureInfo.GetCultureInfo("en-US"));
						if (ColumnWidth > 0 && retValue > ColumnWidth)
						{
							retValue = ColumnWidth * .9;
						}
					}
					else if (calcType == CalcType.Height)
					{
						int counter;
						string retValue1 = GetNumericChar(imgDimension, out counter);
						if (imgDimension.IndexOf("%") > 0)
						{
							double widthInPt = double.Parse(retValue1, CultureInfo.GetCultureInfo("en-US")) / 100 * width;
							if (widthInPt > ColumnWidth)
							{
								widthInPt = ColumnWidth;
							}
							imgDimension = widthInPt.ToString();
							retValue = height / width * widthInPt;
						}
						else
						{
							retValue = height / width * double.Parse(retValue1, CultureInfo.GetCultureInfo("en-US"));
						}
					}
				}
			}
			catch
			{
			}
			return retValue.ToString();
		}