]> Creatis software - creaImageIO.git/commitdiff
Added color for parent/son referencing, last level selection and updating of the...
authorcaballero <caballero>
Wed, 11 Mar 2009 16:26:00 +0000 (16:26 +0000)
committercaballero <caballero>
Wed, 11 Mar 2009 16:26:00 +0000 (16:26 +0000)
src2/creaImageIOGimmickView.h
src2/creaImageIOWxGimmickView.cpp
src2/creaImageIOWxGimmickView.h
src2/creaImageIOWxTreeView.cpp
src2/creaImageIOWxTreeView.h

index 57faaa73d161399dbafabaa530f3f05e21f6d20a..7e7a2471d8b2e8e3a0fdcf576d94472955d64bd4 100644 (file)
@@ -68,6 +68,9 @@ namespace creaImageIO
       { GimmickError("INTERNAL ERROR : GetSelectedFiles not implemented"); }
       virtual void OnSelectionChange(std::vector<tree::Node*>& s)
       { GimmickError("INTERNAL ERROR : OnSelectionChange not implemented"); }
+          virtual void ClearSelection()
+      { GimmickError("INTERNAL ERROR : ClearSelection not implemented"); }
+      
       
       ///Validates the dimension compliance of the images with the maximum and minimum given, and between their sizes
       bool ValidateSelected (std::vector<tree::Node*>& sel, int min_dim, int max_dim);
index bdbb325620ed14a67901f5a4959136dc8317f368..df28207d2dbed0748d53afe55980a30d98f6fb26 100644 (file)
@@ -407,6 +407,7 @@ namespace creaImageIO
    mCurImageItemToShow = sel.front();
    int index = 0;
    std::vector<tree::Node*>::iterator selected;
    for(selected=sel.begin();selected!=sel.end();++selected)
      {
        GimmickDebugMessage(5,
@@ -524,6 +525,16 @@ namespace creaImageIO
        //       mViewer->SetFocus();
      }
   }
+
+   //==================================================
+
+  //==================================================
+   void  WxGimmickView::ClearSelection()
+  {
+       mViewer->SetMovieSize(1);
+       mViewer->SetImage(0,GetDefaultImage());
+       mViewer->RefreshIfNecessary();
+  }
   
   //=================================================
  
@@ -533,6 +544,7 @@ namespace creaImageIO
        //TODO Select current tree handler       
     wxBusyCursor busy;
     GetTreeViewMap()["Local database"]->RemoveSelected(1);
+       ClearSelection();
   }
   //=================================================
 
index 077c83b3634e5995a427a172564035ad03641c3e..63ac15473102d5ea7241763060b7f6ab8adf482f 100644 (file)
@@ -48,6 +48,8 @@ namespace creaImageIO
       void OnSelectionChange(std::vector<tree::Node*>& s);
          ///Stops the player
          void StopPlayer(){mViewer->StopPlayer();}
+         ///Resets the default image
+         void ClearSelection();
 
 
       ///Sends a request to read the currently selected node and the ones that surround it.
index 4aca9f841bb524e9657ded94c9797e43875cb9df..20bd9ab6278da70df20cf0693a42ecfff652b940 100644 (file)
@@ -2,6 +2,7 @@
 #include <creaImageIOGimmickView.h>
 #include <creaImageIOSystem.h>
 #include <wx/splitter.h>
+#include <wx/gdicmn.h>
 ///Comparing function for ordering algorithm. Takes parameters as strings.
 int wxCALLBACK CompareFunctionStrings(long item1, long item2, long sortData)
 {      
@@ -151,6 +152,8 @@ namespace creaImageIO
        mColumnSelected=1;
        mLastSelected=0;
        mDirection=true;
+       mSelectionMade=false;
+       CreateColorPalette();
     UpdateLevel(1);
 
     SetSizer( sizer );     
@@ -298,9 +301,7 @@ namespace creaImageIO
                            <<"'"<<level
                            <<std::endl);
        int _id=0;
-       int r=100;
-       int g=100;
-       int b=100;
+       int colorId=0;
        //Adds columns
        GetTreeHandler()->LoadChildren(*i,1);
        tree::Node::ChildrenListType::reverse_iterator j;
@@ -339,11 +340,18 @@ namespace creaImageIO
            //      item.SetTextColour(*wxRED);
 
                //Setting the color according to the parent
-               /*
                if(l==0)
                {
-               item.SetBackgroundColour(wxColour(r,g,b)); 
-                       mColorMap.insert(NodeColorPair(*j,wxColour(r,g,b)));
+               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)
                {
@@ -354,15 +362,9 @@ namespace creaImageIO
                {
                        item.SetBackgroundColour(mColorMap[*i]); 
                }
-                       r+=20;
-                       g+=20;
-                       b+=20;*/
+               
 
            item.SetColumn(0);
