www.pudn.com > Mandelbrotandjuliashengcheng.rar > MandelbrotView.cpp
// MandelbrotView.cpp : implementation of the CMandelbrotView class
//
#include "stdafx.h"
#include "Mandelbrot.h"
#include "math.h"
#include "MandelbrotDoc.h"
#include "MandelbrotView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMandelbrotView
IMPLEMENT_DYNCREATE(CMandelbrotView, CView)
BEGIN_MESSAGE_MAP(CMandelbrotView, CView)
//{{AFX_MSG_MAP(CMandelbrotView)
ON_COMMAND(ID_mandelbrot,OnMandelbrot)
ON_COMMAND(ID_julia,OnJulia)
ON_COMMAND(ID_mandelbrot3,OnMandelbrot3)
ON_COMMAND(ID_julia3,OnJulia3)
ON_COMMAND(ID_mandelbrot4,OnMandelbrot4)
ON_COMMAND(ID_julia4,OnJulia4)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMandelbrotView construction/destruction
CMandelbrotView::CMandelbrotView()
{
// TODO: add construction code here
}
CMandelbrotView::~CMandelbrotView()
{
}
BOOL CMandelbrotView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CMandelbrotView drawing
void CMandelbrotView::OnDraw(CDC* pDC)
{
CMandelbrotDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
}
/////////////////////////////////////////////////////////////////////////////
// CMandelbrotView printing
BOOL CMandelbrotView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CMandelbrotView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CMandelbrotView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CMandelbrotView diagnostics
#ifdef _DEBUG
void CMandelbrotView::AssertValid() const
{
CView::AssertValid();
}
void CMandelbrotView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CMandelbrotDoc* CMandelbrotView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMandelbrotDoc)));
return (CMandelbrotDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMandelbrotView message handlers
void CMandelbrotView::OnMandelbrot(CDC *CDC)
{
CClientDC *pdc=new CClientDC(this);
CPen *pen1=new CPen(PS_DOT,1,RGB(0,0,0));
CPen *oldpen=(CPen*)pdc->SelectObject(pen1);
float Pmax=3.5,Pmin=-2.5,Qmax=4.2,Qmin=-1.2,x0,y0,xk,yk,r,p0,q0,dp,dq;
int K=20,k,M=100,a=1000,b=1000,np,nq,R,G,B;
dp=(Pmax-Pmin)/(a-1);
dq=(Qmax-Qmin)/(b-1);
for (np=0;npM){
R=0;G=255;B=0;
goto loop2;}
if(k==K){
R=0;G=0;B=0;
goto loop2;}
if(r<=M &&kSetPixelV(np,nq,RGB(R,G,B));
}
}
}
void CMandelbrotView::OnJulia(CDC *CDC)
{
CClientDC *pdc=new CClientDC(this);
CPen *pen1=new CPen(PS_DOT,1,RGB(0,0,0));
CPen *oldpen=(CPen*)pdc->SelectObject(pen1);
float Xmax=3.5,Xmin=-2.5,Ymax=4.2,Ymin=-1.2,x0,y0,xk,yk,r,p0,q0,dx,dy;
int K=20,k,M=100,a=1000,b=1000,nx,ny,R,G,B;
p0=-1.25;
q0=-0.01;
dx=(Xmax-Xmin)/(a-1);
dy=(Ymax-Ymin)/(b-1);
for (nx=0;nxM){
R=0;G=255;B=0;
goto loop2;}
if(k==K){
R=0;G=0;B=0;
goto loop2;}
if(r<=M &&kSetPixelV(nx,ny,RGB(R,G,B));
}
}
}
void CMandelbrotView::OnMandelbrot3(CDC *CDC)
{
CClientDC *pdc=new CClientDC(this);
CPen *pen1=new CPen(PS_DOT,1,RGB(0,0,0));
CPen *oldpen=(CPen*)pdc->SelectObject(pen1);
float Pmax=3.5,Pmin=-2.5,Qmax=4.2,Qmin=-1.2,x0,y0,xk,yk,r,p0,q0,dp,dq;
int K=20,k,M=100,a=1000,b=1000,np,nq,R,G,B;
dp=(Pmax-Pmin)/(a-1);
dq=(Qmax-Qmin)/(b-1);
for (np=0;npM){
R=0;G=255;B=0;
goto loop2;}
if(k==K){
R=0;G=0;B=0;
goto loop2;}
if(r<=M &&kSetPixelV(np,nq,RGB(R,G,B));
}
}
}
void CMandelbrotView::OnJulia3(CDC *CDC)
{
CClientDC *pdc=new CClientDC(this);
CPen *pen1=new CPen(PS_DOT,1,RGB(0,0,0));
CPen *oldpen=(CPen*)pdc->SelectObject(pen1);
float Xmax=3.5,Xmin=-2.5,Ymax=4.2,Ymin=-1.2,x0,y0,xk,yk,r,p0,q0,dx,dy;
int K=20,k,M=100,a=1000,b=1000,nx,ny,R,G,B;
p0=-0.12;
q0=0.74;
dx=(Xmax-Xmin)/(a-1);
dy=(Ymax-Ymin)/(b-1);
for (nx=0;nxM){
R=0;G=255;B=0;
goto loop2;}
if(k==K){
R=0;G=0;B=0;
goto loop2;}
if(r<=M &&kSetPixelV(nx,ny,RGB(R,G,B));
}
}
}
void CMandelbrotView::OnMandelbrot4(CDC *CDC)
{
CClientDC *pdc=new CClientDC(this);
CPen *pen1=new CPen(PS_DOT,1,RGB(0,0,0));
CPen *oldpen=(CPen*)pdc->SelectObject(pen1);
float Pmax=3.5,Pmin=-2.5,Qmax=4.2,Qmin=-1.2,x0,y0,xk,yk,r,p0,q0,dp,dq;
int K=20,k,M=100,a=1000,b=1000,np,nq,R,G,B;
dp=(Pmax-Pmin)/(a-1);
dq=(Qmax-Qmin)/(b-1);
for (np=0;npM){
R=0;G=255;B=0;
goto loop2;}
if(k==K){
R=0;G=0;B=0;
goto loop2;}
if(r<=M &&kSetPixelV(np,nq,RGB(R,G,B));
}
}
}
void CMandelbrotView::OnJulia4(CDC *CDC)
{
CClientDC *pdc=new CClientDC(this);
CPen *pen1=new CPen(PS_DOT,1,RGB(0,0,0));
CPen *oldpen=(CPen*)pdc->SelectObject(pen1);
float Xmax=3.5,Xmin=-2.5,Ymax=4.2,Ymin=-1.2,x0,y0,xk,yk,r,p0,q0,dx,dy;
int K=20,k,M=100,a=1000,b=1000,nx,ny,R,G,B;
p0=-0.12;
q0=0.74;
dx=(Xmax-Xmin)/(a-1);
dy=(Ymax-Ymin)/(b-1);
for (nx=0;nxM){
R=0;G=255;B=0;
goto loop2;}
if(k==K){
R=0;G=0;B=0;
goto loop2;}
if(r<=M &&kSetPixelV(nx,ny,RGB(R,G,B));
}
}
}