Patch level : 2.2
Files correlati : calib Ricompilazione Demo : [ ] Commento : git-svn-id: svn://10.65.10.50/trunk@12528 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
a760476caa
commit
aa031fb00e
@ -21,6 +21,7 @@ public:
|
||||
TPiano_conti_anal_msk::TPiano_conti_anal_msk() : TSimple_anal_msk("ca0400a")
|
||||
{
|
||||
create_key_fields();
|
||||
create_tree_field();
|
||||
}
|
||||
|
||||
TPiano_conti_anal_msk::~TPiano_conti_anal_msk()
|
||||
|
190
ca/calib01.cpp
190
ca/calib01.cpp
@ -1,5 +1,7 @@
|
||||
#include "calib01.h"
|
||||
|
||||
#include <tree.h>
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TAnal_msk
|
||||
///////////////////////////////////////////////////////////
|
||||
@ -53,6 +55,179 @@ TAnal_msk::TAnal_msk(const char* name)
|
||||
xvt_fsys_removefile(outname);
|
||||
}
|
||||
|
||||
short TAnal_msk::create_tree_field()
|
||||
{
|
||||
short id = 0;
|
||||
const int delta = compute_offset();
|
||||
if (delta > 0)
|
||||
{
|
||||
id = 99;
|
||||
add_tree(id, 0, 0, 1, delta*2, -1);
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TSimple_anal_tree
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
class TSimple_anal_tree : public TBidirectional_tree
|
||||
{
|
||||
TLocalisamfile _file;
|
||||
TString16 _key_field, _des_field;
|
||||
|
||||
TRecnotype _curr;
|
||||
TString _str_curr;
|
||||
|
||||
void update_curr();
|
||||
|
||||
protected:
|
||||
virtual void node2id(const TObject* node, TString& id) const;
|
||||
|
||||
virtual bool goto_firstson();
|
||||
virtual bool goto_rbrother();
|
||||
virtual bool goto_node(const TString &id);
|
||||
virtual TObject* curr_node() const;
|
||||
virtual bool goto_father();
|
||||
virtual bool goto_lbrother();
|
||||
virtual bool get_description(TString& desc) const;
|
||||
|
||||
public:
|
||||
virtual bool goto_root();
|
||||
|
||||
TSimple_anal_tree(int logicnum);
|
||||
};
|
||||
|
||||
void TSimple_anal_tree::update_curr()
|
||||
{
|
||||
_curr = _file.recno();
|
||||
_str_curr.format("%ld", _curr);
|
||||
}
|
||||
|
||||
void TSimple_anal_tree::node2id(const TObject* node, TString& id) const
|
||||
{
|
||||
id = *(TString*)node;
|
||||
}
|
||||
|
||||
bool TSimple_anal_tree::goto_root()
|
||||
{
|
||||
const int err = _file.first();
|
||||
if (err == NOERR)
|
||||
update_curr();
|
||||
return err == NOERR;
|
||||
}
|
||||
|
||||
bool TSimple_anal_tree::goto_firstson()
|
||||
{
|
||||
int err = _file.readat(_curr);
|
||||
if (err == NOERR)
|
||||
{
|
||||
const TString pref = _file.curr().get(_key_field);
|
||||
err = _file.next();
|
||||
if (err == NOERR)
|
||||
{
|
||||
const TString now = _file.curr().get(_key_field);
|
||||
if (now.starts_with(pref))
|
||||
update_curr();
|
||||
else
|
||||
err = _iskeynotfound;
|
||||
}
|
||||
}
|
||||
return err == NOERR;
|
||||
}
|
||||
|
||||
bool TSimple_anal_tree::goto_rbrother()
|
||||
{
|
||||
int err = _file.readat(_curr);
|
||||
if (err == NOERR)
|
||||
{
|
||||
const TString pref = _file.curr().get(_key_field);
|
||||
err = _file.next();
|
||||
if (err == NOERR)
|
||||
{
|
||||
const TString now = _file.curr().get(_key_field);
|
||||
if (now.len() == pref.len())
|
||||
update_curr();
|
||||
else
|
||||
err = _iskeynotfound;
|
||||
}
|
||||
}
|
||||
return err == NOERR;
|
||||
}
|
||||
|
||||
bool TSimple_anal_tree::goto_node(const TString &id)
|
||||
{
|
||||
const int err = _file.readat(atol(id));
|
||||
if (err == NOERR)
|
||||
update_curr();
|
||||
return err == NOERR;
|
||||
}
|
||||
|
||||
bool TSimple_anal_tree::goto_father()
|
||||
{
|
||||
int err = _file.readat(_curr);
|
||||
if (err == NOERR)
|
||||
{
|
||||
const TString pref = _file.curr().get(_key_field);
|
||||
while (err == NOERR)
|
||||
{
|
||||
err = _file.prev();
|
||||
if (err == NOERR)
|
||||
{
|
||||
const TString prev = _file.curr().get(_key_field);
|
||||
if (prev.len() < pref.len())
|
||||
{
|
||||
update_curr();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return err == NOERR;
|
||||
}
|
||||
|
||||
bool TSimple_anal_tree::goto_lbrother()
|
||||
{
|
||||
int err = _file.readat(_curr);
|
||||
if (err == NOERR)
|
||||
{
|
||||
const TString pref = _file.curr().get(_key_field);
|
||||
err = _file.prev();
|
||||
if (err == NOERR)
|
||||
{
|
||||
const TString prev = _file.curr().get(_key_field);
|
||||
if (prev.len() == pref.len())
|
||||
update_curr();
|
||||
else
|
||||
err = _iskeynotfound;
|
||||
}
|
||||
}
|
||||
return err == NOERR;
|
||||
}
|
||||
|
||||
TObject* TSimple_anal_tree::curr_node() const
|
||||
{
|
||||
return (TObject*)&_str_curr;
|
||||
}
|
||||
|
||||
bool TSimple_anal_tree::get_description(TString& desc) const
|
||||
{
|
||||
int err = ((TLocalisamfile&)_file).readat(_curr);
|
||||
if (err == NOERR)
|
||||
{
|
||||
desc = _file.curr().get(_key_field);
|
||||
desc << ' ' << _file.curr().get(_des_field);
|
||||
}
|
||||
return err == NOERR;
|
||||
}
|
||||
|
||||
TSimple_anal_tree::TSimple_anal_tree(int logicnum)
|
||||
: _file(logicnum)
|
||||
{
|
||||
_key_field = _file.curr().fieldname(0);
|
||||
_des_field = "DESCR";
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TSimple_anal_msk
|
||||
///////////////////////////////////////////////////////////
|
||||
@ -199,12 +374,23 @@ int TSimple_anal_msk::create_key_fields()
|
||||
return level;
|
||||
}
|
||||
|
||||
short TSimple_anal_msk::create_tree_field()
|
||||
{
|
||||
const short tree_id = TAnal_msk::create_tree_field();
|
||||
if (tree_id != 0)
|
||||
{
|
||||
TSimple_anal_tree* t = new TSimple_anal_tree(get_logicnum());
|
||||
tfield(tree_id).set_tree(t);
|
||||
t->goto_root();
|
||||
t->expand();
|
||||
}
|
||||
return tree_id;
|
||||
}
|
||||
|
||||
TSimple_anal_msk::TSimple_anal_msk(const char* name) : TAnal_msk(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TAnal_app
|
||||
///////////////////////////////////////////////////////////
|
||||
|
@ -20,6 +20,8 @@ protected:
|
||||
|
||||
protected:
|
||||
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
|
||||
|
||||
virtual short create_tree_field();
|
||||
int compute_offset() const;
|
||||
TAnal_msk(const char* name);
|
||||
|
||||
@ -45,6 +47,7 @@ protected:
|
||||
void create_key_browse(TEdit_field& kfld, int level, TConfig& cfg);
|
||||
void create_des_browse(TEdit_field& kfld, int level, TConfig& cfg);
|
||||
virtual int create_key_fields();
|
||||
virtual short create_tree_field();
|
||||
|
||||
protected:
|
||||
TSimple_anal_msk(const char* name);
|
||||
|
Loading…
x
Reference in New Issue
Block a user