From: caballero Date: Wed, 11 Mar 2009 16:26:00 +0000 (+0000) Subject: Added color for parent/son referencing, last level selection and updating of the... X-Git-Tag: EED.02Oct2009~145 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=b1411b0e357cdc5349c9615cca84623d6aa06996;p=creaImageIO.git Added color for parent/son referencing, last level selection and updating of the movie on a new selection. --- diff --git a/src2/creaImageIOGimmickView.h b/src2/creaImageIOGimmickView.h index 57faaa7..7e7a247 100644 --- a/src2/creaImageIOGimmickView.h +++ b/src2/creaImageIOGimmickView.h @@ -68,6 +68,9 @@ namespace creaImageIO { GimmickError("INTERNAL ERROR : GetSelectedFiles not implemented"); } virtual void OnSelectionChange(std::vector& 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& sel, int min_dim, int max_dim); diff --git a/src2/creaImageIOWxGimmickView.cpp b/src2/creaImageIOWxGimmickView.cpp index bdbb325..df28207 100644 --- a/src2/creaImageIOWxGimmickView.cpp +++ b/src2/creaImageIOWxGimmickView.cpp @@ -407,6 +407,7 @@ namespace creaImageIO mCurImageItemToShow = sel.front(); int index = 0; std::vector::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(); } //================================================= diff --git a/src2/creaImageIOWxGimmickView.h b/src2/creaImageIOWxGimmickView.h index 077c83b..63ac154 100644 --- a/src2/creaImageIOWxGimmickView.h +++ b/src2/creaImageIOWxGimmickView.h @@ -48,6 +48,8 @@ namespace creaImageIO void OnSelectionChange(std::vector& 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. diff --git a/src2/creaImageIOWxTreeView.cpp b/src2/creaImageIOWxTreeView.cpp index 4aca9f8..20bd9ab 100644 --- a/src2/creaImageIOWxTreeView.cpp +++ b/src2/creaImageIOWxTreeView.cpp @@ -2,6 +2,7 @@ #include #include #include +#include ///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 <<"'"<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 (levelClearSelection(); + } + 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(levelGetAttribute("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::iterator selectedIts; for(selectedIts=change.begin();selectedIts!=change.end();++selectedIts) { @@ -551,16 +598,8 @@ namespace creaImageIO "WxTreeView::ValidateSelectedImages" < 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 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) diff --git a/src2/creaImageIOWxTreeView.h b/src2/creaImageIOWxTreeView.h index e316b47..a010f94 100644 --- a/src2/creaImageIOWxTreeView.h +++ b/src2/creaImageIOWxTreeView.h @@ -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 mSelected; + ///The last selection of nodes (for the last level) + std::vector mLastLevelSelected; ///The color map typedef std::map ColorMap; typedef std::pair NodeColorPair; ColorMap mColorMap; - + ///Initial color palette + std::vector mColorPalette; + ///Boolean declaring if the last level selection has been made + bool mSelectionMade; DECLARE_EVENT_TABLE()