From: Eduardo DAVILA Date: Fri, 17 Aug 2018 10:41:10 +0000 (+0200) Subject: #3218 creaImageIO Feature New Normal - vtk8itk4wx3-mingw64 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=79372affb878a3ffd7896b8ffbb06b564c0550ce;p=creaImageIO.git #3218 creaImageIO Feature New Normal - vtk8itk4wx3-mingw64 --- diff --git a/bbtk/src/bbcreaImageIOImagesChooserDialogBox.xml b/bbtk/src/bbcreaImageIOImagesChooserDialogBox.xml index 6fd5d71..96c25dd 100644 --- a/bbtk/src/bbcreaImageIOImagesChooserDialogBox.xml +++ b/bbtk/src/bbcreaImageIOImagesChooserDialogBox.xml @@ -79,19 +79,23 @@
-        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;
+	
     
diff --git a/src/creaImageIOGimmick.cpp b/src/creaImageIOGimmick.cpp index 7ba9b2a..898de34 100644 --- a/src/creaImageIOGimmick.cpp +++ b/src/creaImageIOGimmick.cpp @@ -52,10 +52,10 @@ namespace creaImageIO : mImageAdder(0) { RegisterGimmickMessageTypes(); - mSettings=0; - mSynchronizer=0; + mSettings = NULL; + mSynchronizer = NULL; mLocalDescpName = "localdatabase_Descriptor.dscp"; - mLocalDBName = "Local database"; + mLocalDBName = "Local database"; } //============================================================== @@ -63,13 +63,12 @@ namespace creaImageIO //============================================================== Gimmick::~Gimmick() { - - if(mSettings!=0) + if(mSettings!=NULL) { mSettings->writeSettingsFile(); delete mSettings; } - if(mSynchronizer!=0) + if(mSynchronizer!=NULL) { delete mSynchronizer; } @@ -79,8 +78,8 @@ namespace creaImageIO //============================================================== 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(); } @@ -92,22 +91,17 @@ namespace creaImageIO 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(); } diff --git a/src/creaImageIOGimmick.h b/src/creaImageIOGimmick.h index 6943878..d382f73 100644 --- a/src/creaImageIOGimmick.h +++ b/src/creaImageIOGimmick.h @@ -36,13 +36,14 @@ - #ifdef _DEBUG #include #define DEBUG_NEW new(_NORMAL_BLOCK ,__FILE__, __LINE__) #else #define DEBUG_NEW new #endif + + // Only when asked /* #ifdef TRACKING_MEMORY_LEAKS diff --git a/src/creaImageIOGimmickView.cpp b/src/creaImageIOGimmickView.cpp index 0a0dd0c..9b4169f 100644 --- a/src/creaImageIOGimmickView.cpp +++ b/src/creaImageIOGimmickView.cpp @@ -124,6 +124,7 @@ namespace creaImageIO /// Destructor GimmickView::~GimmickView() { + printf("EED GimmickView::~GimmickView DESTROCTEUR \n"); GimmickDebugMessage(1,"GimmickView::~GimmickView" <OnMultiThreadImageReaderEvent(filename,type,image); } //===================================================================== @@ -57,12 +56,9 @@ namespace creaImageIO ThreadedImageReader(MultiThreadImageReader* tir) : mMultiThreadImageReader(tir) {} - void* Entry(); void OnExit(); - vtkImageData* Read(const std::string& filename); - struct deleter { void operator()(ThreadedImageReader* p) @@ -72,11 +68,9 @@ namespace creaImageIO }; friend struct deleter; - private: ImageReader mReader; MultiThreadImageReader* mMultiThreadImageReader; - }; //===================================================================== @@ -94,6 +88,9 @@ namespace creaImageIO mDone = false; // Create the threads + +printf("EED MultiThreadImageReader::MultiThreadImageReader %d \n", number_of_threads); + for (int i=0; i 0) return true; @@ -127,24 +125,21 @@ namespace creaImageIO 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<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< 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 ? @@ -196,26 +195,26 @@ namespace creaImageIO // std::cout << "All threads stopped : OK "<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()" // <0) - { - // std::cout << "Refs = "<GetReferenceCount()<Delete(); - } + if (mImage != NULL) + { + // std::cout << "Refs = "<GetReferenceCount()<Delete(); + } // if } + MultiThreadImageReaderUser* GetUser() const { return mUser; } void SetUser( MultiThreadImageReaderUser* u ) { mUser = u; } const std::string& GetFilename() const { return mFilename; } diff --git a/src/creaImageIOSQLiteTreeHandler.h b/src/creaImageIOSQLiteTreeHandler.h index 023e7d1..c4f1ea7 100644 --- a/src/creaImageIOSQLiteTreeHandler.h +++ b/src/creaImageIOSQLiteTreeHandler.h @@ -48,7 +48,7 @@ namespace creaImageIO public: //==================================================================== /// Ctor with database file name - SQLiteTreeHandler(const std::string& filename); + SQLiteTreeHandler( const std::string& filename); /// Dtor virtual ~SQLiteTreeHandler(); //==================================================================== diff --git a/src/creaImageIOSynchron.h b/src/creaImageIOSynchron.h index ba10cb8..da3b3d2 100644 --- a/src/creaImageIOSynchron.h +++ b/src/creaImageIOSynchron.h @@ -37,7 +37,7 @@ namespace creaImageIO { - using namespace std; +// using namespace std; //================================================================================================================ ///Represents the list of currently added files class AddList @@ -90,7 +90,7 @@ namespace creaImageIO { public: ///Ctor - Synchronizer(const std::string& path); + Synchronizer( const std::string& path); ///Dtor virtual ~Synchronizer(); ///Initializes the database diff --git a/src/creaImageIOSynchronizer.cpp b/src/creaImageIOSynchronizer.cpp index 4404114..7ab34c3 100644 --- a/src/creaImageIOSynchronizer.cpp +++ b/src/creaImageIOSynchronizer.cpp @@ -34,12 +34,12 @@ namespace fs = boost::filesystem; namespace creaImageIO { + YYYYYY //============================================================== Synchronizer::Synchronizer(TreeHandler * th) : mHandler(th) { - } //============================================================== diff --git a/src/creaImageIOWxGimmickReaderDialog.cpp b/src/creaImageIOWxGimmickReaderDialog.cpp index 8c11f03..3af9786 100644 --- a/src/creaImageIOWxGimmickReaderDialog.cpp +++ b/src/creaImageIOWxGimmickReaderDialog.cpp @@ -59,7 +59,7 @@ namespace creaImageIO wxCAPTION ), // mGimmick(0), - mView(0) + mView(NULL) { GimmickDebugMessage(1,"WxGimmickReaderDialog::WxGimmickReaderDialog" <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); diff --git a/src/creaImageIOWxGimmickView.cpp b/src/creaImageIOWxGimmickView.cpp index 0e2fa1e..ea691e3 100644 --- a/src/creaImageIOWxGimmickView.cpp +++ b/src/creaImageIOWxGimmickView.cpp @@ -131,22 +131,19 @@ namespace creaImageIO 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" - <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(); @@ -163,8 +160,7 @@ namespace creaImageIO 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; @@ -195,9 +191,7 @@ namespace creaImageIO mText = new wxStaticText(mBottomPanel, wxID_ANY, wxT("Welcome to Gimmick!")); mbottom_sizer->Add(mText,0,wxGROW,0); - - - + mBottomPanel->SetSizer(mbottom_sizer); // Splitting @@ -208,12 +202,11 @@ namespace creaImageIO 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(); @@ -233,8 +226,7 @@ namespace creaImageIO { // stop the viewer before application exit. mViewer->StopPlayer(); - GimmickDebugMessage(1,"WxGimmickView::~WxGimmickView" - <IsAlive()) { mListener->Delete(); } @@ -313,8 +305,7 @@ namespace creaImageIO void WxGimmickView::CreateTreeView( TreeHandler* h) { std::string name(h->GetTree().GetAttribute("Name")); - GimmickMessage(2,"Creating the tree view for '"<< - name<<"'"<& sel) { - GimmickDebugMessage(5, - "ReadImageThreaded" - <Pulse(s)) { @@ -1350,7 +1339,7 @@ printf("EED WxGimmickView::ClearSelection End\n"); { mProgressDialog->Resume(); mProgressDialog->Destroy(); - mProgressDialog = 0; + mProgressDialog = NULL; } //================================================= diff --git a/src/creaImageIOWxGimmickView.h b/src/creaImageIOWxGimmickView.h index 62e1136..9e2f359 100644 --- a/src/creaImageIOWxGimmickView.h +++ b/src/creaImageIOWxGimmickView.h @@ -150,35 +150,35 @@ namespace creaImageIO 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 mGimmick; - Listener* mListener; + Listener *mListener; /// Callback for adding files void OnAddFiles(wxCommandEvent& event); @@ -247,7 +247,7 @@ namespace creaImageIO void ExportToStorage(const std::vector i_filenames); /// Progress dialog - wxProgressDialog* mProgressDialog; + wxProgressDialog *mProgressDialog; ///The selection's maximum dimension int mSelectionMaxDimension; @@ -256,10 +256,10 @@ namespace creaImageIO 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 > pointers; diff --git a/src/creaImageIOWxSimpleDlg.cpp b/src/creaImageIOWxSimpleDlg.cpp index d5566aa..9ae6791 100644 --- a/src/creaImageIOWxSimpleDlg.cpp +++ b/src/creaImageIOWxSimpleDlg.cpp @@ -146,14 +146,15 @@ namespace creaImageIO 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 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; diff --git a/src/creaImageIOWxTreeView.cpp b/src/creaImageIOWxTreeView.cpp index 3a1c04e..6d43dda 100644 --- a/src/creaImageIOWxTreeView.cpp +++ b/src/creaImageIOWxTreeView.cpp @@ -51,6 +51,7 @@ int wxCALLBACK CompareFunctionStrings(long item1, long item2, long sortData) const std::string& s1(*(data1->attr)); const std::string& s2(*(data2->attr)); + if(sortData==1) { // inverse the order @@ -125,104 +126,91 @@ namespace creaImageIO : wxPanel(parent,id), TreeView(handler, gimmick) { - GimmickDebugMessage(1,"WxTreeView::WxTreeView" - < 0 (not for Root level) - for (int i = 0; - i < handler->GetTree().GetNumberOfLevels() -1; - ++i) - { - GimmickDebugMessage(5,"Creating view for level "<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 "<GetName() - <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 "<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 "<GetName() <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")); @@ -235,20 +223,18 @@ namespace creaImageIO ////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) ); @@ -257,21 +243,18 @@ namespace creaImageIO 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; @@ -281,7 +264,6 @@ namespace creaImageIO SetSizer( msizer ); SetAutoLayout(true); Layout(); - } //===================================================================== @@ -289,61 +271,47 @@ namespace creaImageIO /// Destructor WxTreeView::~WxTreeView() { - GimmickDebugMessage(1,"WxTreeView::~WxTreeView" - <& WxTreeView::GetSelected(int level) { -printf("EED WxTreeView::GetSelected Start\n"); - std::vector& 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) @@ -354,7 +322,6 @@ printf("EED WxTreeView::GetSelected 5.4\n"); } else {*/ -printf("EED WxTreeView::GetSelected 6\n"); sel.push_back(n); //} @@ -385,7 +352,6 @@ printf("EED WxTreeView::GetSelected 6\n"); } // return mLevelList[level-1].Selected; -printf("EED WxTreeView::GetSelected End\n"); return sel; } @@ -404,7 +370,6 @@ printf("EED WxTreeView::GetSelected End\n"); // if no selection, no remove action. if(sel.size() != 0) { - std::stringstream out; std::string levelName=GetTreeHandler()->GetTree().GetLevelDescriptor(mLastLevel).GetName(); out<<"Delete "; @@ -474,7 +439,6 @@ printf("EED WxTreeView::GetSelected End\n"); /// 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 " @@ -483,26 +447,19 @@ printf("EED WxTreeView::UpdateLevel Start\n "); <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 "); } //===================================================================== @@ -511,33 +468,24 @@ 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 " <& 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::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() @@ -553,7 +501,6 @@ printf("EED WxTreeView::RecursiveUpdateLevel 2\n"); j!= (*i)->GetChildrenList().rend(); ++j) { -printf("EED WxTreeView::RecursiveUpdateLevel 3\n"); GimmickDebugMessage(1, "adding children " <<(*j)->GetLabel() @@ -569,9 +516,9 @@ printf("EED WxTreeView::RecursiveUpdateLevel 3\n"); 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); @@ -581,58 +528,55 @@ printf("EED WxTreeView::RecursiveUpdateLevel 3\n"); //Setting attributes for (int k=0; kGetColumnCount(); ++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 << "["<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 << "["<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"); } //===================================================================== @@ -660,18 +604,14 @@ printf("EED WxTreeView::RecursiveUpdateLevel End\n"); //================================================================ void WxTreeView::OnItemSelected(wxListEvent& event) { -printf("EED WxTreeView::OnItemSelected Start\n"); GimmickDebugMessage(1,GetTreeHandler()->GetTree().GetLabel()<<" WxTreeView::OnItemSelected"<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) { @@ -714,37 +647,30 @@ printf("EED WxTreeView::OnItemSelected 5\n"); 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 } //================================================================ @@ -1001,7 +927,6 @@ printf("EED WxTreeView::SelectAll End\n"); //================================================================ void WxTreeView::SortLevel(int level) { -printf("EED WxTreeView::SortLevel Start %d \n", level); GimmickDebugMessage(1, "WxTreeView::SortLevel(" <SortItems(CompareFunctionInts, 0); @@ -1064,8 +986,6 @@ printf("EED WxTreeView::SortLevel 2\n"); } // if ty } //mLevelList -printf("EED WxTreeView::SortLevel 3\n"); - // Reselects the unselected n = GetCtrl(level)->GetItemCount(); int after = 0; @@ -1084,7 +1004,6 @@ printf("EED WxTreeView::SortLevel 3\n"); if (data->selected) { -printf("EED WxTreeView::SortLevel 4\n"); nbselected--; if (nbselected==0) { @@ -1112,9 +1031,7 @@ printf("EED WxTreeView::SortLevel 4\n"); "WxTreeView::SortLevel : " < key; - // The vector of currently selected nodes of the level - std::vector 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 notShownAtts; + // The List Control + wxListCtrl *wxCtrl; + wxSplitterWindow *wxSplitter; + std::vector key; + // The vector of currently selected nodes of the level + std::vector 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 notShownAtts; }; /// The vector of levels : one for each level of the tree std::vector mLevelList; @@ -210,16 +210,16 @@ namespace creaImageIO ///Initial color palette std::vector 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; @@ -244,7 +244,6 @@ namespace creaImageIO wxString title, const wxSize& size); ~RemoveAlertDlg(); - bool isChecked(); private : diff --git a/src/creaImageIOWxViewer.cpp b/src/creaImageIOWxViewer.cpp index ee2258a..0b99b66 100644 --- a/src/creaImageIOWxViewer.cpp +++ b/src/creaImageIOWxViewer.cpp @@ -78,10 +78,9 @@ namespace creaImageIO size) { wxMutexLocker lock(mMutex); - GimmickDebugMessage(6,"WxViewer::WxViewer" - <SetupInteractor ( mInteractor ); - mCurrent = 0; - mPlayer = 0; + mCurrent = 0; + mPlayer = NULL; // Grid to place checkbox and slider mflexSizer = new wxFlexGridSizer(1,2,1,1); @@ -122,8 +121,7 @@ namespace creaImageIO WxViewer::~WxViewer() { wxMutexLocker lock(mMutex); - GimmickDebugMessage(6,"WxViewer::~WxViewer" - < iph = imagePointers[mCurrent]; @@ -195,8 +189,8 @@ namespace creaImageIO mLastImageShown = currIm; } mCurrent++; - } - } + } // if mCurrent + } // if imagePointers } //================================================================ @@ -300,13 +294,12 @@ std::cout << std::endl; bool WxViewer::RefreshIfNecessary() { if (mNeedRefresh) - { - GimmickDebugMessage(10,"WxViewer : Refreshing"<Render(); - mNeedRefresh = false; - return true; - } + { + GimmickDebugMessage(10,"WxViewer : Refreshing"<Render(); + mNeedRefresh = false; + return true; + } return false; } //================================================================ @@ -315,9 +308,9 @@ std::cout << std::endl; void WxViewer::StopPlayer() { wxMutexLocker lock(mMutex); - if (mPlayer==0 ) return; + if (mPlayer==NULL ) return; mPlayer->Delete(); - mPlayer=0; + mPlayer=NULL; mMutex.Unlock(); } //================================================================ @@ -328,15 +321,13 @@ std::cout << std::endl; 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 } //================================================================ @@ -349,7 +340,7 @@ std::cout << std::endl; { mPlayer->Pause(); mPlayer->Delete(); - mPlayer = 0; + mPlayer = NULL; } StartPlayer(); } diff --git a/src/creaImageIOWxViewer.h b/src/creaImageIOWxViewer.h index 566e316..72fe10e 100644 --- a/src/creaImageIOWxViewer.h +++ b/src/creaImageIOWxViewer.h @@ -88,13 +88,13 @@ namespace creaImageIO ///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; @@ -106,7 +106,7 @@ namespace creaImageIO /// 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