]> Creatis software - creaImageIO.git/blobdiff - src2/creaImageIOWxTreeView.cpp
Cleaned the viewer and deactivated color function
[creaImageIO.git] / src2 / creaImageIOWxTreeView.cpp
index 8f0e1f5ad000f8cfde982fab15c68c1a1aee2b65..3a24eb49c714ce34db23bb793f7845ee9cd8bcdb 100644 (file)
@@ -111,23 +111,26 @@ namespace creaImageIO
        level.wxCtrl = ctrl;
        level.wxSplitter->Initialize(ctrl);
 
+       // Create the first column : number of children
+       
+       std::string title = "#";
+       if (i<handler->GetTree().GetNumberOfLevels()-1)
+         {
+           title += handler->GetTree().GetLevelDescriptor(i+1).GetName();
+           if (title[title.size()-1]!='s')
+             title += "s";
+         }
+       ctrl->InsertColumn(0,crea::std2wx(title),col_style);
+                 
+
        // Create the columns : one for each attribute of the level
-       int col = 0;
+       int col = 1;
        tree::LevelDescriptor::AttributeDescriptorListType::const_iterator a;
        for (a  = handler->GetTree().GetAttributeDescriptorList(i).begin();
             a != handler->GetTree().GetAttributeDescriptorList(i).end();
             ++a)
          {
-                 if(col==0)
-                 {
-                   wxListItem it;
-                   it.SetTextColour(*wxRED);
-                   it.SetText(_T("#C"));
-               
-                   ctrl->InsertColumn(col,it);
-                   col++;
-                 }
-                 
+       
                GimmickDebugMessage(5,"Creating column "<<col<<" : "
                                <<a->GetName()
                                <<std::endl);
@@ -152,6 +155,7 @@ namespace creaImageIO
        mLastSelected=0;
        mDirection=true;
        mSelectionMade=false;
+       mProcess=true;
        CreateColorPalette();
     UpdateLevel(1);
 
@@ -292,8 +296,8 @@ namespace creaImageIO
     GetCtrl(l)->DeleteAllItems();
     
     std::vector<tree::Node*>::iterator i;
-       //Adds the first item (filter)
-       GetCtrl(l)->InsertItem(0, "Filter:");
+    //Adds the first item (filter)
+    GetCtrl(l)->InsertItem(0, _T("Filter:"));
     for (i=sel.begin(); i!=sel.end(); ++i)
       {
        GimmickDebugMessage(2,
@@ -302,9 +306,7 @@ namespace creaImageIO
                            <<"'"<<level
                            <<std::endl);
        int _id=1;
-       int colorId=0;
-
-       
+               
 
        //Adds items (other than the first) and sets their attributes 
        GetTreeHandler()->LoadChildren(*i,1);
@@ -338,32 +340,7 @@ namespace creaImageIO
            int n= GetTreeHandler()->GetNumberOfChildren(*j);
            oss << n;
            std::string s(oss.str());
-           item.SetText( crea::std2wx(s));
-       
-               //Setting the color according to the parent
-               if(l==0)
-               {
-               item.SetBackgroundColour(wxColourDatabase().Find(mColorPalette[colorId])); 
-                       mColorMap.insert(NodeColorPair(*j,wxColourDatabase().Find(mColorPalette[colorId])));
-                       if(colorId<64)
-                       {
-                       colorId++;
-                       }
-                       else
-                       {
-                       colorId=0;
-                       }
-               }
-               else if(l!=mLevelList.size()-1)
-               {
-                       item.SetBackgroundColour(mColorMap[*i]); 
-                       mColorMap.insert(NodeColorPair(*j,mColorMap[*i]));
-               }
-               else
-               {
-                       item.SetBackgroundColour(mColorMap[*i]); 
-               }
-               
+           item.SetText( crea::std2wx(s));             
 
            item.SetColumn(0);
            GetCtrl(l)->SetItem(item);
@@ -418,10 +395,14 @@ namespace creaImageIO
                {
                mSelected=GetSelected(level+2);
                }
-               else
+               else if(mProcess)
                {
                mLastLevelSelected=GetSelected(level+2);
                }
+               else
+               {
+                       event.Veto();
+               }
                
                if (level<mLevelList.size()-1) 
                {
@@ -429,7 +410,10 @@ namespace creaImageIO
                        GetGimmickView()->ClearSelection();
                }
                if (level==mLevelList.size()-2) SelectLowerLevel();
-               if (level==mLevelList.size()-1) ValidateSelectedImages ();
+               if (level==(mLevelList.size()-1)&&mProcess) 
+               {
+                       ValidateSelectedImages ();
+               }
        }
        else
        {
@@ -442,6 +426,7 @@ namespace creaImageIO
                
        }
        
+       
   }
   //================================================================
 
@@ -450,17 +435,29 @@ namespace creaImageIO
   {
        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))
+               {
+                       mProcess=true;
+               }
+               else
+               {
+                       mProcess=false;
+               }
+
                if(item!=0)
                {
                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);
                }
+               
     }
 
        
@@ -592,7 +589,7 @@ namespace creaImageIO
                | wxLIST_MASK_TEXT |wxLIST_MASK_IMAGE | wxLIST_MASK_DATA | wxLIST_MASK_WIDTH | wxLIST_MASK_FORMAT);
                        
                }
-               GetCtrl(level)->InsertItem(0,"Filter:");
+               GetCtrl(level)->InsertItem(0,_T("Filter:"));
        }
        
    }
@@ -621,7 +618,7 @@ namespace creaImageIO
                {
                if ( GetCtrl(level) == ctrl ) break;
                }
-               std::string filter=event.m_item.m_text.c_str();
+               std::string filter = crea::wx2std(event.m_item.m_text.c_str());
                
                std::string att;
                
@@ -720,6 +717,40 @@ namespace creaImageIO
          }
   }
 
+   //================================================================
+  void WxTreeView::SetColor(int l)
+  {
+         /*
+         int colorId=0;
+         //Setting the color according to the parent
+               if(l==0)
+               {
+               item.SetBackgroundColour
+                 (wxColourDatabase().Find
+                  (crea::std2wx(mColorPalette[colorId]))); 
+               mColorMap.insert
+                 (NodeColorPair
+                  (*j,wxColourDatabase().Find
+                   (crea::std2wx(mColorPalette[colorId]))));
+               if(colorId<64)
+                 {
+                   colorId++;
+                 }
+               else
+                       {
+                         colorId=0;
+                       }
+               }
+               else if(l!=mLevelList.size()-1)
+                 {
+                   item.SetBackgroundColour(mColorMap[*i]); 
+                       mColorMap.insert(NodeColorPair(*j,mColorMap[*i]));
+               }
+               else
+               {
+                       item.SetBackgroundColour(mColorMap[*i]); 
+               }*/
+  }
   //================================================================
   void WxTreeView::CreateColorPalette()
   {