draw with wife
This commit is contained in:
+1
-1
@@ -1 +1 @@
|
||||
g++ -o bin/debug/famt -std=gnu++20 -g -Og *.cpp -lncursesw
|
||||
g++ -o bin/debug/famt -std=gnu++20 -g -O0 *.cpp -lncursesw
|
||||
|
||||
@@ -6,3 +6,8 @@ unsigned strLen(const char* str);
|
||||
void strCopy(char *to, const char* from);
|
||||
bool strComp(const char* firts, const char* second); //0 - diffrent 1 - same
|
||||
char* mergeStr(const char* first, const char* second);
|
||||
|
||||
inline I32 max(I32 a, I32 b)
|
||||
{
|
||||
return a >= b ? a : b;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ int main()
|
||||
|
||||
test1.addPerson("Rumen", true, Nobody, Nobody, {1968, 8, 9});
|
||||
test1.addPerson("Nadejda", false, Nobody, Nobody, {1972, 12, 15});
|
||||
/* test1.addRelation(0, Husband, 1); */
|
||||
test1.addRelation(0, Spouse, 1);
|
||||
test1.addPerson("Venelin", true, 0, 1, {1998, 6, 9});
|
||||
test1.addPerson("Vasil", true, 0, 1, {2001, 1, 16});
|
||||
/* test1.addRelation(2, Brother, 3); */
|
||||
@@ -30,12 +30,12 @@ int main()
|
||||
|
||||
test2.addPerson("Vasil Dimitrov", true, Nobody, Nobody, {1941, 5, 18});
|
||||
test2.addPerson("Maria", false);
|
||||
/* test2.addRelation(0, Husband, 1); */
|
||||
test2.addRelation(0, Spouse, 1);
|
||||
test2.addPerson("Dimitar", true, 0, 1);
|
||||
test2.addPerson("Nadejda", false, 0, 1, {1972, 12, 15});
|
||||
/* test2.addRelation(2, Brother, 3); */
|
||||
test2.addPerson("Branimira", false);
|
||||
/* test2.addRelation(2, Husband, 4); */
|
||||
test2.addRelation(2, Spouse, 4);
|
||||
test2.addPerson("Ioan", true, 2, 4);
|
||||
test2.addPerson("Rumiana", false, 2, 4);
|
||||
/* test2.addRelation(5, Brother, 6); */
|
||||
|
||||
@@ -389,7 +389,7 @@ void Tree::draw(person_id focused) const
|
||||
|
||||
U16 drawY = 0/* (LINES) / 2 */;
|
||||
U16 drawX = 0/* (COLS) / 2 */;
|
||||
drawLine(focused, drawY, drawX);
|
||||
drawLineWithWives(focused, drawY, drawX);
|
||||
/* people[0].draw(drawY, drawY); */
|
||||
/* for(U32 i=0; i<relations[0].gNum(); ++i) */
|
||||
/* { */
|
||||
@@ -559,40 +559,48 @@ I16 Tree::drawLine(person_id id, I16 drawY, I16 drawX) const
|
||||
return drawX + people[id].boxWidth() + dist_between;
|
||||
}
|
||||
|
||||
I16 Tree::drawLineWithWives(person_id id, I16 drawY, I16 drawX) const
|
||||
I16 Tree::drawLineWithWives(person_id id, I16 drawY, const I16 drawX) const
|
||||
{
|
||||
/* const auto& rels = relations[id]; */
|
||||
/* /\* const auto& rels = relations[id]; *\/ */
|
||||
const Person& person = people[id];
|
||||
const auto& rels = relations[id];
|
||||
|
||||
/* people[id].draw(drawY, drawX); */
|
||||
person.draw(drawY, drawX);
|
||||
|
||||
person_id spouse = Nobody;
|
||||
std::vector<person_id> children;
|
||||
for(person_id i = 0; i < rels.gNum(); ++i)
|
||||
{
|
||||
if(rels[i].type == RelType::Parent)
|
||||
children.push_back(rels[i].id);
|
||||
|
||||
|
||||
/* /\* for(U32 i = 0; i < re *\/ */
|
||||
|
||||
/* std::vector<person_id> children; */
|
||||
/* for(U32 i=0; i<relations[id].gNum(); ++i) */
|
||||
/* { */
|
||||
/* if(relations[id][i] == RelType::Parent) */
|
||||
/* children.push_back(relatives[id][i]); */
|
||||
/* } */
|
||||
|
||||
/* if(!children.empty()) */
|
||||
/* { */
|
||||
/* auto prevX = drawX; */
|
||||
/* drawY += BOX_HEIGHT; */
|
||||
|
||||
/* auto lnHt = linkToFirstBorn(drawY, drawX); /\* Link height *\/ */
|
||||
/* drawX = drawLine(children[0], drawY + lnHt, drawX); */
|
||||
|
||||
/* for(size_t j = 1; j < children.size(); ++j) */
|
||||
/* { */
|
||||
/* lnHt = linkToChild(drawY+1, prevX+1, drawX+1); */
|
||||
/* prevX = drawX; */
|
||||
/* drawX = drawLine(children[j], drawY + lnHt, drawX); */
|
||||
/* } */
|
||||
/* return drawX; */
|
||||
/* } */
|
||||
|
||||
/* return drawX + people[id].boxWidth() + dist_between; */
|
||||
else if(rels[i].type == RelType::Spouse && spouse == Nobody)
|
||||
spouse = rels[i].id;
|
||||
}
|
||||
|
||||
U16 spouse_width = 0;
|
||||
if(spouse != Nobody)
|
||||
{
|
||||
people[spouse].draw(drawY, drawX + person.boxWidth() + spouse_dist);
|
||||
spouse_width = spouse_dist + people[spouse].boxWidth();
|
||||
}
|
||||
|
||||
auto childX = drawX;
|
||||
if(!children.empty())
|
||||
{
|
||||
auto prevX = childX;
|
||||
drawY += BOX_HEIGHT;
|
||||
|
||||
auto lnHt = linkToFirstBorn(drawY, childX); /* Link height */
|
||||
childX = drawLineWithWives(children[0], drawY + lnHt, childX);
|
||||
|
||||
for(size_t j = 1; j < children.size(); ++j)
|
||||
{
|
||||
lnHt = linkToChild(drawY+1, prevX+1, childX+1);
|
||||
prevX = childX;
|
||||
childX = drawLineWithWives(children[j], drawY + lnHt, childX);
|
||||
}
|
||||
}
|
||||
|
||||
return max(drawX + person.boxWidth() + dist_between + spouse_width,
|
||||
childX);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user