1 /*# ---------------------------------------------------------------------
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
5 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
6 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
7 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
9 # This software is governed by the CeCILL-B license under French law and
10 # abiding by the rules of distribution of free software. You can use,
11 # modify and/ or redistribute the software under the terms of the CeCILL-B
12 # license as circulated by CEA, CNRS and INRIA at the following URL
13 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
14 # or in the file LICENSE.txt.
16 # As a counterpart to the access to the source code and rights to copy,
17 # modify and redistribute granted by the license, users are provided only
18 # with a limited warranty and the software's author, the holder of the
19 # economic rights, and the successive licensors have only limited
22 # The fact that you are presently reading this means that you have had
23 # knowledge of the CeCILL-B license and that you accept its terms.
24 # ------------------------------------------------------------------------ */
26 // MaracasDll.cpp : Defines the entry point for the DLL application.
30 #include "wxMaracasApp.h"
31 #include "MaracasDll.h"
34 BOOL APIENTRY DllMain( HANDLE hModule,
35 DWORD ul_reason_for_call,
39 switch (ul_reason_for_call)
41 case DLL_PROCESS_ATTACH:
43 case DLL_THREAD_ATTACH:
44 case DLL_THREAD_DETACH:
45 case DLL_PROCESS_DETACH:
50 // This is the constructor of a class that has been exported.
51 // see MaracasDll.h for the class definition
52 CMaracasController::CMaracasController()
53 :m_pSlicesPixels(NULL)
56 // wxEntry(GetModuleHandle(NULL),NULL,NULL,0,FALSE);
57 m_pMarApp = (wxMaracasApp*)wxTheApp;
61 CMaracasController::~CMaracasController()
63 // TODO : verifier le vidage de la m�moire
64 if (m_pSlicesPixels!=NULL) delete m_pSlicesPixels;
71 int CMaracasController::RunMaracas(void)
73 m_pMarApp->SetVolumeData(
87 int CMaracasController::ShowApp(int nCmdShow)
89 if ( SW_HIDE == nCmdShow )
91 m_pMarApp->ShowFrame(SHOW_WINDOW_MINIMIZED);
93 else if ( SW_SHOW == nCmdShow )
95 m_pMarApp->ShowFrame(SHOW_WINDOW_RESTORE);
97 else if ( SW_NORMAL == nCmdShow )
99 m_pMarApp->ShowFrame(SHOW_WINDOW_NORMAL);
101 else if ( SW_MINIMIZE == nCmdShow )
103 m_pMarApp->ShowFrame(SHOW_WINDOW_MINIMIZED);
105 else if ( SW_MAXIMIZE == nCmdShow )
107 m_pMarApp->ShowFrame(SHOW_WINDOW_MAXIMIZED);
111 m_pMarApp->ShowFrame(SHOW_WINDOW_NORMAL);
116 int CMaracasController::Reset(void)
118 // TODO : verifier le vidage de la m�moire
119 if (m_pSlicesPixels!=NULL) delete m_pSlicesPixels;
120 m_pSlicesPixels=NULL;
125 void CMaracasController::SetVolumeParams(int nX, int nY, int nSlices)
130 if(m_pSlicesPixels==NULL)
132 m_pSlicesPixels=new unsigned short [m_nX*m_nY*m_nSlices];
134 wxString msg=wxString();
137 // wxLogDebug(msg.Format("Volume dimensions received : %d, %d ,%d",m_nX,m_nY,m_nSlices));
141 void CMaracasController::SetSliceParams(float pixelSpacingColumn,
142 float pixelSpacingRow,
143 float pixelSpacingSlice,
145 float RescaleIntercept)
147 m_PixelSpacingColumn = pixelSpacingColumn;
148 m_PixelSpacingRow = pixelSpacingRow;
149 m_PixelSpacingSlice = pixelSpacingSlice;
150 m_RescaleSlope = RescaleSlope;
151 m_RescaleIntercept = RescaleIntercept;
153 wxString msg=wxString();
155 // wxLogDebug(msg.Format("Spacings received: %d, %d, %d",m_PixelSpacingColumn,m_PixelSpacingRow,m_PixelSpacingSlice));
159 void CMaracasController::SetSlicePixels(int numSlice,unsigned short * pixels)
162 wxString msg=wxString();
165 // wxLogDebug(msg.Format("Data for slice %d received",numSlice));
167 int nbPixels=m_nX*m_nY;
168 int startIndex=numSlice*nbPixels;
170 for (int i=0; i<nbPixels;i++)
172 m_pSlicesPixels[i+startIndex]=pixels[i];
176 void CMaracasController::GetSnapshot( unsigned int& rWidth,
177 unsigned int& rHeight,
178 unsigned char*& rpPixels ) /*const*/ {
180 wxColour *colour = new wxColour();
181 wxBitmap *wxbitmap = m_pMarApp->GetSnapshot();
182 wxMemoryDC *wxmemorydc = new wxMemoryDC();
183 wxmemorydc->SelectObject(*wxbitmap);
187 int w = wxbitmap->GetWidth();
188 int h = wxbitmap->GetHeight();
190 _rpPixels=(unsigned char*)malloc( sizeof(unsigned char)*3*w*h );
193 wxmemorydc->GetPixel(i,j,colour);
197 rpPixels[j*3*w+i*3+0]=r;
198 rpPixels[j*3*w+i*3+1]=g;
199 rpPixels[j*3*w+i*3+2]=b;
205 wxbitmap->SaveFile("c:/tmp/MaracasPlamavic.bmp", wxBITMAP_TYPE_BMP );
209 rpPixels = _rpPixels;
213 int CMaracasController::ReleaseSnapshot(){
214 if (_rpPixels!=NULL) {