Создание исследовательского прототипа системы идентификации табличных данных
Рефераты >> Программирование и компьютеры >> Создание исследовательского прототипа системы идентификации табличных данных

WC[FlowCount]++;

}

}

int p;

for(int i=0;i<NC[FlowCount];i++){

for(p=1;p<=StrNumbers[i][FlowCount].Length();p++)

if(!T.NumNDelim.Pos(StrNumbers[i][FlowCount][p]))

break;

Numbers[i][FlowCount]=(StrNumbers[i][FlowCount].SubString(1,p-1).Trim()).ToDouble();

StrNumbers[i][FlowCount]=StrNumbers[i][FlowCount].Delete(1,p-1);

}

for(int i=0;i<WC[FlowCount];i++)

for(int j=1;j<=Words[i][FlowCount].Length();j++)

if(ABC[FlowCount].Pos(Words[i][FlowCount].SubString(j,1).Trim())==0)

ABC[FlowCount]+=AnsiString(Words[i][FlowCount][j]);

if(NC[FlowCount]+WC[FlowCount])

FlowCount++;

}

void TPositions::Clear(){

FlowCount=0;

for(int fl=0;fl<FlowNum;fl++){

WC[fl]=0;

NC[fl]=0;

ABC[fl]=AnsiString();

for(int i=0;i<NumbersNum;i++){

StrNumbers[i][fl]=AnsiString();

Numbers[i][fl]=0;

}

for(int i=0;i<WordsNum;i++)

Words[i][fl]=AnsiString();

}

}

AnsiString TPositions::Sentence(int fl){

AnsiString Sent=AnsiString();

if(fl==-1)

for(int f=0;f<FlowCount;f++)

for(int i=0;i<WC[f];i++)

Sent=Sent+Words[i][f]+AnsiString(' ');

else

for(int i=0;i<WC[fl];i++)

Sent=Sent+Words[i][fl]+AnsiString(' ');

return(Sent);

}

//---------------------------------------------------------------------------

#ifndef PositionTreeH

#define PositionTreeH

#include <stdio.h>

#include "Position.h"

//---------------------------------------------------------------------------

typedef enum {aInit=0,aFind=1,aToList=2} WalkAction ;

class TPositionTree{

public:

int Code;

bool IsGroup;

int Depth;

AnsiString OutPres[FlowNum];

TPositionTree *Next;

TPositionTree *Down;

TPositionTree *Prev;

TPositions IP;

void *Data;

TPositionTree();

~TPositionTree();

void Add(TPositionTree *Node);

void AddChild(TPositionTree *Node);

TPositionTree *Add(int sCode,AnsiString sName);

TPositionTree *AddChild(int Code,AnsiString sName);

void Move(TTreeView *tv,TPositionTree *NewParent);

void Delete();

void DeleteAll();

void DeleteChildren();

void ToTree(TTreeView *tv,TTreeNode *Node);

void ToTreeIts(TTreeView *tv,TTreeNode *Node);

void ToList(TListView *lv);

void SavePositionTo(FILE *f);

bool Save(AnsiString FileName,TProgressBar *ind);

void SaveToFile(FILE *f,TProgressBar *ind);

AnsiString OP();

bool Action(WalkAction ActionIndex,void *Data);

TPositionTree *TreeWalk(WalkAction ActionIndex,void *Data);

TPositionTree *LoadPositionFrom(FILE *f);

void LoadFromFile(FILE *f,TProgressBar *ind);

//void FromFile(AnsiString FileName);

};

TPositionTree *Load(AnsiString FileName,TProgressBar *ind);

TPositionTree *ImportFromFile(AnsiString FileName);

TPositionTree *ImportFromFileCT(AnsiString FileName,bool Price,TProgressBar *ind);

#endif

#include <vcl.h>

#include <stdio.h>

#pragma hdrstop

#include "PositionTree.h"

#include "Position.h"

//---------------------------------------------------------------------------

#pragma package(smart_init)

