1 // MaracasDll.cpp : Defines the entry point for the DLL application.
5 #include "wxMaracasApp.h"
6 #include "MaracasDll.h"
9 BOOL APIENTRY DllMain( HANDLE hModule,
10 DWORD ul_reason_for_call,
14 switch (ul_reason_for_call)
16 case DLL_PROCESS_ATTACH:
18 case DLL_THREAD_ATTACH:
19 case DLL_THREAD_DETACH:
20 case DLL_PROCESS_DETACH:
25 // This is the constructor of a class that has been exported.
26 // see MaracasDll.h for the class definition
27 CMaracasController::CMaracasController()
28 :m_pSlicesPixels(NULL)
31 // wxEntry(GetModuleHandle(NULL),NULL,NULL,0,FALSE);
32 m_pMarApp = (wxMaracasApp*)wxTheApp;
36 CMaracasController::~CMaracasController()
38 // TODO : verifier le vidage de la mémoire
39 if (m_pSlicesPixels!=NULL) delete m_pSlicesPixels;
46 int CMaracasController::RunMaracas(void)
48 m_pMarApp->SetVolumeData(
62 int CMaracasController::ShowApp(int nCmdShow)
64 if ( SW_HIDE == nCmdShow )
66 m_pMarApp->ShowFrame(SHOW_WINDOW_MINIMIZED);
68 else if ( SW_SHOW == nCmdShow )
70 m_pMarApp->ShowFrame(SHOW_WINDOW_RESTORE);
72 else if ( SW_NORMAL == nCmdShow )
74 m_pMarApp->ShowFrame(SHOW_WINDOW_NORMAL);
76 else if ( SW_MINIMIZE == nCmdShow )
78 m_pMarApp->ShowFrame(SHOW_WINDOW_MINIMIZED);
80 else if ( SW_MAXIMIZE == nCmdShow )
82 m_pMarApp->ShowFrame(SHOW_WINDOW_MAXIMIZED);
86 m_pMarApp->ShowFrame(SHOW_WINDOW_NORMAL);
91 int CMaracasController::Reset(void)
93 // TODO : verifier le vidage de la mémoire
94 if (m_pSlicesPixels!=NULL) delete m_pSlicesPixels;
100 void CMaracasController::SetVolumeParams(int nX, int nY, int nSlices)
105 if(m_pSlicesPixels==NULL)
107 m_pSlicesPixels=new unsigned short [m_nX*m_nY*m_nSlices];
109 wxString msg=wxString();
112 // wxLogDebug(msg.Format("Volume dimensions received : %d, %d ,%d",m_nX,m_nY,m_nSlices));
116 void CMaracasController::SetSliceParams(float pixelSpacingColumn,
117 float pixelSpacingRow,
118 float pixelSpacingSlice,
120 float RescaleIntercept)
122 m_PixelSpacingColumn = pixelSpacingColumn;
123 m_PixelSpacingRow = pixelSpacingRow;
124 m_PixelSpacingSlice = pixelSpacingSlice;
125 m_RescaleSlope = RescaleSlope;
126 m_RescaleIntercept = RescaleIntercept;
128 wxString msg=wxString();
130 // wxLogDebug(msg.Format("Spacings received: %d, %d, %d",m_PixelSpacingColumn,m_PixelSpacingRow,m_PixelSpacingSlice));
134 void CMaracasController::SetSlicePixels(int numSlice,unsigned short * pixels)
137 wxString msg=wxString();
140 // wxLogDebug(msg.Format("Data for slice %d received",numSlice));
142 int nbPixels=m_nX*m_nY;
143 int startIndex=numSlice*nbPixels;
145 for (int i=0; i<nbPixels;i++)
147 m_pSlicesPixels[i+startIndex]=pixels[i];
151 void CMaracasController::GetSnapshot( unsigned int& rWidth,
152 unsigned int& rHeight,
153 unsigned char*& rpPixels ) /*const*/ {
155 wxColour *colour = new wxColour();
156 wxBitmap *wxbitmap = m_pMarApp->GetSnapshot();
157 wxMemoryDC *wxmemorydc = new wxMemoryDC();
158 wxmemorydc->SelectObject(*wxbitmap);
162 int w = wxbitmap->GetWidth();
163 int h = wxbitmap->GetHeight();
165 _rpPixels=(unsigned char*)malloc( sizeof(unsigned char)*3*w*h );
168 wxmemorydc->GetPixel(i,j,colour);
172 rpPixels[j*3*w+i*3+0]=r;
173 rpPixels[j*3*w+i*3+1]=g;
174 rpPixels[j*3*w+i*3+2]=b;
180 wxbitmap->SaveFile("c:/tmp/MaracasPlamavic.bmp", wxBITMAP_TYPE_BMP );
184 rpPixels = _rpPixels;
188 int CMaracasController::ReleaseSnapshot(){
189 if (_rpPixels!=NULL) {