return returnValue;
}
-const wxTreeItemId& modelCDMIProjectTreeNode::GetId() const
+const wxCDMTreeItemId& modelCDMIProjectTreeNode::GetId() const
{
return this->id;
}
return this->children;
}
-void modelCDMIProjectTreeNode::SetId(const wxTreeItemId& id)
+void modelCDMIProjectTreeNode::SetId(const wxCDMTreeItemId& id)
{
this->id = id;
}
#include <vector>
#include <creaWx.h>
#include "wx/treectrl.h"
+#include "wxCDMTreeItemId.h"
/**
* Class that represents an element of a Crea Project.
* 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.
* 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.
*/
/**
* Id of the node in the project tree.
*/
- wxTreeItemId id;
+ wxCDMTreeItemId id;
/**
* path of the node in the computer.
*/
}
}
-std::map<wxTreeItemId, modelCDMIProjectTreeNode*>& modelCDMMain::GetModelElements()
+std::map<wxCDMTreeItemId, modelCDMIProjectTreeNode*>& modelCDMMain::GetModelElements()
{
return this->modelElements;
}
* 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();
/**
/**
* Map of all the elements of the currently active project and their IDs.
*/
- std::map< wxTreeItemId, modelCDMIProjectTreeNode* > modelElements;
+ std::map< wxCDMTreeItemId, modelCDMIProjectTreeNode* > modelElements;
};
//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);
}
}
//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);
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();
}
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;
}
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"))
{
//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();
}
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();
}
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();
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();
}
}
}
-void wxCDMProjectsTreeCtrl::BuildTree(const std::vector<modelCDMIProjectTreeNode*>& treeNodes, std::map< wxTreeItemId, modelCDMIProjectTreeNode* >& modelElements, const wxTreeItemId& parent)
+void wxCDMProjectsTreeCtrl::BuildTree(const std::vector<modelCDMIProjectTreeNode*>& treeNodes, std::map< wxCDMTreeItemId, modelCDMIProjectTreeNode* >& modelElements, const wxCDMTreeItemId& parent)
{
for (int i = 0; i < (int)(treeNodes.size()); i++)
{
{
int idIcon = GetIconId(treeNodes[i]);
wxString nodeName((treeNodes[i]->GetName()).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];
/**
* 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:
* @param modelElements Id->node map.
* @param parent ID of the root node ID.
*/
- void BuildTree(const std::vector<modelCDMIProjectTreeNode*>& tree, std::map< wxTreeItemId, modelCDMIProjectTreeNode* >& modelElements, const wxTreeItemId& parent);
+ void BuildTree(const std::vector<modelCDMIProjectTreeNode*>& 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.
--- /dev/null
+/*
+# ---------------------------------------------------------------------
+#
+# 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;
+}
--- /dev/null
+/*
+# ---------------------------------------------------------------------
+#
+# 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 <creaWx.h>
+#include <wx/treectrl.h>
+#include <wx/treebase.h>
+#include <iostream>
+
+/**
+ * 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