]> Creatis software - creaImageIO.git/commitdiff
Added attribute selection functionality.
authorcaballero <caballero>
Tue, 26 May 2009 12:59:56 +0000 (12:59 +0000)
committercaballero <caballero>
Tue, 26 May 2009 12:59:56 +0000 (12:59 +0000)
src2/creaImageIOSQLiteTreeHandler.cpp
src2/creaImageIOSQLiteTreeHandler.h
src2/creaImageIOTreeHandler.h
src2/creaImageIOTreeHandlerImageAdder.cpp
src2/creaImageIOTreeView.h
src2/creaImageIOWxAttributeSelectionPanel.cpp
src2/creaImageIOWxEditFieldsPanel.cpp
src2/creaImageIOWxGimmickView.cpp
src2/creaImageIOWxGimmickView.h
src2/creaImageIOWxTreeView.cpp
src2/creaImageIOWxTreeView.h

index 6d4d25b9ce249d2ce1023d33d72cba8b75feeb04..596a92a17492e963abea3cabcd061ccb084549e4 100644 (file)
@@ -1092,6 +1092,22 @@ namespace creaImageIO
         UPDATEDB(query.str());
        }
 
+       //=====================================================================
+  void SQLiteTreeHandler::BeginTransaction()
+    {
+               std::stringstream out;
+               out<<"begin transaction;";
+        UPDATEDB(out.str());
+       }
+
+       //=====================================================================
+  void SQLiteTreeHandler::EndTransaction()
+    {
+       std::stringstream out;
+               out<<"commit transaction;";
+        UPDATEDB(out.str());
+       }
+
   /*
   //=====================================================================
   bool SQLiteTreeHandler::DBInsert(Node* alien_node,
index d3a055e55eca70ff2d2e337f864c60b6c51dd184..6948675d43d05fe154702695df4fab97a2558e7f 100644 (file)
@@ -55,6 +55,10 @@ namespace creaImageIO
     virtual bool Create(bool writable = false);
     /// Destroys the 'source'
     virtual bool Destroy();
+       /// Begins a transaction
+       virtual void BeginTransaction();
+       ///Commits results and ends transaction
+       virtual void EndTransaction();
     //====================================================================
 
 
index a0d3f45f7afa6cf31d1608c04a2b316282e03792..b84d0f9e64b3cfe85e7944587f449704a9371ece 100644 (file)
@@ -64,6 +64,10 @@ namespace creaImageIO
     virtual bool Create(bool writable = false) { return false; }
     /// Destroys the 'source'
     virtual bool Destroy() { return false; }
+       /// Begins a transaction
+       virtual void BeginTransaction(){}
+       ///Commits results and ends transaction
+       virtual void EndTransaction(){}
     //====================================================================
 
 
index 16008be93bc989f90da80cc57ad922f10727fb02..a6b073764818e4508cbad6240554ba7f47dadbce 100644 (file)
@@ -79,11 +79,13 @@ namespace creaImageIO
        rec<<recurse;
        mSynchronizer->InsertAddOp(directory,rec.str(),"0",mCurrentDB);
        std::string addKey=mSynchronizer->GetAttribute("ADD_KEY","ADD_OPS","PATH",directory,mCurrentDB);
+       mTreeHandler->BeginTransaction();
        AddDirectoryRecursor( directory, recurse, addKey );
        
        int nFiles=GetProgress().GetNumberAddedFiles();
        files<<nFiles;
        mSynchronizer->SetAttribute("FILES_ADDED","ADD_OPS",files.str(),"ADD_KEY",addKey,mCurrentDB);
+       mTreeHandler->EndTransaction();
     GimmickDebugMessage(3,mProgress<<std::endl);
   }
 
index 611c7d0cbe87e06f464cfece867821fde9c866be..a1cb4b2e4cfac5f0ff75df1e651703aa2bf17cdd 100644 (file)
@@ -56,6 +56,12 @@ namespace creaImageIO
 
          /// 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"); }
+         
+         ///Sets the non visible attributes and refreshes the GUI
+         virtual void SetNonVisibleAttributes(const std::vector<std::string>& notShown, int level){ GimmickError("INTERNAL ERROR : TreeView::SetNonVisibleAttributes not overloaded"); }
+
+         ///Creates a new listctrl
+         virtual void CreateCtrl(std::vector<std::string>& notShown, int nlevel){ GimmickError("INTERNAL ERROR : TreeView::CreateCtrl not overloaded"); }
 
     protected:
       TreeHandler* GetTreeHandler() { return mTreeHandler; }
index 113dcfe2897c291e50b955fc708856644d55320a..5697893fd4040412fbf068df90c0b3f11602f26f 100644 (file)
@@ -40,7 +40,7 @@ namespace creaImageIO
        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=new wxListCtrl(this, wxID_ANY, wxPoint(5,30), wxSize(160,90), wxLC_REPORT | wxLC_NO_HEADER );
 
        shownAtts->InsertColumn(0, 
                                   crea::std2wx(""),
@@ -54,7 +54,7 @@ namespace creaImageIO
        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=new wxListCtrl(this, wxID_ANY, wxPoint(255,30), wxSize(160,90), wxLC_REPORT | wxLC_NO_HEADER );
 
        notShownAtts->InsertColumn(0, 
                                   crea::std2wx(""),
@@ -78,11 +78,9 @@ namespace creaImageIO
 
   void WxAttributeSelectionPanel::OnSaveConfig(wxCommandEvent& event)
   {
-         /*mView->OnSaveSettingsCallback(crea::wx2std(copyPath->GetValue()),
-                 crea::wx2std(dbPath->GetValue()),
-                 crea::wx2std(syncEvent->GetValue()),
-                 crea::wx2std(syncFrequency->GetValue()));
-         */
+         int n=levels->GetSelection();
+         if(n<0){n=0;}
+         mView->OnAttributesChanged(notShownA,n);
          dialog->Destroy();
   }
 
