#include <creaImageIODicomImageReader.h>
-#include <gdcmFile.h>
+
#include <vtkGdcmReader.h>
#include <creaImageIOSystem.h>
#include "boost/filesystem/path.hpp"
#include <creaImageIOTreeAttributeDescriptor.h>
#include <vtkStringArray.h>
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#endif
+
namespace creaImageIO
{
return str;
}
//========================================================================
-
+
//=====================================================================
void DicomImageReader::ReadAttributes(const std::string& filename,
std::map<std::string,std::string>& attr)
GimmickMessage(2,"Reading attributes from DICOM file '"
<<filename<<"'"<<std::endl);
- GDCM_NAME_SPACE::File* file = GDCM_NAME_SPACE::File::New();
+ //GDCM_NAME_SPACE::File* file = GDCM_NAME_SPACE::File::New();
+ boost::shared_ptr<GDCM_NAME_SPACE::File> file(GDCM_NAME_SPACE::File::New(), DicomImageReader::deleter());
GDCM_NAME_SPACE::Document *doc= GDCM_NAME_SPACE::File::New();
doc->SetLoadMode( GDCM_NAME_SPACE::LD_ALL);
file->SetLoadMode( GDCM_NAME_SPACE::LD_ALL);
file->SetFileName(filename.c_str());
file->Load();
- if (file->IsReadable() ||((GDCM_NAME_SPACE::Document*) file)->IsReadable())
+ if (file->IsReadable())// ||((GDCM_NAME_SPACE::Document*) file)->IsReadable())
{
std::map<std::string,std::string>::iterator i;
for (i=attr.begin();i!=attr.end();++i)
}
}
}
- file->Delete();
+ // file->Delete();
}
//=====================================================================
#include <creaImageIOAbstractImageReader.h>
-
+#include <gdcmFile.h>
// forward decl
class vtkGdcmReader;
private:
vtkGdcmReader* mReader;
+ struct deleter
+ {
+ void operator()(GDCM_NAME_SPACE::File* p)
+ {
+ p->Delete();
+ }
+ };
+ friend struct deleter;
};
//=====================================================================
# define PATH_MAX 2048
#endif
-#ifdef _RELWITHDEBINFO
-#define new DEBUG_NEW
-#endif
-
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#endif
namespace creaImageIO
{
else
{
/// Open and test it
- GimmickMessage(1,"Opening local database '" <<i_locDB<< "' " << std::endl);
+
+ GimmickDebugMessage(1,"Opening local database '" <<i_locDB<< "' " << std::endl);
if ( !sqlTreeH->Open(true) )
{
GimmickError("ERROR OPENING '"<<i_locDB<<"'");
#include <creaImageIOGimmickReaderDialog.h>
#include <creaImageIOWxGimmickReaderDialog.h>
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#endif
-
-
-
-vtkImageData* getImageDataDialog() {
- // wxApp::OnInit();
- #ifdef __WXGTK__
- //See http://www.wxwindows.org/faqgtk.htm#locale
- setlocale(LC_NUMERIC, "C");
- #endif
- wxInitAllImageHandlers();
-
- creaImageIO::SetGimmickMessageLevel(5);
- creaImageIO::SetGimmickDebugMessageLevel(0);
-
- int min_dim = GIMMICK_2D_IMAGE_SELECTION;
- int max_dim = GIMMICK_3D_IMAGE_SELECTION;
- int output_dim = NATIVE;
- int threads = 1;
-
- creaImageIO::WxGimmickReaderDialog w(
- 0,
- -1,
- "localdatabase_Descriptor.dscp",
- "Local Database",
- _T("Select image(s) - Gimmick! (c) CREATIS-LRMN 2008"),
- wxDefaultPosition,
- wxSize(1200,800),
- min_dim,
- max_dim,
- output_dim,
- threads);
- w.ShowModal();
-
- if (w.GetReturnCode() == wxID_OK)
- {
- std::cout << "$$$$ main : user clicked 'OK' $$$$"<<std::endl;
- std::cout << "$$$$ selected files : "<<std::endl;
- //Puts filenames
- std::vector<std::string> s;
- w.GetSelectedFiles(s);
- std::vector<std::string>::iterator i;
- for (i=s.begin();i!=s.end();++i)
- {
- std::cout << *i << std::endl;
- }
- std::cout << "$$$$ "<<std::endl;
-
- //Puts images
- std::vector<vtkImageData*> images;
- w.GetSelectedImages(images,output_dim);
- std::cout<<images.size()<<std::endl;
-
- w.OnExit();
- return images[0];
-
- //crea::VtkBasicSlicer(images.front());
- //images.front()->Delete();
-
-
- }
- else if (w.GetReturnCode() == wxID_CANCEL)
- {
- w.OnExit();
- std::cout << "$$$$ main : user clicked 'CANCEL' $$$$"<<std::endl;
- }
- else
- {
- w.OnExit();
- std::cout << "$$$$ main : dialog ended without return code ! $$$$"
- <<std::endl;
- }
-
- // std::cout << "$$$$ main : deleting dialog"<<std::endl;
- // delete w;
- std::cout << "$$$$$$$$$$$$$$$$$$$$ main ended "<<std::endl;
- return NULL;
- }
-//
-
namespace creaImageIO
{
-
bool GimmickReaderDialog(std::vector<vtkImageData*>& images,
const std::string i_namedescp ,
int image_out_dim,
int nb_threads)
{
-
+
+
creaImageIO::WxGimmickReaderDialog w(0,
-1,
i_namedescp,
#include <creaImageIOGimmickView.h>
#include <creaImageIOSystem.h>
#include "boost/filesystem.hpp"
-
-#include <gdcmSerieHelper.h> // JPR
-#include <gdcmFile.h> // JPR
-#include <vtkGdcmReader.h> // JPR
-#include <gdcmDebug.h>
-
+#include <gdcmGlobal.h>
+#include <gdcmSerieHelper.h>
+#include <vtkGdcmReader.h>
namespace fs = boost::filesystem;
namespace creaImageIO
public:
ImageExtent(const std::string& x, const std::string& y, const std::string& z, const std::string& t)
{
- sscanf(x.c_str(),"%d",&mExtent[0]);
- sscanf(y.c_str(),"%d",&mExtent[1]);
- sscanf(z.c_str(),"%d",&mExtent[2]);
- sscanf(t.c_str(),"%d",&mExtent[3]);
- if(x==""){mExtent[0]=1;}
- if(y==""){mExtent[1]=1;}
- if(z==""){mExtent[2]=1;}
- if(t==""){mExtent[3]=1;}
-
- if (mExtent[3]>1) mDim=4;
- else if (mExtent[2]>1) mDim=3;
- else if (mExtent[1]>1) mDim=2;
- else if (mExtent[0]>1) mDim=1;
- else mDim=0;
+ sscanf(x.c_str(),"%d",&mExtent[0]);
+ sscanf(y.c_str(),"%d",&mExtent[1]);
+ sscanf(z.c_str(),"%d",&mExtent[2]);
+ sscanf(t.c_str(),"%d",&mExtent[3]);
+ if(x==""){mExtent[0]=1;}
+ if(y==""){mExtent[1]=1;}
+ if(z==""){mExtent[2]=1;}
+ if(t==""){mExtent[3]=1;}
+
+ if (mExtent[3]>1) mDim=4;
+ else if (mExtent[2]>1) mDim=3;
+ else if (mExtent[1]>1) mDim=2;
+ else if (mExtent[0]>1) mDim=1;
+ else mDim=0;
}
+
///Clears the extent
void Clear() { mExtent[0] = mExtent[1] = mExtent[2] = mExtent[3] = 1; }
// Anciently started the threads ...
// Threads now automatically start at first image request
//mReader.Start();
+
}
//======================================================================
}
+
//======================================================================
//======================================================================
}
else if (im.size()>1) // Test inutile ? JPR
{
- // Read the FIRST image to get info ... about all the other ones. ?!? // JPR
vtkImageData* first = mReader.GetImage( im.front());
-
if (dimension == 2)
{
// n3D
s.push_back(out);
}
}
- else if (dimension == 3)
+ else
{
- // n*2D to 3D :: --> NON ! Ca va tres bien pour du 2D+T (le ZSpacing, on s'en tape)
- // // ne convient pas pour du n*2D a lire comme un 3D
- // // Il faut un gdcmSerieHelper !
+ // n*2D to 3D
vtkImageData* out = vtkImageData::New();
out->CopyStructure(first);
out->SetScalarType(first->GetScalarType());
out->SetNumberOfScalarComponents(first->GetNumberOfScalarComponents());
int ext[6];
- //first->GetExtent(ext); // JPR
+ //first->GetExtent(ext); // JPR
first->GetWholeExtent(ext); // renvoie egalement 0,0 en Z // JPR
- // Normal :
if(ext[5] == 0)
{
}
out->SetExtent(ext);
- // LG : TODO : Z Spacing ? // Voir + loin // JPR
+ // LG : TODO : Z Spacing ?
int dim[3];
first->GetDimensions(dim);
if (dimension == 2)
{
// n3D
- std::vector<std::string>::iterator it;
+ std::vector<std::string>::iterator it;
for (it=im.begin(); it!=im.end(); ++it)
{
- std::cout << "----------------------------------------n3D" << std::endl;
vtkImageData* out = vtkImageData::New();
out->ShallowCopy(mReader.GetImage(*it));
s.push_back(out);
{
// n2D to 3D // NO!
// n *2D + T in a vector :
- std::cout << "---------------------------------------- n *2D + T" << std::endl;
+
std::vector<std::string>::iterator it;
for (it=im.begin(); it!=im.end(); ++it)
{
- std::cout << "---------------------------------------- [" << *it << "]" << std::endl;
- //vtkImageData* out = mReader.GetImage( (*it));
- //s.push_back(out);
- vtkImageData* out = vtkImageData::New();
- out->ShallowCopy(mReader.GetImage(*it));
+ vtkImageData* out = mReader.GetImage( (*it));
s.push_back(out);
}
}
void GimmickView::RequestReading(tree::Node* n,
int prio, int selection_index, boost::shared_ptr<ImagePointerHolder> p)
{
- if(!mReaderStarted)
- {
- mReader.Start();
- mReaderStarted=true;
- }
- ImageEventType t(n,selection_index);
- t.pointerHolder = p;
- mImageEventMap[n->GetAttribute("FullFileName")] = t;
- mReader.Request(this,n->GetAttribute("FullFileName"),prio);
+ if(!mReaderStarted)
+ {
+ mReader.Start();
+ mReaderStarted=true;
+ }
+ ImageEventType t(n,selection_index);
+ t.pointerHolder = p;
+ mImageEventMap[n->GetAttribute("FullFileName")] = t;
+ mReader.Request(this,n->GetAttribute("FullFileName"),prio);
}
//======================================================================
#include <wx/utils.h>
#include <creaImageIOSystem.h>
+
namespace creaImageIO
{
#include <creaImageIOSQLiteTreeHandler.h>
#include <creaImageIOSystem.h>
+#include <creaImageIOGimmick.h>
#include <creaImageIOTree.h>
#include "CppSQLite3.h"
#include <boost/algorithm/string.hpp>
using namespace crea;
+
+
namespace creaImageIO
{
using namespace tree;
{
mDB = new CppSQLite3DB;
mIsAdding=false;
- GimmickMessage(1,"SQLite version : "
- <<std::string(mDB->SQLiteVersion())<< std::endl);
+ //GimmickMessage(1,"SQLite version : " <<std::string(mDB->SQLiteVersion())<< std::endl);
}
//=============================================================
#include <creaImageIOSystem.h>
#include <boost/filesystem.hpp>
#include <boost/algorithm/string.hpp>
+
+
//namespace fs = boost::filesystem;
//=====================================================================
#include "creaMessageManager.h"
+
#if defined(_WIN32)
#ifdef CREAIMAGEIO_EXPORT_SYMBOLS
#define CREAIMAGEIO_EXPORT __declspec( dllexport )
}
//==============================================================
+
+
#define GimmickMessage(LEV,MESS) \
creaMessage("Gimmick!",LEV,"[Gimmick!] "<<MESS);
#define GimmickDebugMessage(LEV,MESS) \
creaDebugMessage("Gimmick! DEBUG",LEV,"[Gimmick!] DEBUG: "<<MESS);
#define GimmickError(MESS) \
creaError("[Gimmick!] "<<MESS);
-
+
} // namespace
#endif
#include <creaImageIOTree.h>
#include <creaImageIOSystem.h>
+
namespace creaImageIO
{
namespace tree
#include <boost/filesystem/operations.hpp>
#include <boost/utility.hpp>
-#include <creaImageIOGimmick.h>
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#endif
+
namespace fs = boost::filesystem;
using boost::filesystem::path;
using boost::next;
#include <creaImageIOTreeLevelDescriptor.h>
#include <creaImageIOSystem.h>
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#endif
namespace creaImageIO
{
#include <creaImageIOSystem.h>
#include <algorithm>
#include <creaImageIOGimmick.h>
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#endif
+
namespace creaImageIO
{
namespace tree
#include <creaImageIOSystem.h>
+
namespace creaImageIO
{
// CTor
#include <vtkImageReader2.h>
#include <creaImageIOSystem.h>
#include "boost/filesystem/path.hpp"
-#include <creaImageIOGimmick.h>
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#endif
-namespace creaImageIO
-{
+namespace creaImageIO{
//=====================================================================
VtkImageReader::VtkImageReader(vtkImageReader2* r,
const std::string& name,
#include <creaImageIOWxAttributeSelectionPanel.h>
#include <creaImageIOSystem.h>
+
namespace creaImageIO
{
const int ID_COMBO = 180;
#include <creaImageIOWxGimmickReaderDialog.h>
#include <creaImageIOSystem.h>
-#include <creaImageIOGimmick.h>
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#endif
-
-#ifdef _RELWITHDEBINFO
-#define new DEBUG_NEW
-#endif
namespace creaImageIO
{
int max_dim,
int output_dim, // never used ?!? // JPR
int threads)
- : wxDialog( parent,
+ : wxDialog( parent,
id,
title,
pos,
#include "bruker2dicom.h"
#endif
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#endif
+
namespace creaImageIO
{
#include <wx/gdicmn.h>
#include <boost/date_time/gregorian/gregorian.hpp>
-
//=====================================================================
namespace creaImageIO
{
#include <stdio.h>
#include <time.h>
+
using namespace crea;
// Memory tracking allocation
namespace creaImageIO
mNeedRefresh = false;
mLastImageShown = NULL;
-
- wxBoxSizer *topsizer = new wxBoxSizer(wxVERTICAL);
-
- mslide = new wxSlider(this,-1,0,0,1, wxDefaultPosition, wxSize(400,10), wxSL_HORIZONTAL | wxSL_LABELS);
- Connect( mslide->GetId(), wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &WxViewer::OnSlide );
- mcheck = new wxCheckBox(this,5123,crea::std2wx("Cine Loop"));
- Connect( mcheck->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &WxViewer::OnCineLoop );
- mcheck->SetValue(false);
- // previewer
+
+ // previewer
mInteractor = new crea::creawxVTKRenderWindowInteractor(this,-1);
mInteractor->UseCaptureMouseOn();
mCurrent = 0;
mPlayer = 0;
- topsizer-> Add( mslide,1,wxALIGN_CENTER ,0);
- topsizer-> Add( mInteractor ,1,wxGROW ,0);
-
- SetSizer( topsizer );
+ // Grid to place checkbox and slider
+ mflexSizer = new wxFlexGridSizer(1,2,1,1);
+ //Slider
+ mslide = new wxSlider(this,-1,0,0,1, wxDefaultPosition, wxSize(400,40), wxSL_HORIZONTAL | wxSL_LABELS);
+ Connect( mslide->GetId(), wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &WxViewer::OnSlide );
+ //CheckBox
+ mcheck = new wxCheckBox(this,5123,crea::std2wx("Cine Loop"));
+ Connect( mcheck->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &WxViewer::OnCineLoop );
+ mcheck->SetValue(false);
+ mflexSizer->Add(mcheck,0, wxFIXED_MINSIZE);
+ mflexSizer-> Add( mslide,1,wxALIGN_CENTER | wxFIXED_MINSIZE );
+
+ // Sizer for Previewer and GridSizer
+ mtopSizer = new wxBoxSizer(wxVERTICAL);
+ mtopSizer->Add(mflexSizer,0);
+ mtopSizer-> Add( mInteractor ,1,wxGROW,0);
+ SetSizer(mtopSizer,true);
+
+ Update();
Layout();
}
//=====================================================================
GimmickDebugMessage(6,"WxViewer::~WxViewer"
<<std::endl);
// TO DO : desallocate cleanly
- // delete mPlayer;
- // delete mInteractor;
- delete mslide;
+ if(mPlayer)
+ {
+ mPlayer->Pause();
+ mPlayer->Delete();
+ mPlayer = 0;
+ }
+ delete mInteractor;
+ //delete mslide;
+ //delete mflexSizer;
+ //delete mtopSizer;
}
//=====================================================================
///The vectors of images to be shown
std::vector< boost::shared_ptr<ImagePointerHolder> > imagePointers;
+ /// Sizers to preview images
+ wxFlexGridSizer *mflexSizer;
+ wxBoxSizer *mtopSizer;
+
};
}