]> Creatis software - creaImageIO.git/commitdiff
#3218 creaImageIO Feature New Normal - vtk8itk4wx3-mingw64
authorEduardo DAVILA <davila@creatis.insa-lyon.fr>
Tue, 14 Aug 2018 08:13:21 +0000 (10:13 +0200)
committerEduardo DAVILA <davila@creatis.insa-lyon.fr>
Tue, 14 Aug 2018 08:13:21 +0000 (10:13 +0200)
src/creaImageIOMultiThreadImageReader.cpp
src/creaImageIOWxGimmickView.cpp
src/creaImageIOWxListenerPanel.h
src/creaImageIOWxSimpleDlg.cpp
src/creaImageIOWxTreeView.cpp

index 1679136d3c239fdd7573e51f4d194b942aae21f6..62eb7bdbee05a3d5fb9c5a06e6c65ad091176a64 100644 (file)
@@ -662,9 +662,7 @@ namespace creaImageIO
            //      std::cout << "### Thread "<<GetCurrentId()<<" : reading '"
            //                << i->GetFilename() << "' : DONE" << std::endl;
            
-         }
-       else 
-         {
+         }     else  {
            mMultiThreadImageReader->MultiThreadImageReaderEventUnlock();
            //mMutex.Unlock();
            // Wait a little to avoid blocking 
index 11e8c8889850810d9bf1d5cb1dd9a2f3436bb293..0e2fa1e537a7005d5695f4f288d2a26f58d1f866 100644 (file)
@@ -659,9 +659,7 @@ namespace creaImageIO
   //=================================================
   void WxGimmickView::OnSelectionChange(const std::vector<tree::Node*>& sel, bool isSelection, int selection, bool needProcess)
   {      
-    GimmickDebugMessage(5,
-                       "WxGimmickView::OnSelectionChange"
-                       <<std::endl);
+       GimmickDebugMessage(5,"WxGimmickView::OnSelectionChange"<<std::endl);
     wxBusyCursor busy;
        bool valid=true;
        
@@ -670,9 +668,7 @@ namespace creaImageIO
                valid= ValidateSelected(NULL,
                                mSelectionMinDimension,
                                mSelectionMaxDimension );
-       }
-       else if(needProcess)
-       {
+       } else if(needProcess) {
                ResetExtent();
                std::vector<tree::Node*>::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<tree::Node*>::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<ImagePointerHolder> 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<creaImageIO::ImagePointerHolder>(new ImagePointerHolder(GetDefaultImage())));
        //pointers.push_back(new ImagePointerHolder(GetDefaultImage()));
        mViewer->SetImageVector(pointers);
        mViewer->RefreshIfNecessary();
        ResetExtent();
+printf("EED WxGimmickView::ClearSelection End\n");        
   }
 
   //=================================================
index fe0df44e0176b2b232c940e008a4ce7f52b8a9ad..7308ba284f3bf70948258ed554880ef749396c4b 100644 (file)
@@ -62,14 +62,14 @@ namespace creaImageIO
   
 
   private :
-       bool addFiles;
-       bool removeFiles;
-       bool state;
-       wxCheckBoxaddCheckBox;
-       wxCheckBoxremoveCheckBox;
-       wxComboBoxdrives;
-       wxDialogdialog;
-       WxGimmickViewmView;
+       bool                    addFiles;
+       bool                    removeFiles;
+       bool                    state;
+       wxCheckBox              *addCheckBox;
+       wxCheckBox              *removeCheckBox;
+       wxComboBox              *drives;
+       wxDialog                *dialog;
+       WxGimmickView   *mView;
 
 
   }; // class WxListener
index d2f509cc964e267a630812baaa6f9783248fc1a2..d5566aab01260f2d0bd3763148897d946e0420d2 100644 (file)
@@ -150,6 +150,7 @@ namespace creaImageIO
                 dlg.ShowModal();
                 if (dlg.GetReturnCode() == wxID_OK)
             {
+//EED1 2018-08
 //EED1                         dlg.stopReading();
                        std::vector<creaImageIO::OutStrGimmick> outStrGimmick;
                        dlg.getSelected(outStrGimmick, m_attrDicomTags,true,"");
index c28e00ae518ab5fe5442e63f68ca85305ab14d84..3a1c04e603fc9f3d747c392f15cbe28b35601633 100644 (file)
@@ -302,33 +302,47 @@ namespace creaImageIO
   //=====================================================================
   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;
+       {
+               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; i<n; i++)
                {
@@ -366,13 +380,12 @@ namespace creaImageIO
                                }
                        }
              }*/
-         }
-       else
-       {
+         } else {
                // NOTHING
        }   
         
     //    return mLevelList[level-1].Selected;
+printf("EED WxTreeView::GetSelected End\n");     
     return sel;
   }
 
@@ -430,21 +443,15 @@ namespace creaImageIO
                      }
                    
                    if(needRefresh && mLastLevel>1)
-                     {
-                       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 "
                        <<level
@@ -475,15 +483,26 @@ namespace creaImageIO
                        <<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++)
-      {
-       if (!GetSplitter(i)->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 "
                        <<level
                        <<")"<<std::endl);
     
+printf("EED WxTreeView::RecursiveUpdateLevel 0.1\n");    
     
     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()
@@ -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 << "["<<val<< "]" << std::endl;
@@ -577,19 +606,17 @@ namespace creaImageIO
                        val =  valtmp;
                      }
                    //                                    std::cout << "["<<val<< "]" << std::endl;     
-                 }
-               else if(((*j)->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"<<std::endl);
+printf("EED  WxTreeView::OnItemSelected Start\n");       
+    GimmickDebugMessage(1,GetTreeHandler()->GetTree().GetLabel()<<" WxTreeView::OnItemSelected"<<std::endl);
 
     if (mIgnoreSelectedChanged) 
-      {
-       GimmickDebugMessage(1,
-                           " mIgnoreSelectedChanged true: returning"
-                           <<std::endl);
-       return;
-      }
+    {
+               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;
@@ -652,44 +679,50 @@ namespace creaImageIO
     wxObject* obj = event.GetEventObject();   
     unsigned int level = 0;
     for (level = 0; level<mLevelList.size(); ++level)
-      {
-       if ( GetCtrl(level) == obj ) break;
-      }
+    {
+               if ( GetCtrl(level) == obj ) break;
+    }
        mLastLevel=level;
-    GimmickDebugMessage(1,
-                       " Level "<<level+1
-                       <<std::endl);
+    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) 
-      {
-               
-       UpdateLevel( level + 2 ); 
-       // Reset the viewer setting the default image
-       GetGimmickView()->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(" 
                        <<level<<")"
@@ -979,112 +1015,105 @@ namespace creaImageIO
     int nbselected = 0;
     int n = GetCtrl(level)->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 : " 
                        <<nbselected<<" selected before sorting"
                        <<std::endl);  
 
+printf("EED WxTreeView::SortLevel 1\n");
     mIgnoreSelectedChanged = true; 
     // 
     if (mLevelList[level].SortAscending)
-      {
-       
-       if(ty==1)
-         {
-           GetCtrl(level)->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 : " 
                        <<after<<" selected after sorting"
                        <<std::endl);  
   
+printf("EED WxTreeView::SortLevel End\n");
   }
   //================================================================