@@ -109,9 +107,8 @@ namespace creaImageIO
                        }
                        shownA.erase(it-1);
                        notShownA.push_back(change);
-                       LoadCtrls();    
-               
        }
+       LoadCtrls();
        
   }
 
@@ -139,9 +136,9 @@ namespace creaImageIO
                        }
                        notShownA.erase(it-1);
                        shownA.push_back(change);
-                       LoadCtrls();    
                
        }
+       LoadCtrls();    
          
   }
   
index aa48137b812eac39b68b8c799e4c0a2e15fd4eec..2dc46a58745aa505b5dc9faf8c1924e702612edf 100644 (file)
@@ -38,7 +38,7 @@ namespace creaImageIO
        std::string val=node->GetAttribute(keys[0]);
        if(val.compare("")==0){val="?";}
 
-       wxStaticText * av=new wxStaticText(this,-1,_T(" Actual Value: "), wxPoint(5,40));
+       wxStaticText * av=new wxStaticText(this,-1,_T(" Current Value: "), wxPoint(5,40));
        actualVal=new wxStaticText(this,-1,_T(val), wxPoint(110,40));
 
        wxStaticText * nv=new wxStaticText(this,-1,_T(" New Value: "), wxPoint(5,70));
@@ -60,7 +60,12 @@ namespace creaImageIO
   void WxEditFieldsPanel::OnEdit(wxCommandEvent& event)
   {
          std::string val=crea::wx2std(newVal->GetValue());
-         mView->OnFieldsEdited(node,names[attributes->GetSelection()],keys[attributes->GetSelection()],val);
+         int sel=attributes->GetSelection();
+         if(sel==-1)
+         {
+                 sel=0;
+         }
+         mView->OnFieldsEdited(node,names[sel],keys[sel],val);
          dialog->Destroy();
   }
 
index 0d0ee0a550510893e83cdb3e2f0f4c355cb25d76..9d916f431f89233ed088fc201392ade3a1f2b419 100644 (file)
@@ -816,6 +816,14 @@ namespace creaImageIO
   {
          GetTreeViewMap()[crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection()))]->GetAttributes(shown,nShown,level);
   }
+
+  //===================================================================
+  void WxGimmickView::OnAttributesChanged(const std::vector<std::string>& nShown, int level)
+  {
+         GetTreeViewMap()[crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection()))]->SetNonVisibleAttributes(nShown,level);
+         std::vector<std::string> n=nShown;
+         GetTreeViewMap()[crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection()))]->CreateCtrl(n,level);
+  }
   //===================================================================
   void WxGimmickView::OnSaveSettingsCallback(const std::string& copyPath,
          const std::string& dbPath,
index 79acac41550bd72ed66a48f2d637dca345274185..074a571b7f5d0a83ecd87715fcefc2c85daf35f2 100644 (file)
@@ -95,9 +95,9 @@ namespace creaImageIO
 
        ///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);
-  
-  
+
+       ///Called when there has been a change in the visible attributes of a tree view
+       void OnAttributesChanged(const std::vector<std::string>& nShown, int level);
     
   protected:
     /// Creates the tool bar
index 2f515314ccc6b89cf4b7828e6087a0c43a580a8a..2fced885b158ecc2844ab93c8bb70ebe10625778 100644 (file)
@@ -1203,13 +1203,85 @@ namespace creaImageIO
             a != GetTreeHandler()->GetTree().GetAttributeDescriptorList(level).end();
             ++a)
        {
-               if(a->GetFlags()==creaImageIO::tree::AttributeDescriptor::EDITABLE)
+               if(a->GetFlags()==creaImageIO::tree::AttributeDescriptor::EDITABLE && IsAttributeVisible(a->GetName(),level))
            {
                        areShown.push_back(a->GetName());
                }
        }
        notShown=mLevelList[level-1].notShownAtts;
   }
