コード例 #1
0
        /// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
        /// <summary>
        /// Gets the yCenterCoord.
        /// </summary>
        /// <param name="varArray">the array to get the numbered variables from</param>
        public float GetYCenterCoord(GerberMacroVariableArray varArray)
        {
            if (yCenterCoord == null)
            {
                yCenterCoord = new GerberMacroVariable();
            }
            float workingYCenterCoord    = yCenterCoord.ProcessVariableStringToFloat(varArray);
            float workingDegreesRotation = GetDegreesRotation(varArray);

            // do we have a rotation
            if (workingDegreesRotation != 0)
            {
                // yes, return the converted value
                if (xCenterCoord == null)
                {
                    xCenterCoord = new GerberMacroVariable();
                }
                float  workingXCenterCoord = xCenterCoord.ProcessVariableStringToFloat(varArray);
                double angleInRadians      = MiscGraphicsUtils.DegreesToRadians(workingDegreesRotation);
                return((float)((workingYCenterCoord * Math.Cos(angleInRadians)) + workingXCenterCoord * Math.Sin(angleInRadians)));
            }
            else
            {
                // no just return the eyisting value
                return(workingYCenterCoord);
            }
        }
コード例 #2
0
        /// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
        /// <summary>
        /// Sets the aperture variables from a string.
        /// </summary>
        /// <param name="variableStr">the variable string</param>
        /// <returns>z succes, nz fail</returns>
        public int SetApertureVariablesFromString(string variableStr)
        {
            char[] splitArr = new char[] { 'x', 'X' };

            if (variableStr == null)
            {
                return(-1);
            }
            if (variableStr.Length == 0)
            {
                return(-1);
            }

            // now split it on the X delimiters as per spec
            string[] outParams = variableStr.Split(splitArr, StringSplitOptions.RemoveEmptyEntries);

            // populate the variable arrays
            int varIndex = 1;

            foreach (string paramStr in outParams)
            {
                VariableArray[varIndex] = new GerberMacroVariable(varIndex, paramStr);
                varIndex++;
                if (varIndex > GerberMacroVariableArray.MAX_MACRO_VARIABLES)
                {
                    throw new Exception("Maximum number of Macro Variables Exceeded");
                }
            }
            return(0);
        }
コード例 #3
0
 /// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
 /// <summary>
 /// Reset/Init the array
 /// </summary>
 private void Reset()
 {
     for (int i = 0; i < MAX_MACRO_VARIABLES; i++)
     {
         variableArray[i] = new GerberMacroVariable(i);
     }
 }
コード例 #4
0
 /// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
 /// <summary>
 /// Gets the degreesRotation in degrees counter clockwise
 /// </summary>
 /// <param name="varArray">the array to get the numbered variables from</param>
 public float GetDegreesRotation(GerberMacroVariableArray varArray)
 {
     if (degreesRotation == null)
     {
         degreesRotation = new GerberMacroVariable();
     }
     return(degreesRotation.ProcessVariableStringToFloat(varArray));
 }
コード例 #5
0
 /// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
 /// <summary>
 /// Gets the width
 /// </summary>
 /// <param name="varArray">the array to get the numbered variables from</param>
 public float GetWidth(GerberMacroVariableArray varArray)
 {
     if (width == null)
     {
         width = new GerberMacroVariable();
     }
     return(width.ProcessVariableStringToFloat(varArray));
 }
コード例 #6
0
 /// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
 /// <summary>
 /// Gets the diameter
 /// </summary>
 /// <param name="varArray">the array to get the numbered variables from</param>
 public float GetDiameter(GerberMacroVariableArray varArray)
 {
     if (diameter == null)
     {
         diameter = new GerberMacroVariable();
     }
     return(diameter.ProcessVariableStringToFloat(varArray));
 }
コード例 #7
0
 /// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
 /// <summary>
 /// Gets the numSides
 /// </summary>
 /// <param name="varArray">the array to get the numbered variables from</param>
 public float GetNumSides(GerberMacroVariableArray varArray)
 {
     if (numSides == null)
     {
         numSides = new GerberMacroVariable();
     }
     return(numSides.ProcessVariableStringToFloat(varArray));
 }