-
-               //Sets the last level as selected....How to make it select only the first time?
-               //if (level==mLevelList.size()) item.SetState(wxLIST_STATE_SELECTED);
-
            GetCtrl(l)->SetItem(item);
                
            //      GetCtrl(l)->SetItem(id,0, crea::std2wx(s));
@@ -382,15 +384,15 @@ namespace creaImageIO
                //              GetCtrl(l)->SetItem(id,k, crea::std2wx(val));
                // GetCtrl(l)->SetColumnWidth(k, wxLIST_AUTOSIZE );
                
-             }
-           
+             }     
          }
       }
     
     GetCtrl(l)->Show();
-
+       
     
     if (level<mLevelList.size()) UpdateLevel(level+1);
+       
  }
   //=====================================================================
 
@@ -418,17 +420,48 @@ namespace creaImageIO
                        " Level "<<level+1
                        <<std::endl);
 
-       
+       if(level<mLevelList.size()-1)
+       {
        mSelected=GetSelected(level+2);
+       }
+       else
+       {
+       mLastLevelSelected=GetSelected(level+2);
+       }
        
-    if (level<mLevelList.size()-1) UpdateLevel( level + 2 ); 
-
+    if (level<mLevelList.size()-1) 
+       {
+               UpdateLevel( level + 2 ); 
+               GetGimmickView()->ClearSelection();
+       }
+       if (level==mLevelList.size()-2) SelectLowerLevel();
     if (level==mLevelList.size()-1) ValidateSelectedImages ();
+       
+  }
+  //================================================================
 
+  //================================================================
+  void WxTreeView::SelectLowerLevel()
+  {
+       long item = -1;
+       int level=mLevelList.size()-1;
+    for ( ;; )
+    {
+               item = GetCtrl(level)->GetNextItem(item,
+                                     wxLIST_NEXT_ALL);
+        if ( item == -1 )
+            break;
+
+               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);
+    }
+
+       
   }
+
   //================================================================
 
-//================================================================
+  //================================================================
   void WxTreeView::OnColClick(wxListEvent& event)
   {      
        //Obtain the column name and the level that needs to be organized
@@ -522,15 +555,29 @@ namespace creaImageIO
                        long item = GetCtrl(level)->GetItemData(it);
                        GetCtrl(level)->SetItemData(it,((long*)item)[0]);
                        tree::Node* n= ((ItemData*)((long*)item)[0])->node;
-                       for(selection=mSelected.begin();selection!=mSelected.end();++selection)
+                       if(level<mLevelList.size()-1)
                        {
-                               if((*selection)->GetAttribute("ID").compare(n->GetAttribute("ID"))==0)
+                               for(selection=mSelected.begin();selection!=mSelected.end();++selection)
                                {
-                                       change.push_back(it);   
+                                       if((*selection)->GetAttribute("ID").compare(n->GetAttribute("ID"))==0)
+                                       {
+                                               change.push_back(it);   
+                                       }
+                               }
+                       }
+                       else
+                       {
+                               for(selection=mLastLevelSelected.begin();selection!=mLastLevelSelected.end();++selection)
+                               {
+                                       if((*selection)->GetAttribute("ID").compare(n->GetAttribute("ID"))==0)
+                                       {
+                                               change.push_back(it);   
+                                       }
                                }
                        }
                        
                }
+               //Resets the selected items
                std::vector<long>::iterator selectedIts;
                for(selectedIts=change.begin();selectedIts!=change.end();++selectedIts)
                {
@@ -551,16 +598,8 @@ namespace creaImageIO
                        "WxTreeView::ValidateSelectedImages" 
                        <<std::endl);
     std::vector<tree::Node*> sel(GetSelected(mLevelList.size()+1));
-    GetGimmickView()->OnSelectionChange(sel);
-    /*
-    //Send an event telling wether the selection is valid or not
-    wxCommandEvent event( 0, GetId() );
-    event.SetEventObject( this );
-    std::vector<tree::Node*> sel=GetSelected((mLevelList.size()+1));
-    event.SetClientData(&sel);
-    GetEventHandler()->ProcessEvent( event );
-    */
-    // 
+       GetGimmickView()->OnSelectionChange(sel);
   }
   //================================================================
 
@@ -612,6 +651,79 @@ namespace creaImageIO
                  std::string filename=(*i)->GetAttribute("FullFileName");
                  s.push_back(filename);
          }
