Correzione gestione albero distinta base
git-svn-id: svn://10.65.10.50/branches/R_10_00@22847 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
453890fd36
commit
e4e44ab7f4
80
db/dblib.cpp
80
db/dblib.cpp
@ -471,9 +471,7 @@ TDistinta_expr::TDistinta_expr()
|
||||
|
||||
#define TREE_SEPARATOR '~'
|
||||
|
||||
const TRectype* TDistinta_tree::_curr = NULL;
|
||||
|
||||
|
||||
//const TRectype* TDistinta_tree::_curr = NULL;
|
||||
|
||||
bool TDistinta_tree::isola_codice(TString& code) const
|
||||
{
|
||||
@ -852,7 +850,7 @@ bool TDistinta_tree::restart()
|
||||
|
||||
bool TDistinta_tree::set_root(const TQuantita& qta, const char* livgiac)
|
||||
{
|
||||
bool ok = find_child(qta.articolo(), 1) != NULL;
|
||||
bool ok = has_child_num(qta.articolo(), 1);
|
||||
if (ok)
|
||||
{
|
||||
_tmp = qta.articolo(); // codice
|
||||
@ -873,7 +871,7 @@ bool TDistinta_tree::set_root(const TCodice_articolo& art,
|
||||
const char* um, real qta,
|
||||
const char* livgiac)
|
||||
{
|
||||
bool ok = find_child(art, 1) != NULL;
|
||||
bool ok = has_child_num(art, 1);
|
||||
if (ok)
|
||||
{
|
||||
const TCodice_um umart = um;
|
||||
@ -991,8 +989,13 @@ const TRectype* TDistinta_tree::find_child(const TCodice_articolo& father, int c
|
||||
TString80 key = father;
|
||||
key << '|' << child;
|
||||
const TRectype& rec = cache().get(LF_RDIST,key);
|
||||
return &rec;
|
||||
}
|
||||
|
||||
return rec.empty() ? NULL : &rec;
|
||||
bool TDistinta_tree::has_child_num(const TCodice_articolo& father, int child) const
|
||||
{
|
||||
const TRectype* rec = find_child(father, child);
|
||||
return rec != NULL && !rec->empty();
|
||||
}
|
||||
|
||||
int TDistinta_tree::build_children_list(const TCodice_articolo& father, TArray& children) const
|
||||
@ -1001,7 +1004,7 @@ int TDistinta_tree::build_children_list(const TCodice_articolo& father, TArray&
|
||||
for (int nrig = 1; ; nrig++)
|
||||
{
|
||||
const TRectype* rec = find_child(father, nrig);
|
||||
if (rec == NULL)
|
||||
if (rec == NULL || rec->empty())
|
||||
break;
|
||||
key.add(rec->get("CODCOMP"),0);
|
||||
key.add(rec->get("LIVELLO"),1);
|
||||
@ -1027,31 +1030,31 @@ bool TDistinta_tree::has_son() const
|
||||
{
|
||||
const int depth = curr_depth();
|
||||
if (depth >= _max_depth)
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (is_cyclic())
|
||||
return FALSE;
|
||||
return false;
|
||||
|
||||
TCodice_articolo key; curr_code(key);
|
||||
// TString16 livgiac; curr_giaclev(livgiac);
|
||||
_curr = find_child(key, 1);
|
||||
(TRectype&)_curr = *find_child(key, 1);
|
||||
// Se ci sono almeno due figli ed e' necessario ordinare
|
||||
if (_sort != 0 && find_child(key, 2) != NULL)
|
||||
if (_sort != 0 && has_child_num(key, 2))
|
||||
{
|
||||
TArray children;
|
||||
build_children_list(key, children);
|
||||
const int first = ((TToken_string*)children.objptr(0))->get_int(2);
|
||||
_curr = find_child(key, first);
|
||||
(TRectype&)_curr = *find_child(key, first);
|
||||
}
|
||||
return _curr != NULL;
|
||||
return !_curr.empty();
|
||||
}
|
||||
|
||||
bool TDistinta_tree::add_child()
|
||||
{
|
||||
TCodice_articolo comp = _curr->get("CODCOMP");
|
||||
TCodice_articolo comp = _curr.get("CODCOMP");
|
||||
TString tmp,tmp2;
|
||||
if (_curr->get_char("TIPO") == 'V') // Espando la variabile
|
||||
if (_curr.get_char("TIPO") == 'V') // Espando la variabile
|
||||
{
|
||||
tmp = get_string(comp);
|
||||
if (tmp.blank() || tmp.len() > comp.size())
|
||||
@ -1061,7 +1064,7 @@ bool TDistinta_tree::add_child()
|
||||
_path.add(comp); // 0 - Codice articolo
|
||||
|
||||
_path << TREE_SEPARATOR;
|
||||
tmp = _curr->get("LIVELLO");
|
||||
tmp = _curr.get(RDIST_LIVELLO);
|
||||
if (livgiac().enabled())
|
||||
{
|
||||
TString fgiaclev; father_giaclev(fgiaclev);
|
||||
@ -1069,7 +1072,7 @@ bool TDistinta_tree::add_child()
|
||||
for (int l= 0 ; l < 4; l++) if (livgiac().enabled(l+1))
|
||||
{
|
||||
tmp2 = livgiac().unpack_grpcode(tmp, l+1);
|
||||
if (_curr->get("TIPO_LIV")[l]=='E')
|
||||
if (_curr.get(RDIST_TIPO_LIV)[l]=='E')
|
||||
{
|
||||
tmp2 = livgiac().unpack_grpcode(fgiaclev, l+1);
|
||||
livgiac().pack_grpcode(tmp, tmp2 , l+1);
|
||||
@ -1078,18 +1081,18 @@ bool TDistinta_tree::add_child()
|
||||
}
|
||||
|
||||
_path << tmp; // 1 Livello giacenza
|
||||
long num = _curr->get_long("NRIG");
|
||||
long num = _curr.get_long(RDIST_NRIG);
|
||||
_path << TREE_SEPARATOR << num; // 2 Numero componente
|
||||
if (_sort > 0)
|
||||
{
|
||||
TString16 field; field << "SORT" << _sort;
|
||||
num = _curr->get_long(field);
|
||||
num = _curr.get_long(field);
|
||||
}
|
||||
_path << TREE_SEPARATOR << num; // 3 Numero ordinamento
|
||||
|
||||
_path << TREE_SEPARATOR << _curr->get("UM"); // 4 Unita' di misura
|
||||
_path << TREE_SEPARATOR << _curr.get(RDIST_UM); // 4 Unita' di misura
|
||||
|
||||
const TString& expr = _curr->get("EXPR");
|
||||
const TString& expr = _curr.get(RDIST_EXPR);
|
||||
const real qta = evaluate_numexpr(expr);
|
||||
_path << TREE_SEPARATOR << qta; // 5 Quantita'
|
||||
_path << TREE_SEPARATOR << get_type(comp); // 6 - Articolo, Lavorazione, Virtuale, Ghost
|
||||
@ -1144,20 +1147,20 @@ bool TDistinta_tree::has_rbrother() const
|
||||
if (c >= 0 && c < last)
|
||||
{
|
||||
const int brother = ((TToken_string*)children.objptr(c+1))->get_int(2);
|
||||
_curr = find_child(father, brother);
|
||||
(TRectype&)_curr = *find_child(father, brother);
|
||||
}
|
||||
else
|
||||
_curr = NULL;
|
||||
((TRectype&)_curr).zero();
|
||||
}
|
||||
else
|
||||
_curr = NULL;
|
||||
((TRectype&)_curr).zero();
|
||||
}
|
||||
else
|
||||
{
|
||||
_curr = find_child(father, curr_nrig+1);
|
||||
(TRectype&)_curr = *find_child(father, curr_nrig+1);
|
||||
}
|
||||
|
||||
return _curr != NULL;
|
||||
return !_curr.empty();
|
||||
}
|
||||
|
||||
bool TDistinta_tree::goto_rbrother()
|
||||
@ -1199,24 +1202,24 @@ bool TDistinta_tree::has_lbrother() const
|
||||
if (c > 0)
|
||||
{
|
||||
const int brother = ((TToken_string*)children.objptr(c-1))->get_int(2);
|
||||
_curr = find_child(father, brother);
|
||||
(TRectype&)_curr = *find_child(father, brother);
|
||||
}
|
||||
else
|
||||
_curr = NULL;
|
||||
((TRectype&)_curr).zero();
|
||||
}
|
||||
else
|
||||
_curr = NULL;
|
||||
((TRectype&)_curr).zero();
|
||||
}
|
||||
else
|
||||
{
|
||||
const int brother = curr_nrig - 1;
|
||||
if (brother > 0)
|
||||
_curr = find_child(father, brother);
|
||||
(TRectype&)_curr = *find_child(father, brother);
|
||||
else
|
||||
_curr = NULL;
|
||||
((TRectype&)_curr).zero();
|
||||
}
|
||||
|
||||
return _curr != NULL;
|
||||
return !_curr.empty();
|
||||
}
|
||||
|
||||
bool TDistinta_tree::goto_lbrother()
|
||||
@ -1253,8 +1256,7 @@ bool TDistinta_tree::is_root() const
|
||||
bool TDistinta_tree::is_leaf() const
|
||||
{
|
||||
TCodice_articolo key; curr_code(key);
|
||||
const TRectype* first_son = find_child(key, 1);
|
||||
return first_son == NULL;
|
||||
return !has_child_num(key, 1);
|
||||
}
|
||||
|
||||
bool TDistinta_tree::is_mag(const char* c) const
|
||||
@ -1290,7 +1292,7 @@ char TDistinta_tree::get_type(const char* c) const
|
||||
type = 'L'; // Lavorazione
|
||||
else
|
||||
{
|
||||
if (find_child(c, 1)) // E' una distinta
|
||||
if (has_child_num(c, 1)) // E' una distinta
|
||||
{
|
||||
const TString& artprod = find_head(c).get("ARTPROD");
|
||||
if (artprod.blank())
|
||||
@ -1678,17 +1680,17 @@ static bool explode_callback(TTree& node, void* jolly, word when)
|
||||
{
|
||||
const long sk = tree.curr_sort();
|
||||
if (sk <= 0)
|
||||
return FALSE; // Non fa parte dell'ordinamento
|
||||
return false; // Non fa parte dell'ordinamento
|
||||
}
|
||||
|
||||
if (ep._filter.find(type) < 0)
|
||||
return FALSE;
|
||||
return false;
|
||||
|
||||
TRiga_esplosione* er = new TRiga_esplosione(tree, ep._filter.find('G') >= 0, tree.curr());
|
||||
er->set_mat_base(is_leaf);
|
||||
ep._array->add(er);
|
||||
}
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
int TDistinta_tree::raggruppa(TArray& boom, TExplosion_grouping mode) const
|
||||
@ -1773,7 +1775,7 @@ TCodgiac_livelli &TDistinta_tree::livgiac() const
|
||||
TDistinta_tree::TDistinta_tree()
|
||||
: _sort(0), _max_depth(0), _ignore_ghost(FALSE),
|
||||
_livgiac(NULL),_qta_on_descr(FALSE),_descr_sep('-'),
|
||||
_tmp(80, TREE_SEPARATOR)
|
||||
_tmp(80, TREE_SEPARATOR), _curr(LF_RDIST)
|
||||
{
|
||||
memset(_livgiac_on_descr, 0, sizeof(_livgiac_on_descr));
|
||||
}
|
||||
|
@ -254,7 +254,9 @@ class TDistinta_tree : public TBidirectional_tree
|
||||
bool _qta_on_descr;
|
||||
char _descr_sep;
|
||||
|
||||
static const TRectype* _curr;
|
||||
//static const TRectype* _curr;
|
||||
TRectype _curr;
|
||||
|
||||
TToken_string _tmp;
|
||||
|
||||
TStack _stack;
|
||||
@ -271,6 +273,7 @@ protected:
|
||||
|
||||
virtual const TRectype& find_head(const TCodice_articolo& art) const;
|
||||
virtual const TRectype* find_child(const TCodice_articolo& father, int child) const;
|
||||
bool has_child_num(const TCodice_articolo& father, int child) const;
|
||||
|
||||
// int build_children_pointers(const TCodice_articolo& father, TPointer_array& children) const;
|
||||
int build_children_list(const TCodice_articolo& father, TArray& children) const;
|
||||
@ -311,7 +314,7 @@ public:
|
||||
virtual bool get_description(TString& desc) const;
|
||||
virtual TImage* image(bool selected) const;
|
||||
virtual TObject* curr_node() const;
|
||||
const TRectype * curr() const { return TDistinta_tree::_curr;}
|
||||
const TRectype* curr() const { return &_curr;}
|
||||
|
||||
const TString& describe(const TCodice_articolo& codart) const;
|
||||
bool describe(const TCodice_articolo& codart, TString& descr) const;
|
||||
|
Loading…
x
Reference in New Issue
Block a user