From: Eduardo DAVILA Date: Tue, 14 Aug 2018 08:13:21 +0000 (+0200) Subject: #3218 creaImageIO Feature New Normal - vtk8itk4wx3-mingw64 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=f5a8c7765cb23e949c7fe124a4b8a3b87b2d35ad;p=creaImageIO.git #3218 creaImageIO Feature New Normal - vtk8itk4wx3-mingw64 --- diff --git a/src/creaImageIOMultiThreadImageReader.cpp b/src/creaImageIOMultiThreadImageReader.cpp index 1679136..62eb7bd 100644 --- a/src/creaImageIOMultiThreadImageReader.cpp +++ b/src/creaImageIOMultiThreadImageReader.cpp @@ -662,9 +662,7 @@ namespace creaImageIO // std::cout << "### Thread "<GetFilename() << "' : DONE" << std::endl; - } - else - { + } else { mMultiThreadImageReader->MultiThreadImageReaderEventUnlock(); //mMutex.Unlock(); // Wait a little to avoid blocking diff --git a/src/creaImageIOWxGimmickView.cpp b/src/creaImageIOWxGimmickView.cpp index 11e8c88..0e2fa1e 100644 --- a/src/creaImageIOWxGimmickView.cpp +++ b/src/creaImageIOWxGimmickView.cpp @@ -659,9 +659,7 @@ namespace creaImageIO //================================================= void WxGimmickView::OnSelectionChange(const std::vector& sel, bool isSelection, int selection, bool needProcess) { - GimmickDebugMessage(5, - "WxGimmickView::OnSelectionChange" - <::const_iterator i; for(i=sel.begin();i!=sel.end()&&valid;++i) @@ -680,16 +676,12 @@ namespace creaImageIO valid= ValidateSelected((*i), mSelectionMinDimension, mSelectionMaxDimension ); - } - } - else if(isSelection) - { + } // for + } else if(isSelection) { valid= ValidateSelected(sel.front(), mSelectionMinDimension, mSelectionMaxDimension ); - } - else - { + } else { ResetExtent(); std::vector::const_iterator i; for(i=sel.begin();i!=sel.end()&&valid;++i) @@ -697,22 +689,22 @@ namespace creaImageIO valid= ValidateSelected((*i), mSelectionMinDimension, mSelectionMaxDimension ); - } - } + } // for + } // if sel.size mText->SetLabel(crea::std2wx(GetMessage())); - /*if(valid) - { - ReadImageThreaded(sel); - } - else - { - ClearSelection(); - }*/ +/* + if(valid) + { + ReadImageThreaded(sel); + } else { + ClearSelection(); + } +*/ + - printf("EED Warnning WxGimmickView::OnSelectionChange ....... To avoid threads conflicts//ReadImageThreaded(sel)\n "); +//EED1 2018-08 //EED1 ReadImageThreaded(sel); - } //================================================== @@ -784,17 +776,15 @@ namespace creaImageIO RequestReading(*iterDown,prio,-1,ph); // AddEntryToMap(*iterDown); prio--; - if (prio == maxprio) break; - } - } - else - { + if (prio == maxprio) { break; } + } // for + } else { pointers.clear(); //ImagePointerHolder* ph=new ImagePointerHolder(GetDefaultImage()); boost::shared_ptr ph(new ImagePointerHolder(GetDefaultImage())); pointers.push_back(ph); mViewer->SetImageVector(pointers); - } + } // if } //================================================== @@ -832,12 +822,14 @@ namespace creaImageIO //================================================== void WxGimmickView::ClearSelection() { +printf("EED WxGimmickView::ClearSelection Start\n"); pointers.clear(); pointers.push_back(boost::shared_ptr(new ImagePointerHolder(GetDefaultImage()))); //pointers.push_back(new ImagePointerHolder(GetDefaultImage())); mViewer->SetImageVector(pointers); mViewer->RefreshIfNecessary(); ResetExtent(); +printf("EED WxGimmickView::ClearSelection End\n"); } //================================================= diff --git a/src/creaImageIOWxListenerPanel.h b/src/creaImageIOWxListenerPanel.h index fe0df44..7308ba2 100644 --- a/src/creaImageIOWxListenerPanel.h +++ b/src/creaImageIOWxListenerPanel.h @@ -62,14 +62,14 @@ namespace creaImageIO private : - bool addFiles; - bool removeFiles; - bool state; - wxCheckBox* addCheckBox; - wxCheckBox* removeCheckBox; - wxComboBox* drives; - wxDialog* dialog; - WxGimmickView* mView; + bool addFiles; + bool removeFiles; + bool state; + wxCheckBox *addCheckBox; + wxCheckBox *removeCheckBox; + wxComboBox *drives; + wxDialog *dialog; + WxGimmickView *mView; }; // class WxListener diff --git a/src/creaImageIOWxSimpleDlg.cpp b/src/creaImageIOWxSimpleDlg.cpp index d2f509c..d5566aa 100644 --- a/src/creaImageIOWxSimpleDlg.cpp +++ b/src/creaImageIOWxSimpleDlg.cpp @@ -150,6 +150,7 @@ namespace creaImageIO dlg.ShowModal(); if (dlg.GetReturnCode() == wxID_OK) { +//EED1 2018-08 //EED1 dlg.stopReading(); std::vector outStrGimmick; dlg.getSelected(outStrGimmick, m_attrDicomTags,true,""); diff --git a/src/creaImageIOWxTreeView.cpp b/src/creaImageIOWxTreeView.cpp index c28e00a..3a1c04e 100644 --- a/src/creaImageIOWxTreeView.cpp +++ b/src/creaImageIOWxTreeView.cpp @@ -302,33 +302,47 @@ namespace creaImageIO //===================================================================== const std::vector& 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; + { + sel = mLevelList.back().Selected; + } else { + sel= mLevelList[l].Selected; + } +printf("EED WxTreeView::GetSelected 2\n"); if (sel.size() > 0) { sel.clear(); } - if (level == 1) - { - sel.push_back(GetTreeHandler()->GetTree().GetTree()); - } - else if (level < mLevelList.size()+2 ) +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"); long item = -1; for ( ;; ) { +printf("EED WxTreeView::GetSelected 5.1\n"); 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; /* FCY 18-04-2011: don't understand the real purpose of these lines, if uncomment add last frame in first place @@ -339,12 +353,12 @@ namespace creaImageIO it = sel.insert ( it , n ); } else - {*/ - + {*/ +printf("EED WxTreeView::GetSelected 6\n"); sel.push_back(n); //} - } + } // for /*int n = GetCtrl(l-1)->GetItemCount(); for (int i = 0; i1) - { - UpdateLevel(mLastLevel-2); - } - else if(mLastLevel>1) - { - UpdateLevel(mLastLevel-1); - } - else - { - UpdateLevel(mLastLevel); - } - } - } - else - { + { + UpdateLevel(mLastLevel-2); + } else if(mLastLevel>1) { + UpdateLevel(mLastLevel-1); + } else { + UpdateLevel(mLastLevel); + } // if needRefresh + } // if erase + } else { // no need to incremente level mLastLevel = tempLevel; } @@ -467,7 +474,8 @@ namespace creaImageIO /// Updates a level of the view (adds or removes children, etc.) void WxTreeView::UpdateLevel( int level ) { - GimmickDebugMessage(1, +printf("EED WxTreeView::UpdateLevel Start\n "); + GimmickDebugMessage(1, GetTreeHandler()->GetTree().GetLabel() <<"WxTreeView::UpdateLevel(level " <IsSplit()) - GetSplitter(i)->SplitVertically( GetCtrl(i), GetSplitter(i+1), - 100 ); - } - if (GetSplitter(i)->IsSplit()) GetSplitter(i)->Unsplit(); + { +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 "); } //===================================================================== @@ -492,25 +511,33 @@ namespace creaImageIO /// 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() @@ -526,6 +553,7 @@ namespace creaImageIO j!= (*i)->GetChildrenList().rend(); ++j) { +printf("EED WxTreeView::RecursiveUpdateLevel 3\n"); GimmickDebugMessage(1, "adding children " <<(*j)->GetLabel() @@ -560,9 +588,10 @@ namespace creaImageIO if(k==0 && level <3) { val = (*j)->GetAttribute("NumberOfChildren"); - } - else + } 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 + } 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 - { + } 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); @@ -600,9 +627,12 @@ namespace creaImageIO } } +printf("EED WxTreeView::RecursiveUpdateLevel 6\n"); SortLevel(l); +printf("EED WxTreeView::RecursiveUpdateLevel 7\n"); GetCtrl(l)->Show(); +printf("EED WxTreeView::RecursiveUpdateLevel End\n"); } //===================================================================== @@ -630,20 +660,17 @@ namespace creaImageIO //================================================================ void WxTreeView::OnItemSelected(wxListEvent& event) { - - GimmickDebugMessage(1, - GetTreeHandler()->GetTree().GetLabel() - <<" WxTreeView::OnItemSelected"<GetTree().GetLabel()<<" WxTreeView::OnItemSelected"<ClearSelection(); - } + { +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) - { - if(event.GetEventType()==wxEVT_COMMAND_LIST_ITEM_SELECTED) - { + { + if(event.GetEventType()==wxEVT_COMMAND_LIST_ITEM_SELECTED) + { ValidateSelectedImages (true); - } - else - { + } else { 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 ( ;; ) @@ -710,6 +743,8 @@ namespace creaImageIO 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"); + } //================================================================ @@ -965,7 +1000,8 @@ namespace creaImageIO //================================================================ void WxTreeView::SortLevel(int level) - { + { +printf("EED WxTreeView::SortLevel Start %d \n", level); GimmickDebugMessage(1, "WxTreeView::SortLevel(" <GetItemCount(); for (int i = 0; i < n; i++) - { - - //Gets current item data - ItemData* data = (ItemData*)GetCtrl(level)->GetItemData(i); + { + //Gets current item data + ItemData* data = (ItemData*)GetCtrl(level)->GetItemData(i); + //Extracts the node and the type of attribute + tree::Node* nod = data->node; + if(i==0) + { + (*nod).GetAttributeDescriptor + (mLevelList[level].key[mLevelList[level].SortColumn]) + .DecodeType( ty ); + } // if i + //Obtains the organizing attribute + data->attr = & (*nod).GetAttribute(mLevelList[level].key[mLevelList[level].SortColumn]); + //Selected ? + data->selected = false; + if (GetCtrl(level)->GetItemState(i,wxLIST_STATE_SELECTED)>0) + { + data->selected = true; + nbselected++; + } // if + }// for - //Extracts the node and the type of attribute - tree::Node* nod = data->node; - if(i==0) - { - (*nod).GetAttributeDescriptor - (mLevelList[level].key[mLevelList[level].SortColumn]) - .DecodeType( ty ); - } - //Obtains the organizing attribute - data->attr = & (*nod).GetAttribute - (mLevelList[level].key[mLevelList[level].SortColumn]); - //Selected ? - data->selected = false; - if (GetCtrl(level)->GetItemState(i,wxLIST_STATE_SELECTED)>0) - { - data->selected = true; - nbselected++; - } - - } GimmickDebugMessage(1, "WxTreeView::OnSort : " <SortItems(CompareFunctionInts, 0); - } - else - { - GetCtrl(level)->SortItems(CompareFunctionStrings, 0); - } + { +printf("EED WxTreeView::SortLevel 2\n"); - } - else - { - if(ty==1) - { - GetCtrl(level)->SortItems(CompareFunctionInts, 1); - } - else - { - GetCtrl(level)->SortItems(CompareFunctionStrings, 1); - } - } + if(ty==1) + { + GetCtrl(level)->SortItems(CompareFunctionInts, 0); + } else { + GetCtrl(level)->SortItems(CompareFunctionStrings, 0); + } // if ty + } else { + if(ty==1) + { + GetCtrl(level)->SortItems(CompareFunctionInts, 1); + } else { + GetCtrl(level)->SortItems(CompareFunctionStrings, 1); + } // if ty + } //mLevelList +printf("EED WxTreeView::SortLevel 3\n"); // Reselects the unselected n = GetCtrl(level)->GetItemCount(); int after = 0; for (int i = 0; i < n; i++) - { - - //Gets current item data - ItemData* data = (ItemData*)GetCtrl(level)->GetItemData(i); - - // long item = -1; - // for ( ;; ) - // { - // item = GetCtrl(level)->GetNextItem(item,wxLIST_NEXT_ALL); - // if ( item == -1 ) break; - //Gets current item data - // ItemData* data = (ItemData*)GetCtrl(level)->GetItemData(item); - // was selected ? - - if (data->selected) - { - nbselected--; - if (nbselected==0) - { - // if it is the last one we must process the selection - mIgnoreSelectedChanged = false; - } - GetCtrl(level)->SetItemState(i, - wxLIST_STATE_SELECTED, - wxLIST_MASK_STATE - | wxLIST_MASK_TEXT - | wxLIST_MASK_IMAGE - | wxLIST_MASK_DATA - | wxLIST_MASK_WIDTH - | wxLIST_MASK_FORMAT); - } - if (GetCtrl(level)->GetItemState(i,wxLIST_STATE_SELECTED)>0) - { - after++; - } + { + //Gets current item data + ItemData* data = (ItemData*)GetCtrl(level)->GetItemData(i); + // long item = -1; + // for ( ;; ) + // { + // item = GetCtrl(level)->GetNextItem(item,wxLIST_NEXT_ALL); + // if ( item == -1 ) break; + //Gets current item data + // ItemData* data = (ItemData*)GetCtrl(level)->GetItemData(item); + // was selected ? + + if (data->selected) + { +printf("EED WxTreeView::SortLevel 4\n"); + nbselected--; + if (nbselected==0) + { + // if it is the last one we must process the selection + mIgnoreSelectedChanged = false; + } + GetCtrl(level)->SetItemState(i, + wxLIST_STATE_SELECTED, + wxLIST_MASK_STATE + | wxLIST_MASK_TEXT + | wxLIST_MASK_IMAGE + | wxLIST_MASK_DATA + | wxLIST_MASK_WIDTH + | wxLIST_MASK_FORMAT); + } // if data + if (GetCtrl(level)->GetItemState(i,wxLIST_STATE_SELECTED)>0) + { + after++; + } - } + } // for mIgnoreSelectedChanged = false; - GimmickDebugMessage(1, + GimmickDebugMessage(1, "WxTreeView::SortLevel : " <