Permalink
Browse files

Beginning to refactor, split JuliaThread and MandelThread into sepera…

…te files.
  • Loading branch information...
ecordell committed Aug 17, 2009
1 parent d222bc1 commit db75b855325e6b49a79a1a584191891748c865b4
View
Binary file not shown.
View
Binary file not shown.
@@ -0,0 +1,15 @@
+<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
+<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>
+ <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
+ <security>
+ <requestedPrivileges>
+ <requestedExecutionLevel level='asInvoker' uiAccess='false' />
+ </requestedPrivileges>
+ </security>
+ </trustInfo>
+ <dependency>
+ <dependentAssembly>
+ <assemblyIdentity type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*' />
+ </dependentAssembly>
+ </dependency>
+</assembly>
Binary file not shown.
Binary file not shown.
View
Binary file not shown.
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
@@ -0,0 +1 @@
+Manifest resource last updated at 0:49:24.44 on Mon 08/17/2009
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
@@ -192,6 +192,14 @@
RelativePath="..\src\gradientdlg.cpp"
>
</File>
+ <File
+ RelativePath="..\src\JuliaThread.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\src\MandelThread.cpp"
+ >
+ </File>
</Filter>
<Filter
Name="Header Files"
@@ -214,6 +222,14 @@
RelativePath="..\src\gradientdlg.h"
>
</File>
+ <File
+ RelativePath="..\src\JuliaThread.h"
+ >
+ </File>
+ <File
+ RelativePath="..\src\MandelThread.h"
+ >
+ </File>
</Filter>
<Filter
Name="Resource Files"
View
@@ -22,9 +22,6 @@
*/
#include "ChaosToolsFrm.h"
-DEFINE_EVENT_TYPE(wxEVT_MTHREAD)
-DEFINE_EVENT_TYPE(wxEVT_JTHREAD)
-
BEGIN_EVENT_TABLE(ChaosToolsFrm,wxFrame)
EVT_COMMAND(wxID_ANY, wxEVT_MTHREAD, ChaosToolsFrm::OnMandelThread)
EVT_COMMAND(wxID_ANY, wxEVT_JTHREAD, ChaosToolsFrm::OnJuliaThread)
@@ -1318,231 +1315,6 @@ wxColour ChaosToolsFrm::getColour(double iter)
B *= 255.0F;
return wxColour((int)R,(int)G,(int)B);
}
-
-MandelThread::MandelThread(wxEvtHandler* pParent, int row, double &xmint, double &xmaxt, double &ymint, double &ymaxt, int &widtht, int &heightt, int &max) : wxThread(wxTHREAD_DETACHED), m_pParent(pParent)
-{
- width = widtht;
- height = heightt;
- xmin = xmint;
- xmax = xmaxt;
- ymin = ymint;
- ymax = ymaxt;
- dx = (xmax-xmin)/(width);
- dy = (ymax-ymin)/(height);
- maxiter = max;
- r = row;
-}
-void* MandelThread::Entry()
-{
- wxCommandEvent evt(wxEVT_MTHREAD, GetId());
- evt.SetInt(r);
- evt.SetClientData(DrawMandelRow());
- wxPostEvent(m_pParent, evt);
- return 0;
-}
-unsigned char* MandelThread::DrawMandelRow()
-{
- int i, iter=0;
- double x, y, x0, y0, xtemp;
- unsigned char* rgbdata = new unsigned char[width*3];
- y0 = ymax - r*dy;
- for (i=0; i<width; i++) //columns: x
- {
- y = y0;
- x = x0 = xmin + i*dx;
- iter = 0;
- while (x*x+y*y < 4 && iter<maxiter)
- {
- xtemp = x*x - y*y + x0;
- y = x*y + x*y + y0;
- x = xtemp;
- iter++;
- }
-
- if(iter==maxiter)
- {
- rgbdata[i*3] = (unsigned char)0;
- rgbdata[i*3+1] = (unsigned char)0;
- rgbdata[i*3+2] = (unsigned char)0;
- }
- else
- {
- unsigned char* temp = getColour(4*(iter - (log(log(x*x+y*y)))/log(2.0)));
- rgbdata[i*3] = temp[0];
- rgbdata[i*3+1] = temp[1];
- rgbdata[i*3+2] = temp[2];
- delete[] temp;
- }
- }
- return rgbdata;
-}
-unsigned char* MandelThread::getColour(double iter)
-{
- double R = 1, G = 0, B = 0;
- double H, S, V;
- H = iter;
- S = 1;
- V = 1;
- int hi = (int)floor(H / 60.0)%6;
- double f = H/60 - floor(H/60);
- double pv = V * ( 1 - S );
- double qv = V * ( 1 - S * f );
- double tv = V * ( 1 - S * ( 1 - f ) );
- switch(hi)
- {
- case 0:
- R = V;
- G = tv;
- B = pv;
- break;
- case 1:
- R = qv;
- G = V;
- B = pv;
- break;
- case 2:
- R = pv;
- G = V;
- B = tv;
- break;
- case 3:
- R = pv;
- G = qv;
- B = V;
- break;
- case 4:
- R = tv;
- G = pv;
- B = V;
- break;
- case 5:
- R = V;
- G = pv;
- B = qv;
- break;
- default:
- break;
- }
- unsigned char* res = new unsigned char[3];
- res[0] = (unsigned char)(int)(R*255.0F);
- res[1] = (unsigned char)(int)(G*255.0F);
- res[2] = (unsigned char)(int)(B*255.0F);
- return res;
-}
-
-JuliaThread::JuliaThread(wxEvtHandler* pParent, int row, double &cxt, double &cyt, double &xmint, double &xmaxt, double &ymint, double &ymaxt, int &widtht, int &heightt, int &max) : wxThread(wxTHREAD_DETACHED), m_pParent(pParent)
-{
- width = widtht;
- height = heightt;
- xmin = xmint;
- xmax = xmaxt;
- ymin = ymint;
- ymax = ymaxt;
- dx = (xmax-xmin)/(width);
- dy = (ymax-ymin)/(height);
- maxiter = max;
- cx = cxt;
- cy = cyt;
- r = row;
-}
-void* JuliaThread::Entry()
-{
- wxCommandEvent evt(wxEVT_JTHREAD, GetId());
- evt.SetInt(r);
- evt.SetClientData(DrawJuliaRow());
- wxPostEvent(m_pParent, evt);
- return 0;
-}
-unsigned char* JuliaThread::DrawJuliaRow()
-{
- int i, iter=0;
- double x, y, xtemp;
- unsigned char* rgbdata = new unsigned char[width*3];
- for (i=0; i<width; i++) //columns: x
- {
- y = ymax - r*dy;
- x = xmin + i*dx;
- iter = 0;
- while (x*x+y*y < 4 && iter<maxiter)
- {
- xtemp = x*x - y*y + cx;
- y = x*y + x*y + cy;
- x = xtemp;
- iter++;
- }
-
- if(iter==maxiter)
- {
- rgbdata[i*3] = (unsigned char)0;
- rgbdata[i*3+1] = (unsigned char)0;
- rgbdata[i*3+2] = (unsigned char)0;
- }
- else
- {
- unsigned char* temp = getColour((4*(iter - (log(log(x*x+y*y)))/log(2.0))));
- rgbdata[i*3] = temp[0];
- rgbdata[i*3+1] = temp[1];
- rgbdata[i*3+2] = temp[2];
- delete[] temp;
- }
- }
- return rgbdata;
-}
-unsigned char* JuliaThread::getColour(double iter)
-{
- double R = 1, G = 0, B = 0;
- double H, S, V;
- H = iter;
- S = 1;
- V = 1;
- int hi = (int)floor(H / 60.0)%6;
- double f = H/60 - floor(H/60);
- double pv = V * ( 1 - S );
- double qv = V * ( 1 - S * f );
- double tv = V * ( 1 - S * ( 1 - f ) );
- switch(hi)
- {
- case 0:
- R = V;
- G = tv;
- B = pv;
- break;
- case 1:
- R = qv;
- G = V;
- B = pv;
- break;
- case 2:
- R = pv;
- G = V;
- B = tv;
- break;
- case 3:
- R = pv;
- G = qv;
- B = V;
- break;
- case 4:
- R = tv;
- G = pv;
- B = V;
- break;
- case 5:
- R = V;
- G = pv;
- B = qv;
- break;
- default:
- break;
- }
- unsigned char* res = new unsigned char[3];
- res[0] = (unsigned char)(int)(R*255.0F);
- res[1] = (unsigned char)(int)(G*255.0F);
- res[2] = (unsigned char)(int)(B*255.0F);
- return res;
-}
-
-
void ChaosToolsFrm::iterBookPageChanged(wxNotebookEvent& event)
{
}
Oops, something went wrong.

0 comments on commit db75b85

Please sign in to comment.