+
+  //================================================================
+  void WxTreeView::SetNonVisibleAttributes(const std::vector<std::string>& notShown, int nlevel)
+  {
+       mLevelList[nlevel].notShownAtts=notShown;
+  }
+
+  //================================================================
+   void WxTreeView::CreateCtrl(std::vector<std::string>& notShown, int nlevel)
+  {
+       int ctrl_style = wxLC_REPORT | wxLC_VRULES;
+    int col_style = wxLIST_FORMAT_LEFT;
+       LevelType level;
+       mLevelList[nlevel].SelectedUpToDate = true;
+       mLevelList[nlevel].SortColumn = 0;
+       mLevelList[nlevel].key.clear();
+       
+       mLevelList[nlevel].wxCtrl = new wxListCtrl(mLevelList[nlevel].wxSplitter,
+                                         nlevel,
+                                         wxDefaultPosition, 
+                                         wxDefaultSize,
+                                         ctrl_style);
+       wxWindow* oldWin=mLevelList[nlevel].wxSplitter->GetWindow1();
+       mLevelList[nlevel].wxSplitter->ReplaceWindow(oldWin,mLevelList[nlevel].wxCtrl);
+       mLevelList[nlevel].wxSplitter->Initialize(mLevelList[nlevel].wxCtrl);
+   
+       // Create the columns : one for each attribute of the level
+       int col = 0;
+       std::string title;
+
+       tree::LevelDescriptor::AttributeDescriptorListType::const_iterator a;
+       for (a  = GetTreeHandler()->GetTree().GetAttributeDescriptorList(nlevel+1).begin();
+            a != GetTreeHandler()->GetTree().GetAttributeDescriptorList(nlevel+1).end();
+            ++a)
+
+       {   
+           if(a->GetFlags()!=creaImageIO::tree::AttributeDescriptor::PRIVATE && IsAttributeVisible(a->GetName(),nlevel+1))
+             {
+                 title=a->GetName();
+                 std::string temp = a->GetKey();
+                 if (temp.compare("ID") != 0)
+                 {
+                       mLevelList[nlevel].wxCtrl->InsertColumn(col, 
+                                       crea::std2wx(title),
+                                       col_style);
+                       col++;
+                 }
+               mLevelList[nlevel].key.push_back(a->GetKey());
+             }
+               
+         }
+       oldWin->Destroy();
+       UpdateLevel(1);
+       }
+
+   //================================================================
+  bool WxTreeView::IsAttributeVisible(const std::string& val, int level)
+  {
+         std::vector<std::string> ns=mLevelList[level-1].notShownAtts;
+         std::vector<std::string>::iterator it;
+         bool found=false;
+         for(it=ns.begin();it!=ns.end()&&!found;++it)
+         {
+                 if(val.compare(*it)==0)
+                 {
+                         found=true;
+                 }
+         }
+
+         return !found;
+  }
+
   //================================================================
   //================================================================
   BEGIN_EVENT_TABLE(WxTreeView, wxPanel)   
index 76440a4ae0993526a8608e6471097ced25a5e41b..a0f6b658d062b032214c81f313bde350f1a98127 100644 (file)
@@ -68,6 +68,15 @@ namespace creaImageIO
          
          /// 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);
+
+         ///Sets the non visible attributes and refreshes the GUI
+         void SetNonVisibleAttributes(const std::vector<std::string>& notShown, int level);
+
+         ///Creates a new listctrl
+         void CreateCtrl(std::vector<std::string>& notShown, int nlevel);
+  
+         ///Returns true if the attribute passed as a parameter is visible or not
+         bool IsAttributeVisible(const std::string& val, int level);
       
       /// Actual processing of item selection/deselection 
       /// Called by OnItemSelected and OnItemDeSelected