From 741b9c1d03c7984f7ac4a39188e2bb114471f579 Mon Sep 17 00:00:00 2001 From: Daniel Gonzalez Date: Tue, 29 Jan 2013 13:42:15 +0100 Subject: [PATCH] Feature #1711 CreaDevManager application implementation - Changes for windows compatibility. TreeItemId wrapping to work with windows --- .../modelCDMIProjectTreeNode.cpp | 4 +- .../modelCDMIProjectTreeNode.h | 7 +- lib/creaDevManagerLib/modelCDMMain.cpp | 2 +- lib/creaDevManagerLib/modelCDMMain.h | 4 +- lib/creaDevManagerLib/wxCDMMainFrame.cpp | 32 ++--- .../wxCDMProjectsTreeCtrl.cxx | 9 +- lib/creaDevManagerLib/wxCDMProjectsTreeCtrl.h | 4 +- lib/creaDevManagerLib/wxCDMTreeItemId.cpp | 77 +++++++++++ lib/creaDevManagerLib/wxCDMTreeItemId.h | 128 ++++++++++++++++++ 9 files changed, 237 insertions(+), 30 deletions(-) create mode 100644 lib/creaDevManagerLib/wxCDMTreeItemId.cpp create mode 100644 lib/creaDevManagerLib/wxCDMTreeItemId.h diff --git a/lib/creaDevManagerLib/modelCDMIProjectTreeNode.cpp b/lib/creaDevManagerLib/modelCDMIProjectTreeNode.cpp index e7edd2b..8b07658 100644 --- a/lib/creaDevManagerLib/modelCDMIProjectTreeNode.cpp +++ b/lib/creaDevManagerLib/modelCDMIProjectTreeNode.cpp @@ -84,7 +84,7 @@ bool modelCDMIProjectTreeNode::CompareNodeItem(const modelCDMIProjectTreeNode* x return returnValue; } -const wxTreeItemId& modelCDMIProjectTreeNode::GetId() const +const wxCDMTreeItemId& modelCDMIProjectTreeNode::GetId() const { return this->id; } @@ -132,7 +132,7 @@ const std::vector& modelCDMIProjectTreeNode::GetChild return this->children; } -void modelCDMIProjectTreeNode::SetId(const wxTreeItemId& id) +void modelCDMIProjectTreeNode::SetId(const wxCDMTreeItemId& id) { this->id = id; } diff --git a/lib/creaDevManagerLib/modelCDMIProjectTreeNode.h b/lib/creaDevManagerLib/modelCDMIProjectTreeNode.h index d1688de..ddfae33 100644 --- a/lib/creaDevManagerLib/modelCDMIProjectTreeNode.h +++ b/lib/creaDevManagerLib/modelCDMIProjectTreeNode.h @@ -39,6 +39,7 @@ #include #include #include "wx/treectrl.h" +#include "wxCDMTreeItemId.h" /** * Class that represents an element of a Crea Project. @@ -61,7 +62,7 @@ public: * Returns the id of the node in the tree of the project. * @return Id of the node in the tree project. */ - const wxTreeItemId& GetId() const; + const wxCDMTreeItemId& GetId() const; /** * Returns the full path to the node, including the name of the node. * @return Node's full path. @@ -106,7 +107,7 @@ public: * Sets the id of the node in the project tree. * @param id Id of the node. */ - void SetId(const wxTreeItemId& id); + void SetId(const wxCDMTreeItemId& id); /** * Sorts the children using the compareNodeItem function. */ @@ -134,7 +135,7 @@ public: /** * Id of the node in the project tree. */ - wxTreeItemId id; + wxCDMTreeItemId id; /** * path of the node in the computer. */ diff --git a/lib/creaDevManagerLib/modelCDMMain.cpp b/lib/creaDevManagerLib/modelCDMMain.cpp index 58469c2..71f60f6 100644 --- a/lib/creaDevManagerLib/modelCDMMain.cpp +++ b/lib/creaDevManagerLib/modelCDMMain.cpp @@ -290,7 +290,7 @@ bool modelCDMMain::RefreshProject( } } -std::map& modelCDMMain::GetModelElements() +std::map& modelCDMMain::GetModelElements() { return this->modelElements; } diff --git a/lib/creaDevManagerLib/modelCDMMain.h b/lib/creaDevManagerLib/modelCDMMain.h index 322f823..d028487 100644 --- a/lib/creaDevManagerLib/modelCDMMain.h +++ b/lib/creaDevManagerLib/modelCDMMain.h @@ -68,7 +68,7 @@ public: * Retrieves the map of all the nodes inside the current active project. * @return Map with ids and node reference of the project. */ - std::map< wxTreeItemId, modelCDMIProjectTreeNode* >& GetModelElements(); + std::map< wxCDMTreeItemId, modelCDMIProjectTreeNode* >& GetModelElements(); /** @@ -123,7 +123,7 @@ private: /** * Map of all the elements of the currently active project and their IDs. */ - std::map< wxTreeItemId, modelCDMIProjectTreeNode* > modelElements; + std::map< wxCDMTreeItemId, modelCDMIProjectTreeNode* > modelElements; }; diff --git a/lib/creaDevManagerLib/wxCDMMainFrame.cpp b/lib/creaDevManagerLib/wxCDMMainFrame.cpp index 45dc8e5..5017c44 100755 --- a/lib/creaDevManagerLib/wxCDMMainFrame.cpp +++ b/lib/creaDevManagerLib/wxCDMMainFrame.cpp @@ -300,7 +300,7 @@ void wxCDMMainFrame::OnMenuNewProject(wxCommandEvent& event) //populate tree control tree_Projects->BuildTree(this->model->GetModelElements(),this->model->GetProject()); tree_Projects->Unselect(); - tree_Projects->SelectItem(this->model->GetProject()->GetId()); + tree_Projects->SelectItem(this->model->GetProject()->GetId().GetWxId()); wxMessageBox(wxT("ProjectSelected") ,_T("New Project - Success!"),wxOK | wxICON_ERROR); } } @@ -346,7 +346,7 @@ void wxCDMMainFrame::OnMenuOpenProject(wxCommandEvent& event) //populate tree control tree_Projects->BuildTree(this->model->GetModelElements(), this->model->GetProject()); tree_Projects->Unselect(); - tree_Projects->SelectItem(this->model->GetProject()->GetId(), true); + tree_Projects->SelectItem(this->model->GetProject()->GetId().GetWxId(), true); @@ -470,7 +470,7 @@ void wxCDMMainFrame::OnMenuRefreshProject(wxCommandEvent& event) this->auiManager.Update(); this->tree_Projects->Unselect(); - this->tree_Projects->SelectItem(this->model->GetProject()->GetId(), true); + this->tree_Projects->SelectItem(this->model->GetProject()->GetId().GetWxId(), true); } event.Skip(); } @@ -825,8 +825,8 @@ void wxCDMMainFrame::OnChangeView(wxCommandEvent& event) myItem = ((modelCDMIProjectTreeNode*)event.GetClientData()); //select out old one to generate selection event this->tree_Projects->Unselect(); - this->tree_Projects->SelectItem(myItem->GetId(), true); - this->tree_Projects->Expand(myItem->GetId()); + this->tree_Projects->SelectItem(myItem->GetId().GetWxId(), true); + this->tree_Projects->Expand(myItem->GetId().GetWxId()); break; case 1: wxPanel* description = NULL; @@ -846,14 +846,14 @@ void wxCDMMainFrame::OnChangeView(wxCommandEvent& event) } else if(event.GetString() == wxT("manage_libraries")) { - this->tree_Projects->SelectItem(this->model->GetProject()->GetLib()->GetId(), true); - this->tree_Projects->Expand(this->model->GetProject()->GetLib()->GetId()); + this->tree_Projects->SelectItem(this->model->GetProject()->GetLib()->GetId().GetWxId(), true); + this->tree_Projects->Expand(this->model->GetProject()->GetLib()->GetId().GetWxId()); break; } else if(event.GetString() == wxT("manage_applications")) { - this->tree_Projects->SelectItem(this->model->GetProject()->GetAppli()->GetId(), true); - this->tree_Projects->Expand(this->model->GetProject()->GetAppli()->GetId()); + this->tree_Projects->SelectItem(this->model->GetProject()->GetAppli()->GetId().GetWxId(), true); + this->tree_Projects->Expand(this->model->GetProject()->GetAppli()->GetId().GetWxId()); break; } else if(event.GetString() == wxT("blackbox")) @@ -892,10 +892,10 @@ void wxCDMMainFrame::OnElementSelected(wxCommandEvent& event) { //std::cout << "element " << event.GetInt() << std::endl; modelCDMIProjectTreeNode* item = (modelCDMIProjectTreeNode*)event.GetClientData(); - this->tree_Projects->EnsureVisible(item->GetId()); - this->tree_Projects->SetItemBold(item->GetId(), true); - this->tree_Projects->SetItemTextColour(item->GetId(), wxColour(0,0,255)); - this->tree_Projects->SetItemBackgroundColour(item->GetId(), wxColour(230,230,255)); + this->tree_Projects->EnsureVisible(item->GetId().GetWxId()); + this->tree_Projects->SetItemBold(item->GetId().GetWxId(), true); + this->tree_Projects->SetItemTextColour(item->GetId().GetWxId(), wxColour(0,0,255)); + this->tree_Projects->SetItemBackgroundColour(item->GetId().GetWxId(), wxColour(230,230,255)); this->tree_Projects->UpdateWindowUI(wxUPDATE_UI_RECURSE); auiManager.Update(); } @@ -903,9 +903,9 @@ void wxCDMMainFrame::OnElementSelected(wxCommandEvent& event) void wxCDMMainFrame::OnElementDeselected(wxCommandEvent& event) { modelCDMIProjectTreeNode* item = (modelCDMIProjectTreeNode*)event.GetClientData(); - this->tree_Projects->SetItemBold(item->GetId(), false); - this->tree_Projects->SetItemTextColour(item->GetId(), wxColour(0,0,0)); - this->tree_Projects->SetItemBackgroundColour(item->GetId(), wxColour(255,255,255)); + this->tree_Projects->SetItemBold(item->GetId().GetWxId(), false); + this->tree_Projects->SetItemTextColour(item->GetId().GetWxId(), wxColour(0,0,0)); + this->tree_Projects->SetItemBackgroundColour(item->GetId().GetWxId(), wxColour(255,255,255)); this->tree_Projects->UpdateWindowUI(wxUPDATE_UI_RECURSE); auiManager.Update(); } diff --git a/lib/creaDevManagerLib/wxCDMProjectsTreeCtrl.cxx b/lib/creaDevManagerLib/wxCDMProjectsTreeCtrl.cxx index af393af..6f7e333 100755 --- a/lib/creaDevManagerLib/wxCDMProjectsTreeCtrl.cxx +++ b/lib/creaDevManagerLib/wxCDMProjectsTreeCtrl.cxx @@ -99,11 +99,12 @@ bool wxCDMProjectsTreeCtrl::Create( this->AssignImageList(images); wxTreeItemId rootIndex = this->AddRoot(wxT("No Open Project"), this->ID_Cicon, this->ID_Cicon); + this->Update(); return TRUE; } -void wxCDMProjectsTreeCtrl::BuildTree(std::map< wxTreeItemId, modelCDMIProjectTreeNode* >& modelElements, modelCDMProject* projectTree) +void wxCDMProjectsTreeCtrl::BuildTree(std::map< wxCDMTreeItemId, modelCDMIProjectTreeNode* >& modelElements, modelCDMProject* projectTree) { std::cout << "building tree" << std::endl; this->DeleteAllItems(); @@ -117,7 +118,7 @@ void wxCDMProjectsTreeCtrl::BuildTree(std::map< wxTreeItemId, modelCDMIProjectTr std::cout << "Building TreeCtrl for " << projectTree->GetName() << std::endl; this->BuildTree(projectTree->GetChildren(), modelElements, projectTree->GetId()); - this->Expand(projectTree->GetId()); + this->Expand(projectTree->GetId().GetWxId()); this->Update(); } @@ -127,7 +128,7 @@ void wxCDMProjectsTreeCtrl::BuildTree(std::map< wxTreeItemId, modelCDMIProjectTr } } -void wxCDMProjectsTreeCtrl::BuildTree(const std::vector& treeNodes, std::map< wxTreeItemId, modelCDMIProjectTreeNode* >& modelElements, const wxTreeItemId& parent) +void wxCDMProjectsTreeCtrl::BuildTree(const std::vector& treeNodes, std::map< wxCDMTreeItemId, modelCDMIProjectTreeNode* >& modelElements, const wxCDMTreeItemId& parent) { for (int i = 0; i < (int)(treeNodes.size()); i++) { @@ -136,7 +137,7 @@ void wxCDMProjectsTreeCtrl::BuildTree(const std::vectorGetName()).c_str(), wxConvUTF8); - treeNodes[i]->SetId(this->AppendItem(parent, nodeName, idIcon)); + treeNodes[i]->SetId(wxCDMTreeItemId(this->AppendItem(parent.GetWxId(), nodeName, idIcon))); modelElements[treeNodes[i]->GetId()] = treeNodes[i]; diff --git a/lib/creaDevManagerLib/wxCDMProjectsTreeCtrl.h b/lib/creaDevManagerLib/wxCDMProjectsTreeCtrl.h index 33f21f4..08b52b6 100755 --- a/lib/creaDevManagerLib/wxCDMProjectsTreeCtrl.h +++ b/lib/creaDevManagerLib/wxCDMProjectsTreeCtrl.h @@ -97,7 +97,7 @@ public: /** * Builds the tree hierarchy with the given model elements. */ - void BuildTree(std::map< wxTreeItemId, modelCDMIProjectTreeNode* >& modelElements, modelCDMProject* tree = NULL); + void BuildTree(std::map< wxCDMTreeItemId, modelCDMIProjectTreeNode* >& modelElements, modelCDMProject* tree = NULL); private: @@ -152,7 +152,7 @@ private: * @param modelElements Id->node map. * @param parent ID of the root node ID. */ - void BuildTree(const std::vector& tree, std::map< wxTreeItemId, modelCDMIProjectTreeNode* >& modelElements, const wxTreeItemId& parent); + void BuildTree(const std::vector& tree, std::map< wxCDMTreeItemId, modelCDMIProjectTreeNode* >& modelElements, const wxCDMTreeItemId& parent); /** * Retrieves the icon ID of the given node by its type. * @param node Node to search its icon. diff --git a/lib/creaDevManagerLib/wxCDMTreeItemId.cpp b/lib/creaDevManagerLib/wxCDMTreeItemId.cpp new file mode 100644 index 0000000..635ec07 --- /dev/null +++ b/lib/creaDevManagerLib/wxCDMTreeItemId.cpp @@ -0,0 +1,77 @@ +/* +# --------------------------------------------------------------------- +# +# Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image +# pour la Sante) +# Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton +# Previous Authors : Laurent Guigues, Jean-Pierre Roux +# CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil +# +# This software is governed by the CeCILL-B license under French law and +# abiding by the rules of distribution of free software. You can use, +# modify and/ or redistribute the software under the terms of the CeCILL-B +# license as circulated by CEA, CNRS and INRIA at the following URL +# http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html +# or in the file LICENSE.txt. +# +# As a counterpart to the access to the source code and rights to copy, +# modify and redistribute granted by the license, users are provided only +# with a limited warranty and the software's author, the holder of the +# economic rights, and the successive licensors have only limited +# liability. +# +# The fact that you are presently reading this means that you have had +# knowledge of the CeCILL-B license and that you accept its terms. +# ------------------------------------------------------------------------ +*/ + + +/* + * wxCDMTreeItemId.cpp + * + * Created on: 29/1/2013 + * Author: Daniel Felipe Gonzalez Obando + */ + +#include "wxCDMTreeItemId.h" + +wxCDMTreeItemId::wxCDMTreeItemId(){} + +wxCDMTreeItemId::wxCDMTreeItemId(const wxTreeItemId& id) +{ + this->_idWx = id; + this->_id = id.m_pItem; +} + +wxCDMTreeItemId::~wxCDMTreeItemId(){} + +const wxTreeItemId& wxCDMTreeItemId::GetWxId() const +{ + return this->_idWx; +} + +const wxTreeItemIdValue& wxCDMTreeItemId::GetId() const +{ + return this->_id; +} + +bool wxCDMTreeItemId::operator == (const wxCDMTreeItemId& id) const +{ + return this->_id == id._id; +} + +bool wxCDMTreeItemId::operator != (const wxCDMTreeItemId& id) const +{ + return !(*this == id); +} + +bool wxCDMTreeItemId::operator < (const wxCDMTreeItemId& id) const +{ + return this->_id < id._id; +} + +std::ostream& operator << (std::ostream& stream, const wxCDMTreeItemId& id) +{ + stream << id._id; + return stream; +} diff --git a/lib/creaDevManagerLib/wxCDMTreeItemId.h b/lib/creaDevManagerLib/wxCDMTreeItemId.h new file mode 100644 index 0000000..f334a40 --- /dev/null +++ b/lib/creaDevManagerLib/wxCDMTreeItemId.h @@ -0,0 +1,128 @@ +/* +# --------------------------------------------------------------------- +# +# Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image +# pour la Sante) +# Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton +# Previous Authors : Laurent Guigues, Jean-Pierre Roux +# CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil +# +# This software is governed by the CeCILL-B license under French law and +# abiding by the rules of distribution of free software. You can use, +# modify and/ or redistribute the software under the terms of the CeCILL-B +# license as circulated by CEA, CNRS and INRIA at the following URL +# http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html +# or in the file LICENSE.txt. +# +# As a counterpart to the access to the source code and rights to copy, +# modify and redistribute granted by the license, users are provided only +# with a limited warranty and the software's author, the holder of the +# economic rights, and the successive licensors have only limited +# liability. +# +# The fact that you are presently reading this means that you have had +# knowledge of the CeCILL-B license and that you accept its terms. +# ------------------------------------------------------------------------ +*/ + + +/* + * wxCDMTreeItemId.h + * + * Created on: 29/1/2013 + * Author: Daniel Felipe Gonzalez Obando + */ + +#ifndef _WXCDMTREEITEMID_H_ +#define _WXCSMTREEITEMID_H_ + + +#include +#include +#include +#include + +/** + * Class Name: wxCDMTreeItemId + * Class Id manager for the project tree control. + */ +class wxCDMTreeItemId +{ + +//--------------------------------------------- +//Methods and attributes exposed to other classes +//--------------------------------------------- +public : + /** + * Default Constructor + */ + wxCDMTreeItemId(); + /** + * Constructor + * @param id Original TreeItem Id. + */ + wxCDMTreeItemId(const wxTreeItemId& id); + /** + * Destructor + */ + ~wxCDMTreeItemId(); + + /** + * Retrieves the id from the wxTreeItemId object + * @return id name + */ + const wxTreeItemId& GetWxId() const; + /** + * Retrieves the private id of the tree item. + * @return id value + */ + const wxTreeItemIdValue& GetId() const; + + /** + * Operator == + * @id comparing tree item id + * @return true if the id value is the same. + */ + bool operator == (const wxCDMTreeItemId& id) const; + /** + * Operator != + * @id comparing tree item id + * @return true if the id value is not the same. + */ + bool operator != (const wxCDMTreeItemId& id) const; + /** + * Operator < + * @id comparing tree item id + * @return true if the id value is less than the one in the given id. + */ + bool operator < (const wxCDMTreeItemId& id) const; + /** + * operator << allows to manage output stream printing of the object. + * @param stream Target stream. + * @param id Tree item id to print. + * @return Stream modified. + */ + friend std::ostream& operator << (std::ostream& stream, const wxCDMTreeItemId& id); + +//--------------------------------------------- +//Methods and attributes exposed only to classes +//that are derived from this class +//--------------------------------------------- +protected: + /** + * Real tree item + */ + wxTreeItemId _idWx; + /** + * Tree item value + */ + wxTreeItemIdValue _id; +//--------------------------------------------- +//Methods and attributes only visible by this class +//--------------------------------------------- +private: + +}; + +//-end of _WXCDMTREEITEMID_H_------------------------------------------------------ +#endif -- 2.47.1