Sei sulla pagina 1di 5

Lucrare de laborator nr.

1
*****************************************************************************************
Varianta 3.21
n

1+ x
x2 k1
ln =
=
, x(1,1)
1x k=1 2 k 1
****************************************************************************************
// secondView.cpp : implementation of the CsecondView class
//
#include "stdafx.h"
// SHARED_HANDLERS can be defined in an ATL project implementing preview, thumbnail
// and search filter handlers and allows sharing of document code with that project.
#ifndef SHARED_HANDLERS
#include "second.h"
#include "stdafx.h"
#endif
#include "secondDoc.h"
#include "secondView.h"
#include "math.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// CsecondView
IMPLEMENT_DYNCREATE(CsecondView, CView)
BEGIN_MESSAGE_MAP(CsecondView, CView)
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, &CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, &CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, &CsecondView::OnFilePrintPreview)
ON_WM_CONTEXTMENU()
ON_WM_RBUTTONUP()
END_MESSAGE_MAP()
// CsecondView construction/destruction
CsecondView::CsecondView()
{
// TODO: add construction code here
}
CsecondView::~CsecondView()
{
}
BOOL CsecondView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
}

return CView::PreCreateWindow(cs);

// CsecondView drawing
double var22(double x, double e) {
int k;
double t, s;
k = 1;
t=s=x;
for(k = 2; k <= 100; k++){
t *= ((2 *k - 3)*x *x )/(2*k-1);
s += t;
}
return s;
}
void CsecondView::OnDraw(CDC* pDC)
{
CsecondDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
if (!pDoc)
return;
// TODO: add draw code for native data here
/*pDC -> SetPixel(90, 100, RGB(200, 0, 0));
pDC -> MoveTo(150, 150);
pDC -> LineTo(370, 400);
CPen penP1(PS_SOLID, 5, RGB(200, 150, 180)); //am creat o penita
pDC -> SelectObject(&penP1); //am selectat penita
pDC -> LineTo(150, 600);*/

///////////////////desenam axa Ox/////////////////////////


CRect rcClient; //am creat un dreptunghi cu numele Client
GetClientRect(&rcClient);
CPen penAxe(PS_SOLID, 1, RGB(0, 0, 0)); // am creat o penita
CPen penFun(PS_SOLID, 2, RGB(0, 0, 200));
pDC -> SelectObject(&penAxe); // am selectat penita creata
pDC -> MoveTo(0, rcClient.CenterPoint().y); // am mutat cursorul pe coordonatele date
pDC -> LineTo(rcClient.Width(), rcClient.CenterPoint().y);
//Sageata Y
pDC->MoveTo(rcClient.CenterPoint().x,0);
pDC->LineTo(rcClient.CenterPoint().x-5,10);
pDC->MoveTo(rcClient.CenterPoint().x,0);
pDC->LineTo(rcClient.CenterPoint().x+5,10);
//Sageata X
pDC->MoveTo(rcClient.Width(),rcClient.CenterPoint().y);
pDC->LineTo(rcClient.Width()-10,rcClient.CenterPoint().y-5);
pDC->MoveTo(rcClient.Width(),rcClient.CenterPoint().y);
pDC->LineTo(rcClient.Width()-10,rcClient.CenterPoint().y+5);

///////////////////desenam axa Oy/////////////////////////


pDC -> MoveTo(rcClient.CenterPoint().x, 0);
pDC -> LineTo(rcClient.CenterPoint().x, rcClient.Height());
double x, y, a = -1, b = 1, s = 0.0025, scx = 40.0, scy1 = 40.0, scy = 100.0, e = 0.0001;

////////segmente x////////////////
double depl=scx;
while (depl<=rcClient.Width()){
pDC->MoveTo(rcClient.CenterPoint().x+depl,rcClient.CenterPoint().y-5);
pDC->LineTo(rcClient.CenterPoint().x+depl,rcClient.CenterPoint().y+5);
pDC->MoveTo(rcClient.CenterPoint().x-depl,rcClient.CenterPoint().y-5);
pDC->LineTo(rcClient.CenterPoint().x-depl,rcClient.CenterPoint().y+5);
depl+=scx;
}

//////////segmente y////////////////
depl=scy1;
while (depl<=rcClient.Height()-5){
pDC->MoveTo(rcClient.CenterPoint().x-5,rcClient.CenterPoint().y-depl);
pDC->LineTo(rcClient.CenterPoint().x+5,rcClient.CenterPoint().y-depl);
pDC->MoveTo(rcClient.CenterPoint().x-5,rcClient.CenterPoint().y+depl);
pDC->LineTo(rcClient.CenterPoint().x+5,rcClient.CenterPoint().y+depl);
depl+=scy1;
}

x = a;
while(x < b) {
y = log((1 + x)/(1-x));
pDC -> SetPixel(rcClient.CenterPoint().x + (int)(x * scx), rcClient.CenterPoint().y - (int)
(y * scy),RGB(200, 0, 0));
x += s;
}
x = a;
pDC -> SelectObject(&penFun);
while(x < b){
y = var22(x, e)*1.5 ;
pDC -> LineTo(rcClient.CenterPoint().x + (int)(x * scx), rcClient.CenterPoint().y - (int)(y
* scy));
}

x += s;
}

// CsecondView printing
void CsecondView::OnFilePrintPreview()
{
#ifndef SHARED_HANDLERS
AFXPrintPreview(this);
#endif
}
BOOL CsecondView::OnPreparePrinting(CPrintInfo* pInfo)

{
}

// default preparation
return DoPreparePrinting(pInfo);

void CsecondView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)


{
// TODO: add extra initialization before printing
}
void CsecondView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
void CsecondView::OnRButtonUp(UINT /* nFlags */, CPoint point)
{
ClientToScreen(&point);
OnContextMenu(this, point);
}
void CsecondView::OnContextMenu(CWnd* /* pWnd */, CPoint point)
{
#ifndef SHARED_HANDLERS
theApp.GetContextMenuManager()->ShowPopupMenu(IDR_POPUP_EDIT, point.x, point.y, this,
TRUE);
#endif
}
// CsecondView diagnostics
#ifdef _DEBUG
void CsecondView::AssertValid() const
{
CView::AssertValid();
}
void CsecondView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CsecondDoc* CsecondView::GetDocument() const // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CsecondDoc)));
return (CsecondDoc*)m_pDocument;
}
#endif //_DEBUG
// CsecondView message handlers

Rezultatul:

Potrebbero piacerti anche