]> Creatis software - creaImageIO.git/commitdiff
Added interface for attribute visualization selection.
authorcaballero <caballero>
Fri, 22 May 2009 16:09:08 +0000 (16:09 +0000)
committercaballero <caballero>
Fri, 22 May 2009 16:09:08 +0000 (16:09 +0000)
src2/CMakeLists.txt
src2/creaImageIOTreeView.h
src2/creaImageIOWxAttributeSelectionPanel.cpp [new file with mode: 0644]
src2/creaImageIOWxAttributeSelectionPanel.h [new file with mode: 0644]
src2/creaImageIOWxGimmickView.cpp
src2/creaImageIOWxGimmickView.h
src2/creaImageIOWxTreeView.cpp
src2/creaImageIOWxTreeView.h

index 0ced6db0bcec3473e6f5d3c1c84e8aab0103e318..951ccc7671bb71d64e8e7ce9ee8154ef08909996 100644 (file)
@@ -51,6 +51,7 @@ SET( SRCS
   creaImageIOWxCustomizeConfigPanel
   creaImageIOWxListenerPanel
   creaImageIOWxEditFieldsPanel
+  creaImageIOWxAttributeSelectionPanel
 
   # 
   BlockScopeWxApp
index df92b146927f90216d97669bbd011566fc4ce057..611c7d0cbe87e06f464cfece867821fde9c866be 100644 (file)
@@ -54,6 +54,9 @@ namespace creaImageIO
          /// Gets the next nodes on the list, be it up(true) or down(false).
       virtual void GetNodes(std::vector<tree::Node*>& nodes, bool direction){ GimmickError("INTERNAL ERROR : TreeView::GetNodes not overloaded"); }
 
+         /// Gets the attributes that are being shown and the ones that have been blocked on a specific level
+         virtual void GetAttributes(std::vector<std::string>& areShown, std::vector<std::string>& notShown, int level){ GimmickError("INTERNAL ERROR : TreeView::GetAttributes not overloaded"); }
+
     protected:
       TreeHandler* GetTreeHandler() { return mTreeHandler; }
          GimmickView* GetGimmickView() { return mGimmickView; }
diff --git a/src2/creaImageIOWxAttributeSelectionPanel.cpp b/src2/creaImageIOWxAttributeSelectionPanel.cpp
new file mode 100644 (file)
index 0000000..113dcfe
--- /dev/null
@@ -0,0 +1,192 @@
+#include <creaImageIOWxAttributeSelectionPanel.h>
+#include <creaImageIOSystem.h>
+
+namespace creaImageIO
+{
+       const int  ID_COMBO             = 180;
+  // CTor
+  WxAttributeSelectionPanel::WxAttributeSelectionPanel(wxWindow *parent, 
+         wxDialog* dial, 
+         WxGimmickView* view,
+         std::vector<std::string> sAtts,
+         std::vector<std::string> nsAtts,
+         int numLev)
+ :   wxPanel( parent, 
+                 -1, wxDefaultPosition, 
+                 wxDefaultSize,
+                 wxRESIZE_BORDER | 
+             wxSYSTEM_MENU  |
+                 wxCLOSE_BOX |
+                 wxMAXIMIZE_BOX | 
+                 wxMINIMIZE_BOX | 
+                 wxCAPTION  
+              ),       
+                  dialog(dial),
+                  shownA(sAtts),
+                  notShownA(nsAtts),
+                  mView(view)
+  {
+    GimmickDebugMessage(1,"WxCustomizeConfigPanel::WxCustomizeConfigPanel"
+                       <<std::endl);
+       wxStaticText * aa=new wxStaticText(this,-1,_T(" Currently shown attributes for level: "), wxPoint(5,10));
+       wxArrayString as;
+       std::stringstream out;
+       for(int i=1;i<=numLev;i++)
+       {
+               out<<i;
+               as.Add(out.str());
+               out.str("");
+       }
+       levels=new wxComboBox(this, ID_COMBO,"1",wxPoint(190, 5),wxDefaultSize,as);
+       wxStaticText * na=new wxStaticText(this,-1,_T(" Currently hidden attributes: "), wxPoint(255,10));
+
+    shownAtts=new wxListCtrl(this, wxID_ANY, wxPoint(5,30), wxSize(160,90), wxLC_REPORT | wxLC_NO_HEADER | wxLC_SINGLE_SEL );
+
+       shownAtts->InsertColumn(0, 
+                                  crea::std2wx(""),
+                                  wxLIST_FORMAT_LEFT);
+       shownAtts->SetColumnWidth(0,155);
+       shownAtts->Show();
+
+       wxButton *add = new wxButton(this,wxID_ANY,_T(">>"), wxPoint(170,50) );
+       Connect( add->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxAttributeSelectionPanel::OnAdd ); 
+
+       wxButton *remove = new wxButton(this,wxID_ANY,_T("<<"), wxPoint(170,70) );
+       Connect( remove->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxAttributeSelectionPanel::OnRemove ); 
+       
+       notShownAtts=new wxListCtrl(this, wxID_ANY, wxPoint(255,30), wxSize(160,90), wxLC_REPORT | wxLC_NO_HEADER | wxLC_SINGLE_SEL );
+
+       notShownAtts->InsertColumn(0, 
+                                  crea::std2wx(""),
+                                  wxLIST_FORMAT_LEFT);
+       notShownAtts->SetColumnWidth(0,155);
+       notShownAtts->Show();
+       LoadCtrls();
+
+       wxButton *save = new wxButton(this,wxID_ANY,_T("Save Changes"), wxPoint(5,130) );
+       Connect( save->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxAttributeSelectionPanel::OnSaveConfig ); 
+   
+    Layout(); 
+  }
+
+  /// Destructor
+  WxAttributeSelectionPanel::~WxAttributeSelectionPanel()
+  {
+    GimmickDebugMessage(1,"WxAttributeSelectionPanel::~WxAttributeSelectionPanel"
+                       <<std::endl);
+  }
+
+  void WxAttributeSelectionPanel::OnSaveConfig(wxCommandEvent& event)
+  {
+         /*mView->OnSaveSettingsCallback(crea::wx2std(copyPath->GetValue()),
+                 crea::wx2std(dbPath->GetValue()),
+                 crea::wx2std(syncEvent->GetValue()),
+                 crea::wx2std(syncFrequency->GetValue()));
+         */
+         dialog->Destroy();
+  }
+
+  void WxAttributeSelectionPanel::OnAdd(wxCommandEvent& event)
+  {
+       long item = -1;
+       for ( ;; )
+       {
+               item = shownAtts->GetNextItem(item,
+                                                                               wxLIST_NEXT_ALL,
+                                                                               wxLIST_STATE_SELECTED);
+               if ( item == -1 )
+                       break;
+       
+                       std::string change=shownAtts->GetItemText(item);
+                       std::vector<std::string>::iterator it;
+                       bool found=false;
+                       for(it=shownA.begin();it!=shownA.end()&&!found;++it)
+                       {
+                               if((*it).compare(change)==0)
+                               {
+                                       found=true;
+                               }
+                       }
+                       shownA.erase(it-1);
+                       notShownA.push_back(change);
+                       LoadCtrls();    
+               
+       }
+       
+  }
+
+  void WxAttributeSelectionPanel::OnRemove(wxCommandEvent& event)
+  {
+
+       long item = -1;
+       for ( ;; )
+       {
+               item = notShownAtts->GetNextItem(item,
+                                                                               wxLIST_NEXT_ALL,
+                                                                               wxLIST_STATE_SELECTED);
+               if ( item == -1 )
+                       break;
+       
+                       std::string change=notShownAtts->GetItemText(item);
+                       std::vector<std::string>::iterator it;
+                       bool found=false;
+                       for(it=notShownA.begin();it!=notShownA.end()&&!found;++it)
+                       {
+                               if((*it).compare(change)==0)
+                               {
+                                       found=true;
+                               }
+                       }
+                       notShownA.erase(it-1);
+                       shownA.push_back(change);
+                       LoadCtrls();    
+               
+       }
+         
+  }
+  
+
+  void WxAttributeSelectionPanel::LoadCtrls()
+  {
+
+         wxListItem item;
+           item.SetMask(wxLIST_MASK_STATE | 
+                        wxLIST_MASK_TEXT |
+                        //                      wxLIST_MASK_IMAGE |
+                        wxLIST_MASK_DATA |
+                        //                      wxLIST_MASK_WIDTH |
+                        wxLIST_MASK_FORMAT
+                        );
+       std::vector<std::string>::iterator it;
+       shownAtts->DeleteAllItems();
+       notShownAtts->DeleteAllItems();
+       for(it=shownA.begin();it!=shownA.end();++it)
+       {
+               item.SetText(crea::std2wx(*it));
+               shownAtts->InsertItem(item);
+       }
+
+       
+       for(it=notShownA.begin();it!=notShownA.end();++it)
+       {
+               item.SetText(crea::std2wx(*it));
+               notShownAtts->InsertItem(item);
+       }
+
+  }
+  void WxAttributeSelectionPanel::OnComboChange(wxCommandEvent& event)
+  {
+      int n=levels->GetSelection()+1;
+         mView->GetVisibleAttributes(shownA,notShownA,n);
+         LoadCtrls();
+  }
+  
+//======================================================================
+BEGIN_EVENT_TABLE(WxAttributeSelectionPanel, wxPanel)
+EVT_COMBOBOX  (ID_COMBO,WxAttributeSelectionPanel::OnComboChange)
+END_EVENT_TABLE()
+//======================================================================
+
+} // EO namespace creaImageIO
+
+
diff --git a/src2/creaImageIOWxAttributeSelectionPanel.h b/src2/creaImageIOWxAttributeSelectionPanel.h
new file mode 100644 (file)
index 0000000..8e3cf77
--- /dev/null
@@ -0,0 +1,61 @@
+#ifndef __creaImageIOWxAttributeSelectionPanel_h_INCLUDED__
+#define __creaImageIOWxAttributeSelectionPanel_h_INCLUDED__
+
+#ifdef USE_WXWIDGETS
+#include <creaWx.h>
+#include <creaImageIOWxGimmickView.h>
+#include <wx/listctrl.h>
+
+
+namespace creaImageIO
+{
+  /**
+   * \ingroup GUI
+   */
+  //=====================================================================
+ //=====================================================================
+  class WxAttributeSelectionPanel : public wxPanel
+  {
+  public:
+    WxAttributeSelectionPanel();    
+       WxAttributeSelectionPanel(wxWindow *parent, 
+               wxDialog* dial,
+               WxGimmickView* view,
+               std::vector<std::string> sAtts,
+           std::vector<std::string> nsAtts,
+               int numLev);
+    
+    ~WxAttributeSelectionPanel();
+       ///Saves the configuration
+        void OnSaveConfig(wxCommandEvent& event);
+        ///Changes items from shown to notShown
+        void OnAdd(wxCommandEvent& event);
+        ///Changes items from notShown to shown
+        void OnRemove(wxCommandEvent& event);
+        void OnComboChange(wxCommandEvent& event);
+  
+
+  private :
+         ///Loads the information on the vectors onto the lists
+          void LoadCtrls();
+         std::vector<std::string> shownA;
+         std::vector<std::string> notShownA;
+         wxComboBox* levels;
+         wxListCtrl* shownAtts;
+         wxListCtrl* notShownAtts;
+       wxDialog* dialog;
+       WxGimmickView* mView;
+
+       
+       DECLARE_EVENT_TABLE()
+
+  }; // class WxAttributeSelectionPanel
+  //=====================================================================
+
+  
+} // EO namespace creaImageIO
+
+
+#endif // USE_WIDGETS
+// EOF
+#endif  
\ No newline at end of file
index a900d0d5be2e1bf5ba3be86313d1a1314b74962d..0d0ee0a550510893e83cdb3e2f0f4c355cb25d76 100644 (file)
@@ -4,6 +4,7 @@
 #include <creaImageIOWxCustomizeConfigPanel.h>
 #include <creaImageIOWxListenerPanel.h>
 #include <creaImageIOWxEditFieldsPanel.h>
+#include <creaImageIOWxAttributeSelectionPanel.h>
 
 using namespace crea;
 // Icons
@@ -800,11 +801,21 @@ namespace creaImageIO
          WxListenerPanel* cdWatch=new WxListenerPanel(nb,dial, this, mListener->IsPaused());
          nb->AddPage( cdWatch, crea::std2wx("CD/DVD") );
 
-         //Fourth page: Selection of attributes to show (edit)
-         wxPanel* attSelection=new wxPanel(nb);
+         //Fourth page: Selection of attributes to show
+         std::vector<std::string> shown;
+      std::vector<std::string> nShown;
+         GetTreeViewMap()[crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection()))]->GetAttributes(shown,nShown,1);
+         int nLev=GetTreeViewMap()[crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection()))]->GetNumberOfLevels();
+         WxAttributeSelectionPanel* attSelection=new WxAttributeSelectionPanel(nb,dial,this,shown,nShown,nLev);
          nb->AddPage( attSelection, crea::std2wx("Selection of Attributes") );
   }
 
