Salome HOME
First publish of HEXABLOCKcomponant
[modules/hexablock.git] / src / HEXABLOCK / HexEltBase.cxx
1
2 // C++ : Gestion des noeuds
3
4 #include "HexEltBase.hxx"
5 #include "HexDocument.hxx"
6
7 BEGIN_NAMESPACE_HEXA
8 // =================================================== Constructeur
9 EltBase::EltBase (Document* doc, EnumElt type)
10 {
11    el_root   = doc;
12    el_type   = type;
13    el_id     = el_root->doc_nbr_elt [type];
14
15    el_next   = NULL;
16    el_assoc  = NULL;
17    el_status = HOK;
18    el_mark   = 0;
19
20    el_root->doc_nbr_elt  [type] ++;
21    el_root->doc_last_elt [type] -> el_next = this;
22    el_root->doc_last_elt [type] = this;
23    el_root->setDeprecated (1);
24 }
25 // =================================================== Destructeur
26 EltBase::~EltBase ()
27 {
28    //  printf (" delete ");
29    //  dump ();
30 }
31 // =================================================== Constructeur Bis
32 // Utilise uniquement dans le constructeur de Document
33 // Creation d'un premier element fictif pour accelerer les chainages
34 EltBase::EltBase (EnumElt type)
35 {
36    el_root   = NULL;
37    el_type   = type;
38    el_id     = -1;
39
40    el_next   = NULL;
41    el_status = HOK;
42    el_mark   = 0;
43 }
44 // =================================================== remove
45 void EltBase::remove ()
46 {
47    if (el_type == EL_REMOVED)
48       return;
49
50    el_root->setDeprecated (2);
51    el_type = EL_REMOVED;
52    int nbp = el_parent.size();
53    for (int nro=0 ; nro<nbp ; nro++)
54        {
55        EltBase* elt = el_parent[nro];
56        if (elt != NULL && elt->isHere())
57            elt->remove ();
58        }           
59 }
60 // =================================================== suppress
61 void EltBase::suppress ()
62 {
63    if (el_type == EL_REMOVED)
64       return;
65
66    el_root->setDeprecated (2);
67    el_type = EL_REMOVED;
68 }
69 END_NAMESPACE_HEXA
70