#include <creaImageIOTreeAttributeDescriptor.h>
#include <vtkStringArray.h>
-
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#endif
namespace creaImageIO
{
+
#include <creaImageIOGimmick.h>
#include <creaImageIOSystem.h>
# define PATH_MAX 2048
#endif
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#endif
+
namespace creaImageIO
{
//==============================================================
Gimmick::Gimmick()
: mImageAdder(0)
{
- RegisterGimmickMessageTypes();
+ RegisterGimmickMessageTypes();
mSettings=0;
mSynchronizer=0;
}
}
}
- ////////////////////////////////////////////////////////////////////////
- // create a DB from a attributes descriptor file for medical images //
- // @param i_name : DB name //
- // @param i_locDesc : location of descriptor file //
- // @param i_locDB : location of DB //
- // return : the SQLiteTreeHandler object on DB //
- //////////////////////////////////////////////////////////////////
- SQLiteTreeHandler *Gimmick::createDB(const std::string &i_name,
- const std::string &i_locDesc,
- const std::string &i_locDB)
+ ///////////////////////////////////////////////////////////////////////////
+ // create a DB from a attributes descriptor file for medical images //
+ // @param i_name : DB name //
+ // @param i_locDesc : location of descriptor file //
+ // @param i_locDB : location of DB //
+ // return : the SQLiteTreeHandler object on DB //
+ /////////////////////////////////////////////////////////////////////////
+ SQLiteTreeHandler* Gimmick::createDB(const std::string &i_name,
+ const std::string &i_locDesc,
+ const std::string &i_locDB)
{
- SQLiteTreeHandler *sqlTreeH = new SQLiteTreeHandler(i_locDB);
+ SQLiteTreeHandler* sqlTreeH( new SQLiteTreeHandler(i_locDB) );
// Create or open local database
if (! boost::filesystem::exists(i_locDB) )
{
#include <creaImageIOSynchron.h>
#include <creaImageIOSettings.h>
+
+#ifdef _DEBUG
+#include <crtdbg.h>
+#define DEBUG_NEW new(_NORMAL_BLOCK ,__FILE__, __LINE__)
+#else
+#define DEBUG_NEW new
+#endif
+// Only when asked
+/*
+#ifdef TRACKING_MEMORY_LEAKS
+#ifdef WIN32
+#pragma warning(disable : 4291)
+#endif
+
+void * operator new( size_t size, int line, const char *file );
+void * operator new[]( size_t size, int line, const char *file );
+void operator delete( void *p );
+void operator delete[]( void *p );
+
+#ifdef OMISCID_NEW
+#undef OMISCID_NEW
+#endif
+
+#define OMISCID_NEW new( __LINE__, __FILE__ )
+
+#else // TRACKING_MEMORY_LEAKS is not defined
+
+#define OMISCID_NEW new
+
+#endif*/
+
+
namespace creaImageIO
{
/**
static void SetDebugMessageLevel(int level);
/// Type of map from TreeHandler name to TreeHandler*
- typedef std::map<std::string, TreeHandler*> TreeHandlerMapType;
+ typedef std::map<std::string, TreeHandler*> TreeHandlerMapType;
/// Returns the TreeHandlerMap (ref)
TreeHandlerMapType& GetTreeHandlerMap() { return mTreeHandlerMap; }
void Print(const std::string& handler);
///create a DB from a given descriptor file and for a specific location
- SQLiteTreeHandler *createDB(const std::string &i_name,
+ SQLiteTreeHandler* createDB(const std::string &i_name,
const std::string &i_locDesc,
const std::string &i_locDB);
TreeHandler* GetTreeHandler(const std::string& name) const;
///
- SQLiteTreeHandler* GetLocalDatabase() { return mLocalDatabase; }
+ SQLiteTreeHandler* GetLocalDatabase() { return mLocalDatabase; }
- const SQLiteTreeHandler* GetLocalDatabase() const
- { return mLocalDatabase; }
+ const SQLiteTreeHandler* GetLocalDatabase() const { return mLocalDatabase; }
///Returns the given setting value for the given setting parameter
void GetSetting(const std::string& name, std::string& value);
//=============================================
private:
- SQLiteTreeHandler* mLocalDatabase;
+ SQLiteTreeHandler* mLocalDatabase;
TreeHandlerMapType mTreeHandlerMap;
Synchronizer* mSynchronizer;
#include <creaImageIOGimmickReaderDialog.h>
#include <creaImageIOWxGimmickReaderDialog.h>
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#endif
namespace creaImageIO
{
#include <creaImageIOGimmickView.h>
#include <creaImageIOSystem.h>
-
#include "boost/filesystem.hpp"
namespace fs = boost::filesystem;
//======================================================================
///Requests the reading of an image
void GimmickView::RequestReading(tree::Node* n,
- int prio, int selection_index, ImagePointerHolder *p)
+ int prio, int selection_index, boost::shared_ptr<ImagePointerHolder> p)
{
if(!mReaderStarted)
{
mReader.Start();
mReaderStarted=true;
}
- ImageEventType t(n,selection_index, p);
+ ImageEventType t(n,selection_index);
+ t.pointerHolder = p;
mImageEventMap[n->GetAttribute("FullFileName")] = t;
mReader.Request(this,n->GetAttribute("FullFileName"),prio);
}
void ReadImagesNotThreaded(std::vector<vtkImageData*>& s,std::vector<std::string> files, int dim);
///Requests the reading of an image with priority and index in the
/// current selection (-1 if not in selection)
- void RequestReading(tree::Node* n, int prio, int selection_index , ImagePointerHolder *p);
+ //void RequestReading(tree::Node* n, int prio, int selection_index , ImagePointerHolder *p);
+ void RequestReading(tree::Node* n, int prio, int selection_index , boost::shared_ptr<ImagePointerHolder> p);
///Obtains the message of the state
private:
/// Controller which manages the interaction with the model
- Gimmick* mGimmick;
+ boost::shared_ptr< Gimmick> mGimmick;
/// The views
TreeViewMapType mTreeViewMap;
/// The message that results from the validation
struct ImageEventType
{
ImageEventType( tree::Node* no = 0,
- int sel_index = -1,
- ImagePointerHolder* ph= 0)
- : node(no), index(sel_index), pointerHolder(ph){}
+ int sel_index = -1)
+// ImagePointerHolder* ph= 0)
+: node(no), index(sel_index){}//, pointerHolder(ph){}
ImageEventType(vtkImageData* im )
: image(im) {}
tree::Node* node;
vtkImageData* image;
int index;
- ImagePointerHolder* pointerHolder;
+ boost::shared_ptr<ImagePointerHolder> pointerHolder;
};
typedef std::map<std::string,ImageEventType> ImageEventTypeMap;
/// Map of images' names to ImageEventType
//#include <vtkGESignalReader.h>
-
#include "boost/filesystem/path.hpp"
namespace creaImageIO
ImageReader::ImageReader()
:
mUnreadableImage(0),
- mLastFilename("&&&&&&&&&&&&&&&&&&&&&&&&&&&&&"),
- mLastReader(0)
-
+ mLastFilename("&&&&&&&&&&&&&&&&&&&&&&&&&&&&&")
{
// std::cout << "#### ImageReader::ImageReader()"<<std::endl;
if (mUnreadableImage!=0) return;
-
-
- Register(new VtkImageReader(vtkPNGReader::New(), "PNG", ".png"));
- Register(new VtkImageReader(vtkTIFFReader::New(), "JPEG", ".jpeg"));
- Register(new VtkImageReader(vtkJPEGReader::New()));
- Register(new VtkImageReader(vtkBMPReader::New()));
- Register(new VtkImageReader(vtkSLCReader::New()));
- Register(new VtkImageReader(vtkMetaImageReader::New(),"MHD",".mhd"));
+
+ Register( boost::shared_ptr<AbstractImageReader>(new VtkImageReader(vtkPNGReader::New(), "PNG", ".png")));
+ Register(boost::shared_ptr<AbstractImageReader>(new VtkImageReader(vtkTIFFReader::New(), "JPEG", ".jpeg")));
+ Register(boost::shared_ptr<AbstractImageReader>(new VtkImageReader(vtkJPEGReader::New())));
+ Register(boost::shared_ptr<AbstractImageReader>(new VtkImageReader(vtkBMPReader::New())));
+ Register(boost::shared_ptr<AbstractImageReader>(new VtkImageReader(vtkSLCReader::New())));
+ Register(boost::shared_ptr<AbstractImageReader>(new VtkImageReader(vtkMetaImageReader::New(),"MHD",".mhd")));
// Register(new VtkImageReader(vtkGESignalReader::New()));
- Register(new DicomImageReader);
- Register(new UltrasonixImageReader);
+ Register(boost::shared_ptr<AbstractImageReader>(new DicomImageReader));
+ Register(boost::shared_ptr<AbstractImageReader>(new UltrasonixImageReader));
mUnreadableImage = vtkImageData::New();
//=====================================================================
ImageReader::~ImageReader()
{
- std::vector<AbstractImageReader*>::iterator i;
- for (i=mReader.begin(); i!=mReader.end(); i++)
- {
- delete (*i);
- }
- mReader.clear();
+
+ // for (i=mReader.begin(); i!=mReader.end(); i++)
+ // {
+ //delete (*i);
+ // }
+// mReader.clear();
if (mUnreadableImage!=0)
{
mUnreadableImage->Delete();
//=====================================================================
//=====================================================================
- void ImageReader::Register(AbstractImageReader* r)
+ void ImageReader::Register(boost::shared_ptr<AbstractImageReader> r)
{
mReader.push_back(r);
bool ok = false;
if(filename != "")
{
- std::vector<AbstractImageReader*>::iterator i;
+ std::vector<boost::shared_ptr<AbstractImageReader> >::iterator i;
for (i=mReader.begin(); i!=mReader.end(); i++)
{
ok = (*i)->CanRead(filename);
/// Pushes back all kwown extensions (without dot) in the vector given
void ImageReader::PushBackExtensions(std::vector<std::string>& v)
{
- std::vector<AbstractImageReader*>::iterator i;
+ std::vector<boost::shared_ptr<AbstractImageReader> >::iterator i;
for (i=mReader.begin(); i!=mReader.end(); i++)
{
(*i)->PushBackExtensions(v);
protected:
/// Register a reader
- void Register(AbstractImageReader*);
+ void Register( boost::shared_ptr<AbstractImageReader> );
- std::vector<AbstractImageReader*> mReader;
+ std::vector<boost::shared_ptr<AbstractImageReader> > mReader;
vtkImageData* mUnreadableImage;
std::string mLastFilename;
- AbstractImageReader* mLastReader;
+ boost::shared_ptr<AbstractImageReader> mLastReader;
private:
/// returns the size of the Heap
inline int size() const {return m_p.size(); }
/// empties the Heap
- void clear();
+ void clear();
//======================================================================
//======================================================================
{
for (typename std::vector<T>::iterator i=m_p.begin(); i!=m_p.end(); ++i)
{
+ (*m_i)(*i)->delete();
(*m_i)(*i)=-1;
}
m_p.clear();
#include <boost/filesystem/operations.hpp>
#include <boost/utility.hpp>
-
namespace fs = boost::filesystem;
using boost::filesystem::path;
// Create the threads
for (int i=0; i<number_of_threads; i++)
{
- ThreadedImageReader* t = new ThreadedImageReader(this);
+ //ThreadedImageReader* t = new ThreadedImageReader(this);
+ boost::shared_ptr<ThreadedImageReader> t(new ThreadedImageReader(this));
mThreadedImageReaderList.push_back(t);
std::cout << " ===> Thread "<<i
<<" successfully added"<< std::endl;
// <<std::endl;
Stop();
if (mReader) delete mReader;
+ mThreadedImageReaderList.clear();
}
//=====================================================================
ImageToLoadPtrIndexer> mQueue;
/// The type of list of threaded readers
- typedef std::vector<ThreadedImageReader*> ThreadedImageReaderListType;
+ typedef std::vector<boost::shared_ptr<ThreadedImageReader> > ThreadedImageReaderListType;
ThreadedImageReaderListType mThreadedImageReaderList;
/// The number of currently running threaded readers
int mNumberOfThreadedReadersRunning;
#include <iostream>
#include <fstream>
+// Memory tracking allocation
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#endif
using namespace boost;
namespace po = boost::program_options;
#include <boost/algorithm/string.hpp>
//namespace fs = boost::filesystem;
-
//=====================================================================
//=====================================================================
Synchronizer::~Synchronizer()
{
-
+ delete mDB;
}
//=====================================================================
#define CREAIMAGEIO_CDECL
#endif // defined(_WIN32)
+
namespace creaImageIO
{
//==============================================================
#include <creaImageIOTreeLevelDescriptor.h>
#include <creaImageIOSystem.h>
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#endif
+
namespace creaImageIO
{
namespace tree
//=============================================================
/// Ctor with parent
Node::Node(Node* parent)
- : mParent(parent),
- mData(0),
+ : mParent(parent),//mData(0),
mChildrenLoaded(false)
{
if (parent)
//=============================================================
/// Ctor with parent and attributes map
Node::Node(Node* parent, const AttributeMapType& attr)
- : mParent(parent),
- mData(0),
+ : mParent(parent),//mData(0),
mChildrenLoaded(false)
{
GimmickDebugMessage(6,"Node constructor (level "<<GetLevel()<<")"
<< std::endl);
+
if (parent)
{
// Insert into parent's children list
{
delete *i;
}
- if (mData)
- {
- delete mData;
- mData = 0;
- }
+
}
//=============================================================
#include <creaImageIOTreeDescriptor.h>
#include <creaImageIOTreeComparators.h>
+#include<boost/filesystem/operations.hpp>
#include <vector>
#include <map>
+
namespace creaImageIO
{
{ if (mData!=0) return dynamic_cast<T>(mData); return 0; }
/// Sets the node data. Deletes existing data if any.
- void SetData(NodeData* d) { if (mData) delete mData; mData = d; }
+ void SetData(boost::shared_ptr<NodeData> d) { mData = d; }//{ if (mData) delete mData; mData = d; }
/// Sorts the children of the node
void SortChildren(const LexicographicalComparator&);
/// The map of attributes
AttributeMapType mAttributeMap;
/// User data
- NodeData* mData;
+ boost::shared_ptr<NodeData> mData;
/// Are the children loaded ?
bool mChildrenLoaded;
/// The number of children
virtual ~VtkImageReader();
+
+
/// Add file extensions read by the reader
virtual void PushBackExtensions(std::vector<std::string>&);
/// Test if file is read by this reader
#include <creaImageIOWxEditFieldsPanel.h>
#include <creaImageIOSystem.h>
#include <wx/arrstr.h>
+
//using namespace tree;
namespace creaImageIO
{
#include <creaImageIOWxGimmickReaderDialog.h>
#include <creaImageIOSystem.h>
+
namespace creaImageIO
{
// CTor
wxMINIMIZE_BOX |
wxCAPTION
),
- mGimmick(0),
+ mGimmick(0),
mView(0)
{
GimmickDebugMessage(1,"WxGimmickReaderDialog::WxGimmickReaderDialog"
// void OnButtonCancel(wxCommandEvent& event);
private :
-
- Gimmick* mGimmick;
+
+ Gimmick* mGimmick;
WxGimmickView* mView;
wxButton* mOkButton;
wxButton* mCancelButton;
+
enum
{
#include <creaImageIOWxGimmickTools.h>
+
namespace creaImageIO
{
/**
+#include <creaImageIOPACSConnection.h>
+#include <creaImageIOWxPACSConnectionPanel.h>
#include <creaImageIOWxGimmickView.h>
#include <creaImageIOWxTreeView.h>
#include <creaImageIOSystem.h>
#include <creaImageIOWxListenerPanel.h>
#include <creaImageIOWxEditFieldsPanel.h>
#include <creaImageIOWxAttributeSelectionPanel.h>
-#include <creaImageIOWxPACSConnectionPanel.h>
#include <creaImageIOWxDescriptorPanel.h>
using namespace crea;
#if defined(BUILD_BRUKER)
#include "bruker2dicom.h"
#endif
-
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#endif
namespace creaImageIO
{
// Previewer
mViewer = new WxViewer(mBottomPanel, wxID_ANY, wxT("Gimmick! Viewer"),wxDefaultPosition, wxDefaultSize );
- pointers.push_back(new ImagePointerHolder(GetDefaultImage()));
- mViewer->SetImageVector(pointers);
- mViewer->StartPlayer();
+ //pointers.push_back(new ImagePointerHolder(GetDefaultImage())
+ pointers.push_back(boost::shared_ptr<creaImageIO::ImagePointerHolder>(new ImagePointerHolder(GetDefaultImage())));
+
+ mViewer->SetImageVector(pointers);
+ mViewer->StartPlayer();
bottom_sizer->Add(mViewer,1,wxGROW,1);
"Requesting image from selected "
<<(*selected)->GetAttribute("FullFileName")
<<std::endl);
- ImagePointerHolder* ph=new ImagePointerHolder(GetDefaultImage());
+ //ImagePointerHolder* ph=new ImagePointerHolder(GetDefaultImage());
+ boost::shared_ptr<ImagePointerHolder> ph(new ImagePointerHolder(GetDefaultImage()));
pointers.push_back(ph);
RequestReading(*selected,prio,index,ph);
// AddEntryToMap(*selected);
"Requesting image from neighbors up "
<<(*iterUp)->GetAttribute("FullFileName")
<<std::endl);
- ImagePointerHolder* ph=new ImagePointerHolder(GetDefaultImage());
+// ImagePointerHolder* ph=new ImagePointerHolder(GetDefaultImage());
+ boost::shared_ptr<ImagePointerHolder> ph(new ImagePointerHolder(GetDefaultImage()));
RequestReading(*iterUp,prio,-1,ph);
// AddEntryToMap(*iterUp);
prio--;
"Requesting image from neighbors down "
<<(*iterDown)->GetAttribute("FullFileName")
<<std::endl);
- ImagePointerHolder* ph=new ImagePointerHolder(GetDefaultImage());
+ //ImagePointerHolder* ph=new ImagePointerHolder(GetDefaultImage());
+ boost::shared_ptr<ImagePointerHolder> ph(new ImagePointerHolder(GetDefaultImage()));
RequestReading(*iterDown,prio,-1,ph);
// AddEntryToMap(*iterDown);
prio--;
else
{
pointers.clear();
- ImagePointerHolder* ph=new ImagePointerHolder(GetDefaultImage());
+ //ImagePointerHolder* ph=new ImagePointerHolder(GetDefaultImage());
+ boost::shared_ptr<ImagePointerHolder> ph(new ImagePointerHolder(GetDefaultImage()));
pointers.push_back(ph);
mViewer->SetImageVector(pointers);
}
void WxGimmickView::ClearSelection()
{
pointers.clear();
- pointers.push_back(new ImagePointerHolder(GetDefaultImage()));
+ pointers.push_back(boost::shared_ptr<creaImageIO::ImagePointerHolder>(new ImagePointerHolder(GetDefaultImage())));
+ //pointers.push_back(new ImagePointerHolder(GetDefaultImage()));
mViewer->SetImageVector(pointers);
mViewer->RefreshIfNecessary();
ResetExtent();
//////////////////////////////////////////////////
void WxGimmickView::OnCreateDB(wxCommandEvent& event)
{
+ // PACSConnection("");
WxDescriptorPanel * DescriptorPan = new WxDescriptorPanel(this, mGimmick->GetHomeDirectory());
DescriptorPan->Layout();
if ( DescriptorPan->ShowModal() == ID_DSCP_APPLY)
///Currently Displayed Node
tree::Node* mCurImageItemToShow;
//Pointer holders for images to be shown
- std::vector<ImagePointerHolder*> pointers;
+ std::vector< boost::shared_ptr<ImagePointerHolder> > pointers;
wxString mCurrentDirectory;
#include <wx/gdicmn.h>
#include <boost/date_time/gregorian/gregorian.hpp>
-const std::string empty_string("");
//=====================================================================
namespace creaImageIO
{
- //=====================================================================
- /// Data stored by the list items
- struct ItemData
- {
- ItemData() : node(0), id(-1), attr(&empty_string) {}
- // The corresponding Node
- tree::Node* node;
- // The id ?
- int id;
- // The pointer on the current attribute string to sort on
- const std::string* attr;
- // Was the item previously selected ?
- // Useful for reselecting the item after sort
- bool selected;
- };
+
//=====================================================================
}
//=====================================================================
{
GimmickDebugMessage(1,"WxTreeView::~WxTreeView"
<<std::endl);
+ delete menu;
+ delete menuItem;
+
}
//=====================================================================
int l = level - 1;
// the selection of upper level
std::vector<tree::Node*>& sel(mLevelList[l].Selected);
- sel.clear();
+ if (sel.size() > 0)
+ {
+ sel.clear();
+ }
if (level == 1)
{
sel.push_back(GetTreeHandler()->GetTree().GetTree());
wxLIST_MASK_FORMAT
);
- ItemData* data = new ItemData;
+ ItemData* data = new ItemData();
data->node = *j;
data->id = _id;
-
+
item.SetId(_id);
item.SetData(data);
-
+
_id++;
GetCtrl(l)->InsertItem(item);
item.SetText( crea::std2wx(val));
item.SetColumn(k);
GetCtrl(l)->SetItem(item);
+ item.Clear();
}
}
#include <wx/listctrl.h>
#include <wx/splitter.h>
//#include <vector>
-
+const std::string empty_string("");
namespace creaImageIO
{
+ //=====================================================================
+ /// Data stored by the list items
+ struct ItemData
+ {
+ ItemData() : node(0), id(-1), attr(&empty_string) {}
+ // The corresponding Node
+ tree::Node* node;
+ // The id ?
+ int id;
+ // The pointer on the current attribute string to sort on
+ const std::string* attr;
+ // Was the item previously selected ?
+ // Useful for reselecting the item after sort
+ bool selected;
+ };
/**
* \ingroup View
*/
// or sorting
bool mIgnoreSelectedChanged;
-
DECLARE_EVENT_TABLE()
};
// EO class WxTreeView
#include <time.h>
using namespace crea;
-
+// Memory tracking allocation
namespace creaImageIO
{
//=====================================================================
//================================================================
- void WxViewer::SetImageVector(std::vector<ImagePointerHolder*>& pointers)
+ void WxViewer::SetImageVector(std::vector<boost::shared_ptr<ImagePointerHolder> >& pointers)
{
wxMutexLocker lock(mMutex);
GimmickDebugMessage(6,"WxViewer::SetImageVector"<<std::endl);
{
if (mCurrent<imagePointers.size())
{
- ImagePointerHolder* iph=imagePointers[mCurrent];
+ boost::shared_ptr<ImagePointerHolder> iph = imagePointers[mCurrent];
+ //ImagePointerHolder* iph= imagePointers[mCurrent];
vtkImageData* currIm=iph->Get();
ShowImage(currIm);
if ( currIm != mLastImageShown )
else
{
mCurrent = 0;
- ImagePointerHolder* iph=imagePointers[mCurrent];
+ //ImagePointerHolder* iph=imagePointers[mCurrent];
+ boost::shared_ptr<ImagePointerHolder> iph = imagePointers[mCurrent];
vtkImageData* currIm=iph->Get();
ShowImage(currIm);
if ( currIm != mLastImageShown )
///Refreshes the interface if the current image shown has changed
bool RefreshIfNecessary();
///Sets a new image vector to be read
- void SetImageVector(std::vector<ImagePointerHolder*>& pointers);
+
+ void SetImageVector(std::vector<boost::shared_ptr<ImagePointerHolder> > &pointers);
private:
vtkImageViewer2* mViewer;
/// Associated wxvtk interactor
crea::creawxVTKRenderWindowInteractor *mInteractor;
+
/// Current extent
int mx1,mx2,my1,my2,mz1,mz2;
/// Current spacing
///Last image shown
vtkImageData* mLastImageShown;
///The vectors of images to be shown
- std::vector<ImagePointerHolder*> imagePointers;
+ std::vector< boost::shared_ptr<ImagePointerHolder> > imagePointers;
};