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"
42 #include "wxCDMTreeItemId.h"
45 * Class that represents an element of a Crea Project.
47 class modelCDMIProjectTreeNode
51 * Destructor that doesn't do anything.
53 virtual ~modelCDMIProjectTreeNode() {};
56 * Compares the precedence of an modelCDMIProjectTreeNode object with another by the node's name and its type (first folder then file).
57 * @return Either if the node x goes before (true) or after (false) y.
59 static bool CompareNodeItem(const modelCDMIProjectTreeNode* x, const modelCDMIProjectTreeNode* y);
62 * Returns the id of the node in the tree of the project.
63 * @return Id of the node in the tree project.
65 const wxCDMTreeItemId& GetId() const;
67 * Returns the full path to the node, including the name of the node.
68 * @return Node's full path.
70 const std::string& GetPath() const;
72 * Return the name of the node, either the file name or the folder name.
73 * @return Name of the node.
75 const std::string& GetName() const;
77 * Returns the type of node.
78 * @return Either wxDIR_FILES for files or wxDIR_DIRS for folders.
80 const unsigned char& GetType() const;
82 * Returns the level of the node in the project tree.
83 * @return Level of the node in the project tree.
85 const int& GetLevel() const;
87 * Returns a reference to the parent node of the actual node.
88 * @return The reference of the parent node or NULL.
90 modelCDMIProjectTreeNode* GetParent() const;
92 * Returns an array with the hierarchy route between the node and the project root
93 * @return Hierarchy array ordered from higher to lower node level down to the project root.
95 std::vector<modelCDMIProjectTreeNode*> GetParents() const;
97 * Returns the children nodes of the actual node.
98 * @return An array with the children nodes.
100 const std::vector<modelCDMIProjectTreeNode*>& GetChildren() const;
102 * Returns the file size of the node.
105 const int& GetLength();
107 * Sets the id of the node in the project tree.
108 * @param id Id of the node.
110 void SetId(const wxCDMTreeItemId& id);
112 * Sorts the children using the compareNodeItem function.
116 * Sets the children array of the node. Warning: it discards the older children.
117 * @param children Array of children nodes.
119 void SetChildren(const std::vector<modelCDMIProjectTreeNode*>& children);
122 * Refreshes the structure of the node and its children.
123 * @param result Result of the procedure.
124 * @return True if the procedure was successful.
126 virtual const bool Refresh(std::string*& result);
128 * Opens the file explorer in the containing folder of the file or in the folder itself.
129 * @param result Result of the procedure.
130 * @return True if the procedure was successful.
132 const bool OpenInFileExplorer(std::string*& result) const;
136 * Id of the node in the project tree.
140 * path of the node in the computer.
144 * Name of the folder or file.
148 * Type of the node. Either wxDIR_FILES for files or wxDIR_DIRS for folders.
152 * Level of the node in the file hierarchy.
156 * Length of the file in the system.
160 * Reference to the parent node.
162 modelCDMIProjectTreeNode* parent;
164 * Array of references to the children nodes.
166 std::vector<modelCDMIProjectTreeNode*> children;
171 #endif /* MODELCDMIPROJECTTREENODE_H_ */