TPositionTree::TPositionTree(){

Next=NULL;

Down=NULL;

Prev=NULL;

Data=NULL;

Code=0;

for(int i=0;i<FlowNum;i++)

OutPres[i]=AnsiString();

IsGroup=false;

Depth=0;

}

TPositionTree::~TPositionTree(){}

void TPositionTree::Delete(){

if(Next)

Next->Prev=Prev;

if(Prev){

if(Prev->Next==this)

Prev->Next=Next;

else

Prev->Down=Next;

}

if(Down)

Down->DeleteAll();

if(IsGroup)

((TTreeNode *)Data)->Delete();

delete this;

}

void TPositionTree::DeleteAll(){

if(Down)

Down->DeleteAll();

if(Next)

Next->DeleteAll();

delete this;

}

void TPositionTree::DeleteChildren(){

Down->DeleteAll();

}

void TPositionTree::AddChild(TPositionTree *Node){

if(Down!=NULL){

if(Down->OutPres[0].AnsiCompare(Node->OutPres[0])<0){

Down->Add(Node);

return;

}else Down->Prev=Node;

}

Node->Next=Down;

Down=Node;

Down->Depth=Depth+1;

Down->Prev=this;

}

void TPositionTree::Add(TPositionTree *Node){

if(Next!=NULL){

if(Next->OutPres[0].AnsiCompare(Node->OutPres[0])<0){

Next->Add(Node);

return;

}else Next->Prev=Node;

}

Node->Next=Next;

Next=Node;

Next->Depth=Depth;

Next->Prev=this;

}

TPositionTree *TPositionTree::Add(int sCode,AnsiString sName){

TPositionTree *Node=new TPositionTree();

Node->Code=sCode;

Node->OutPres[0]=sName;

Add(Node);

return(Node);

}

TPositionTree *TPositionTree::AddChild(int sCode,AnsiString sName){

TPositionTree *Node=new TPositionTree();

Node->Code=sCode;

Node->OutPres[0]=sName;

AddChild(Node);

return(Node);

}

void TPositionTree::ToTreeIts(TTreeView *tv,TTreeNode *Node){

TTreeNode *tn;

if(Down!=NULL){

if(Down->IsGroup){

tn=tv->Items->AddChild(Node,Down->OutPres[0]);

tn->Data=Down;

Down->Data=tn;

}

Down->ToTreeIts(tv,tn);

}

if(Next!=NULL){

if(Next->IsGroup){

tn=tv->Items->Add(Node,Next->OutPres[0]);

tn->Data=Next;

Next->Data=tn;

}

Next->ToTreeIts(tv,tn);

}

}

void TPositionTree::ToTree(TTreeView *tv,TTreeNode *Node){

if(IsGroup){

if(Node)

Node=tv->Items->AddChild(Node,OutPres[0]);

else

Node=tv->Items->Add(Node,OutPres[0]);

Node->Data=this;

Data=Node;

if(Down!=NULL){

if(Down->IsGroup){

Node=tv->Items->AddChild(Node,Down->OutPres[0]);

Node->Data=Down;

Down->Data=Node;

}

Down->ToTreeIts(tv,Node);

}

}

}

void TPositionTree::ToList(TListView *lv){

TListItem *li;

if(!lv->Items->Count){

li=lv->Items->Add();

li->Caption=AnsiString(">> .<<");

li->Data=Prev;

li->ImageIndex=IsGroup;

li->SubItems->Add("-");

}

li=lv->Items->Add();

li->Caption=IntToStr(Code);

li->Data=this;

li->ImageIndex=IsGroup;

// li->ImageIndex=IsGroup;

// li->SubItems->Add(IntToStr(Code));

for(int i=0;i<IP.FlowCount;i++){

li->SubItems->Add(OutPres[i]);

}

if(Next!=NULL)

Next->ToList(lv);

}

void TPositionTree::Move(TTreeView *tv,TPositionTree *NewParent){

if(this==NewParent)

return;

TPositionTree *Parent;

TTreeNode *tn;

if(IsGroup&&tv){

tn=((TTreeNode *)Data);

tn->Delete();

}

Parent=Prev;

Data=NULL;


Страница: