コード例 #1
0
        //--------------------------------------------------------------------//
        //                                                        M e t h o d //
        // g e n e r a t e P a g e                                            //
        //--------------------------------------------------------------------//
        //                                                                    //
        // Write individual test data page sequences to output file.          //
        //                                                                    //
        //--------------------------------------------------------------------//

        private static void generatePage(BinaryWriter prnWriter,
                                         Int32 indxPaperSize,
                                         Int32 indxPaperType,
                                         Int32 indxOrientation,
                                         Boolean formAsMacro,
                                         UInt16 logXOffset)
        {
            String lbCRTerm = "\x0d" + "~";

            Int16 posX,
                  posY;

            Int16 ptSize,
                  degrees;

            Int16 boxX,
                  boxY,
                  boxHeight,
                  boxWidth;

            Double scaleX,
                   scaleY;

            Double angle,
                   sinAngle,
                   cosAngle;

            //----------------------------------------------------------------//

            if (formAsMacro)
            {
                PCLWriter.macroControl(prnWriter, _macroId,
                                       PCLWriter.eMacroControl.Call);
            }
            else
            {
                generateOverlay(prnWriter, false, logXOffset,
                                indxPaperSize, indxOrientation);
            }

            //----------------------------------------------------------------//
            //                                                                //
            // HP-GL/2 picture frame and initialisation.                      //
            //                                                                //
            // Plotter units are always absolute at 0.025mm (1/1016 inch),    //
            // but many HP-GL/2 commands use (definable) user units.          //
            // It makes the code clearer if we use the same units in HP-GL/2  //
            // as we do in PCL, so the SC (scale) command is used to set      //
            // user-units to 600 units-per-inch.                              //
            //                                                                //
            // Note that the default HP-GL/2 Y-axis has its origin at         //
            // lower-left of the picture frame, and Y-coordinate values       //
            // increase UP the page, whilst the PCL Y-axis has its origin at  //
            // the top margin and Y-coordinate values increase DOWN the page. //
            //                                                                //
            // It is possible to use the same (600 upi) coordinates as PCL by //
            // using:                                                         //
            //  SC0,1.6933,0,-1.6933,2                                        //
            //  IR0,100,100,0                                                 //
            // Note that the IR coordinates shown in the example in the "PCL  //
            // Technical Reference" manual are different and are incorrect!   //
            // One drawback to using the same origin and axis direction is    //
            // that some commands (such as SR) then have to use negative      //
            // Y-values to avoid mirroring.                                   //
            //                                                                //
            //----------------------------------------------------------------//

            scaleX = (Double)_plotUnitsPerInch / _unitsPerInch;
            scaleY = (Double)_plotUnitsPerInch / _unitsPerInch;

            boxX      = 0;
            boxY      = 0;
            boxWidth  = (Int16)(_logPageWidth);
            boxHeight = (Int16)(_logPageHeight);

            PCLWriter.pictureFrame(prnWriter,
                                   boxX,
                                   boxY,
                                   boxHeight,
                                   boxWidth);

            PCLWriter.modeHPGL2(prnWriter, false, false);

            PCLWriter.cmdHPGL2(prnWriter, "IN", "", false);
            PCLWriter.cmdHPGL2(prnWriter, "SP", "1", true);
            PCLWriter.cmdHPGL2(prnWriter, "DT", "~", false);

            PCLWriter.cmdHPGL2(prnWriter, "SC",
                               "0," + scaleX.ToString("F4") +
                               ",0," + (-scaleY).ToString("F4") +
                               ",2",
                               false);

            PCLWriter.cmdHPGL2(prnWriter, "IR", "0,100,100,0", false);
            PCLWriter.cmdHPGL2(prnWriter, "PU", "0,0", true);

            PCLWriter.modePCL(prnWriter, true);

            //----------------------------------------------------------------//
            //                                                                //
            // Rotated text.                                                  //
            //                                                                //
            //----------------------------------------------------------------//

            ptSize = 36;

            PCLWriter.font(prnWriter, true, "19U",
                           PCLFonts.getPCLFontSelect(_indxFontArial,
                                                     PCLFonts.eVariant.Regular,
                                                     ptSize, 0));

            //----------------------------------------------------------------//
            // Orthogonal text                                                //
            //----------------------------------------------------------------//

            posX = (Int16)(_posXData1 - logXOffset);
            posY = _posYData1;

            posX += _lineInc / 4;

            PCLWriter.printDirection(prnWriter, 0);

            PCLWriter.textRotated(prnWriter, posX, posY, 0, 0, true,
                                  "angle 0");

            posX -= _lineInc / 2;

            PCLWriter.textRotated(prnWriter, posX, posY, 0, 180, true,
                                  "ccw 180");

            posX += _lineInc / 4;
            posY -= _lineInc / 4;

            PCLWriter.textRotated(prnWriter, posX, posY, 0, 90, true,
                                  "ccw 90");

            posY += _lineInc / 2;

            PCLWriter.textRotated(prnWriter, posX, posY, 0, 270, true,
                                  "ccw 270");

            //----------------------------------------------------------------//
            // direction quadrants I and III                                  //
            //----------------------------------------------------------------//

            posX = (Int16)(_posXData2 - logXOffset);
            posY = _posYData2;

            PCLWriter.modeHPGL2(prnWriter, false, false);

            PCLWriter.cmdHPGL2(prnWriter, "SD",
                               PCLFonts.getHPGL2FontDef(_indxFontArial,
                                                        PCLFonts.eVariant.Regular,
                                                        14, ptSize, 0),
                               true);

            PCLWriter.cmdHPGL2(prnWriter, "PA",
                               posX.ToString() + "," +
                               posY.ToString(), false);

            degrees  = 30;
            angle    = Math.PI * degrees / 180.0;
            sinAngle = Math.Sin(angle);
            cosAngle = Math.Cos(angle);

            PCLWriter.cmdHPGL2(prnWriter, "DI",
                               cosAngle.ToString() + "," +
                               sinAngle.ToString(), false);

            PCLWriter.cmdHPGL2(prnWriter, "LB",
                               "angle +30" + lbCRTerm, true);

            PCLWriter.cmdHPGL2(prnWriter, "DI",
                               "-" + cosAngle.ToString() + "," +
                               "-" + sinAngle.ToString(), false);

            PCLWriter.cmdHPGL2(prnWriter, "LB",
                               "angle +210" + lbCRTerm, true);

            //----------------------------------------------------------------//
            // direction quadrants II and IV                                  //
            //----------------------------------------------------------------//

            posX = (Int16)(_posXData2 - logXOffset - ((1 * _incInch) / 4));

            PCLWriter.modeHPGL2(prnWriter, false, false);

            PCLWriter.cmdHPGL2(prnWriter, "SD",
                               PCLFonts.getHPGL2FontDef(_indxFontArial,
                                                        PCLFonts.eVariant.Regular,
                                                        14, ptSize, 0),
                               true);

            PCLWriter.cmdHPGL2(prnWriter, "PA",
                               posX.ToString() + "," +
                               posY.ToString(), false);

            degrees  = 45;
            angle    = Math.PI * degrees / 180.0;
            sinAngle = Math.Sin(angle);
            cosAngle = Math.Cos(angle);

            PCLWriter.cmdHPGL2(prnWriter, "DI",
                               "-" + cosAngle.ToString() + "," +
                               sinAngle.ToString(), false);

            PCLWriter.cmdHPGL2(prnWriter, "LB",
                               "angle +135" + lbCRTerm, true);

            posX += ((1 * _incInch) / 2);
            posY += ((_lineInc * 1) / 6);

            PCLWriter.cmdHPGL2(prnWriter, "PA",
                               posX.ToString() + "," +
                               posY.ToString(), false);

            PCLWriter.cmdHPGL2(prnWriter, "DI",
                               cosAngle.ToString() + "," +
                               "-" + sinAngle.ToString(), false);

            PCLWriter.cmdHPGL2(prnWriter, "LB",
                               "angle +315" + lbCRTerm, true);

            //----------------------------------------------------------------//
            // resets                                                         //
            //----------------------------------------------------------------//

            posX  = (Int16)(_posXData2 - logXOffset);
            posY += ((_lineInc * 1) / 2);

            PCLWriter.cmdHPGL2(prnWriter, "DI", "1,0", false);

            //----------------------------------------------------------------//

            PCLWriter.formFeed(prnWriter);
        }
