CAVector CToolCervicales::SegmentationGlob(CDib * m_Dib, CRxDoc * i_Document, CList<CPoint, CPoint&>& i_List) { CList<CPoint, CPoint&> Result; Result.AddTail(i_List.GetHead()); Segmentation(m_Dib, i_Document, i_List.GetHeadPosition(), i_List.GetTailPosition(), i_List, 0, Result); Result.AddTail(i_List.GetTail()); CAVector Vector; CPoint l_Point; POSITION c_Pos = Result.GetHeadPosition(); while (c_Pos != NULL) { l_Point = Result.GetNext(c_Pos); Vector.Add(CPoint(l_Point.x, m_Dib->GetHeight()-l_Point.y)); } /* replace very close points by an intermediate value */ for (int i=2;i<(int)((double)(m_Dib->GetWidth() + m_Dib->GetHeight())/2 * 0.03);i++) RemoveClosePoints(Vector, i); /* remove pattern points */ RemovePatternPoints(Vector); //i_Document->Add(Vector); return Vector; }
void CHello2Dlg::OnProcessSel(int id) { int curch = m_chlist.GetCurSel(); if(m_cmdbase == ID_32773) //data operation { CList<double,double> *data = &m_ridlgs[curch]->m_data; if(m_ridlgs[curch]->show_type == SHOW_ORGDATA) data = &m_ridlgs[curch]->m_output; if(id == 1) //show converted result { m_ridlgs[curch]->show_type = SHOW_MAINDATA; } if(id == 2) //show raw result { m_ridlgs[curch]->show_type = SHOW_ORGDATA; } if(id == 3) //delete the current record { int pos = m_history.GetCurSel(); if((pos >= 0) && (data)) { POSITION p = data->GetHeadPosition(); while(pos-- > 0 ) data->GetNext(p); data->RemoveAt(p); } } if(id == 4) //delete all the record { data->RemoveAll(); } if(id == 5) //export all the record { CFile cf; if(!cf.Open(DATAOUT_NAME,CFile::modeCreate|CFile::modeWrite)) return; //write to txt and open with notepad if(data && (data->GetCount() > 0)) { POSITION pos = data->GetHeadPosition(); char r[50]; do{ double v = data->GetAt(pos); sprintf(r,"%8f\r\n",v); cf.Write(r,strlen(r)); if(pos == data->GetTailPosition()) break; data->GetNext(pos); }while(1); } cf.Close(); SHELLEXECUTEINFO execInf; ZeroMemory (&execInf, sizeof (execInf)); execInf.cbSize = sizeof (SHELLEXECUTEINFO); execInf.fMask = SEE_MASK_NOCLOSEPROCESS; execInf.nShow = SW_SHOWNORMAL; execInf.lpFile = _T("\\windows\\pword.exe"); execInf.lpVerb = _T("open"); execInf.lpParameters = DATAOUT_NAME; ShellExecuteEx (&execInf); } } if(m_cmdbase == ID_32772) { if(id == 1) { m_ridlgs[curview]->sidedata = NULL; }else{ m_ridlgs[curview]->sidedata = &m_ridlgs[id-2]->m_data; m_ridlgs[curview]->side_ch = id-2; } m_ridlgs[curview]->SaveLastConfig(); } if(m_cmdbase == ID_32771) //channel config { if(m_cfgtype == CFGTYPE_BORE) { CSetting<PROBECFG> prbset; prbset.InstallFromFile(PRB_DEFINFO); if(id == 1)//just close it { m_ridlgs[curch]->cfg_now = CFGTYPE_NONE; for(int i=0;i<sizeof(m_ridlgs)/sizeof(CRunitemDialog*);i++){ if((m_ridlgs[i]->cfg_now == CFGTYPE_BORE) && (i != curch) && (m_ridlgs[i]->side_ch == curch)) { m_ridlgs[i]->sidedata = NULL; } } }else{ m_ridlgs[curch]->m_prbid = prbset.GetNameAt(id-2); m_ridlgs[curch]->cfg_now = CFGTYPE_BORE; } m_ridlgs[curch]->SaveLastConfig(); } if(m_cfgtype == CFGTYPE_THMO) { if(m_ridlgs[curch]->IsValid() && (id == 1)) //just close it { m_ridlgs[curch]->cfg_now = CFGTYPE_NONE; for(int i=0;i<sizeof(m_ridlgs)/sizeof(CRunitemDialog*);i++){ if((m_ridlgs[i]->cfg_now == CFGTYPE_THMO) && (i != curch) && (m_ridlgs[i]->side_ch == curch)) { m_ridlgs[i]->sidedata = NULL; } } }else{ if(id != 1){ m_ridlgs[curch]->cfg_now = CFGTYPE_THMO; CString types(_T("TBEJKNRS")); m_ridlgs[curch]->m_prbid = types.GetAt(id-2); } } m_ridlgs[curch]->SaveLastConfig(); } } LoadCurrentView(); }
void CHello2Dlg::Refresh() { int curch = m_chlist.GetCurSel(); if(curch < 0) return; int curcfg = m_cfgtype; //clear the history and graph while(m_history.GetCount() > 0) m_history.DeleteString(0); if(m_ridlgs[curch]->cfg_now != m_cfgtype) { m_graph.AssignMainData(NULL); m_graph.AssignSideData(NULL); m_graph.Invalidate(); return; } //update data shown in graph, (data and text) m_graph.AssignMainData(&m_ridlgs[curch]->m_data); m_graph.ch = curch; m_graph.AssignSideData(m_ridlgs[curch]->sidedata); m_graph.side_ch = m_ridlgs[curch]->side_ch; CString dat; if(m_ridlgs[curch]->cfg_now == CFGTYPE_THMO) { m_graph.smalltext.Format(_T("%.4f mV"),CGraph::GetAverage(&m_ridlgs[curch]->m_output)); m_graph.bigtext.Format(_T("%.4f ℃"),CGraph::GetAverage(&m_ridlgs[curch]->m_data)); }else{ if(m_ridlgs[curch]->cfg_now == CFGTYPE_RESI) { m_graph.smalltext.Format(_T("%.4f Ω"),CGraph::GetAverage(&m_ridlgs[curch]->m_output)); m_graph.bigtext.Format(_T("%.4f ℃"),CGraph::GetAverage(&m_ridlgs[curch]->m_data)); }else{ m_graph.smalltext = m_ridlgs[curch]->m_smalltxt; m_graph.bigtext = m_ridlgs[curch]->m_bigtxt; } } m_graph.ch = curview; m_graph.Invalidate(); //add data to history listbox CList<double,double> *data = &m_ridlgs[curch]->m_data; if(m_ridlgs[curch]->show_type == SHOW_ORGDATA) data = &m_ridlgs[curch]->m_output; if(data && (data->GetCount() > 0)) { POSITION pos = data->GetHeadPosition(); do{ double v = data->GetAt(pos); CString r; r.Format(_T("%8f"),v); m_history.AddString(r); if(pos == data->GetTailPosition()) break; data->GetNext(pos); }while(1); if(m_history.GetCount() > 0) m_history.SetCaretIndex(m_history.GetCount()-1,0); } }