コード例 #8
0
 /// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
 /// <summary>
 /// Gets the height
 /// </summary>
 /// <param name="varArray">the array to get the numbered variables from</param>
 public float GetHeight(GerberMacroVariableArray varArray)
 {
     if (height == null)
     {
         height = new GerberMacroVariable();
     }
     return(height.ProcessVariableStringToFloat(varArray));
 }
コード例 #9
0
 /// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
 /// <summary>
 /// Gets the aperture on/off state. This may require using numbered variables
 /// to resolve this
 /// </summary>
 /// <param name="varArray">the array to get the numbered variables from</param>
 public bool GetApertureIsOn(GerberMacroVariableArray varArray)
 {
     if (apertureIsOn == null)
     {
         apertureIsOn = new GerberMacroVariable(DEFAULT_APERTURE_STATE);
     }
     return(Convert.ToBoolean(apertureIsOn.ProcessVariableStringToFloat(varArray)));
 }
コード例 #10
0
 /// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
 /// <summary>
 /// Sets the numSides
 /// </summary>
 /// <param name="numSidesStr">a string defining the degrees rotation</param>
 public void SetNumSides(string numSidesStr)
 {
     if ((numSidesStr == null) || (numSidesStr == ""))
     {
         numSides = new GerberMacroVariable();
     }
     else
     {
         numSides = new GerberMacroVariable(numSidesStr);
     }
 }
コード例 #11
0
 /// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
 /// <summary>
 /// Sets the degreesRotation in degrees counter clockwise
 /// </summary>
 /// <param name="degreesRotationStr">a string defining the degrees rotation</param>
 public void SetDegreesRotation(string degreesRotationStr)
 {
     if ((degreesRotationStr == null) || (degreesRotationStr == ""))
     {
         degreesRotation = new GerberMacroVariable();
     }
     else
     {
         degreesRotation = new GerberMacroVariable(degreesRotationStr);
     }
 }
コード例 #12
0
 /// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
 /// <summary>
 /// Sets the degreesRotation in degrees counter clockwise
 /// </summary>
 /// <param name="apertureStateStr">a string defining the aperture state</param>
 public void SetApertureIsOn(string apertureStateStr)
 {
     if ((apertureStateStr == null) || (apertureStateStr == ""))
     {
         apertureIsOn = new GerberMacroVariable(DEFAULT_APERTURE_STATE);
     }
     else
     {
         apertureIsOn = new GerberMacroVariable(apertureStateStr);
     }
 }
コード例 #13
0
 /// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
 /// <summary>
 /// Sets the width
 /// </summary>
 /// <param name="widthStr">a string defining the width</param>
 public void SetWidth(string widthStr)
 {
     if ((widthStr == null) || (widthStr == ""))
     {
         width = new GerberMacroVariable();
     }
     else
     {
         width = new GerberMacroVariable(widthStr);
     }
 }
コード例 #14
0
 /// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
 /// <summary>
 /// Sets the yEndCoord.
 /// </summary>
 /// <param name="endYCoordStr">a string defining the endYCoord</param>
 public void SetYEndCoord(string endYCoordStr)
 {
     if ((endYCoordStr == null) || (endYCoordStr == ""))
     {
         yEndCoord = new GerberMacroVariable();
     }
     else
     {
         yEndCoord = new GerberMacroVariable(endYCoordStr);
     }
 }
コード例 #15
0
 /// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
 /// <summary>
 /// Sets the yCenterCoord.
 /// </summary>
 /// <param name="centerYCoordStr">a string defining the centerYCoord</param>
 public void SetYCenterCoord(string centerYCoordStr)
 {
     if ((centerYCoordStr == null) || (centerYCoordStr == ""))
     {
         yCenterCoord = new GerberMacroVariable();
     }
     else
     {
         yCenterCoord = new GerberMacroVariable(centerYCoordStr);
     }
 }
