Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Class Members | File Members

NuclearFamily.h

Go to the documentation of this file.
00001 
00002 //
00003 // This file is part of the MADELINE 2 program 
00004 // written by Edward H. Trager and Ritu Khanna
00005 // Copyright (c) 2005 by the
00006 // Regents of the University of Michigan.
00007 // All Rights Reserved.
00008 // 
00009 // The latest version of this program is available from:
00010 // 
00011 //   http://eyegene.ophthy.med.umich.edu/madeline/
00012 //   
00013 // Released under the GNU General Public License.
00014 // A copy of the GPL is included in the distribution
00015 // package of this software, or see:
00016 // 
00017 //   http://www.gnu.org/copyleft/
00018 //   
00019 // ... for licensing details.
00020 // 
00022 //
00023 // 2006.02.03.RK
00024 //
00025 
00026 //
00027 // NuclearFamily.h
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; // # of Twin groups in the NF
00046         std::vector<Individual*> _childrenInClassicalOrder; // empty if there is no consanguinity or external connections
00047         std::vector<Individual*> _sortedChildren; // the current default is order by id
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         // Constructors:
00057         //
00058         NuclearFamily() { _twinGroupCount=0; _leftConnectionShiftFlag=false; }
00059         NuclearFamily(Individual* mother,Individual* father){ _mother=mother; _father=father; _twinGroupCount=0; _leftConnectionShiftFlag = false; }
00060         //
00061         // Methods:
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         // Setters:
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         // Getters:
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                 // True if both the mother and father are consanguinous:
00104                 return _father->isConsanguinous() && _mother->isConsanguinous(); 
00105         }
00106         
00107         bool hasExternalConnection(void) { 
00108                 // True if both the mother and father have an external connection:
00109                 return _father->hasExternalConnection() && _mother->hasExternalConnection(); 
00110         }
00111         
00112         unsigned getTwinGroupCount(void) { return _twinGroupCount; }
00113         
00114         // Debug:
00115         void display();
00116         
00117 };
00118 
00119 #endif
00120 

Generated on Fri Nov 18 16:24:39 2011 for MADELINE by  doxygen 1.4.4