public void AddPerioMeasure(int intTooth, PerioSequenceType sequenceType, int mb, int b, int db, int ml, int l, int dl) { PerioMeasure pm = new PerioMeasure(); pm.MBvalue = mb; pm.Bvalue = b; pm.DBvalue = db; pm.MLvalue = ml; pm.Lvalue = l; pm.DLvalue = dl; pm.IntTooth = intTooth; pm.SequenceType = sequenceType; tcData.ListPerioMeasure.Add(pm); }
///<summary>This gets the entire set of lines for one perio row for one sequence type. The allowed types are GM, MGJ, and CAL. Each LineSimple is a series of connected lines. But the result could have interruptions, so we return a list, each item in the list being continuous. There may be zero items in the list. Each line in the list is guaranteed to have at least 2 points in it.</summary> public List<LineSimple> GetHorizontalLines(PerioSequenceType sequenceType,bool isMaxillary,bool isBuccal) { List<LineSimple> retVal=new List<LineSimple>(); int startTooth=1; int stopTooth=17;//doesn't perform a loop for 17. if(!isMaxillary) { startTooth=32;//We still go Left to Right, even on mand. stopTooth=16; } LineSimple line=new LineSimple(); Vertex3f vertex; int val1=-1; int val2=-1; int val3=-1; int t=startTooth; PerioSurf surf1; PerioSurf surf2; PerioSurf surf3; while(t!=stopTooth){ if(!ListToothGraphics[t.ToString()].Visible && !ListToothGraphics[t.ToString()].IsImplant) { //stop any existing line. if(line.Vertices.Count==1) {//if there is already one point, then clear it, because a line can't have one point. line.Vertices.Clear(); } if(line.Vertices.Count>1) {//if 2 or more points in the line, then add the line to the result. retVal.Add(line); line=new LineSimple();//and initialize a new line for future points. } //increment to next tooth if(isMaxillary) { t++; } else { t--; } continue; } //We are considering 3 points per tooth. Reinitialize for the new tooth. val1=-1; val2=-1; val3=-1; surf1=PerioSurf.None; surf2=PerioSurf.None; surf3=PerioSurf.None; for(int i=0;i<ListPerioMeasure.Count;i++) { if(ListPerioMeasure[i].IntTooth!=t) { continue; } if(ListPerioMeasure[i].SequenceType!=sequenceType) { continue; } //so we are now on the specific PerioMeasure for this sequence and tooth. It contains 6 values, and we will use 3. PerioMeasure pmGM=null; //We need to draw MGJ as dist from GM, not CEJ if(sequenceType==PerioSequenceType.MGJ) {//we only care about this if we are trying to calculate MGJ for(int m=0;m<ListPerioMeasure.Count;m++) { if(ListPerioMeasure[m].IntTooth==t && ListPerioMeasure[m].SequenceType==PerioSequenceType.GingMargin) { pmGM=ListPerioMeasure[m];//get the GM for this same tooth. break; } } } if(isBuccal) { if(ToothGraphic.IsRight(t.ToString())) { val1=ListPerioMeasure[i].DBvalue; val2=ListPerioMeasure[i].Bvalue; val3=ListPerioMeasure[i].MBvalue; if(sequenceType==PerioSequenceType.MGJ && pmGM!=null) { if(pmGM.DBvalue!=-1) { val1+=PerioMeasures.AdjustGMVal(pmGM.DBvalue); } if(pmGM.Bvalue!=-1) { val2+=PerioMeasures.AdjustGMVal(pmGM.Bvalue); } if(pmGM.MBvalue!=-1) { val3+=PerioMeasures.AdjustGMVal(pmGM.MBvalue); } } surf1=PerioSurf.DB; surf2=PerioSurf.B; surf3=PerioSurf.MB; } else {//for UL and LL val1=ListPerioMeasure[i].MBvalue; val2=ListPerioMeasure[i].Bvalue; val3=ListPerioMeasure[i].DBvalue; if(sequenceType==PerioSequenceType.MGJ && pmGM!=null) { if(pmGM.MBvalue!=-1) { val1+=PerioMeasures.AdjustGMVal(pmGM.MBvalue); } if(pmGM.Bvalue!=-1) { val2+=PerioMeasures.AdjustGMVal(pmGM.Bvalue); } if(pmGM.DBvalue!=-1) { val3+=PerioMeasures.AdjustGMVal(pmGM.DBvalue); } } surf1=PerioSurf.MB; surf2=PerioSurf.B; surf3=PerioSurf.DB; } } else {//lingual if(ToothGraphic.IsRight(t.ToString())) { val1=ListPerioMeasure[i].DLvalue; val2=ListPerioMeasure[i].Lvalue; val3=ListPerioMeasure[i].MLvalue; if(sequenceType==PerioSequenceType.MGJ && pmGM!=null) { if(pmGM.DLvalue!=-1) { val1+=PerioMeasures.AdjustGMVal(pmGM.DLvalue); } if(pmGM.Lvalue!=-1) { val2+=PerioMeasures.AdjustGMVal(pmGM.Lvalue); } if(pmGM.MLvalue!=-1) { val3+=PerioMeasures.AdjustGMVal(pmGM.MLvalue); } } surf1=PerioSurf.DL; surf2=PerioSurf.L; surf3=PerioSurf.ML; } else {//for UL and LL val1=ListPerioMeasure[i].MLvalue; val2=ListPerioMeasure[i].Lvalue; val3=ListPerioMeasure[i].DLvalue; if(sequenceType==PerioSequenceType.MGJ && pmGM!=null) { if(pmGM.MLvalue!=-1) { val1+=PerioMeasures.AdjustGMVal(pmGM.MLvalue); } if(pmGM.Lvalue!=-1) { val2+=PerioMeasures.AdjustGMVal(pmGM.Lvalue); } if(pmGM.DLvalue!=-1) { val3+=PerioMeasures.AdjustGMVal(pmGM.DLvalue); } } surf1=PerioSurf.ML; surf2=PerioSurf.L; surf3=PerioSurf.DL; } } } //We have now filled our 3 points with values and need to evaluate those values. //Any or all of the values may still be -1. if(val1==-1) { //we won't add a point to this line if(line.Vertices.Count==1) {//if there is already one point, then clear it, because a line can't have one point. line.Vertices.Clear(); } if(line.Vertices.Count>1) {//if 2 or more points in the line, then add the line to the result. retVal.Add(line); line=new LineSimple();//and initialize a new line for future points. } } else {//just add a point to the current line. vertex=new Vertex3f(); vertex.Z=0;//we don't use z if(isMaxillary) { //this is safe to run on all sequence types because -1 has already been handled and because other types wouldn't have values > 100. //Also safe to process on the vals that are MGJ, calculated above, because if they are ever negative, //it would be an obvious entry error, and the MGJ line would just harmlessly disappear for -1 vals. vertex.Y=PerioMeasures.AdjustGMVal(val1); } else { vertex.Y=-PerioMeasures.AdjustGMVal(val1); } vertex.X=GetXShiftPerioSite(t,surf1)+ToothGraphic.GetDefaultOrthoXpos(t); line.Vertices.Add(vertex); } //val2-------------------------- if(val2==-1) { if(line.Vertices.Count==1) { line.Vertices.Clear(); } if(line.Vertices.Count>1) { retVal.Add(line); line=new LineSimple(); } } else { vertex=new Vertex3f(); vertex.Z=0; if(isMaxillary) { vertex.Y=PerioMeasures.AdjustGMVal(val2); } else { vertex.Y=-PerioMeasures.AdjustGMVal(val2); } vertex.X=GetXShiftPerioSite(t,surf2)+ToothGraphic.GetDefaultOrthoXpos(t); line.Vertices.Add(vertex); } //val3------------------------- if(val3==-1) { if(line.Vertices.Count==1) { line.Vertices.Clear(); } if(line.Vertices.Count>1) { retVal.Add(line); line=new LineSimple(); } } else { vertex=new Vertex3f(); vertex.Z=0; if(isMaxillary) { vertex.Y=PerioMeasures.AdjustGMVal(val3); } else { vertex.Y=-PerioMeasures.AdjustGMVal(val3); } vertex.X=GetXShiftPerioSite(t,surf3)+ToothGraphic.GetDefaultOrthoXpos(t); line.Vertices.Add(vertex); } //increment to next tooth if(isMaxillary) { t++; } else { t--; } } if(line.Vertices.Count>1) { retVal.Add(line); } return retVal; }
///<summary></summary> public ContrPerio() { //InitializeComponent();// This call is required by the Windows.Forms Form Designer. this.BackColor = System.Drawing.SystemColors.Window; cBorder=Color.Black; //cBackShort=Color.FromArgb(237,237,237);//larger numbers will make it whiter cBackShort=Color.FromArgb(225,225,225); cHi=Color.FromArgb(158,146,142);//Color.DarkSalmon; cSkip=Color.LightGray; cVertical=Color.Silver; cHoriz=Color.LightGray; cBack=Color.White; cHorizShort=Color.Silver;//or darkgrey cRedText=Color.Red; SetColors(); cOldText=Color.FromArgb(120,120,120); cOldTextRed=Color.FromArgb(200,80,80); RowsProbing=6; RowTypes=new PerioSequenceType[4][]; //Upper facial: RowTypes[0]=new PerioSequenceType[5+RowsProbing]; RowTypes[0][0]=PerioSequenceType.Mobility; RowTypes[0][1]=PerioSequenceType.Furcation; RowTypes[0][2]=PerioSequenceType.CAL; RowTypes[0][3]=PerioSequenceType.GingMargin; RowTypes[0][4]=PerioSequenceType.MGJ; for(int i=0;i<RowsProbing;i++){ RowTypes[0][5+i]=PerioSequenceType.Probing; } //Upper lingual: RowTypes[1]=new PerioSequenceType[3+RowsProbing]; RowTypes[1][0]=PerioSequenceType.Furcation; RowTypes[1][1]=PerioSequenceType.CAL; RowTypes[1][2]=PerioSequenceType.GingMargin; for(int i=0;i<RowsProbing;i++){ RowTypes[1][3+i]=PerioSequenceType.Probing; } //Lower lingual: RowTypes[2]=new PerioSequenceType[4+RowsProbing]; RowTypes[2][0]=PerioSequenceType.Furcation; RowTypes[2][1]=PerioSequenceType.CAL; RowTypes[2][2]=PerioSequenceType.GingMargin; RowTypes[2][3]=PerioSequenceType.MGJ; for(int i=0;i<RowsProbing;i++){ RowTypes[2][4+i]=PerioSequenceType.Probing; } //Lower facial: RowTypes[3]=new PerioSequenceType[5+RowsProbing]; RowTypes[3][0]=PerioSequenceType.Mobility; RowTypes[3][1]=PerioSequenceType.Furcation; RowTypes[3][2]=PerioSequenceType.CAL; RowTypes[3][3]=PerioSequenceType.GingMargin; RowTypes[3][4]=PerioSequenceType.MGJ; for(int i=0;i<RowsProbing;i++){ RowTypes[3][5+i]=PerioSequenceType.Probing; } Wmeas=10; Wleft=65; Hprob=16; Hshort=12; Htooth=16; ClearDataArray(); FillTopCoordinates(); CurCell=new Point(-1,-1);//my way of setting it to null. }
public void AddPerioMeasure(int intTooth,PerioSequenceType sequenceType,int mb,int b,int db,int ml,int l, int dl) { PerioMeasure pm=new PerioMeasure(); pm.MBvalue=mb; pm.Bvalue=b; pm.DBvalue=db; pm.MLvalue=ml; pm.Lvalue=l; pm.DLvalue=dl; pm.IntTooth=intTooth; pm.SequenceType=sequenceType; tcData.ListPerioMeasure.Add(pm); }
///<summary>This gets the entire set of lines for one perio row for one sequence type. The allowed types are GM, MGJ, and CAL. Each LineSimple is a series of connected lines. But the result could have interruptions, so we return a list, each item in the list being continuous. There may be zero items in the list. Each line in the list is guaranteed to have at least 2 points in it.</summary> public List<LineSimple> GetHorizontalLines(PerioSequenceType sequenceType,bool isMaxillary,bool isBuccal) { List<LineSimple> retVal=new List<LineSimple>(); int startTooth=1; int stopTooth=17;//doesn't perform a loop for 17. if(!isMaxillary) { startTooth=32;//We still go Left to Right, even on mand. stopTooth=16; } LineSimple line=new LineSimple(); Vertex3f vertex; int val1=-1; int val2=-1; int val3=-1; int t=startTooth; PerioSurf surf1; PerioSurf surf2; PerioSurf surf3; while(t!=stopTooth){ if(!ListToothGraphics[t.ToString()].Visible && !ListToothGraphics[t.ToString()].IsImplant) { //stop any existing line. if(line.Vertices.Count==1) {//if there is already one point, then clear it, because a line can't have one point. line.Vertices.Clear(); } if(line.Vertices.Count>1) {//if 2 or more points in the line, then add the line to the result. retVal.Add(line); line=new LineSimple();//and initialize a new line for future points. } //increment to next tooth if(isMaxillary) { t++; } else { t--; } continue; } //We are considering 3 points per tooth. Reinitialize for the new tooth. val1=-1; val2=-1; val3=-1; surf1=PerioSurf.None; surf2=PerioSurf.None; surf3=PerioSurf.None; for(int i=0;i<ListPerioMeasure.Count;i++) { if(ListPerioMeasure[i].IntTooth!=t) { continue; } if(ListPerioMeasure[i].SequenceType!=sequenceType) { continue; } PerioMeasure pmGM=null; //We need to draw MGJ as dist from GM, not CEJ if(sequenceType==PerioSequenceType.MGJ) { for(int m=0;m<ListPerioMeasure.Count;m++) { if(ListPerioMeasure[m].IntTooth==t && ListPerioMeasure[m].SequenceType==PerioSequenceType.GingMargin) { pmGM=ListPerioMeasure[m]; break; } } } if(isBuccal) { if(ToothGraphic.IsRight(t.ToString())) { val1=ListPerioMeasure[i].DBvalue; val2=ListPerioMeasure[i].Bvalue; val3=ListPerioMeasure[i].MBvalue; if(sequenceType==PerioSequenceType.MGJ && pmGM!=null) { if(pmGM.DBvalue!=-1) { val1+=pmGM.DBvalue; } if(pmGM.Bvalue!=-1) { val2+=pmGM.Bvalue; } if(pmGM.MBvalue!=-1) { val3+=pmGM.MBvalue; } } surf1=PerioSurf.DB; surf2=PerioSurf.B; surf3=PerioSurf.MB; } else {//for UL and LL val1=ListPerioMeasure[i].MBvalue; val2=ListPerioMeasure[i].Bvalue; val3=ListPerioMeasure[i].DBvalue; if(sequenceType==PerioSequenceType.MGJ && pmGM!=null) { if(pmGM.MBvalue!=-1) { val1+=pmGM.MBvalue; } if(pmGM.Bvalue!=-1) { val2+=pmGM.Bvalue; } if(pmGM.DBvalue!=-1) { val3+=pmGM.DBvalue; } } surf1=PerioSurf.MB; surf2=PerioSurf.B; surf3=PerioSurf.DB; } } else {//lingual if(ToothGraphic.IsRight(t.ToString())) { val1=ListPerioMeasure[i].DLvalue; val2=ListPerioMeasure[i].Lvalue; val3=ListPerioMeasure[i].MLvalue; if(sequenceType==PerioSequenceType.MGJ && pmGM!=null) { if(pmGM.DLvalue!=-1) { val1+=pmGM.DLvalue; } if(pmGM.Lvalue!=-1) { val2+=pmGM.Lvalue; } if(pmGM.MLvalue!=-1) { val3+=pmGM.MLvalue; } } surf1=PerioSurf.DL; surf2=PerioSurf.L; surf3=PerioSurf.ML; } else {//for UL and LL val1=ListPerioMeasure[i].MLvalue; val2=ListPerioMeasure[i].Lvalue; val3=ListPerioMeasure[i].DLvalue; if(sequenceType==PerioSequenceType.MGJ && pmGM!=null) { if(pmGM.MLvalue!=-1) { val1+=pmGM.MLvalue; } if(pmGM.Lvalue!=-1) { val2+=pmGM.Lvalue; } if(pmGM.DLvalue!=-1) { val3+=pmGM.DLvalue; } } surf1=PerioSurf.ML; surf2=PerioSurf.L; surf3=PerioSurf.DL; } } } //We have now filled our 3 points with values and need to evaluate those values. //Any or all of the values may still be -1. if(val1==-1) { //we won't add a point to this line if(line.Vertices.Count==1) {//if there is already one point, then clear it, because a line can't have one point. line.Vertices.Clear(); } if(line.Vertices.Count>1) {//if 2 or more points in the line, then add the line to the result. retVal.Add(line); line=new LineSimple();//and initialize a new line for future points. } } else {//just add a point to the current line. vertex=new Vertex3f(); vertex.Z=0;//we don't use z if(isMaxillary) { vertex.Y=val1; } else { vertex.Y=-val1; } vertex.X=GetXShiftPerioSite(t,surf1)+ToothGraphic.GetDefaultOrthoXpos(t); line.Vertices.Add(vertex); } //val2-------------------------- if(val2==-1) { if(line.Vertices.Count==1) { line.Vertices.Clear(); } if(line.Vertices.Count>1) { retVal.Add(line); line=new LineSimple(); } } else { vertex=new Vertex3f(); vertex.Z=0; if(isMaxillary) { vertex.Y=val2; } else { vertex.Y=-val2; } vertex.X=GetXShiftPerioSite(t,surf2)+ToothGraphic.GetDefaultOrthoXpos(t); line.Vertices.Add(vertex); } //val3------------------------- if(val3==-1) { if(line.Vertices.Count==1) { line.Vertices.Clear(); } if(line.Vertices.Count>1) { retVal.Add(line); line=new LineSimple(); } } else { vertex=new Vertex3f(); vertex.Z=0; if(isMaxillary) { vertex.Y=val3; } else { vertex.Y=-val3; } vertex.X=GetXShiftPerioSite(t,surf3)+ToothGraphic.GetDefaultOrthoXpos(t); line.Vertices.Add(vertex); } //increment to next tooth if(isMaxillary) { t++; } else { t--; } } if(line.Vertices.Count>1) { retVal.Add(line); } return retVal; }
///<summary>Used in LoadData.</summary> private Point GetCell(int examIndex,PerioSequenceType seqType,int intTooth,PerioSurf surf){ int col=0; int row=0; if(intTooth<=16){ col=(intTooth*3)-2;//left-most column if(surf==PerioSurf.B || surf==PerioSurf.L){ col++; } if(intTooth<=8){ if(surf==PerioSurf.MB || surf==PerioSurf.ML) col+=2; } else{//9-16 if(surf==PerioSurf.DB || surf==PerioSurf.DL) col+=2; } } else{//17-32 col=((33-intTooth)*3)-2;//left-most column if(surf==PerioSurf.B || surf==PerioSurf.L){ col++; } if(intTooth>=25){ if(surf==PerioSurf.MB || surf==PerioSurf.ML) col+=2; } else{//17-24 if(surf==PerioSurf.DB || surf==PerioSurf.DL) col+=2; } } int section; if(intTooth<=16){ if(surf==PerioSurf.MB || surf==PerioSurf.B || surf==PerioSurf.DB){ section=0; } else{//Lingual section=1; } } else{//17-32 if(surf==PerioSurf.MB || surf==PerioSurf.B || surf==PerioSurf.DB){ section=3; } else{//Lingual section=2; } } row=GetTableRow(examIndex,section,seqType); return new Point(col,row); }
///<summary>Returns a list of strings, each between "1" and "32" (or similar international #'s), representing the teeth with red values based on prefs. The result can be used to print summary, or can be counted to show # of teeth.</summary> public ArrayList CountTeeth(PerioSequenceType seqType){ if(selectedExam==-1){ return new ArrayList(); } int prefVal=0; switch(seqType){ case PerioSequenceType.Probing: prefVal=PrefC.GetInt(PrefName.PerioRedProb); break; case PerioSequenceType.MGJ: prefVal=PrefC.GetInt(PrefName.PerioRedMGJ); break; case PerioSequenceType.GingMargin: prefVal=PrefC.GetInt(PrefName.PerioRedGing); break; case PerioSequenceType.CAL: prefVal=PrefC.GetInt(PrefName.PerioRedCAL); break; case PerioSequenceType.Furcation: prefVal=PrefC.GetInt(PrefName.PerioRedFurc); break; case PerioSequenceType.Mobility: prefVal=PrefC.GetInt(PrefName.PerioRedMob); break; } ArrayList retList=new ArrayList(); string cellText=""; int intTooth=0; int row=0; for(int section=0;section<4;section++){ for(int x=1;x<1+3*16;x++){ row=GetTableRow(selectedExam,section,seqType); if(row==-1) continue;//eg MGJ or Mobility cellText=DataArray[x,row].Text; if(cellText==null || cellText==""){ continue; } if((seqType==PerioSequenceType.MGJ && PIn.Long(cellText)<=prefVal) || (seqType!=PerioSequenceType.MGJ && PIn.Long(cellText)>=prefVal)){ intTooth=(int)Math.Ceiling((double)x/3); if(section==2 || section==3){//if mand intTooth=33-intTooth; } if(!retList.Contains(Tooth.ToInternat(intTooth.ToString()))){ retList.Add(Tooth.ToInternat(intTooth.ToString())); } } } } return retList; }
///<summary>Used in GetCell during LoadData. Also used in AdvanceCell when looping to a new section.</summary> private int GetTableRow(int examIndex,int section,PerioSequenceType seqType){ if(seqType==PerioSequenceType.Probing || seqType==PerioSequenceType.Bleeding){ if(examIndex-ProbingOffset<0)//older exam that won't fit. return -1; int sectionRow=examIndex-ProbingOffset//correct for offset +RowTypes[section].Length-RowsProbing;//plus number of non-probing rows return GetTableRow(section,sectionRow); } //for types other than probing and bleeding, do a loop through the non-probing rows: for(int i=0;i<RowTypes[section].Length-RowsProbing;i++){ if(RowTypes[section][i]==seqType) return GetTableRow(section,i); } //MessageBox.Show("Error in GetTableRows: seqType not found"); return -1; }
///<summary>Used in SaveCurExam to retrieve data from grid to save it.</summary> private int GetCellValue(int examIndex,PerioSequenceType seqType,int intTooth,PerioSurf surf){ Point curCell=GetCell(examIndex,seqType,intTooth,surf); if(curCell.X==-1 || curCell.Y==-1){ return -1; } //if(intTooth==4) //MessageBox.Show(DataArray[curCell.X,curCell.Y].Text); if(DataArray[curCell.X,curCell.Y].Text==null || DataArray[curCell.X,curCell.Y].Text==""){ //MessageBox.Show("empty"); return -1; } //MessageBox.Show("full"); return PIn.Int(DataArray[curCell.X,curCell.Y].Text); }