
The content in the file are a lot of coordinates (x and y).
You only have to evaluate it. How? You can do step by step
with the instructions on the left side...
The HPGL File you can download on this link:
Download the HPGL Plotfile (16,0 Kbyte)
// View HPGL PlotfileDoc.cpp : implementation of the CViewHPGLPlotfileDoc class #include "stdafx.h" #include "View HPGL Plotfile.h" #include "View HPGL PlotfileDoc.h" #ifdef _DEBUG #define new DEBUG_NEW #endif char cBuffer[1000000]; // big memory for the whole HPGL File int nFileSize; // the lenght of the file
void CosciDoc::Serialize(CArchive& ar) { if (ar.IsStoring()) { // TODO: add storing code here } else { // TODO: add loading code here nFileSize = ar.Read(cBuffer,100000); //here you have to insert the line //with this line the program read the file } }
// View HPGL PlotfileView.cpp : implementation of the CViewHPGLPlotfileView class #include "stdafx.h" #include "View HPGL Plotfile.h" #include "View HPGL PlotfileDoc.h" #include "View HPGL PlotfileView.h" #ifdef _DEBUG #define new DEBUG_NEW #endif extern char cBuffer[1000000]; // big memory from View HPGL PlotfileDoc.cpp declared as extern extern int nFileSize; //the lenght of the file from View HPGL PlotfileDoc.cpp declared as extern char *ptr1,*ptr1end; //pointers who read the lenght of the file char cLine[100]; //little memory to scan only pieces from the file char *ptr2; //pointer who takes the values into the little memory int penx = 0; //you need this one at the end for draw int xx, yy, aa, bb; //variables for draw
void CViewHPGLPlotfileView::OnDraw(CDC* /*pDC*/)
void CViewHPGLPlotfileView::OnDraw(CDC* pDC)
write this lines into the position at point 7 ptr1 = &cBuffer[0]; ptr1end = ptr1 + nFileSize; //Pointer are set
write this lines after you have set the pointers while(ptr1 < ptr1end) { ptr2 = &cLine[0]; // ptr2 on top of the small memory while(*ptr1 != ';') *ptr2++ = *ptr1++; // while the volume (the byte) irregular; while ptr1 unequal ";" load the adress from ptr2 // a plus at the end increments the pointer { ptr1++; // jump over the semicolon // ====files are in the small memory==== *ptr2=NULL; //mark off the files if(cLine[0]=='P') // evaluation only when the first letter is a 'P' { if(cLine[1]== 'U') penx = 0; //if the first letter is an 'U' pen x = 0 (move to) if(cLine[1]== 'D') penx = 1; //if the first letter is an 'D' pen x = 1 (line to) if(cLine[1]== 'A') //if the first letter is an 'A' the linescan can begin { sscanf(cLine,"PA%d,%d", &aa, &bb); aa/=20; bb/=20;//scan the line(line,"how exactly looks the line",make aa & bb looks like the coordinats) xx=800-aa; //move the picture in x-direction yy=600-bb; //move the picture in y-direction if(penx == 0) pDC->MoveTo(xx,yy);//move to the coordinats xx,yy only when penx=0 else pDC->LineTo(xx,yy);//line to the coordinats xx,yy only when penx=! }//end when 'A' }//end when first letter = 'P' }// End of ptr1 }
// View HPGL PlotfileDoc.cpp : implementation of the CViewHPGLPlotfileDoc class // #include "stdafx.h" #include "View HPGL Plotfile.h" #include "View HPGL PlotfileDoc.h" #ifdef _DEBUG #define new DEBUG_NEW #endif extern char cBuffer[]; // grosse Speicher extern int nFileSize; // CViewHPGLPlotfileDoc IMPLEMENT_DYNCREATE(CViewHPGLPlotfileDoc, CDocument) BEGIN_MESSAGE_MAP(CViewHPGLPlotfileDoc, CDocument) END_MESSAGE_MAP() // CViewHPGLPlotfileDoc construction/destruction CViewHPGLPlotfileDoc::CViewHPGLPlotfileDoc() { // TODO: add one-time construction code here } CViewHPGLPlotfileDoc::~CViewHPGLPlotfileDoc() { } BOOL CViewHPGLPlotfileDoc::OnNewDocument() { if (!CDocument::OnNewDocument()) return FALSE; // TODO: add reinitialization code here // (SDI documents will reuse this document) return TRUE; } // CViewHPGLPlotfileDoc serialization void CViewHPGLPlotfileDoc::Serialize(CArchive& ar) { if (ar.IsStoring()) { // TODO: add storing code here } else { nFileSize = ar.Read(cBuffer,5000000); // TODO: add loading code here } } // CViewHPGLPlotfileDoc diagnostics #ifdef _DEBUG void CViewHPGLPlotfileDoc::AssertValid() const { CDocument::AssertValid(); } void CViewHPGLPlotfileDoc::Dump(CDumpContext& dc) const { CDocument::Dump(dc); } #endif //_DEBUG // CViewHPGLPlotfileDoc commands