View HPGL PlotfileDoc.cpp:
// 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
View HPGL PlotfileView.cpp:
// 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
char cBuffer[100000000]; // grosse Speicher
int nFileSize;
char *ptr1;
char *ptr1ende;
int stiftx = 0; //0= Stift oben 1= Stift unten
char cZeile[100]; //kleine Speicher
char *ptr2;
int xx, yy, aa, bb;
// CViewHPGLPlotfileView
IMPLEMENT_DYNCREATE(CViewHPGLPlotfileView, CView)
BEGIN_MESSAGE_MAP(CViewHPGLPlotfileView, CView)
END_MESSAGE_MAP()
// CViewHPGLPlotfileView construction/destruction
CViewHPGLPlotfileView::CViewHPGLPlotfileView()
{
// TODO: add construction code here
}
CViewHPGLPlotfileView::~CViewHPGLPlotfileView()
{
}
BOOL CViewHPGLPlotfileView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
// CViewHPGLPlotfileView drawing
void CViewHPGLPlotfileView::OnDraw(CDC* pDC) // pointer freimachen
{
CViewHPGLPlotfileDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
if (!pDoc)
return;
// Anzeigen dass Datei geladen ist!
if(nFileSize==0) return;
CString str1;
str1.Format("File open %d %X", nFileSize, nFileSize);
pDC->TextOut(800,75,str1);
// scan in the buffer
ptr1 = &cBuffer[0];
ptr1ende = ptr1 + nFileSize; //Pointer are set
while(ptr1 < ptr1ende)
{
ptr2 = &cZeile[0]; // ptr2 on top of the small memory
while(*ptr1 != ';') *ptr2++ = *ptr1++;
{
// while the volume (the byte) irregular Solange der Inhalt (das Byte) wo ptr1 hinzeigt ungleich dem Strichpunkt
// lade in die Adresse wo ptr2 hinzeigt, den Inhalt von wo ptr1 hinzeigt
// PlusPlus am Ende erhöht die Zeiger
ptr1++; // Den Strich überspringen
// ====Daten sind im kleinem Speicher====
*ptr2=NULL; //Daten abgrenzen
if(cZeile[0]=='P') // Auswertung nur wenn der erste Buchstabe ein 'P' ist
{
if(cZeile[1]== 'U') stiftx = 0;
if(cZeile[1]== 'D') stiftx = 1;
if(cZeile[1]== 'A')
{
sscanf(cZeile,"PA%d,%d", &aa, &bb); aa/=20; bb/=20;
xx=800-aa;
yy=600-bb;
if(stiftx == 0) pDC->MoveTo(xx,yy);
else pDC->LineTo(xx,yy);
}// Ende wenn 'A'
}//Ende wenn erster Buchstabe 'P'
} // End of ptr1
}
pDC->TextOut(800,100,"File loaded");
}
// CViewHPGLPlotfileView diagnostics
#ifdef _DEBUG
void CViewHPGLPlotfileView::AssertValid() const
{
CView::AssertValid();
}
void CViewHPGLPlotfileView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CViewHPGLPlotfileDoc* CViewHPGLPlotfileView::GetDocument() const // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CViewHPGLPlotfileDoc)));
return (CViewHPGLPlotfileDoc*)m_pDocument;
}
#endif //_DEBUG
// CViewHPGLPlotfileView message handlers