2 # ---------------------------------------------------------------------
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
6 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
8 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
10 # This software is governed by the CeCILL-B license under French law and
11 # abiding by the rules of distribution of free software. You can use,
12 # modify and/ or redistribute the software under the terms of the CeCILL-B
13 # license as circulated by CEA, CNRS and INRIA at the following URL
14 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
15 # or in the file LICENSE.txt.
17 # As a counterpart to the access to the source code and rights to copy,
18 # modify and redistribute granted by the license, users are provided only
19 # with a limited warranty and the software's author, the holder of the
20 # economic rights, and the successive licensors have only limited
23 # The fact that you are presently reading this means that you have had
24 # knowledge of the CeCILL-B license and that you accept its terms.
25 # ------------------------------------------------------------------------
29 * modelCDMIProjectTreeNode.h
31 * Created on: 13/11/2012
32 * Author: Daniel Felipe Gonzalez Obando
35 #ifndef MODELCDMIPROJECTTREENODE_H_
36 #define MODELCDMIPROJECTTREENODE_H_
41 #include "wx/treectrl.h"
44 * Class that represents an element of a Crea Project.
46 class modelCDMIProjectTreeNode
50 * Destructor that doesn't do anything.
52 virtual ~modelCDMIProjectTreeNode() {};
55 * Compares the precedence of an modelCDMIProjectTreeNode object with another by the node's name and its type (first folder then file).
56 * @return Either if the node x goes before (true) or after (false) y.
58 static bool CompareNodeItem(const modelCDMIProjectTreeNode* x, const modelCDMIProjectTreeNode* y);
61 * Returns the id of the node in the tree of the project.
62 * @return Id of the node in the tree project.
64 const wxTreeItemId& GetId() const;
66 * Returns the full path to the node, including the name of the node.
67 * @return Node's full path.
69 const std::string& GetPath() const;
71 * Return the name of the node, either the file name or the folder name.
72 * @return Name of the node.
74 const std::string& GetName() const;
76 * Returns the type of node.
77 * @return Either wxDIR_FILES for files or wxDIR_DIRS for folders.
79 const unsigned char& GetType() const;
81 * Returns the level of the node in the project tree.
82 * @return Level of the node in the project tree.
84 const int& GetLevel() const;
86 * Returns a reference to the parent node of the actual node.
87 * @return The reference of the parent node or NULL.
89 modelCDMIProjectTreeNode* GetParent() const;
91 * Returns an array with the hierarchy route between the node and the project root
92 * @return Hierarchy array ordered from higher to lower node level down to the project root.
94 std::vector<modelCDMIProjectTreeNode*> GetParents() const;
96 * Returns the children nodes of the actual node.
97 * @return An array with the children nodes.
99 const std::vector<modelCDMIProjectTreeNode*>& GetChildren() const;
101 * Returns the file size of the node.
104 const int& GetLength();
106 * Sets the id of the node in the project tree.
107 * @param id Id of the node.
109 void SetId(const wxTreeItemId& id);
111 * Sorts the children using the compareNodeItem function.
115 * Sets the children array of the node. Warning: it discards the older children.
116 * @param children Array of children nodes.
118 void SetChildren(const std::vector<modelCDMIProjectTreeNode*>& children);
121 * Refreshes the structure of the node and its children.
122 * @param result Result of the procedure.
123 * @return True if the procedure was successful.
125 virtual const bool Refresh(std::string*& result);
127 * Opens the file explorer in the containing folder of the file or in the folder itself.
128 * @param result Result of the procedure.
129 * @return True if the procedure was successful.
131 const bool OpenInFileExplorer(std::string*& result) const;
135 * Id of the node in the project tree.
139 * path of the node in the computer.
143 * Name of the folder or file.
147 * Type of the node. Either wxDIR_FILES for files or wxDIR_DIRS for folders.
151 * Level of the node in the file hierarchy.
155 * Length of the file in the system.
159 * Reference to the parent node.
161 modelCDMIProjectTreeNode* parent;
163 * Array of references to the children nodes.
165 std::vector<modelCDMIProjectTreeNode*> children;
170 #endif /* MODELCDMIPROJECTTREENODE_H_ */