Jayhoonova
19/04/2005, 10:00
Merhaba
Ben C/C++ Bilmiyorum ancak elimde veritabanından gelen bir veri var ve bu veri C koduna girip bir şekilde çıkarken grafik çiziyor... Ben bu grafiğin aynısını php de çıkartmak istiyorum. Çizim ile ilgili php de tek ihtiyacım olan verilerin düzgün şekilde php de değişkenime vermek... Ancak C de gelen kodun nasıl bir mantıkla çevrilip anlamlı bir X,Y koordinatına geldiğini halen çözemedim...
Aşağıda vereceğim kodlara biraz bakıp Bu gelen verinin x, y olarak neleri verdiğini söyleyebilir misiniz? Ben de php de ona göre anlamlı birşey yazayım
gelen veri : 80210021002100210022002300250025002600260026002700 28002B002C002E0030003100340036003A003F00420047004B 00500055005B00600068006F0078007F00880090009800A000 A900B100B900C100C900D000D700DE00E500EB00F000F700FC 01010105010A010F01140119011F012901390154018401DF02 7D0377
Yorumlayan kod
void COrnekTakipElekroForez::GrafikYazdir()
{
if (GragikLog.IsEmpty())
return;
int FrantionCount = 0;
POINT Fraktion [10] ;
POINT apt [300] ;
int KY = 0;
CString Str;
Str.Format("%d",currsatir);
int j = 0;
int x = 150;
for (int i = 0; i < 1200 ; i = i + 4,j++)
{
CString Fraction = GragikLog.Mid(i,1);
int Y = BBHexToInt(GragikLog.Mid(i + 1,3));
//CETDEGIS_AFTBRS_OK
//apt[j].y = currsatir + 1200 - Y / 3;
apt[j].y = currsatir + 1450 - Y / 3;
//CETDEGIS_AFTBRS_OK
apt[j].x = x;
x = x + 7;
if (KY < apt[j].y)
KY = apt[j].y;
if (Fraction[0] == '8' || Fraction[0] == 'C')
{
Fraktion[FrantionCount].y = apt[j].y;
Fraktion[FrantionCount].x = apt[j].x;
FrantionCount++;
}
}
CPen pen;
pen.CreatePen(PS_SOLID, 0,RGB(0,255,0));
CPen* pOldpen = PSS->dc->SelectObject(&pen);
for (i = 0; i < FrantionCount;i++)
{
PSS->dc->MoveTo(Fraktion[i].x,Fraktion[i].y);
PSS->dc->LineTo(Fraktion[i].x,KY + 30);
}
if (FrantionCount > 0)
{
PSS->dc->MoveTo(apt[0].x,KY);
PSS->dc->LineTo(Fraktion[FrantionCount - 1].x,KY);
}
PSS->dc->SelectObject(pOldpen);
PSS->dc->LPtoDP(apt, 300) ;
PSS->dc->Polyline (apt, 300);
//PSS->dc->LPtoDP(Fraktion, 10) ;
}
int BBHexToInt(CString& sHex)
{
if(sHex.IsEmpty())
return 0;
int dgr = 0;
for(int i = sHex.GetLength() - 1,j =0; i >= 0;--i,++j)
{
double dgr0 = pow((double)16,(double)i);
int dgr1;
if(sHex[j] >= '0' && sHex[j] <= '9')
dgr1 = sHex[j] - '0';
else
dgr1 = 10 + sHex[j] - 'A';
dgr += ((int)dgr0 * dgr1);
}
return dgr;
}
Ben C/C++ Bilmiyorum ancak elimde veritabanından gelen bir veri var ve bu veri C koduna girip bir şekilde çıkarken grafik çiziyor... Ben bu grafiğin aynısını php de çıkartmak istiyorum. Çizim ile ilgili php de tek ihtiyacım olan verilerin düzgün şekilde php de değişkenime vermek... Ancak C de gelen kodun nasıl bir mantıkla çevrilip anlamlı bir X,Y koordinatına geldiğini halen çözemedim...
Aşağıda vereceğim kodlara biraz bakıp Bu gelen verinin x, y olarak neleri verdiğini söyleyebilir misiniz? Ben de php de ona göre anlamlı birşey yazayım
gelen veri : 80210021002100210022002300250025002600260026002700 28002B002C002E0030003100340036003A003F00420047004B 00500055005B00600068006F0078007F00880090009800A000 A900B100B900C100C900D000D700DE00E500EB00F000F700FC 01010105010A010F01140119011F012901390154018401DF02 7D0377
Yorumlayan kod
void COrnekTakipElekroForez::GrafikYazdir()
{
if (GragikLog.IsEmpty())
return;
int FrantionCount = 0;
POINT Fraktion [10] ;
POINT apt [300] ;
int KY = 0;
CString Str;
Str.Format("%d",currsatir);
int j = 0;
int x = 150;
for (int i = 0; i < 1200 ; i = i + 4,j++)
{
CString Fraction = GragikLog.Mid(i,1);
int Y = BBHexToInt(GragikLog.Mid(i + 1,3));
//CETDEGIS_AFTBRS_OK
//apt[j].y = currsatir + 1200 - Y / 3;
apt[j].y = currsatir + 1450 - Y / 3;
//CETDEGIS_AFTBRS_OK
apt[j].x = x;
x = x + 7;
if (KY < apt[j].y)
KY = apt[j].y;
if (Fraction[0] == '8' || Fraction[0] == 'C')
{
Fraktion[FrantionCount].y = apt[j].y;
Fraktion[FrantionCount].x = apt[j].x;
FrantionCount++;
}
}
CPen pen;
pen.CreatePen(PS_SOLID, 0,RGB(0,255,0));
CPen* pOldpen = PSS->dc->SelectObject(&pen);
for (i = 0; i < FrantionCount;i++)
{
PSS->dc->MoveTo(Fraktion[i].x,Fraktion[i].y);
PSS->dc->LineTo(Fraktion[i].x,KY + 30);
}
if (FrantionCount > 0)
{
PSS->dc->MoveTo(apt[0].x,KY);
PSS->dc->LineTo(Fraktion[FrantionCount - 1].x,KY);
}
PSS->dc->SelectObject(pOldpen);
PSS->dc->LPtoDP(apt, 300) ;
PSS->dc->Polyline (apt, 300);
//PSS->dc->LPtoDP(Fraktion, 10) ;
}
int BBHexToInt(CString& sHex)
{
if(sHex.IsEmpty())
return 0;
int dgr = 0;
for(int i = sHex.GetLength() - 1,j =0; i >= 0;--i,++j)
{
double dgr0 = pow((double)16,(double)i);
int dgr1;
if(sHex[j] >= '0' && sHex[j] <= '9')
dgr1 = sHex[j] - '0';
else
dgr1 = 10 + sHex[j] - 'A';
dgr += ((int)dgr0 * dgr1);
}
return dgr;
}