From: caballero Date: Tue, 26 May 2009 12:59:56 +0000 (+0000) Subject: Added attribute selection functionality. X-Git-Tag: EED.02Oct2009~58 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=381f766db11094bd9b96f9e948527cbec24f680a;p=creaImageIO.git Added attribute selection functionality. --- diff --git a/src2/creaImageIOSQLiteTreeHandler.cpp b/src2/creaImageIOSQLiteTreeHandler.cpp index 6d4d25b..596a92a 100644 --- a/src2/creaImageIOSQLiteTreeHandler.cpp +++ b/src2/creaImageIOSQLiteTreeHandler.cpp @@ -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, diff --git a/src2/creaImageIOSQLiteTreeHandler.h b/src2/creaImageIOSQLiteTreeHandler.h index d3a055e..6948675 100644 --- a/src2/creaImageIOSQLiteTreeHandler.h +++ b/src2/creaImageIOSQLiteTreeHandler.h @@ -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(); //==================================================================== diff --git a/src2/creaImageIOTreeHandler.h b/src2/creaImageIOTreeHandler.h index a0d3f45..b84d0f9 100644 --- a/src2/creaImageIOTreeHandler.h +++ b/src2/creaImageIOTreeHandler.h @@ -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(){} //==================================================================== diff --git a/src2/creaImageIOTreeHandlerImageAdder.cpp b/src2/creaImageIOTreeHandlerImageAdder.cpp index 16008be..a6b0737 100644 --- a/src2/creaImageIOTreeHandlerImageAdder.cpp +++ b/src2/creaImageIOTreeHandlerImageAdder.cpp @@ -79,11 +79,13 @@ namespace creaImageIO rec<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<SetAttribute("FILES_ADDED","ADD_OPS",files.str(),"ADD_KEY",addKey,mCurrentDB); + mTreeHandler->EndTransaction(); GimmickDebugMessage(3,mProgress<& areShown, std::vector& 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& notShown, int level){ GimmickError("INTERNAL ERROR : TreeView::SetNonVisibleAttributes not overloaded"); } + + ///Creates a new listctrl + virtual void CreateCtrl(std::vector& notShown, int nlevel){ GimmickError("INTERNAL ERROR : TreeView::CreateCtrl not overloaded"); } protected: TreeHandler* GetTreeHandler() { return mTreeHandler; } diff --git a/src2/creaImageIOWxAttributeSelectionPanel.cpp b/src2/creaImageIOWxAttributeSelectionPanel.cpp index 113dcfe..5697893 100644 --- a/src2/creaImageIOWxAttributeSelectionPanel.cpp +++ b/src2/creaImageIOWxAttributeSelectionPanel.cpp @@ -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(); } diff --git a/src2/creaImageIOWxEditFieldsPanel.cpp b/src2/creaImageIOWxEditFieldsPanel.cpp index aa48137..2dc46a5 100644 --- a/src2/creaImageIOWxEditFieldsPanel.cpp +++ b/src2/creaImageIOWxEditFieldsPanel.cpp @@ -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(); } diff --git a/src2/creaImageIOWxGimmickView.cpp b/src2/creaImageIOWxGimmickView.cpp index 0d0ee0a..9d916f4 100644 --- a/src2/creaImageIOWxGimmickView.cpp +++ b/src2/creaImageIOWxGimmickView.cpp @@ -816,6 +816,14 @@ namespace creaImageIO { GetTreeViewMap()[crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection()))]->GetAttributes(shown,nShown,level); } + + //=================================================================== + void WxGimmickView::OnAttributesChanged(const std::vector& nShown, int level) + { + GetTreeViewMap()[crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection()))]->SetNonVisibleAttributes(nShown,level); + std::vector n=nShown; + GetTreeViewMap()[crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection()))]->CreateCtrl(n,level); + } //=================================================================== void WxGimmickView::OnSaveSettingsCallback(const std::string& copyPath, const std::string& dbPath, diff --git a/src2/creaImageIOWxGimmickView.h b/src2/creaImageIOWxGimmickView.h index 79acac4..074a571 100644 --- a/src2/creaImageIOWxGimmickView.h +++ b/src2/creaImageIOWxGimmickView.h @@ -95,9 +95,9 @@ namespace creaImageIO ///Called upon to return the visible attributes of the current tab void GetVisibleAttributes(std::vector& shown,std::vector& nShown, int level); - - - + + ///Called when there has been a change in the visible attributes of a tree view + void OnAttributesChanged(const std::vector& nShown, int level); protected: /// Creates the tool bar diff --git a/src2/creaImageIOWxTreeView.cpp b/src2/creaImageIOWxTreeView.cpp index 2f51531..2fced88 100644 --- a/src2/creaImageIOWxTreeView.cpp +++ b/src2/creaImageIOWxTreeView.cpp @@ -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& notShown, int nlevel) + { + mLevelList[nlevel].notShownAtts=notShown; + } + + //================================================================ + void WxTreeView::CreateCtrl(std::vector& 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 ns=mLevelList[level-1].notShownAtts; + std::vector::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) diff --git a/src2/creaImageIOWxTreeView.h b/src2/creaImageIOWxTreeView.h index 76440a4..a0f6b65 100644 --- a/src2/creaImageIOWxTreeView.h +++ b/src2/creaImageIOWxTreeView.h @@ -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& areShown, std::vector& notShown, int level); + + ///Sets the non visible attributes and refreshes the GUI + void SetNonVisibleAttributes(const std::vector& notShown, int level); + + ///Creates a new listctrl + void CreateCtrl(std::vector& 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