コード例 #16
0
 /// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
 /// <summary>
 /// Sets the diameter
 /// </summary>
 /// <param name="diameterStr">a string defining the degrees rotation</param>
 public void SetDiameter(string diameterStr)
 {
     if ((diameterStr == null) || (diameterStr == ""))
     {
         diameter = new GerberMacroVariable();
     }
     else
     {
         diameter = new GerberMacroVariable(diameterStr);
     }
 }
コード例 #17
0
        /// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
        /// <summary>
        /// Get the parameters for this primitive from the supplied string
        /// </summary>
        /// <param name="primStr">the string with the primitives</param>
        /// <returns>z success, nz fail</returns>
        public override int ParsePrimitiveString(string primStr)
        {
            // these come in the form "$1=$2x0.8" and are used to re-assign a variable value on the fly

            char[]   splitChars = { '=' };
            string[] paramArray = null;

            if ((primStr == null) || (primStr.Length == 0))
            {
                // should never happen
                LogMessage("ParsePrimitiveString(Variable), (primStr==null) || (primStr.Length==0)");
                return(10);
            }
            if (primStr.StartsWith(GerberLine_AMCode.AM_VARIABLE_PRIMITIVE) == false)
            {
                // should never happen
                LogMessage("ParsePrimitiveString(Variable), start marker not present");
                return(20);
            }

            // record this
            PrimitiveString = primStr;

            // split the parameters out
            paramArray = primStr.Split(splitChars, StringSplitOptions.RemoveEmptyEntries);
            // this should never be null
            if (paramArray == null)
            {
                LogMessage("ParsePrimitiveString(Variable), blockArray == null");
                return(30);
            }
            // we only two parameters. The first is the variable number and the second is the operation to apply
            if (paramArray.Length != 2)
            {
                // should never happen
                LogMessage("ParsePrimitiveString(Variable), blockArray.Length != 2 is " + paramArray.Length.ToString());
                return(40);
            }
            try
            {
                // param 0 is the variable target, this must convert, remove the $ sign first
                string varNumOnly = paramArray[0].Replace("$", "");
                VariableNumber = Convert.ToInt32(varNumOnly.Trim());

                // param 1 is the operation
                VariableOperation = new GerberMacroVariable(paramArray[1].Trim());
            }
            catch (Exception ex)
            {
                LogMessage("ParsePrimitiveString(Circle), param conversion failed, msg=" + ex.Message);
                return(100);
            }
            return(0);
        }
コード例 #18
0
 /// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
 /// <summary>
 /// Sets the height
 /// </summary>
 /// <param name="heightStr">a string defining the height</param>
 public void SetHeight(string heightStr)
 {
     if ((heightStr == null) || (heightStr == ""))
     {
         height = new GerberMacroVariable();
     }
     else
     {
         height = new GerberMacroVariable(heightStr);
     }
 }
コード例 #19
0
 /// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
 /// <summary>
 /// Sets the yStartCoord.
 /// </summary>
 /// <param name="startYCoordStr">a string defining the startYCoord</param>
 public void SetYStartCoord(string startYCoordStr)
 {
     if ((startYCoordStr == null) || (startYCoordStr == ""))
     {
         yStartCoord = new GerberMacroVariable();
     }
     else
     {
         yStartCoord = new GerberMacroVariable(startYCoordStr);
     }
 }
コード例 #20
0
 /// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
 /// <summary>
 /// An indexer for the array, will never get or set a null variable
 /// </summary>
 public GerberMacroVariable this[int index]
 {
     get
     {
         if (VariableArray[index] == null)
         {
             VariableArray[index] = new GerberMacroVariable(index);
         }
         return(VariableArray[index]);
     }
     set
     {
         VariableArray[index] = value;
         if (VariableArray[index] == null)
         {
             VariableArray[index] = new GerberMacroVariable(index);
         }
     }
 }
コード例 #21
0
 /// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="xVarStringIn">the xVar value</param>
 /// <param name="yVarStringIn">the yVar value</param>
 public GerberMacroVariablePair(string xVarStringIn, string yVarStringIn)
 {
     xVar = new GerberMacroVariable(xVarStringIn);
     yVar = new GerberMacroVariable(yVarStringIn);
 }