+  }
+
+  //================================================================
+  void WxTreeView::CreateColorPalette()
+  {
+  GimmickDebugMessage(6,"WxTreeView::CreateColorPalette");
+  mColorPalette.push_back("WHITE");
+  mColorPalette.push_back("LIGHT GREY");
+  mColorPalette.push_back("AQUAMARINE");
+  mColorPalette.push_back("MEDIUM FOREST GREEN");
+  mColorPalette.push_back("INDIAN RED");
+  mColorPalette.push_back("KHAKI");
+  mColorPalette.push_back("ORANGE");
+  mColorPalette.push_back("LIGHT BLUE");
+  mColorPalette.push_back("LIGHT STEEL BLUE");
+  mColorPalette.push_back("PINK");
+  mColorPalette.push_back("PLUM");
+  mColorPalette.push_back("PURPLE");
+  mColorPalette.push_back("RED");
+  mColorPalette.push_back("SEA GREEN");
+  mColorPalette.push_back("SIENNA");
+  mColorPalette.push_back("SKY BLUE");
+  mColorPalette.push_back("SLATE BLUE");
+  mColorPalette.push_back("SPRING GREEN");
+  mColorPalette.push_back("TAN");
+  mColorPalette.push_back("THISTLE");
+  mColorPalette.push_back("TURQUOISE");
+  mColorPalette.push_back("VIOLET");
+  mColorPalette.push_back("VIOLET RED");
+  mColorPalette.push_back("WHEAT");
+  mColorPalette.push_back("YELLOW");
+  mColorPalette.push_back("YELLOW GREEN");
+  mColorPalette.push_back("BLUE");
+  mColorPalette.push_back("BLUE VIOLET");
+  mColorPalette.push_back("BROWN");
+  mColorPalette.push_back("CADET BLUE");
+  mColorPalette.push_back("CORAL");
+  mColorPalette.push_back("CORNFLOWER BLUE");
+  mColorPalette.push_back("CYAN");
+  mColorPalette.push_back("DARK GREY");
+  mColorPalette.push_back("DARK GREEN");
+  mColorPalette.push_back("DARK OLIVE GREEN");
+  mColorPalette.push_back("DARK ORCHID");
+  mColorPalette.push_back("DARK SLATE BLUE");
+  mColorPalette.push_back("DARK SLATE GREY");
+  mColorPalette.push_back("DARK TURQUOISE");
+  mColorPalette.push_back("FIREBRICK");
+  mColorPalette.push_back("FOREST GREEN");
+  mColorPalette.push_back("GOLD");
+  mColorPalette.push_back("GOLDENROD");
+  mColorPalette.push_back("GREY");
+  mColorPalette.push_back("GREEN");
+  mColorPalette.push_back("GREEN YELLOW");
+  mColorPalette.push_back("LIME GREEN");
+  mColorPalette.push_back("MAGENTA");
+  mColorPalette.push_back("MAROON");
+  mColorPalette.push_back("MEDIUM AQUAMARINE");
+  mColorPalette.push_back("MEDIUM BLUE");
+  mColorPalette.push_back("MEDIUM GOLDENROD");
+  mColorPalette.push_back("MEDIUM ORCHID");
+  mColorPalette.push_back("MEDIUM SEA GREEN");
+  mColorPalette.push_back("MEDIUM SLATE BLUE");
+  mColorPalette.push_back("MEDIUM SPRING GREEN");
+  mColorPalette.push_back("MEDIUM TURQUOISE");
+  mColorPalette.push_back("MEDIUM VIOLET RED");
+  mColorPalette.push_back("MIDNIGHT BLUE");
+  mColorPalette.push_back("NAVY");
+  mColorPalette.push_back("ORANGE RED");
+  mColorPalette.push_back("ORCHID, PALE GREEN");
+  mColorPalette.push_back("STEEL BLUE");
+  mColorPalette.push_back("BLACK");
+
+
   }
   //================================================================
   BEGIN_EVENT_TABLE(WxTreeView, wxPanel)
index e316b47da0a33ff50fd6f551fb48848d2fed4170..a010f94d08cca1cfe6a96e00cbfea3ff1be2b75b 100644 (file)
@@ -73,6 +73,10 @@ namespace creaImageIO
       /// Updates the view of a level given the selected items of upper level
       /// Recursive method
       virtual void RecursiveUpdateLevel( int );
+         ///Creates the color palette for the first level
+         void CreateColorPalette();
+         ///Selects the lowest level (images)
+         void SelectLowerLevel();
 
 
       /// Currently Selected Column
@@ -82,13 +86,18 @@ namespace creaImageIO
          bool mDirection;
          ///The last selected item on the list
          long mLastSelected;
-         ///The last selection of nodes
+         ///The last selection of nodes (for every level, except the last)
          std::vector<tree::Node*> mSelected;
+         ///The last selection of nodes (for the last level)
+         std::vector<tree::Node*> mLastLevelSelected;
          ///The color map
          typedef std::map<tree::Node*,wxColour> ColorMap;
          typedef std::pair<tree::Node*,wxColour> NodeColorPair;
       ColorMap mColorMap;
-       
+         ///Initial color palette
+         std::vector<std::string> mColorPalette;
+         ///Boolean declaring if the last level selection has been made
+         bool mSelectionMade;
          
 
       DECLARE_EVENT_TABLE()