<process>
<PRE>
- creaImageIO::WxSimpleDlg dlg(0,crea::std2wx(bbGetInputTitle()),"localdatabase_Descriptor.dscp","Local Database");
- dlg.SetAttrDicomTags( bbGetInputDicomTags() );
- dlg.ShowModal();
- bbSetOutputDicomInfo( dlg.getDicomInfoImagesSelected() );
- if (dlg.getImagesSelected().size()!=0)
+// creaImageIO::WxSimpleDlg dlg(0,crea::std2wx(bbGetInputTitle()),"localdatabase_Descriptor.dscp","Local Database");
+ creaImageIO::WxSimpleDlg *dlg = new creaImageIO::WxSimpleDlg(0,crea::std2wx(bbGetInputTitle()),"localdatabase_Descriptor.dscp","Local Database");
+ dlg->SetAttrDicomTags( bbGetInputDicomTags() );
+ dlg->ShowModal();
+ bbSetOutputDicomInfo( dlg->getDicomInfoImagesSelected() );
+ if (dlg->getImagesSelected().size()!=0)
{
- bbSetOutputFileName( std::string( dlg.getInfoImage().mb_str() ) );
- bbSetOutputOut( dlg.getVolumeSelected() );
+ bbSetOutputFileName( std::string( dlg->getInfoImage().mb_str() ) );
+ bbSetOutputOut( dlg->getVolumeSelected() );
} else {
bbSetOutputOut( NULL );
- } // if dlg.getImagesSelected().size()!=0
- bbSetOutputOutImages( dlg.getImagesSelected());
+ } // if dlg getImagesSelected() size() !=0
+ bbSetOutputOutImages( dlg->getImagesSelected());
bbSignalOutputModification( );
+
+ delete dlg;
+
</PRE>
</process>
: mImageAdder(0)
{
RegisterGimmickMessageTypes();
- mSettings=0;
- mSynchronizer=0;
+ mSettings = NULL;
+ mSynchronizer = NULL;
mLocalDescpName = "localdatabase_Descriptor.dscp";
- mLocalDBName = "Local database";
+ mLocalDBName = "Local database";
}
//==============================================================
//==============================================================
Gimmick::~Gimmick()
{
-
- if(mSettings!=0)
+ if(mSettings!=NULL)
{
mSettings->writeSettingsFile();
delete mSettings;
}
- if(mSynchronizer!=0)
+ if(mSynchronizer!=NULL)
{
delete mSynchronizer;
}
//==============================================================
void Gimmick::Initialize(const std::string i_namedescp, const std::string i_namedb)
{
- mLocalDescpName = i_namedescp;
- mLocalDBName = i_namedb;
+ mLocalDescpName = i_namedescp;
+ mLocalDBName = i_namedb;
Initialize();
}
CreateUserSettingsDirectory();
// Sets the current directory to the home dir
mCurrentDirectory = GetHomeDirectory();
- mSynchronizer= new Synchronizer(GetUserSettingsDirectory()+"share/creaImageIO/");
-
+ mSynchronizer= new Synchronizer( GetUserSettingsDirectory()+"share/creaImageIO/" );
mSettings = new Settings(mCurrentDirectory);
-
std::string dbpath = GetLocalDatabasePath();
-
// Create or open local database
std::string dpath= mCurrentDirectory + "/.creaImageIO/share/creaImageIO/" + mLocalDescpName;
-
boost::algorithm::replace_all( dpath,
INVALID_FILE_SEPARATOR ,
VALID_FILE_SEPARATOR);
mLocalDatabase = createDB(i_nameDB, dpath, dbpath);
// Add it to the TreeHandlerMap
mTreeHandlerMap[i_nameDB] = mLocalDatabase;
-
//Add additional DB from user Settings
addDBSettings();
}
-
#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
/// Destructor
GimmickView::~GimmickView()
{
+ printf("EED GimmickView::~GimmickView DESTROCTEUR \n");
GimmickDebugMessage(1,"GimmickView::~GimmickView"
<<std::endl);
}
/// Finalize
void GimmickView::Finalize()
{
+ printf("EED GimmickView::Finalize \n");
}
//======================================================================
vtkImageData* image)
{
wxMutexLocker lock(mMultiThreadImageReaderUserMutex);
-
this->OnMultiThreadImageReaderEvent(filename,type,image);
}
//=====================================================================
ThreadedImageReader(MultiThreadImageReader* tir) :
mMultiThreadImageReader(tir)
{}
-
void* Entry();
void OnExit();
-
vtkImageData* Read(const std::string& filename);
-
struct deleter
{
void operator()(ThreadedImageReader* p)
};
friend struct deleter;
-
private:
ImageReader mReader;
MultiThreadImageReader* mMultiThreadImageReader;
-
};
//=====================================================================
mDone = false;
// Create the threads
+
+printf("EED MultiThreadImageReader::MultiThreadImageReader %d \n", number_of_threads);
+
for (int i=0; i<number_of_threads; i++)
{
//ThreadedImageReader* t = new ThreadedImageReader(this);
//=====================================================================
bool MultiThreadImageReader::Start()
{
+printf("EED MultiThreadImageReader::Start Start\n");
// std::cout << "#### MultiThreadImageReader::Start()"
// <<std::endl;
if (mNumberOfThreadedReadersRunning > 0) return true;
for (i =mThreadedImageReaderList.begin();
i!=mThreadedImageReaderList.end();
i++)
- {
- (*i)->Create();
- if ( (*i)->Run() != wxTHREAD_NO_ERROR )
- {
- std::cout << "ERROR starting a thread"<< std::endl;
- return false;
- }
- else
- {
- std::cout << " ===> Thread "<<(*i)->GetCurrentId()
- <<" successfully created"<< std::endl;
-
- }
- }
- wxMutexLocker locker(GetMultiThreadImageReaderUserMutex());
- // std::cout << "EO Start : #Threads running = "
- // << mNumberOfThreadedReadersRunning<<std::endl;
-
+ {
+ (*i)->Create();
+ if ( (*i)->Run() != wxTHREAD_NO_ERROR )
+ {
+ std::cout << "ERROR starting a thread"<< std::endl;
+ return false;
+ } else {
+ std::cout << " ===> Thread "<<(*i)->GetCurrentId()
+ <<" successfully created"<< std::endl;
+ } // if
+ } // for
+ wxMutexLocker locker(GetMultiThreadImageReaderUserMutex());
+ // std::cout << "EO Start : #Threads running = "
+ // << mNumberOfThreadedReadersRunning<<std::endl;
+printf("EED MultiThreadImageReader::Start Start\n");
return true;
}
//=====================================================================
//=====================================================================
void MultiThreadImageReader::Stop()
{
+printf("EED MultiThreadImageReader::Stop Start\n");
// std::cout << "#### MultiThreadImageReader::Stop()"
// <<std::endl;
// std::cout << "Sending stop order to the threads..."<<std::endl;
+
if (mDone) return;
ThreadedImageReaderListType::iterator i;
for (i =mThreadedImageReaderList.begin();
i!=mThreadedImageReaderList.end();
i++)
- { std::cout << " ===> Thread "<<(*i)->GetCurrentId()
+ {
+ std::cout << " ===> Thread "<<(*i)->GetCurrentId()
<<" successfully stopped"<< std::endl;
if((*i)->IsAlive())
- {(*i)->Pause();
+ {
+ (*i)->Pause();
(*i).reset();
- // (*i)->Delete();
- }
- }
+// (*i)->Delete();
+ } // if i
+ } // for
mThreadedImageReaderList.clear();
// Wait a little to be sure that all threads have stopped
// A better way to do this ?
// std::cout << "All threads stopped : OK "<<std::endl;
ImageMapType::iterator j;
- for (j =mImages.begin();
- j!=mImages.end();
- ++j)
-
- {
- delete j->first;
- }
+ for (j =mImages.begin(); j!=mImages.end(); ++j)
+ {
+ delete j->first;
+ } //for
mImages.clear();
mDone = true;
+printf("EED MultiThreadImageReader::Stop End\n");
}
//=====================================================================
//=====================================================================
MultiThreadImageReader::~MultiThreadImageReader()
{
+printf("EED MultiThreadImageReader::~MultiThreadImageReader Start\n");
// std::cout << "#### MultiThreadImageReader::~MultiThreadImageReader()"
// <<std::endl;
Stop();
if (mReader) delete mReader;
mThreadedImageReaderList.clear();
+printf("EED MultiThreadImageReader::~MultiThreadImageReader End\n");
}
//=====================================================================
mPriority(prio),
mIndex(-1),
mUnloadIndex(-1),
- mImage(0)
+ mImage(NULL)
{}
+
~ImageToLoad()
{
- if (mImage>0)
- {
- // std::cout << "Refs = "<<mImage->GetReferenceCount()<<std::endl;
- mImage->Delete();
- }
+ if (mImage != NULL)
+ {
+ // std::cout << "Refs = "<<mImage->GetReferenceCount()<<std::endl;
+ mImage->Delete();
+ } // if
}
+
MultiThreadImageReaderUser* GetUser() const { return mUser; }
void SetUser( MultiThreadImageReaderUser* u ) { mUser = u; }
const std::string& GetFilename() const { return mFilename; }
public:
//====================================================================
/// Ctor with database file name
- SQLiteTreeHandler(const std::string& filename);
+ SQLiteTreeHandler( const std::string& filename);
/// Dtor
virtual ~SQLiteTreeHandler();
//====================================================================
namespace creaImageIO
{
- using namespace std;
+// using namespace std;
//================================================================================================================
///Represents the list of currently added files
class AddList
{
public:
///Ctor
- Synchronizer(const std::string& path);
+ Synchronizer( const std::string& path);
///Dtor
virtual ~Synchronizer();
///Initializes the database
namespace creaImageIO
{
+ YYYYYY
//==============================================================
Synchronizer::Synchronizer(TreeHandler * th)
: mHandler(th)
{
-
}
//==============================================================
wxCAPTION
),
// mGimmick(0),
- mView(0)
+ mView(NULL)
{
GimmickDebugMessage(1,"WxGimmickReaderDialog::WxGimmickReaderDialog"
<<std::endl);
mView->Initialize();
// Connect the AddProgress callback
mView->ConnectValidationObserver( boost::bind( &WxGimmickReaderDialog::OnValid , this, _1 ) );
- }
- catch (crea::Exception e)
- {
- e.Print();
- return;
+ } catch (crea::Exception e) {
+ printf("EED WxGimmickReaderDialog::WxGimmickReaderDialog catch 1\n");
+ e.Print();
+ printf("EED WxGimmickReaderDialog::WxGimmickReaderDialog catch 2\n");
+ return;
}
mtopsizer->Add( mView,1,wxGROW,0);
wxSizer* bsizer = this->CreateSeparatedButtonSizer(wxOK|wxCANCEL);
const wxPoint& pos,
const wxSize& size,
int min_dim,
- int max_dim,
+ int max_dim,
int number_of_threads)
: wxPanel(parent,id,pos,size),
GimmickView(gimmick, number_of_threads),
- mProgressDialog(0),
+ mProgressDialog(NULL),
mConstructed(false)
{
- GimmickDebugMessage(1,"WxGimmickView::WxGimmickView"
- <<std::endl);
+ GimmickDebugMessage(1,"WxGimmickView::WxGimmickView" <<std::endl);
// Sets the current directory to the home dir
mCurrentDirectory = std2wx(gimmick->GetHomeDirectory());
-
// Connect the AddProgress callback
- gimmick->ConnectAddProgressObserver
- ( boost::bind( &WxGimmickView::OnAddProgress , this, _1 ) );
+ gimmick->ConnectAddProgressObserver( boost::bind( &WxGimmickView::OnAddProgress , this, _1 ) );
// Create the list of icons (mIcon)
CreateIconList();
mSplitter = new wxSplitterWindow( this , -1);
// Notebook
- mNotebook = new wxNotebook(mSplitter,
- -1, wxDefaultPosition, wxDefaultSize, 0);
+ mNotebook = new wxNotebook(mSplitter, -1, wxDefaultPosition, wxDefaultSize, 0);
//Gimmick
mGimmick=gimmick;
mText = new wxStaticText(mBottomPanel, wxID_ANY, wxT("Welcome to Gimmick!"));
mbottom_sizer->Add(mText,0,wxGROW,0);
-
-
-
+
mBottomPanel->SetSizer(mbottom_sizer);
// Splitting
int bottom_minsize = 50;
mSplitter->SetMinimumPaneSize( bottom_minsize );
- mSplitter->SplitHorizontally( mNotebook, mBottomPanel,
- top_minsize);
+ mSplitter->SplitHorizontally( mNotebook, mBottomPanel, top_minsize);
msizer->Add( mSplitter, 1, wxGROW, 0);
- mProgressDialog=0;
+ mProgressDialog=NULL;
SetSizer( msizer );
SetAutoLayout(true);
Layout();
{
// stop the viewer before application exit.
mViewer->StopPlayer();
- GimmickDebugMessage(1,"WxGimmickView::~WxGimmickView"
- <<std::endl);
+ GimmickDebugMessage(1,"WxGimmickView::~WxGimmickView" <<std::endl);
delete mIcon;
delete mViewer;
//if(mListener->IsAlive()) { mListener->Delete(); }
void WxGimmickView::CreateTreeView( TreeHandler* h)
{
std::string name(h->GetTree().GetAttribute("Name"));
- GimmickMessage(2,"Creating the tree view for '"<<
- name<<"'"<<std::endl);
+ GimmickMessage(2,"Creating the tree view for '"<< name<<"'"<<std::endl);
// Create the WxTreeView
WxTreeView* view = new WxTreeView(h, this, mNotebook, -1);
//EED1 2018-08
-//EED1 ReadImageThreaded(sel);
+// ReadImageThreaded(sel);
}
///Reads Images (Threaded)
void WxGimmickView::ReadImageThreaded(const std::vector<tree::Node*>& sel)
{
- GimmickDebugMessage(5,
- "ReadImageThreaded"
- <<std::endl);
+ GimmickDebugMessage(5, "ReadImageThreaded" <<std::endl);
int maxprio = GetMaximalPriority();
int prio = maxprio + 2000;
wxString s(wxString::From8BitData(mess));
// std::cout << "Pulse"<<std::endl;
- if(mProgressDialog != 0)
+ if(mProgressDialog != NULL)
{
if (!mProgressDialog->Pulse(s))
{
{
mProgressDialog->Resume();
mProgressDialog->Destroy();
- mProgressDialog = 0;
+ mProgressDialog = NULL;
}
//=================================================
private:
- wxBoxSizer *mbottom_sizer;
- wxBoxSizer *msizer;
+ wxBoxSizer *mbottom_sizer;
+ wxBoxSizer *msizer;
/// Is set to true at the end of constructor
/// (in order to lock callbacks from threaded objects or event
/// before everything is ok)
- bool mConstructed;
+ bool mConstructed;
/// The ToolBar and the tools
- wxToolBar* mToolBar;
- wxToolBarToolBase* mToolAddFile;
- wxToolBarToolBase* mToolAddDir;
- wxToolBarToolBase* mToolRemove;
- wxToolBarToolBase* mToolAddDatabase;
- wxToolBarToolBase* mToolHelp;
- wxToolBarToolBase* mToolSynchronize;
- wxToolBarToolBase* mToolSettings;
- wxToolBarToolBase* mToolTools;
+ wxToolBar *mToolBar;
+ wxToolBarToolBase *mToolAddFile;
+ wxToolBarToolBase *mToolAddDir;
+ wxToolBarToolBase *mToolRemove;
+ wxToolBarToolBase *mToolAddDatabase;
+ wxToolBarToolBase *mToolHelp;
+ wxToolBarToolBase *mToolSynchronize;
+ wxToolBarToolBase *mToolSettings;
+ wxToolBarToolBase *mToolTools;
- wxSplitterWindow* mSplitter;
- wxPanel* mBottomPanel;
- wxStaticText * mText;
- wxNotebook* mNotebook;
+ wxSplitterWindow *mSplitter;
+ wxPanel *mBottomPanel;
+ wxStaticText *mText;
+ wxNotebook *mNotebook;
/// The list of icons
- wxImageList * mIcon;
+ wxImageList *mIcon;
void CreateIconList();
boost::shared_ptr<Gimmick> mGimmick;
- Listener* mListener;
+ Listener *mListener;
/// Callback for adding files
void OnAddFiles(wxCommandEvent& event);
void ExportToStorage(const std::vector<std::string> i_filenames);
/// Progress dialog
- wxProgressDialog* mProgressDialog;
+ wxProgressDialog *mProgressDialog;
///The selection's maximum dimension
int mSelectionMaxDimension;
int mSelectionMinDimension;
///Image previewer
- WxViewer* mViewer;
+ WxViewer *mViewer;
///Currently Displayed Node
- tree::Node* mCurImageItemToShow;
+ tree::Node *mCurImageItemToShow;
//Pointer holders for images to be shown
std::vector< boost::shared_ptr<ImagePointerHolder> > pointers;
GIMMICK_2D_IMAGE_SELECTION,
GIMMICK_3D_IMAGE_SELECTION,
_3D,
- 1);
+ 0);
dlg.ShowModal();
if (dlg.GetReturnCode() == wxID_OK)
{
-//EED1 2018-08
-//EED1 dlg.stopReading();
+ dlg.stopReading();
std::vector<creaImageIO::OutStrGimmick> outStrGimmick;
+printf("EED WxSimpleDlg::OnReadGimmick 1 \n");
dlg.getSelected(outStrGimmick, m_attrDicomTags,true,"");
+printf("EED WxSimpleDlg::OnReadGimmick 2 \n");
m_results.clear();
int size=(int)outStrGimmick.size();
int ii;
const std::string& s1(*(data1->attr));
const std::string& s2(*(data2->attr));
+
if(sortData==1)
{
// inverse the order
: wxPanel(parent,id),
TreeView(handler, gimmick)
{
- GimmickDebugMessage(1,"WxTreeView::WxTreeView"
- <<std::endl);
+ GimmickDebugMessage(1,"WxTreeView::WxTreeView"<<std::endl);
-
// Split part below toolbar into notebook for views and panel
// for preview, messages...
// TO DO : Splitter
// mSplitter = new wxSplitterWindow( this , -1);
// Global sizer
- msizer = new wxBoxSizer(wxHORIZONTAL);
-
- int ctrl_style = wxLC_REPORT | wxLC_VRULES;
- int col_style = wxLIST_FORMAT_LEFT;
-
+ msizer = new wxBoxSizer(wxHORIZONTAL);
+ int ctrl_style = wxLC_REPORT | wxLC_VRULES;
+ int col_style = wxLIST_FORMAT_LEFT;
// Creating the ListCtrl for the levels > 0 (not for Root level)
- for (int i = 0;
- i < handler->GetTree().GetNumberOfLevels() -1;
- ++i)
- {
- GimmickDebugMessage(5,"Creating view for level "<<i
- <<std::endl);
- LevelType level;
- level.SelectedUpToDate = true;
- level.SortColumn = 0;
-
- // If the first level : parent = this
- wxWindow* sparent = this;
- // else parent = last splitter
- if (i>0)
- sparent = mLevelList[i-1].wxSplitter;
-
- level.wxSplitter = new wxSplitterWindow( sparent , -1);
- if(i!=0)
- {
- level.wxSplitter->Show(false);
- }
- // level.wxSplitter->SetMinimumPaneSize(100);
-
- wxListCtrl* ctrl = new wxListCtrl(level.wxSplitter,
- i,
- wxDefaultPosition,
- wxDefaultSize,
- ctrl_style);
- level.wxCtrl = ctrl;
- level.wxSplitter->Initialize(ctrl);
-
- // Create the columns : one for each attribute of the level
- int col = 0;
- std::string title;
-
- tree::LevelDescriptor::AttributeDescriptorListType::const_iterator a;
- for (a = handler->GetTree().GetAttributeDescriptorList(i+1).begin();
- a != handler->GetTree().GetAttributeDescriptorList(i+1).end();
- ++a)
-
-{
-
- GimmickDebugMessage(5,"Creating column "<<col<<" : "
- <<a->GetName()
- <<std::endl);
-
- if(a->GetFlags()!=creaImageIO::tree::AttributeDescriptor::PRIVATE)
- {
-
- if(a->GetName()=="UNKNOWN")
- {
- title = "#";
- title += handler->GetTree().GetLevelDescriptor(i+1).GetName();
- if (title[title.size()-1]!='s')
- title += "s";
-
- }
- else
- {
- title=a->GetName();
- }
- std::string temp = a->GetKey();
- if (temp.compare("ID") != 0)
- {
+ for (int i = 0;i < handler->GetTree().GetNumberOfLevels() -1; ++i)
+ {
+ GimmickDebugMessage(5,"Creating view for level "<<i <<std::endl);
+ LevelType level;
+ level.SelectedUpToDate = true;
+ level.SortColumn = 0;
+
+ // If the first level : parent = this
+ wxWindow* sparent = this;
+ // else parent = last splitter
+ if (i>0)
+ {
+ sparent = mLevelList[i-1].wxSplitter;
+ } // if
+ level.wxSplitter = new wxSplitterWindow( sparent , -1);
+ if(i!=0)
+ {
+ level.wxSplitter->Show(false);
+ } // if
+ // level.wxSplitter->SetMinimumPaneSize(100);
- ctrl->InsertColumn(col,
- crea::std2wx(title),
- col_style);
- col++;
- }
- level.key.push_back(a->GetKey());
- }
+ wxListCtrl* ctrl = new wxListCtrl(level.wxSplitter,
- }
-
- mLevelList.push_back(level);
- }
+// EED1 2018-08-16
+// i,
+ wxID_ANY,
+
+ wxDefaultPosition,
+ wxDefaultSize,
+ ctrl_style);
+ level.wxCtrl = ctrl;
+ level.wxSplitter->Initialize(ctrl);
+
+ // Create the columns : one for each attribute of the level
+ int col = 0;
+ std::string title;
+
+ tree::LevelDescriptor::AttributeDescriptorListType::const_iterator a;
+ for (a = handler->GetTree().GetAttributeDescriptorList(i+1).begin();
+ a != handler->GetTree().GetAttributeDescriptorList(i+1).end();
+ ++a)
+ {
+ GimmickDebugMessage(5,"Creating column "<<col<<" : " <<a->GetName() <<std::endl);
+ if(a->GetFlags()!=creaImageIO::tree::AttributeDescriptor::PRIVATE)
+ {
+ if(a->GetName()=="UNKNOWN")
+ {
+ title = "#";
+ title += handler->GetTree().GetLevelDescriptor(i+1).GetName();
+ if (title[title.size()-1]!='s')
+ {
+ title += "s";
+ } // if
+ } else {
+ title=a->GetName();
+ } // if a
+ std::string temp = a->GetKey();
+ if (temp.compare("ID") != 0)
+ {
+ ctrl->InsertColumn(col,crea::std2wx(title),col_style);
+ col++;
+ } // if temp
+ level.key.push_back(a->GetKey());
+ } // if
+
+ } // for a
+ mLevelList.push_back(level);
+ } // for i
#if wxUSE_MENUS
// Column Menu
- menu =new wxMenu;
+ menu =new wxMenu();
wxMenuItem* m1=menu->Append(wxID_ANY, _T("&Sort ascending"));
wxMenuItem* m2=menu->Append(wxID_ANY, _T("&Sort descending"));
wxMenuItem* m3=menu->Append(wxID_ANY, _T("&Filter"));
////SubMenuItem EXPORT
- subExportMenu = new wxMenu;
+ subExportMenu = new wxMenu();
wxMenuItem *subExp1 = subExportMenu->Append(wxID_ANY, _T("&Export to Storage"));
Connect( subExp1->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(WxTreeView::OnExportToStorage) );
//ItemMenu
- menuItem =new wxMenu;
-
+ menuItem =new wxMenu();
wxMenuItem* m2Item=menuItem->Append(wxID_ANY, _T("&Local Copy"));
wxMenuItem* m3Item=menuItem->Append(wxID_ANY, _T("&Edit Fields"));
wxMenuItem* m4Item=menuItem->Append(wxID_ANY, _T("&Display Dicom Tags"));
menuItem->AppendSubMenu(subExportMenu, wxT("&Export"));
-
wxMenuItem* m1Item=menuItem->Append(wxID_ANY, _T("&Anonymize"));
mAnonymizingID=m1Item->GetId();
Connect( mAnonymizingID, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(WxTreeView::OnAnonymizer) );
mEditFieldID=m3Item->GetId();
mDumpID=m4Item->GetId();
-
Connect( mLocalCopyID, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(WxTreeView::OnLocalCopy) );
Connect( mEditFieldID, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(WxTreeView::OnEditField) );
Connect( mDumpID, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(WxTreeView::OnDumpTags) );
-
-
#endif // wxUSE_MENUS
/// Initialize the first level splitter
msizer->Add( mLevelList[0].wxSplitter ,1, wxGROW ,0);
- // mColumnSelected=1;
- mLastSelected=0;
- mLastLevel=0;
- // mDirection=true;
+ // mColumnSelected = 1;
+ mLastSelected = 0;
+ mLastLevel = 0;
+ // mDirection = true;
mIgnoreSelectedChanged = false;
SetSizer( msizer );
SetAutoLayout(true);
Layout();
-
}
//=====================================================================
/// Destructor
WxTreeView::~WxTreeView()
{
- GimmickDebugMessage(1,"WxTreeView::~WxTreeView"
- <<std::endl);
+ GimmickDebugMessage(1,"WxTreeView::~WxTreeView"<<std::endl);
delete menu;
delete menuItem;
-
}
//=====================================================================
-
-
//=====================================================================
const std::vector<tree::Node*>& WxTreeView::GetSelected(int level)
{
-printf("EED WxTreeView::GetSelected Start\n");
-
std::vector<tree::Node*>& sel = mLevelList[0].Selected;
// if (GetSelectedUpToDate(level))
int l = level - 1;
// the selection of upper level
-printf("EED WxTreeView::GetSelected 1\n");
if(mLevelList.size() == level -1)
{
sel = mLevelList.back().Selected;
} else {
sel= mLevelList[l].Selected;
}
-printf("EED WxTreeView::GetSelected 2\n");
if (sel.size() > 0)
{
sel.clear();
}
-printf("EED WxTreeView::GetSelected 3\n");
if (level == 1)
{
-printf("EED WxTreeView::GetSelected 4\n");
- sel.push_back(GetTreeHandler()->GetTree().GetTree());
- } else if (level < mLevelList.size()+2 )
- {
-printf("EED WxTreeView::GetSelected 5\n");
+ sel.push_back( GetTreeHandler()->GetTree().GetTree() );
+ } else if (level < mLevelList.size()+2 ) {
long item = -1;
for ( ;; )
{
-printf("EED WxTreeView::GetSelected 5.1\n");
- item = GetCtrl(l-1)->GetNextItem(item,
+ item = GetCtrl(l-1)->GetNextItem(item,
wxLIST_NEXT_ALL,
wxLIST_STATE_SELECTED);
-printf("EED WxTreeView::GetSelected 5.2\n");
if ( item == -1 )
{
-printf("EED WxTreeView::GetSelected 5.3\n");
break;
}
- long adr = (long)GetCtrl(l-1)->GetItemData(item);
-printf("EED WxTreeView::GetSelected 5.4\n");
- tree::Node* n = ((ItemData*)adr)->node;
+// long adr = (long)GetCtrl(l-1)->GetItemData(item);
+ ItemData* adr = (ItemData*)GetCtrl(l-1)->GetItemData(item);
+// tree::Node* n = ((ItemData*)adr)->node;
+ tree::Node* n = adr->node;
/* FCY 18-04-2011: don't understand the real purpose of these lines,
if uncomment add last frame in first place
if(mLastSelected==item)
}
else
{*/
-printf("EED WxTreeView::GetSelected 6\n");
sel.push_back(n);
//}
}
// return mLevelList[level-1].Selected;
-printf("EED WxTreeView::GetSelected End\n");
return sel;
}
// if no selection, no remove action.
if(sel.size() != 0)
{
-
std::stringstream out;
std::string levelName=GetTreeHandler()->GetTree().GetLevelDescriptor(mLastLevel).GetName();
out<<"Delete ";
/// Updates a level of the view (adds or removes children, etc.)
void WxTreeView::UpdateLevel( int level )
{
-printf("EED WxTreeView::UpdateLevel Start\n ");
GimmickDebugMessage(1,
GetTreeHandler()->GetTree().GetLabel()
<<"WxTreeView::UpdateLevel(level "
<<std::endl);
wxBusyCursor busy;
-printf("EED WxTreeView::UpdateLevel 1\n ");
RecursiveUpdateLevel(level);
-printf("EED WxTreeView::UpdateLevel 2\n ");
int i;
for (i=0; i<level-1; i++)
{
-printf("EED WxTreeView::UpdateLevel 3\n ");
if (!GetSplitter(i)->IsSplit())
{
-printf("EED WxTreeView::UpdateLevel 4\n ");
GetSplitter(i)->SplitVertically( GetCtrl(i), GetSplitter(i+1),100 );
} // if
} // for
-printf("EED WxTreeView::UpdateLevel 5\n ");
if (GetSplitter(i)->IsSplit())
{
-printf("EED WxTreeView::UpdateLevel 6\n ");
GetSplitter(i)->Unsplit();
}
-printf("EED WxTreeView::UpdateLevel End\n ");
}
//=====================================================================
/// Recursive method called upon by UpdateLevel to refresh all windows
void WxTreeView::RecursiveUpdateLevel( int level )
{
-printf("EED WxTreeView::RecursiveUpdateLevel Start\n");
GimmickDebugMessage(1,
GetTreeHandler()->GetTree().GetLabel()
<<"WxTreeView::RecursiveUpdateLevel(level "
<<level
<<")"<<std::endl);
-printf("EED WxTreeView::RecursiveUpdateLevel 0.1\n");
-
+ int l = level - 1;
const std::vector<tree::Node*>& sel(GetSelected(level));
-printf("EED WxTreeView::RecursiveUpdateLevel 0.2\n");
- int l = level - 1;
-printf("EED WxTreeView::RecursiveUpdateLevel 0.3\n");
// to speed up inserting we hide the control temporarily
GetCtrl(l)->Hide();
-printf("EED WxTreeView::RecursiveUpdateLevel 0.4\n");
GetCtrl(l)->DeleteAllItems();
-printf("EED WxTreeView::RecursiveUpdateLevel 0.5\n");
std::vector<tree::Node*>::const_iterator i;
-printf("EED WxTreeView::RecursiveUpdateLevel 1\n");
for (i=sel.begin(); i!=sel.end(); ++i)
{
-printf("EED WxTreeView::RecursiveUpdateLevel 2\n");
GimmickDebugMessage(1,
"adding children of '"
<<(*i)->GetLabel()
j!= (*i)->GetChildrenList().rend();
++j)
{
-printf("EED WxTreeView::RecursiveUpdateLevel 3\n");
GimmickDebugMessage(1,
"adding children "
<<(*j)->GetLabel()
wxLIST_MASK_FORMAT
);
- ItemData* data = new ItemData();
- data->node = *j;
- data->id = _id;
+ ItemData* data = new ItemData();
+ data->node = *j;
+ data->id = _id;
item.SetId(_id);
item.SetData(data);
//Setting attributes
for (int k=0; k<GetCtrl(l)->GetColumnCount(); ++k)
- {
- std::string val;
- // Temporary correction : it works but no explanation about the problem FCY
-
- if(k==0 && level <3)
- {
- val = (*j)->GetAttribute("NumberOfChildren");
- } else {
- val = (*j)->GetAttribute(mLevelList[l].key[k]);
- }
-printf("EED WxTreeView::RecursiveUpdateLevel 4\n");
- if(((*j)->GetAttributeDescriptor(mLevelList[l].key[k])).isDateEntry()) // Date
- {
- // std::cout << "["<<val<< "]" << std::endl;
- std::string valtmp(val);
- try
- {
- boost::gregorian::date d1(boost::gregorian::from_undelimited_string(val));
- val = to_iso_extended_string(d1);
- }
- catch (...)
- {
- val = valtmp;
- }
- // std::cout << "["<<val<< "]" << std::endl;
- } else if(((*j)->GetAttributeDescriptor(mLevelList[l].key[k])).isTimeEntry()) // Time
- {
- if ((val.size()>6) &&
- (val != "" || val != " "))
- val = val.substr(0,2) + " : "
- + val.substr(2,2) + " : "
- + val.substr(4,2);
- } else {
- if (val.size()==0) val = "?";
- }
-printf("EED WxTreeView::RecursiveUpdateLevel 5\n");
- if (val.size()==0) val = "X";
- item.SetText( crea::std2wx(val));
- item.SetColumn(k);
+ {
+ std::string val;
+ // Temporary correction : it works but no explanation about the problem FCY
+ if(k==0 && level <3)
+ {
+ val = (*j)->GetAttribute("NumberOfChildren");
+ } else {
+ val = (*j)->GetAttribute(mLevelList[l].key[k]);
+ }
+ if(((*j)->GetAttributeDescriptor(mLevelList[l].key[k])).isDateEntry()) // Date
+ {
+ // std::cout << "["<<val<< "]" << std::endl;
+ std::string valtmp(val);
+ try
+ {
+ boost::gregorian::date d1(boost::gregorian::from_undelimited_string(val));
+ val = to_iso_extended_string(d1);
+ } catch (...) {
+ val = valtmp;
+ }
+ // std::cout << "["<<val<< "]" << std::endl;
+ } else if(((*j)->GetAttributeDescriptor(mLevelList[l].key[k])).isTimeEntry()) // Time
+ {
+ if ((val.size()>6) && (val != "" || val != " "))
+ {
+ val = val.substr(0,2) + " : " + val.substr(2,2) + " : " + val.substr(4,2);
+ }
+ } else {
+ if (val.size()==0)
+ {
+ val = "?";
+ }
+ } // if j
+ if (val.size()==0)
+ {
+ val = "X";
+ }
+ item.SetText( crea::std2wx(val));
+ item.SetColumn(k);
- GetCtrl(l)->SetItem(item);
- }
+ GetCtrl(l)->SetItem(item);
+ } // for k
item.Clear();
- }
- }
-printf("EED WxTreeView::RecursiveUpdateLevel 6\n");
+ } // for j
+ } // for i
SortLevel(l);
-printf("EED WxTreeView::RecursiveUpdateLevel 7\n");
GetCtrl(l)->Show();
-printf("EED WxTreeView::RecursiveUpdateLevel End\n");
}
//=====================================================================
//================================================================
void WxTreeView::OnItemSelected(wxListEvent& event)
{
-printf("EED WxTreeView::OnItemSelected Start\n");
GimmickDebugMessage(1,GetTreeHandler()->GetTree().GetLabel()<<" WxTreeView::OnItemSelected"<<std::endl);
if (mIgnoreSelectedChanged)
{
GimmickDebugMessage(1, " mIgnoreSelectedChanged true: returning"<<std::endl);
-printf("EED WxTreeView::OnItemSelected 0.1\n");
return;
}
-
-printf("EED WxTreeView::OnItemSelected 1\n");
-
+
wxListItem info;
info.m_itemId = event.m_itemIndex;
mLastSelected = event.m_itemIndex;
mLastLevel=level;
GimmickDebugMessage(1," Level "<<level+1<<std::endl);
-printf("EED WxTreeView::OnItemSelected 2 %d %d \n", level, mLevelList.size() );
// Update the children level (if selection not at last level)
if (level<mLevelList.size()-1)
{
-printf("EED WxTreeView::OnItemSelected 2.0\n");
UpdateLevel( level + 2 );
// Reset the viewer setting the default image
-printf("EED WxTreeView::OnItemSelected 2.1\n");
GetGimmickView()->ClearSelection();
-printf("EED WxTreeView::OnItemSelected 2.2\n");
}
-printf("EED WxTreeView::OnItemSelected 3\n");
// Select all images if the selection is at series level
if (level==mLevelList.size()-2)
{
-printf("EED WxTreeView::OnItemSelected 4\n");
SelectAll(level+1);
}
-printf("EED WxTreeView::OnItemSelected 5\n");
// Validate selected images if the selection is at image level
if (level==(mLevelList.size()-1)) //&&mProcess)
{
ValidateSelectedImages (false);
}
} // if
-printf("EED WxTreeView::OnItemSelected End\n");
}
//================================================================
//================================================================
void WxTreeView::SelectAll(int level)
- {
-printf("EED WxTreeView::SelectAll Start\n");
-
+ {
long item = -1;
// int level=mLevelList.size()-1;
for ( ;; )
- {
- item = GetCtrl(level)->GetNextItem(item,
- wxLIST_NEXT_ALL);
- if ( item == -1 )
- break;
-
- if(item==(GetCtrl(level)->GetItemCount()-1))
- {
- mIgnoreSelectedChanged = false;//mProcess=true;
- }
- else
- {
- mIgnoreSelectedChanged = true;// mProcess=false;
- }
- GetCtrl(level)->SetItemState(item,wxLIST_STATE_SELECTED, wxLIST_MASK_STATE
- | wxLIST_MASK_TEXT |wxLIST_MASK_IMAGE | wxLIST_MASK_DATA | wxLIST_MASK_WIDTH | wxLIST_MASK_FORMAT);
- }
-printf("EED WxTreeView::SelectAll End\n");
-
+ {
+ item = GetCtrl(level)->GetNextItem(item,wxLIST_NEXT_ALL);
+ if ( item == -1 )
+ {
+ break;
+ }
+ if(item==(GetCtrl(level)->GetItemCount()-1))
+ {
+ mIgnoreSelectedChanged = false;//mProcess=true;
+ } else {
+ mIgnoreSelectedChanged = true;// mProcess=false;
+ }
+ GetCtrl(level)->SetItemState(item,wxLIST_STATE_SELECTED, wxLIST_MASK_STATE
+ | wxLIST_MASK_TEXT |wxLIST_MASK_IMAGE | wxLIST_MASK_DATA | wxLIST_MASK_WIDTH | wxLIST_MASK_FORMAT);
+ } // for
}
//================================================================
//================================================================
void WxTreeView::SortLevel(int level)
{
-printf("EED WxTreeView::SortLevel Start %d \n", level);
GimmickDebugMessage(1,
"WxTreeView::SortLevel("
<<level<<")"
<<nbselected<<" selected before sorting"
<<std::endl);
-printf("EED WxTreeView::SortLevel 1\n");
mIgnoreSelectedChanged = true;
//
if (mLevelList[level].SortAscending)
{
-printf("EED WxTreeView::SortLevel 2\n");
-
if(ty==1)
{
GetCtrl(level)->SortItems(CompareFunctionInts, 0);
} // if ty
} //mLevelList
-printf("EED WxTreeView::SortLevel 3\n");
-
// Reselects the unselected
n = GetCtrl(level)->GetItemCount();
int after = 0;
if (data->selected)
{
-printf("EED WxTreeView::SortLevel 4\n");
nbselected--;
if (nbselected==0)
{
"WxTreeView::SortLevel : "
<<after<<" selected after sorting"
<<std::endl);
-
-printf("EED WxTreeView::SortLevel End\n");
- }
+ }
//================================================================
/// such as the vector of attribute keys corresponding to the columns
struct LevelType
{
- // The List Control
- wxListCtrl* wxCtrl;
- wxSplitterWindow* wxSplitter;
- std::vector<std::string> key;
- // The vector of currently selected nodes of the level
- std::vector<tree::Node*> Selected;
- // True iff the vector Selected is up to date
- bool SelectedUpToDate;
- // The column used for sorting
- unsigned int SortColumn;
- ///Boolean that defines the direction of the sort
- ///True is ascending order and false is descending
- bool SortAscending;
- //The vector of not shown attributes
- std::vector<std::string> notShownAtts;
+ // The List Control
+ wxListCtrl *wxCtrl;
+ wxSplitterWindow *wxSplitter;
+ std::vector<std::string> key;
+ // The vector of currently selected nodes of the level
+ std::vector<tree::Node*> Selected;
+ // True iff the vector Selected is up to date
+ bool SelectedUpToDate;
+ // The column used for sorting
+ unsigned int SortColumn;
+ ///Boolean that defines the direction of the sort
+ ///True is ascending order and false is descending
+ bool SortAscending;
+ //The vector of not shown attributes
+ std::vector<std::string> notShownAtts;
};
/// The vector of levels : one for each level of the tree
std::vector<LevelType> mLevelList;
///Initial color palette
std::vector<std::string> mColorPalette;
- wxMenu* menu;
+ wxMenu *menu;
- wxObject* senderCtrl;
+ wxObject *senderCtrl;
int mAscendingID;
int mDescendingID;
int mFilterID;
unsigned int mLastLevel;
- wxMenu* menuItem;
- wxMenu *subExportMenu;
+ wxMenu *menuItem;
+ wxMenu *subExportMenu;
int mAnonymizingID;
int mLocalCopyID;
int mEditFieldID;
wxString title,
const wxSize& size);
~RemoveAlertDlg();
-
bool isChecked();
private :
size)
{
wxMutexLocker lock(mMutex);
- GimmickDebugMessage(6,"WxViewer::WxViewer"
- <<std::endl);
+ GimmickDebugMessage(6,"WxViewer::WxViewer" <<std::endl);
- mNeedRefresh = false;
+ mNeedRefresh = false;
mLastImageShown = NULL;
// previewer
mViewer = vtkImageViewer2::New();
mViewer->SetupInteractor ( mInteractor );
- mCurrent = 0;
- mPlayer = 0;
+ mCurrent = 0;
+ mPlayer = NULL;
// Grid to place checkbox and slider
mflexSizer = new wxFlexGridSizer(1,2,1,1);
WxViewer::~WxViewer()
{
wxMutexLocker lock(mMutex);
- GimmickDebugMessage(6,"WxViewer::~WxViewer"
- <<std::endl);
+ GimmickDebugMessage(6,"WxViewer::~WxViewer"<<std::endl);
// TO DO : desallocate cleanly
if(mPlayer)
{
void WxViewer::ShowNextImage()
{
-
-
- mMutex.Unlock();
+ mMutex.Unlock();
wxMutexLocker lock(mMutex);
GimmickMessage(2,"WxViewer::ShowNextImage() "
mNeedRefresh = true;
mLastImageShown = currIm;
}
- mCurrent++;
- }
- else
- {
+ mCurrent++;
+ } else {
mCurrent = 0;
//ImagePointerHolder* iph=imagePointers[mCurrent];
boost::shared_ptr<ImagePointerHolder> iph = imagePointers[mCurrent];
mLastImageShown = currIm;
}
mCurrent++;
- }
- }
+ } // if mCurrent
+ } // if imagePointers
}
//================================================================
bool WxViewer::RefreshIfNecessary()
{
if (mNeedRefresh)
- {
- GimmickDebugMessage(10,"WxViewer : Refreshing"<<std::endl);
-
- mInteractor->Render();
- mNeedRefresh = false;
- return true;
- }
+ {
+ GimmickDebugMessage(10,"WxViewer : Refreshing"<<std::endl);
+ mInteractor->Render();
+ mNeedRefresh = false;
+ return true;
+ }
return false;
}
//================================================================
void WxViewer::StopPlayer()
{
wxMutexLocker lock(mMutex);
- if (mPlayer==0 ) return;
+ if (mPlayer==NULL ) return;
mPlayer->Delete();
- mPlayer=0;
+ mPlayer=NULL;
mMutex.Unlock();
}
//================================================================
if(mcheck->IsChecked())
{
// wxMutexLocker lock(mMutex);
- if (mPlayer != 0) return;
+ if (mPlayer != NULL) return;
mPlayer = new WxViewerPlayer(this);
mPlayer->Create();
mPlayer->Run();
- }
- else
- {
+ } else {
ShowNextImage();
- }
+ } // if
}
//================================================================
{
mPlayer->Pause();
mPlayer->Delete();
- mPlayer = 0;
+ mPlayer = NULL;
}
StartPlayer();
}
///Shows the image passed as parameter
void ShowImage(vtkImageData* im);
/// Previewer
- vtkImageViewer2* mViewer;
+ vtkImageViewer2 *mViewer;
///Slider
- wxSlider *mslide ;
+ wxSlider *mslide ;
///CheckBox to cine loop
- wxCheckBox *mcheck;
+ wxCheckBox *mcheck;
/// Associated wxvtk interactor
crea::wxVTKRenderWindowInteractor *mInteractor;
/// Current image shown
int mCurrent;
///The threaded movie player
- WxViewerPlayer* mPlayer;
+ WxViewerPlayer *mPlayer;
/// The mutex
wxMutex mMutex;
/// Boolean that declares if the player needs to be refreshed