コード例 #2
0
        //--------------------------------------------------------------------//
        //                                                        M e t h o d //
        // g e n e r a t e P a g e                                            //
        //--------------------------------------------------------------------//
        //                                                                    //
        // Write individual test data page sequences to output file.          //
        //                                                                    //
        //--------------------------------------------------------------------//

        private static void generatePage(BinaryWriter prnWriter,
                                         Int32 indxPaperSize,
                                         Int32 indxPaperType,
                                         Int32 indxOrientation,
                                         Boolean formAsMacro,
                                         UInt16 logXOffset)
        {
            String sampleText = "0123456789";
            String lbTerm     = "~";

            Int16 posX,
                  posY;

            Int16 ptSize,
                  degrees;

            Int16 boxX,
                  boxY,
                  boxHeight,
                  boxWidth;

            Double scaleX,
                   scaleY;

            Double angle,
                   tanAngle;

            //----------------------------------------------------------------//

            if (formAsMacro)
            {
                PCLWriter.macroControl(prnWriter, _macroId,
                                       PCLWriter.eMacroControl.Call);
            }
            else
            {
                generateOverlay(prnWriter, false, logXOffset,
                                indxPaperSize, indxOrientation);
            }

            //----------------------------------------------------------------//
            //                                                                //
            // HP-GL/2 picture frame and initialisation.                      //
            //                                                                //
            // Plotter units are always absolute at 0.025mm (1/1016 inch),    //
            // but many HP-GL/2 commands use (definable) user units.          //
            // It makes the code clearer if we use the same units in HP-GL/2  //
            // as we do in PCL, so the SC (scale) command is used to set      //
            // user-units to 600 units-per-inch.                              //
            //                                                                //
            // Note that the default HP-GL/2 Y-axis has its origin at         //
            // lower-left of the picture frame, and Y-coordinate values       //
            // increase UP the page, whilst the PCL Y-axis has its origin at  //
            // the top margin and Y-coordinate values increase DOWN the page. //
            //                                                                //
            // It is possible to use the same (600 upi) coordinates as PCL by //
            // using:                                                         //
            //  SC0,1.6933,0,-1.6933,2                                        //
            //  IR0,100,100,0                                                 //
            // Note that the IR coordinates shown in the example in the "PCL  //
            // Technical Reference" manual are different and are incorrect!   //
            // One drawback to using the same origin and axis direction is    //
            // that some commands (such as SR) then have to use negative      //
            // Y-values to avoid mirroring.                                   //
            //                                                                //
            //----------------------------------------------------------------//

            scaleX = (Double)_plotUnitsPerInch / _unitsPerInch;
            scaleY = (Double)_plotUnitsPerInch / _unitsPerInch;

            boxX      = 0;
            boxY      = 0;
            boxWidth  = (Int16)(_logPageWidth);
            boxHeight = (Int16)(_logPageHeight);

            PCLWriter.pictureFrame(prnWriter,
                                   boxX,
                                   boxY,
                                   boxHeight,
                                   boxWidth);

            PCLWriter.modeHPGL2(prnWriter, false, false);

            PCLWriter.cmdHPGL2(prnWriter, "IN", "", false);
            PCLWriter.cmdHPGL2(prnWriter, "SP", "1", true);
            PCLWriter.cmdHPGL2(prnWriter, "DT", "~", false);

            PCLWriter.cmdHPGL2(prnWriter, "SC",
                               "0," + scaleX.ToString("F4") +
                               ",0," + (-scaleY).ToString("F4") +
                               ",2",
                               false);

            PCLWriter.cmdHPGL2(prnWriter, "IR", "0,100,100,0", false);
            PCLWriter.cmdHPGL2(prnWriter, "PU", "0,0", true);

            PCLWriter.modePCL(prnWriter, true);

            //----------------------------------------------------------------//
            //                                                                //
            // Descriptive text.                                              //
            //                                                                //
            //----------------------------------------------------------------//

            ptSize = 18;

            PCLWriter.font(prnWriter, true, "19U",
                           PCLFonts.getPCLFontSelect(_indxFontCourier,
                                                     PCLFonts.eVariant.Regular,
                                                     ptSize, 0));

            posX = (Int16)(_posXData1 - logXOffset);
            posY = _posYDesc;

            posY += _lineInc;

            PCLWriter.text(prnWriter, posX, posY, 0,
                           "Arial");

            posY += _lineInc;

            PCLWriter.text(prnWriter, posX, posY, 0,
                           "");

            posY += _lineInc;

            PCLWriter.text(prnWriter, posX, posY, 0,
                           "");

            posY += _lineInc;

            PCLWriter.text(prnWriter, posX, posY, 0,
                           "+30");

            posY += _lineInc;

            PCLWriter.text(prnWriter, posX, posY, 0,
                           "-45");

            posY += _lineInc;

            PCLWriter.text(prnWriter, posX, posY, 0,
                           "+ve");

            posY += _lineInc;

            PCLWriter.text(prnWriter, posX, posY, 0,
                           "-ve");

            //----------------------------------------------------------------//
            //                                                                //
            // Embellished text.                                              //
            //                                                                //
            //----------------------------------------------------------------//

            ptSize = 36;

            posX = (Int16)(_posXData2 - logXOffset);
            posY = _posYData;

            //----------------------------------------------------------------//
            // standard                                                       //
            //----------------------------------------------------------------//

            posY += _lineInc;

            PCLWriter.modeHPGL2(prnWriter, false, false);

            PCLWriter.cmdHPGL2(prnWriter, "SD",
                               PCLFonts.getHPGL2FontDef(_indxFontArial,
                                                        PCLFonts.eVariant.Regular,
                                                        14, ptSize, 0),
                               true);

            PCLWriter.cmdHPGL2(prnWriter, "PA",
                               posX.ToString() + "," +
                               posY.ToString(), false);

            PCLWriter.cmdHPGL2(prnWriter, "LB", sampleText + lbTerm, true);

            //----------------------------------------------------------------//
            // size X                                                         //
            //----------------------------------------------------------------//

            posY += _lineInc;

            PCLWriter.cmdHPGL2(prnWriter, "SD",
                               PCLFonts.getHPGL2FontDef(_indxFontArial,
                                                        PCLFonts.eVariant.Regular,
                                                        14, ptSize, 0),
                               true);

            PCLWriter.cmdHPGL2(prnWriter, "PA",
                               posX.ToString() + "," +
                               posY.ToString(), false);

            PCLWriter.cmdHPGL2(prnWriter, "SR", "4,-3", true);

            PCLWriter.cmdHPGL2(prnWriter, "LB", sampleText + lbTerm, true);

            PCLWriter.cmdHPGL2(prnWriter, "SR", "", true);

            //----------------------------------------------------------------//
            // size Y                                                         //
            //----------------------------------------------------------------//

            posY += _lineInc;

            PCLWriter.cmdHPGL2(prnWriter, "SD",
                               PCLFonts.getHPGL2FontDef(_indxFontArial,
                                                        PCLFonts.eVariant.Regular,
                                                        14, ptSize, 0),
                               true);

            PCLWriter.cmdHPGL2(prnWriter, "PA",
                               posX.ToString() + "," +
                               posY.ToString(), false);

            PCLWriter.cmdHPGL2(prnWriter, "SR", "3.2,-6", true);

            PCLWriter.cmdHPGL2(prnWriter, "LB", sampleText + lbTerm, true);

            PCLWriter.cmdHPGL2(prnWriter, "SI", "", true);

            //----------------------------------------------------------------//
            // slant X positive                                               //
            //----------------------------------------------------------------//

            posY += _lineInc;

            PCLWriter.cmdHPGL2(prnWriter, "SD",
                               PCLFonts.getHPGL2FontDef(_indxFontArial,
                                                        PCLFonts.eVariant.Regular,
                                                        14, ptSize, 0),
                               true);

            PCLWriter.cmdHPGL2(prnWriter, "PA",
                               posX.ToString() + "," +
                               posY.ToString(), false);

            degrees  = 30;
            angle    = Math.PI * degrees / 180.0;
            tanAngle = Math.Tan(angle);

            PCLWriter.cmdHPGL2(prnWriter, "SL",
                               tanAngle.ToString(), false);

            PCLWriter.cmdHPGL2(prnWriter, "LB", sampleText + lbTerm, true);

            //----------------------------------------------------------------//
            // slant X negative                                               //
            //----------------------------------------------------------------//

            posY += _lineInc;

            PCLWriter.cmdHPGL2(prnWriter, "SD",
                               PCLFonts.getHPGL2FontDef(_indxFontArial,
                                                        PCLFonts.eVariant.Regular,
                                                        14, ptSize, 0),
                               true);

            PCLWriter.cmdHPGL2(prnWriter, "PA",
                               posX.ToString() + "," +
                               posY.ToString(), false);

            degrees  = 45;
            angle    = Math.PI * degrees / 180.0;
            tanAngle = Math.Tan(angle);

            PCLWriter.cmdHPGL2(prnWriter, "SL",
                               "-" + tanAngle.ToString(), false);

            PCLWriter.cmdHPGL2(prnWriter, "LB", sampleText + lbTerm, true);

            PCLWriter.cmdHPGL2(prnWriter, "SL", "0", false);

            //----------------------------------------------------------------//
            // extra space X positive                                         //
            //----------------------------------------------------------------//

            posY += _lineInc;

            PCLWriter.cmdHPGL2(prnWriter, "SD",
                               PCLFonts.getHPGL2FontDef(_indxFontArial,
                                                        PCLFonts.eVariant.Regular,
                                                        14, ptSize, 0),
                               true);

            PCLWriter.cmdHPGL2(prnWriter, "PA",
                               posX.ToString() + "," +
                               posY.ToString(), false);

            PCLWriter.cmdHPGL2(prnWriter, "ES", ".2,0", false);

            PCLWriter.cmdHPGL2(prnWriter, "LB", sampleText + lbTerm, true);

            //----------------------------------------------------------------//
            // extra space X negative                                         //
            //----------------------------------------------------------------//

            posY += _lineInc;

            PCLWriter.cmdHPGL2(prnWriter, "SD",
                               PCLFonts.getHPGL2FontDef(_indxFontArial,
                                                        PCLFonts.eVariant.Regular,
                                                        14, ptSize, 0),
                               true);

            PCLWriter.cmdHPGL2(prnWriter, "PA",
                               posX.ToString() + "," +
                               posY.ToString(), false);

            PCLWriter.cmdHPGL2(prnWriter, "ES", "-.1,0", false);

            PCLWriter.cmdHPGL2(prnWriter, "LB", sampleText + lbTerm, true);

            //----------------------------------------------------------------//

            PCLWriter.modePCL(prnWriter, true);

            PCLWriter.formFeed(prnWriter);
        }