00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef NuclearFamily_INCLUDED
00030 #define NuclearFamily_INCLUDED
00031
00032 #include "Width.h"
00033 #include "utility.h"
00034 #include "Date.h"
00035 #include <deque>
00036
00037 class DrawingCanvas;
00038 class Individual;
00039 class NuclearFamily{
00040 private:
00041 Individual* _mother;
00042 Individual* _father;
00043 Width _width;
00044 bool _leftConnectionShiftFlag;
00045 unsigned _twinGroupCount;
00046 std::vector<Individual*> _childrenInClassicalOrder;
00047 std::vector<Individual*> _sortedChildren;
00048
00049 void _rearrangeIndividualsBasedOnTwins(const bool consanguinousLoop,std::deque<Individual*>& initial,std::deque<Individual*>& leftLoopIndividuals,std::deque<Individual*>& rightLoopIndividuals);
00050 void _orderTwins(Individual* pivotIndividual,std::deque<Individual*>& srcLoopIndividuals, std::deque<Individual*>& dstLoopIndividuals,const std::deque<unsigned>& indices,bool front=false );
00051 void _drawTwinConnectors(DrawingCanvas& dc,bool classicalOrder,double verticalDropY);
00052 inline bool _isMaleWithLoopFlags(Individual* individual,unsigned nuclearFamilyIndex);
00053 bool _hasIndividualInDeque(Individual* individual,const std::deque<Individual*>& individualQ);
00054 public:
00055
00056
00057
00058 NuclearFamily() { _twinGroupCount=0; _leftConnectionShiftFlag=false; }
00059 NuclearFamily(Individual* mother,Individual* father){ _mother=mother; _father=father; _twinGroupCount=0; _leftConnectionShiftFlag = false; }
00060
00061
00062
00063 void addChild(Individual* child){ _sortedChildren.push_back(child); }
00064 bool hasChild(Individual* child){
00065 std::vector<Individual*>::iterator it = _sortedChildren.begin();
00066 while(it != _sortedChildren.end()){
00067 if((*it)->getId() == child->getId()){
00068 return true;
00069 }
00070 ++it;
00071 }
00072 return false;
00073 }
00074 void calculateWidth(bool classicalOrder);
00075 void drawVerticalDropToIndividual(DrawingCanvas & dc, Individual *pChild, double x,double y);
00076 void draw(Individual* startIndividual,DrawingCanvas& dc,double startX,double startY, bool classicalOrder,bool dashedOrg=false);
00077 void drawSpouseConnectors(Individual* individual,const double horizontalInterval,const double iconInterval,const double iconDiameter,DrawingCanvas& dc);
00078 void sortChildrenInClassicalOrder(bool consanguinousFlag,bool mutipleDT=false);
00079 void sortChildrenBasedOnDataField(const std::string& name,bool dobSortOrder);
00080 void findTwinsByDOB();
00081
00082
00083
00084 void setTotalWidth(unsigned total){ _width.setTotal(total); }
00085 void setLeftWidth(unsigned left){ _width.setLeft(left); }
00086 void setRightWidth(unsigned right){ _width.setRight(right); }
00087 void setTwinGroupCount(unsigned twinGroupCount) { _twinGroupCount=twinGroupCount; }
00088 void setLeftConnectionShiftFlag(bool value) { _leftConnectionShiftFlag = true; }
00089
00090
00091
00092
00093 Individual* getMother(){ return _mother; }
00094 Individual* getFather(){ return _father; }
00095 unsigned getTotalWidth() { return _width.getTotal(); }
00096 unsigned getLeftWidth() { return _width.getLeft(); }
00097 unsigned getRightWidth() { return _width.getRight(); }
00098 unsigned getNumberOfChildren() { return _sortedChildren.size(); }
00099 bool getLeftConnectionShiftFlag() { return _leftConnectionShiftFlag; }
00100 Individual* getChildInClassicalOrder(unsigned index);
00101
00102 bool isConsanguinous(void){
00103
00104 return _father->isConsanguinous() && _mother->isConsanguinous();
00105 }
00106
00107 bool hasExternalConnection(void) {
00108
00109 return _father->hasExternalConnection() && _mother->hasExternalConnection();
00110 }
00111
00112 unsigned getTwinGroupCount(void) { return _twinGroupCount; }
00113
00114
00115 void display();
00116
00117 };
00118
00119 #endif
00120