+  //===================================================================
+  void WxGimmickView::GetVisibleAttributes(std::vector<std::string>& shown, 
+         std::vector<std::string>& nShown, int level)
+  {
+         GetTreeViewMap()[crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection()))]->GetAttributes(shown,nShown,level);
+  }
   //===================================================================
   void WxGimmickView::OnSaveSettingsCallback(const std::string& copyPath,
          const std::string& dbPath,
@@ -902,9 +913,7 @@ namespace creaImageIO
   /// AddProgress Gimmick callback
   void WxGimmickView::OnAddProgress( Gimmick::AddProgress& p)
   {
-
     char mess[200];
-   
        sprintf(mess,"%i dirs : %i files :\n            %i handled - %i added",
           p.GetNumberScannedDirs(),
           p.GetNumberScannedFiles(),
index f4dcb2da5407de4bc881c906b5c3af3985fb9b2a..79acac41550bd72ed66a48f2d637dca345274185 100644 (file)
@@ -92,6 +92,10 @@ namespace creaImageIO
 
        ///Called upon when a field has been edited
        void OnFieldsEdited(tree::Node* node, const std::string& name, const std::string& key, const std::string& val);
+
+       ///Called upon to return the visible attributes of the current tab
+       void GetVisibleAttributes(std::vector<std::string>& shown,std::vector<std::string>& nShown, int level);
   
   
     
index ef99f2848427de7bb6c76584908b494b6f556644..2f515314ccc6b89cf4b7828e6087a0c43a580a8a 100644 (file)
@@ -1192,6 +1192,25 @@ namespace creaImageIO
 
 
   }
+
+   //================================================================
+  void WxTreeView::GetAttributes(std::vector<std::string>& areShown, std::vector<std::string>& notShown, int level)
+  {
+         areShown.clear();
+         notShown.clear();
+       tree::LevelDescriptor::AttributeDescriptorListType::const_iterator a;
+       for (a  = GetTreeHandler()->GetTree().GetAttributeDescriptorList(level).begin();
+            a != GetTreeHandler()->GetTree().GetAttributeDescriptorList(level).end();
+            ++a)
+       {
+               if(a->GetFlags()==creaImageIO::tree::AttributeDescriptor::EDITABLE)
+           {
+                       areShown.push_back(a->GetName());
+               }
+       }
+       notShown=mLevelList[level-1].notShownAtts;
+  }
+  //================================================================
   //================================================================
   BEGIN_EVENT_TABLE(WxTreeView, wxPanel)   
   /*
index d6290c8828c8707233f5f7824d3d57bfc21e7994..76440a4ae0993526a8608e6471097ced25a5e41b 100644 (file)
@@ -63,8 +63,11 @@ namespace creaImageIO
       ///Callback on mouse click
       void OnMouseClick(wxMouseEvent& event);
 
-         // Display a menu for items
+         /// Displays a menu for items
          void OnItemMenu(wxListEvent &event);
+         
+         /// Gets the attributes that are being shown and the ones that have been blocked on a specific level
+         void GetAttributes(std::vector<std::string>& areShown, std::vector<std::string>& notShown, int level);
       
       /// Actual processing of item selection/deselection 
       /// Called by OnItemSelected and OnItemDeSelected
@@ -79,6 +82,8 @@ namespace creaImageIO
        wxListCtrl* wxCtrl;
        wxSplitterWindow* wxSplitter;
        std::vector<std::string> key;
+       //The vector of not shown attributes
+       std::vector<std::string> notShownAtts;
        // The vector of currently selected nodes of the level
        std::vector<tree::Node*> Selected;
        // True iff the vector Selected is up to date
@@ -110,9 +115,9 @@ namespace creaImageIO
       void ValidateSelectedImages(bool isSelection);   
       ///Gets selected filenames
       void GetSelectedAsString(std::vector<std::string>&s);
-          ///Gets the filenames of the given nodes and returns them on the given vector. Is recursive.
+         ///Gets the filenames of the given nodes and returns them on the given vector. Is recursive.
          void GetFilenamesAsString(const std::vector<tree::Node*>& nodes, std::vector<std::string>&s);
-        /// Gets the next nodes on the list, be it up(true) or down(false).
+      /// Gets the next nodes on the list, be it up(true) or down(false).
       void GetNodes(std::vector<tree::Node*>& nodes, bool direction);
       /// Updates the view of a level given the selected items of upper level
       /// Recursive method