initial draw

This commit is contained in:
vrd
2022-12-18 00:35:01 +02:00
parent 0da0f98dc9
commit 5e9d2d8501
4 changed files with 43 additions and 11 deletions
+27 -10
View File
@@ -8,7 +8,7 @@ using std::cout;
Tree::Tree()
: treeName("Unnamed")
: treeName("Unnamed")
, numPeople(0)
{}
@@ -34,7 +34,7 @@ Tree Tree::operator+ (const Tree& other)//
result.numPeople = idCounter; //The number of members the resulting tree has
result.people.resize(result.numPeople);
result.people = people; //Adds the members of the I tree to the resulting tree
result.people = people; //Adds the members of the I tree to the resulting tree
for (unsigned i=0; i < other.numPeople; ++i) //Adds the members of the II tree to the resulting tree
{
if (newId[i] >= numPeople)
@@ -48,14 +48,14 @@ Tree Tree::operator+ (const Tree& other)//
for (unsigned i=0; i < other.numPeople; ++i) //Adds the relatives from the II tree
{
if (newId[i] >= numPeople) //If the member is found in the II tree but not in the I
if (newId[i] >= numPeople) //If the member is found in the II tree but not in the I
{
result.relatives.push(other.relatives[i]);
result.relations.push(other.relations[i]);
}
else //If he's found in both
{
for (unsigned j = 0; j < other.people[i].numRel_; ++j) //Adds the number of relatives from the II to the number in the I
for (unsigned j = 0; j < other.people[i].numRel_; ++j) //Adds the number of relatives from the II to the number in the I
{
if(newId[other.relatives[i][j]] > numPeople)
++result.people[newId[i]].numRel_;
@@ -66,7 +66,7 @@ Tree Tree::operator+ (const Tree& other)//
result.relatives[newId[i]] = relatives[newId[i]];
result.relations[newId[i]] = relations[newId[i]];
result.relatives[newId[i]] += other.relatives[i]; //The relatives from the II tree
result.relatives[newId[i]] += other.relatives[i]; //The relatives from the II tree
result.relations[newId[i]] += other.relations[i];
}
}
@@ -95,7 +95,7 @@ Tree& Tree::operator+=(const Tree& other)
}
people.resize(idCounter);
for (unsigned i = 0; i < other.numPeople; ++i) //Adds the member personal data of II tree to I tree
for (unsigned i = 0; i < other.numPeople; ++i) //Adds the member personal data of II tree to I tree
{
if (newId[i] >= numPeople)
people.push(other.people[i]);
@@ -103,7 +103,7 @@ Tree& Tree::operator+=(const Tree& other)
relatives.resize(idCounter);
relations.resize(idCounter);
for (unsigned i = 0; i < other.numPeople; ++i) //Merges the relative data
for (unsigned i = 0; i < other.numPeople; ++i) //Merges the relative data
{
if (newId[i] >= numPeople)
{
@@ -114,7 +114,7 @@ Tree& Tree::operator+=(const Tree& other)
}
else //If the member is present in both trees
{
for (unsigned j = 0; j < other.people[i].numRel_; ++j) //Adds the number of relatives from the II to the number in the I
for (unsigned j = 0; j < other.people[i].numRel_; ++j) //Adds the number of relatives from the II to the number in the I
{
if (newId[other.relatives[i][j]] >= numPeople)
++people[newId[i]].numRel_;
@@ -160,7 +160,7 @@ void Tree::rename(const char* newName)
unsigned Tree::findId(const char* name, const short year, const unsigned char month, const unsigned char day)const
{
//TODO
//TODO
//Person sought(name, day, month, year,)
for (unsigned i = 0; i < numPeople; ++i)
{
@@ -378,7 +378,7 @@ void Tree::removeRelation(const char* firstName, const char* secondName)
void Tree::removePerson(const unsigned id)
{
unsigned relId; //Íoìåð íà òåêóùèÿ ðîäíèíàòà
unsigned relId; //Íoìåð íà òåêóùèÿ ðîäíèíàòà
for (unsigned i = 0; i < people[id].numRel_; ++i) //Ïðåìàõâàò ñå âðúçêèòå íà ÷ëåíà çà ïðåìàõâàíå
{
relId = relatives[id][i];
@@ -442,6 +442,23 @@ void Tree::removeRelation(const unsigned firstId, const unsigned secondId)
void Tree::draw() const
{
WINDOW* father = people[0].createPad();
WINDOW* mother = people[1].createPad();
U16 fw = getmaxx(father); /* return size, not coords */
U16 fh = getmaxy(father);
U16 mw = getmaxx(mother);
U16 mh = getmaxy(mother);
U16 drawX = (COLS - fw - mw) / 2;
pnoutrefresh(father, 0, 0,
1, drawX,
1 +fh-1, drawX + fw-1);
/* pnoutrefresh(mother, 0, 0, 1, d */
doupdate();
getch();
}