]> Creatis software - crea.git/commitdiff
Feature #1711
authorDaniel Gonzalez <daniel.gonzalez@creatis.insa-lyon.fr>
Tue, 29 Jan 2013 12:42:15 +0000 (13:42 +0100)
committerDaniel Gonzalez <daniel.gonzalez@creatis.insa-lyon.fr>
Tue, 29 Jan 2013 12:42:15 +0000 (13:42 +0100)
CreaDevManager application implementation

- Changes for windows compatibility. TreeItemId wrapping to work with windows

lib/creaDevManagerLib/modelCDMIProjectTreeNode.cpp
lib/creaDevManagerLib/modelCDMIProjectTreeNode.h
lib/creaDevManagerLib/modelCDMMain.cpp
lib/creaDevManagerLib/modelCDMMain.h
lib/creaDevManagerLib/wxCDMMainFrame.cpp
lib/creaDevManagerLib/wxCDMProjectsTreeCtrl.cxx
lib/creaDevManagerLib/wxCDMProjectsTreeCtrl.h
lib/creaDevManagerLib/wxCDMTreeItemId.cpp [new file with mode: 0644]
lib/creaDevManagerLib/wxCDMTreeItemId.h [new file with mode: 0644]

index e7edd2bcc80766b6e3fa01a1c529e55931074137..8b076580636b29a0a9a715c5e7b0e9ae0b2639c5 100644 (file)
@@ -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*>& modelCDMIProjectTreeNode::GetChild
   return this->children;
 }
 
-void modelCDMIProjectTreeNode::SetId(const wxTreeItemId& id)
+void modelCDMIProjectTreeNode::SetId(const wxCDMTreeItemId& id)
 {
   this->id = id;
 }
index d1688de5a8715da49defcd82ec8c46aa3efd0aa0..ddfae33b24685085248dbddc4a757985e89fd891 100644 (file)
@@ -39,6 +39,7 @@
 #include <vector>
 #include <creaWx.h>
 #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.
    */
index 58469c22f994221f3b03f1e787c7dbc19e32084c..71f60f6b84513eabe5ad63dce70c3ec48441242c 100644 (file)
@@ -290,7 +290,7 @@ bool modelCDMMain::RefreshProject(
     }
 }
 
-std::map<wxTreeItemId, modelCDMIProjectTreeNode*>& modelCDMMain::GetModelElements()
+std::map<wxCDMTreeItemId, modelCDMIProjectTreeNode*>& modelCDMMain::GetModelElements()
 {
   return this->modelElements;
 }
index 322f82375d04316a2a957f113cece8bf51eb97ba..d028487404e97f36190ad0975ad90eebdda826bb 100644 (file)
@@ -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;
 };
 
 
index 45dc8e587af7b58c181854246764400458d2b57e..5017c440ee1b368bd25f15208535ffd2be61fc61 100755 (executable)
@@ -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();
 }
index af393af26e2fc55e16f7f40603b2b9abb91c7138..6f7e33354cbff7aeb8eb380e1b112a4aa345c81f 100755 (executable)
@@ -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<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++)
     {
@@ -136,7 +137,7 @@ void wxCDMProjectsTreeCtrl::BuildTree(const std::vector<modelCDMIProjectTreeNode
         {
           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];
 
index 33f21f40bc42f6da7b3d85dacf38121cba98a955..08b52b6def5dda2eb7bb0cf4640ff6cd196d86a7 100755 (executable)
@@ -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<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.
diff --git a/lib/creaDevManagerLib/wxCDMTreeItemId.cpp b/lib/creaDevManagerLib/wxCDMTreeItemId.cpp
new file mode 100644 (file)
index 0000000..635ec07
--- /dev/null
@@ -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 (file)
index 0000000..f334a40
--- /dev/null
@@ -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 <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