UWORD ParseCPPLines ( struct SyntaxHandle *handle, LineDef** lines, BSTR textData, UWORD startoffset, UWORD maxlength, CArray <SyntaxChunk, SyntaxChunk>& SyntaxArr ) { SyntaxArr.SetSize(maxlength); // hm.. TODO, add instead SyntaxChunk* syntax = SyntaxArr.GetData(); int ChunkUsed = 0; int pos = 0; while (pos < maxlength) { if (textData[pos] == L'<') { while } } SyntaxArr.SetSize(ChunkUsed); return 0; }
TTaskResult CBeep::Execute(CRobot * Robot, CExecutableRWGraphicObjectList * ExecutableObjectList, bool & result) { if (Robot->GetSoftwareRevision() <= 1.06) /*Do the tune as beeps for robots before version 1.07*/ { Robot->AddBeepToInstructions(GetFrequency(), GetDuration()); CFlowZap *FZ = (CFlowZap*)m_fc; CBeep* LastBeep = this; CInstruction *Next = FZ->GetNextInstructionInList(this); // Next = FZ->GetNextExecutableInstruction(Next); while (Next->IsKindOf(RUNTIME_CLASS(CBeep))) { LastBeep = (CBeep*)Next; Robot->AddBeepToInstructions(LastBeep->GetFrequency(), LastBeep->GetDuration()); Next = FZ->GetNextInstructionInList(Next); // Next = FZ->GetNextExecutableInstruction(Next); } FZ->SetCueToInstruction(LastBeep); FZ->RedrawWindow(); } else { unsigned int NumberOfNotes = 1; CArray<short, short> FrequencyList; FrequencyList.SetSize(20, 20); CArray<int, int> DurationList; DurationList.SetSize(20, 20); FrequencyList[0] = GetFrequency(); DurationList[0] = GetDuration(); CFlowZap *FZ = (CFlowZap*)m_fc; CBeep* LastBeep = this; CInstruction *Next = FZ->GetNextInstructionInList(this); // Next = FZ->GetNextExecutableInstruction(Next); while (Next->IsKindOf(RUNTIME_CLASS(CBeep))) { LastBeep = (CBeep*)Next; FrequencyList[NumberOfNotes] = LastBeep->GetFrequency(); DurationList[NumberOfNotes] = LastBeep->GetDuration(); NumberOfNotes++; Next = FZ->GetNextInstructionInList(Next); // Next = FZ->GetNextExecutableInstruction(Next); } FrequencyList[NumberOfNotes] = -1; DurationList[NumberOfNotes] = 0; NumberOfNotes++; Robot->AddTuneToInstructions(FrequencyList.GetData(), DurationList.GetData(), NumberOfNotes); FZ->SetCueToInstruction(LastBeep); FZ->RedrawWindow(); } TTaskResult TaskResult; TaskResult = Robot->FollowInstructions(true, true, IR_InstructionComplete); return TaskResult; }
void ProcessForm::OnLvnColumnclickList1(NMHDR *pNMHDR, LRESULT *pResult) { LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR); int Length = m_listCtrl.GetItemCount(); CArray<CString,CString> ItemData; ItemData.SetSize(Length); for (int i = 0; i < Length; i++) { ItemData[i] = m_listCtrl.GetItemText(i,pNMLV->iSubItem); m_listCtrl.SetItemData(i,(DWORD_PTR)&ItemData[i]);//设置排序关键字 } static int sort = 0; static int SubItem = 0; if (SubItem != pNMLV->iSubItem) { sort = 0; SubItem = pNMLV->iSubItem; } else { sort = 1 - sort; } if(SubItem == 1) isNum = true; else isNum = false; m_listCtrl.SortItems(MyCompareProc,(DWORD_PTR)&sort);//排序 *pResult = 0; }
void CSortingListControl::LoadPersistentAttributes() { CArray<int, int> arr; arr.SetSize(GetHeaderCtrl()->GetItemCount()); GetColumnOrderArray(arr.GetData(), arr.GetSize()); CPersistence::GetColumnOrder(m_name, arr); SetColumnOrderArray(arr.GetSize(), arr.GetData()); for (int i=0; i < arr.GetSize(); i++) arr[i]= GetColumnWidth(i); CPersistence::GetColumnWidths(m_name, arr); for (i=0; i < arr.GetSize(); i++) { // To avoid "insane" settings we set the column width to // maximal twice the default width. int maxWidth= GetColumnWidth(i) * 2; int w= min(arr[i], maxWidth); SetColumnWidth(i, w); } // Not so good: CPersistence::GetSorting(m_name, GetHeaderCtrl()->GetItemCount(), m_sorting.column1, m_sorting.ascending1, m_sorting.column2, m_sorting.ascending2); // We refrain from saving the sorting because it is too likely, that // users start up with insane settings and don't get it. }
//Private BOOL COXMultiComboBox::ChangeMasterColumn(int /* nCol */) { int nNumItems = GetCount(); CArray<COXRowData*,COXRowData*> aPtrsRowData; aPtrsRowData.SetSize(nNumItems); int nIndex=0; for(nIndex=0; nIndex < nNumItems; nIndex++) { COXRowData* pRowData = GetRowData(nIndex); aPtrsRowData[nIndex] = pRowData; if (pRowData == NULL) TRACE0("In COXMultiComboBox::ChangeMasterColumn : GetRowData() returned NULL.\n"); } // ... To avoid deleting the Rowdata in DeleteItem m_fMasterColumnChanging = TRUE; // ... Delete all the Items ResetContent(); // ... Resets the flag m_fMasterColumnChanging = FALSE; int nRetVal; // Again add all the items. This deletion and addition is to effect // the sorting order based on current master column for(nIndex=0; nIndex < nNumItems; nIndex++) { if((nRetVal = CComboBox::AddString((aPtrsRowData[nIndex])->GetColumnString(m_nMasterColumn))) != CB_ERR) SetRowData(nRetVal,aPtrsRowData[nIndex]); else return FALSE; } return TRUE; }
void CMultiSelDlg::OnOK() { // now copy selection to the selection strings CString strSel; if(m_bSingleSelect) { int iSel = m_tListBox.GetCurSel(); if(iSel>=0) { m_tListBox.GetText(iSel, strSel); m_astrStringsSel.Add(strSel); } } else { CArray<int,int> aiListBoxSel; int iCount = m_tListBox.GetSelCount(); aiListBoxSel.SetSize(iCount); m_tListBox.GetSelItems(iCount, aiListBoxSel.GetData()); for(int iSel = 0; iSel < iCount; ++iSel) { m_tListBox.GetText(aiListBoxSel[iSel], strSel); m_astrStringsSel.Add(strSel); } } CDialog::OnOK(); }
void DoTestFiles(const char *filelist, const char *environment) { if (!GetTestFiles(filelist)) { printf("No Files to test!\r\n"); return; } Results.SetSize(IsapiFileList.GetSize()); ReadGlobalEnvironment(environment); DoThreads(); printf("\r\nRESULTS:\r\n"); // show results: DWORD r = Results.GetSize(); for (DWORD i=0; i< r; i++) { TResults result = Results.GetAt(i); printf("%s\r\nOK: %d FAILED: %d\r\n", TestNames.GetAt(i), result.ok, result.bad); } // delete temp files printf("Deleting Temp Files\r\n"); DeleteTempFiles("exp.*"); DeleteTempFiles("pht.*"); printf("Done\r\n"); }
bool SgmlFile::ReadLine(BYTE *aBuffer, int iBufferLength, int *piReadPointer, CString &csLine, UINT nCodepage) { bool bSuccess = true; if (aBuffer == NULL || iBufferLength <= 0) bSuccess = false; if (bSuccess && (*piReadPointer >= iBufferLength)) bSuccess = false; CArray<BYTE, BYTE> aLineBytes; aLineBytes.SetSize(0, 500); bool bBreakFound = false; if (bSuccess) { bSuccess = GetNextLineFromBuffer(aBuffer, aLineBytes, *piReadPointer, iBufferLength, bBreakFound); } if (bSuccess && !bBreakFound) bSuccess = false; if (bSuccess) bSuccess = ConvertBufferToString(aLineBytes, csLine, nCodepage); return bSuccess; }
CString ConvertReceivedDataToString(CByteArray & data) { // data is UTF-8 encoded CArray<WCHAR, WCHAR> wc; // First, compute the amount of space required. n will include the // space for the terminal NUL character INT_PTR n = ::MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)data.GetData(), (int)data.GetSize(), NULL, 0); if(n == 0) { /* failed */ DWORD err = ::GetLastError(); TRACE(_T("%s: MultiByteToWideChar (1) returned error %d\n"), AfxGetApp()->m_pszAppName, err); return CString(_T("")); } /* failed */ else { /* success */ wc.SetSize(n); n = ::MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)data.GetData(), (int)data.GetSize(), (LPWSTR)wc.GetData(), (int)n); if(n == 0) { /* failed */ DWORD err = ::GetLastError(); TRACE(_T("%s: MultiByteToWideChar (2) returned error %d\n"), AfxGetApp()->m_pszAppName, err); return CString(_T("")); } /* failed */ } /* success */ // Data is now in Unicode // If we are a Unicode app we are done // If we are an ANSI app, convert it back to ANSI #ifdef _UNICODE // If this is a Unicode app we are done return CString(wc.GetData(), (int)wc.GetSize()); #else // ANSI // Invert back to ANSI CString s; n = ::WideCharToMultiByte(CP_ACP, 0, (LPCWSTR)wc.GetData(), (int)wc.GetSize(), NULL, 0, NULL, NULL); if(n == 0) { /* failed */ DWORD err = ::GetLastError(); TRACE(_T("%s: WideCharToMultiByte (1) returned error %d\n"), AfxGetApp()->m_pszAppName, err); return CString(""); } /* failed */ else { /* success */ LPSTR p = s.GetBuffer((int)n); n = ::WideCharToMultiByte(CP_ACP, 0, wc.GetData(), (int)wc.GetSize(), p, (int)n, NULL, NULL); if(n == 0) { /* conversion failed */ DWORD err = ::GetLastError(); TRACE(_T("%s: WideCharToMultiByte (2) returned error %d\n"), AfxGetApp()->m_pszAppName, err); s.ReleaseBuffer(); return CString(""); } /* conversion failed */ s.ReleaseBuffer(); return s; } /* success */ #endif } // ConvertReceivedDataToString
void CTreemap::EqualizeColors(const COLORREF *colors, int count, CArray<COLORREF, COLORREF&>& out) { out.SetSize(count); for (int i=0; i < count; i++) { out[i] = CColorSpace::MakeBrightColor(colors[i], PALETTE_BRIGHTNESS); } }
int CReportCtrl::MoveTo(int nItem, int nNewPosition) { if(!_IsValidIndex(nItem)) { return(-1); } EndEdit(TRUE); const int ITEMS = CListCtrl :: GetItemCount(); nNewPosition = max(0, nNewPosition); nNewPosition = min(ITEMS - 1, nNewPosition); if(nItem == nNewPosition) { return(nNewPosition); } _UnsetSortedColumn(); // Backup all states and attributes const int COLS = GetColumnCount(); const DWORD STATES = GetItemStates(nItem); const DWORD DATA = CListCtrl :: GetItemData(nItem); CArray<int, int> aImages; CStringArray aTexts; aImages.SetSize(COLS); aTexts.SetSize(COLS); for(int i = 0; i < COLS; i++) { aImages[i] = GetItemImage(nItem, i); aTexts[i] = GetItemText(nItem, i); } // Delete the item CListCtrl :: DeleteItem(nItem); // Insert a new item to the new position const int IDX = CListCtrl :: InsertItem(nNewPosition, _T("")); // Restore all states & attributes to the newly inserted item for(int j = 0; j < COLS; j++) { CListCtrl :: SetItemText(IDX, j, aTexts[j]); SetItemImage(IDX, j, aImages[j]); } CListCtrl :: SetItemData(IDX, DATA); SetItemStates(IDX, STATES); return(IDX); }
void CSortingListControl::SavePersistentAttributes() { CArray<int, int> arr; arr.SetSize(GetHeaderCtrl()->GetItemCount()); GetColumnOrderArray(arr.GetData(), arr.GetSize()); CPersistence::SetColumnOrder(m_name, arr); for (int i=0; i < arr.GetSize(); i++) arr[i]= GetColumnWidth(i); CPersistence::SetColumnWidths(m_name, arr); // Not so good: CPersistence::SetSorting(m_name, m_sorting.column1, m_sorting.ascending1, m_sorting.column2, m_sorting.ascending2); }
void CTreemap::GetDefaultPalette(CArray<COLORREF, COLORREF&>& palette) { if (CColorSpace::Is256Colors()) { palette.SetSize(countof(_defaultCushionColors256)); for (int i=0; i < countof(_defaultCushionColors256); i++) palette[i]= _defaultCushionColors256[i]; // We don't do //EqualizeColors(_defaultCushionColors256, countof(_defaultCushionColors256), palette); // because on 256 color screens, the resulting colors are not distinguishable. } else { EqualizeColors(_defaultCushionColors, countof(_defaultCushionColors), palette); } }
bool SgmlFile::ReadLine(HANDLE hFile, CString &csLine, UINT nCodepage) { bool bSuccess = true; if (hFile == INVALID_HANDLE_VALUE || hFile == NULL) bSuccess = false; // The buffer is empty or all bytes are read if (bSuccess && (m_iBytesInBuffer == 0 || m_iBufferPointer == m_iBytesInBuffer)) { bool bSomethingRead = ReadNextBuffer(hFile, m_aBuffer, 4096, &m_iBytesInBuffer); m_iBufferPointer = 0; if (!bSomethingRead) bSuccess = false; } CArray<BYTE, BYTE> aLineBytes; aLineBytes.SetSize(0, 500); bool bBreakFound = false; while (bSuccess && !bBreakFound) { bSuccess = GetNextLineFromBuffer(m_aBuffer, aLineBytes, m_iBufferPointer, m_iBytesInBuffer, bBreakFound); // The end of the line is not in the current buffer // read next buffer if (!bBreakFound) { bool bSomethingRead = ReadNextBuffer(hFile, m_aBuffer, 4096, &m_iBytesInBuffer); m_iBufferPointer = 0; if (!bSomethingRead) bSuccess = false; } } if (!bBreakFound) bSuccess = false; if (bSuccess) bSuccess = ConvertBufferToString(aLineBytes, csLine, nCodepage); return bSuccess; }
void CRemoveChannelsDlg::OnOK() //----------------------------- { int nCount = m_RemChansList.GetSelCount(); CArray<int,int> aryListBoxSel; aryListBoxSel.SetSize(nCount); m_RemChansList.GetSelItems(nCount, aryListBoxSel.GetData()); m_bKeepMask.assign(m_nChannels, true); for (int n = 0; n < nCount; n++) { m_bKeepMask[aryListBoxSel[n]] = false; } if ((static_cast<UINT>(nCount) == m_nRemove && nCount > 0) || (m_nRemove == 0 && (m_pSndFile->GetNumChannels() >= nCount + m_pSndFile->GetModSpecifications().channelsMin))) CDialog::OnOK(); else CDialog::OnCancel(); }
void CCommunicationTrafficDlg::OnBnClickedCopy() { //-------------------------------------------------------------------------------------------------------------------- CArray <int, int> aryListSel; int nCount= m_DataList.GetSelCount(); aryListSel.SetSize(nCount); m_DataList.GetSelItems(nCount, aryListSel.GetData()); // aryListSel中存的就是选中列的index值,如果需要取内容,加以下语句: CString str,content; for (int i= nCount-1; i>= 0; i--) { m_DataList.GetText(aryListSel.GetAt(i), (CString&)str); str+=_T("\n"); content==str; } //-------------------------------------------------------------------------------------------------------------------- HGLOBAL hClip; //定义一个HGLOBAL句柄变量用来指向分配的内存块 if (OpenClipboard()) { EmptyClipboard(); //将剪贴板内容清空 hClip=GlobalAlloc(GMEM_MOVEABLE,content.GetLength()+1); //在堆上分配可移动的内存块,程序返回一个内存句柄 char * buff; //定义指向字符型的指针变量 buff=(char*)GlobalLock(hClip); //对分配的内存块进行加锁,将内存块句柄转化成一个指针,并将相应的引用计数器加1 strcpy(buff,(char*)content.GetBuffer()); //将用户输入的数据复制到指针变量中,实际上就是复制到分配的内存块中 GlobalUnlock(hClip); //数据写入完毕,进行解锁操作,并将引用计数器数字减1 SetClipboardData(CF_TEXT,hClip); //将存放有数据的内存块放入剪贴板的资源管理中 CloseClipboard(); //关闭剪贴板,释放剪贴板资源的占用权 } //-------------------------------------------------------------------------------------------------------------------- }
void CSeperator_EfficiencyCurve::CalculateEfficiencyCurve( MIPSD &in_PSD , double in_D50 , double in_Alpha, double in_Beta, double in_C, double &inout_BetaStar, CArray <double, double&> &out_Eu ) { long l_SizeCount = in_PSD.getSizeCount(); long l_PSDVectorCount = in_PSD.getPSDVectorCount(); // // Calculate BetaStar // inout_BetaStar = CalcBetaStar(in_Alpha, in_Beta ); // // Build probability passing from specified d50, Alpha parameters and PSD size // interval data // out_Eu.SetSize(l_SizeCount); for( int lSzIndex=0; lSzIndex < l_SizeCount; lSzIndex++ ) { const double NominalSize = in_PSD.getDefn().getGeometricMean(lSzIndex); //use geometrical mean const double d = in_Alpha*inout_BetaStar*NominalSize/in_D50; if (d>230.0)//limit of exp() out_Eu[lSzIndex] = 1.0; else { //out_Eu[lSzIndex] = (exp(d)-1.0) / (exp(d) + exp(in_Alpha) - 2.0); //out_Eu[lSzIndex] = 1.0 - in_C*(exp(in_Alpha)-1.0) / (exp(d) + exp(in_Alpha) - 2.0); double num = (1.0+in_Beta*inout_BetaStar*NominalSize/in_D50)*(exp(in_Alpha)-1.0 ); double den = exp(d) + exp(in_Alpha) - 2.0; out_Eu[lSzIndex] = 1.0 - in_C*num/GTZ(den); if (out_Eu[lSzIndex]>1.0) out_Eu[lSzIndex] = 1.0; if (out_Eu[lSzIndex]<0.0) out_Eu[lSzIndex] = 0.0; } } //out_Eu[0] = 0.0; }
// This is a little tricky. We need to delete the current selection, // while highlighting the newly dropped items, without letting them // screw each other's indices up. // We know that the newly dropped items are in a contiguous block, // which helps. void OleListCtrl::DeleteOldAndHighlightNew() { // First, get a reverse-order list of selected items, // which will be deleted. CArray <int, int> anSelectedItems; anSelectedItems.SetSize( 0, 50 ); int nA = -1; while ( ( nA = GetNextItem( nA, LVNI_SELECTED ) ) != -1 ) { anSelectedItems.Add( nA ); } UnselectAll(); // Now select the dropped items. std::vector<int>::iterator it; for ( it = m_vnNewlyDroppedItems.begin(); it != m_vnNewlyDroppedItems.end(); ++it ) { SetItemState( (*it), LVIS_SELECTED, LVIS_SELECTED ); } // Now step through the deleted items, deleting. // We track the first newly dropped item as we go. int nFirst = m_vnNewlyDroppedItems[0]; for ( nA = anSelectedItems.GetUpperBound(); nA >= 0; nA-- ) { // There should be no overlap here! ASSERT( anSelectedItems[nA] != m_vnNewlyDroppedItems[0] ); DeleteItem( anSelectedItems[nA], false ); // Track the first slot as it slides up. if ( anSelectedItems[nA] < nFirst ) nFirst--; } if ( nFirst >= 0 ) { SetItemState( nFirst, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED ); } m_vnNewlyDroppedItems.clear(); }
CActuator::CActuator(pTagObjClass pClass_, pchar TagIn, pTaggedObject pAttach, TagObjAttachment eAttach) : FlwNode(pClass_, TagIn, pAttach, eAttach) //, m_MXRH(this) { if (ActuatorIOAreaList.GetSize()==0) { ActuatorIOAreaList.SetSize(MaxIOListLen); IONames.SetSize(MaxIOListLen); int j=0; for (int i=0; i<MaxXMTs; i++) { IONames[j].Set("A%i.Rqd", i); ActuatorIOAreaList[j]=BaseActuatorIOArea; ActuatorIOAreaList[j].m_Id=CtrlIOId(j); ActuatorIOAreaList[j].SetIOName(IONames[j]()); ActuatorIOAreaList[j].SetIODesc(""); j++; //IONames[j].Set("T%i.Raw", i); //ActuatorIOAreaList[j]=BaseActuatorIOArea; //ActuatorIOAreaList[j].Id=j; //ActuatorIOAreaList[j].pName=IONames[j](); //j++; } ActuatorIOAreaList[j++]=BaseActuatorIOArea; } AttachClassInfo(nc_Control, &ActuatorIOAreaList[0], &NullFlwGroup); SetActiveOptions(true, true); bOn = 1; //bDoneExtRefs = 0; bAboutToStart = 0; //m_DataBlk.GetSize() = 0; //m_DataBlk = NULL; for (int i=0; i<3; i++) m_StateLine[i] = ""; m_StateLine[0] = "OK"; //SetCount(MaxXMTs); }
void CChartDlg::UpdateChart() { // Get the indexes of all the selected items. int nCount = m_Datasel.GetSelCount(); if(nCount <= 0) return; UpdateData(); m_Chart.ClearAll(); m_Chart.SetAxis(m_dBase+5.0*m_dVary,m_dBase-5.0*m_dVary,m_dBase,m_dVary*4.0); CArray<int,int> aryListBoxSel; aryListBoxSel.SetSize(nCount); m_Datasel.GetSelItems(nCount, aryListBoxSel.GetData()); int nTotal = nCount; CString sCurr; while(nCount > 0) { m_Datasel.GetText(nTotal-nCount--,sCurr); m_Chart.AddData(atof(sCurr)); } }
void CSelectPassenger::OnSelectPassenger() { int selCount = listboxPassenger.GetSelCount(); CArray<PassengerInfo>& passlist = CConfig::GetConfig().GetPassenger(); CArray<int> selectedIndex; selectedIndex.SetSize(selCount); listboxPassenger.GetSelItems(selCount, selectedIndex.GetData()); for(int i = 0; i < passlist.GetCount(); i++) { for(int j = 0; j < selectedIndex.GetCount(); j++) { CString str; listboxPassenger.GetText(selectedIndex[j], str); if(passlist[i].name == str) { selectedpass.Add(passlist[i]); } } } }
void CCollegeTimeTableView::OnInitialUpdate() { CString wdays[]={"MON","TUE","WED","THU","FRI","SAT"}; LinesPerPage=35; PageArray.SetSize(100); /// 100 pages, large enough to avoid mem alloc CRect rect(0,0,509,630); m_master.Create(rect,this, 21111); m_master.SetRowCount(ROWS); m_master.SetColumnCount(COLS); m_master.SetFixedRowCount(); //m_master.SetFixedColumnCount(); for(int i=1;i<7;i++) { m_master.SetColumnWidth(i,68); m_master.SetItemText(0,i,wdays[i-1]); m_master.SetItemFormat(0,i-1,ES_CENTER | ES_UPPERCASE); } m_master.SetItemFormat(0,6,ES_CENTER | ES_UPPERCASE); CRect rect1(509,80,1018,580); m_indiv.Create(rect1,this, 21112); m_indiv.SetRowCount(RO); m_indiv.SetColumnCount(7); m_indiv.SetFixedRowCount(); //m_indiv.SetFixedColumnCount(); for(i=1;i<7;i++) { m_indiv.SetColumnWidth(i,68); m_indiv.SetItemText(0,i,wdays[i-1]); m_indiv.SetItemFormat(0,i-1,ES_CENTER | ES_UPPERCASE | ES_READONLY); } m_indiv.SetColumnWidth(6,68); m_indiv.SetItemFormat(0,6,ES_CENTER | ES_UPPERCASE); m_indiv.SetColumnWidth(0,84); CFormView::OnInitialUpdate(); GetParentFrame()->RecalcLayout(); ResizeParentToFit(); }
BOOL ReadFileList(const char *filelist) { FILE *fp = fopen(filelist, "r"); if (!fp) { printf("Unable to open %s\r\n", filelist); } char line[2048]; int i=0; while (fgets(line, sizeof(line)-1, fp)) { // file.php arg1 arg2 etc. stripcrlf(line); if (strlen(line)>3) { char *p = strchr(line, ' '); if (p) { *p = 0; // get file IsapiFileList.Add(line); IsapiGetData.Add(p+1); } else { // just a filename is all IsapiFileList.Add(line); IsapiGetData.Add(""); } } // future use IsapiPostData.Add(""); IsapiMatchData.Add(""); TestNames.Add(""); i++; } Results.SetSize(TestNames.GetSize()); fclose(fp); return IsapiFileList.GetSize() > 0; }
COLORREF TracedUnitBasinFormula::getColor(Complex z) { static CArray<Complex> s_v; if(s_v.GetSize() != m_nIterations) s_v.SetSize(m_nIterations); Complex zn1, zstart(z); Complex zm3(z), zm2(z), zm1(z); double q = (1-1.0/m_nRoots); int iter; for(iter=0; iter<m_nIterations; ++iter) { zm3 = zm2; zm2 = zm1; zm1 = z; zn1 = pow(zm1, m_nRoots-1); z = zm1*q + 1/(m_nRoots*zn1); double dist=normal(z-zm1); if(dist < m_fBailout) break; } if(m_nRootFlags > 0) { int n = whichRoot(z); if(!(m_nRootFlags & (1<<n))) return 0; } GLcolor c; // good standby: basin rings are hued if(!c.SetHSV(arg(z*(zm2-zm3))*360/6.283, 0.8, tanh(0.1*iter))) // basin rings are busily hued // if(!c.SetHSV(arg(conj(zm2-zm3)*(z-zm1))*360/6.283, 0.8, tanh(0.1*iter))) // hue=direction of landing. try this with wide cutoff ~0.1 // if(!c.SetHSV((znext-z).arg()*360/6.283, 0.8, tanh(0.1*iter))) // with tight cutoff, bright colors--but try with wide (~0.2) for singed colors return 0; return c; }
CLimn_ModelData_ParmDef::CLimn_ModelData_ParmDef(LPCSTR Class, LPCSTR Tag, int Index, LPCTSTR CnvStr, bool IsBool, bool Hide, CArray<CLimn_ModelData_ParmHdr, CLimn_ModelData_ParmHdr&> & RqdHdrs) { m_Class = "DW_"; m_Class += Class; m_Tag = Tag; m_iIndex = Index; m_IsBool=IsBool; m_Hide=Hide; m_ArrayBegin=false; m_ArrayEnd=false; m_ArrayLen=0; for (int i=0; i<RqdHdrs.GetCount(); i++) m_Hdrs.Add(RqdHdrs[i]); RqdHdrs.SetSize(0); #ifdef LIMNDW gs_Cnvs.Create(CnvStr, m_Cnv); if (m_Cnv.m_Txt.GetLength()>0) { int xxx=0; } m_Scale = gs_Cnvs.Scale(m_Cnv); #endif // LIMNDW };
void CChartDlg::OnBnClickedAutoupdate() { // TODO: 在此添加控件通知处理程序代码 //auto size the chart int nCount = m_Datasel.GetSelCount(); if(nCount <= 0) return; CArray<int,int> aryListBoxSel; aryListBoxSel.SetSize(nCount); m_Datasel.GetSelItems(nCount, aryListBoxSel.GetData()); int nTotal = nCount; CString sCurr; double new_base=0; while(nCount > 0) { m_Datasel.GetText(nTotal-nCount--,sCurr); new_base += atof(sCurr); } new_base = new_base/nTotal; nCount = nTotal; double new_vary=0; while(nCount > 0) { m_Datasel.GetText(nTotal-nCount--,sCurr); new_vary += (atof(sCurr)-new_base)*(atof(sCurr)-new_base); } new_vary = sqrt(new_vary/nTotal); m_dBase = new_base; m_dVary = new_vary; UpdateData(FALSE); UpdateChart(); }
Sector CStarmap::CalcPath(const Sector &pos, const Sector &target, unsigned char range, unsigned char speed, CArray<Sector> &path) { AssertBotE(pos.on_map()); AssertBotE(target.on_map()); // bisherige Einträge von path löschen path.RemoveAll(); // gegebene Parameter prüfen if (pos == target // Start == Ziel || range < 1 || range > 3 || m_Range.at(CoordsToIndex(pos.x, pos.y)) < range // Start außerhalb des Gebiets der Reichweite || m_Range.at(CoordsToIndex(target.x, target.y)) < range // Ziel außerhalb der Reichweite || speed < 1) { return Sector(); } // Array zur Berechnung der Koordinaten sämtlicher Nachbarn eines Sektors (schräg/gerade abwechselnd, // mit schräg beginnend) Sector neighbours[8] = {Sector(-1, -1), Sector(0, -1), Sector(1, -1), Sector(1, 0), Sector(1, 1), Sector(0, 1), Sector(-1, 1), Sector(-1, 0)}; // Berechnung neu beginnen? if (pos != pathStart || range != pathRange) { // pathMap zurücksetzen for (int j = 0; j < STARMAP_SECTORS_VCOUNT; j++) for (int i = 0; i < STARMAP_SECTORS_HCOUNT; i++) { /*PathSector *tmp = &(pathMap.at(CoordsToIndex(i, j))); tmp->used = false; tmp->distance = 0.; tmp->hops = 0; tmp->parent.x = tmp->parent.y = -1; tmp->position.x = i; // für Zugriff aus leafList heraus merken tmp->position.y = j;*/ const int index = CoordsToIndex(i, j); pathMap.at(index).used=false; pathMap.at(index).distance=0; pathMap.at(index).hops=0; pathMap.at(index).parent.x=-1; pathMap.at(index).parent.y=-1; pathMap.at(index).position.x=i; pathMap.at(index).position.y=j; } // leaves zurücksetzen leaves.Clear(); // Startknoten zur Liste der auszuwählenden Blätter hinzufügen leaves.Add(&(pathMap.at(CoordsToIndex(pos.x, pos.y)))); // Parameter merken pathStart = pos; pathRange = range; } // ist der Weg zum angegebenen Ziel bereits bekannt? if (pathMap.at(CoordsToIndex(target.x, target.y)).parent.x == -1 || pathMap.at(CoordsToIndex(target.x, target.y)).parent.y == -1) { // kürzeste Wege zu allen anderen Knoten bestimmen, bis uns der Zielknoten über den Weg läuft bool found = false; while (!found) { // Zeiger auf ein neues Blatt mit einer kürzesten Gesamtentfernung zum // Start-Sektor ermitteln PathSector *next = leaves.PopFirst(); if (!next) return Sector(); // keine Knoten mehr, Zielknoten ist nicht erreichbar if (next->used) continue; // Knoten wurde schonmal gewählt // Knoten als ausgewählt markieren next->used = true; // bisher noch nicht ausgewählte Nachbarn innerhalb der Reichweite in leaves // eintragen; // die Nachbarn müssen auch eingetragen werden, wenn next bereits der Zielknoten ist, // da der nächste Aufruf von CalcPath() die Zwischenergebnisse wiederverwendet for (int i = 0; i < 8; i++) { // Koordinaten des Nachbarn ermitteln (Sektoren nur betrachten, wenn sie // noch auf der Starmap liegen!) Sector npos = next->position + neighbours[i]; if (!npos.is_in_rect(0, 0, STARMAP_SECTORS_HCOUNT, STARMAP_SECTORS_VCOUNT)) continue; // nur Nachbarn betrachten, die noch nicht ausgewählt wurden und innerhalb der // Reichweite liegen PathSector *neighb = &(pathMap.at(CoordsToIndex(npos.x, npos.y))); if (neighb->used || m_Range.at(CoordsToIndex(npos.x, npos.y)) < range) continue; // kann der Nachbar über next auf einem kürzeren Weg als bisher erreicht werden, // dann die bisherige Info überschreiben double distance = next->distance + ((i % 2) ? WEIGHT_DIR : WEIGHT_DIAG); // Anomalien beachten distance += m_BadMapModifiers.at(next->position.x + next->position.y * STARMAP_SECTORS_HCOUNT); if (neighb->distance == 0. || distance < neighb->distance) { // (distance ist für alle anderen Sektoren außer dem Start-Sektor > 0., // der Wert 0. weist darauf hin, dass distance noch nicht gesetzt wurde) neighb->distance = distance; neighb->hops = next->hops + 1; neighb->parent = next->position; // den Knoten in leaves neu einsortieren (derselbe Knoten ist evtl. unter // einer anderen Entfernung früher bereits einsortiert worden; da nun die // Entfernung aber kürzer ist, wird das neu einsortierte Element zuerst // gewählt; liefert die Liste eines der vorher eingeordneten Elemente, ist // dessen used-Feld bereits true und es wird sofort mit dem nächsten Eintrag // fortgesetzt); // @TODO besser wäre es, den früher einsortierten Knoten zu entfernen leaves.Add(neighb); } } if (next->position == target) found = true; // Zielknoten gefunden } } // Ziel gefunden; Weg vom Ziel bis zum Startknoten zurück verfolgen, // dabei von hinten beginnend in Array eintragen Sector next = target; int idx = pathMap.at(CoordsToIndex(target.x, target.y)).hops; AssertBotE(idx >= 1); path.SetSize(idx); // Größe des Arrays setzen (= Länge des Weges) while (next.x > -1 && next.y > -1 && --idx >= 0) // Start-Sektor nicht mit eintragen { AssertBotE(next.on_map()); path[idx] = next; next = pathMap.at(CoordsToIndex(next.x, next.y)).parent; } AssertBotE(idx == -1); // entsprechend speed den nächsten Knoten des Weges zurückgeben; bzw. den Zielknoten, // wenn der Weg kürzer ist return path[min(speed - 1, path.GetUpperBound())]; }
void CBCGPTransferFunction::Calculate(CArray<double, double>& output) const { output.RemoveAll(); int size = (int)m_Points.GetSize(); if (size == 0) { return; } int count = (int)fabs((m_InputValueMax - m_InputValueMin) / m_InputValueStep) + 1; if (count == 1) { return; } output.SetSize(count); XPoint pt(m_Points[0]); if (m_InputValueMin < pt.m_Point) { for (int i = 0; i <= GetIndex(pt.m_Point); i++) { output[i] = pt.m_Value; } } if (size > 1) { pt = m_Points[size - 1]; } if (pt.m_Point < m_InputValueMax) { for (int i = GetIndex(pt.m_Point); i < count; i++) { output[i] = pt.m_Value; } } // linear size = (int)m_Points.GetSize (); if (size < 2) { return; } for(long k = size - 1; k >= 1; k--) { CArray<double, double> points; XPoint pt1(m_Points[k - 1]); XPoint pt2(m_Points[k]); int index1 = GetIndex(pt1.m_Point); int index2 = GetIndex(pt2.m_Point); double dY = (pt2.m_Value - pt1.m_Value) / (double)(index2 - index1); double value = pt1.m_Value; for(int i = index1; i <= index2; i++) { points.Add(bcg_clamp(value, m_OutputValueMin, m_OutputValueMax)); value += dY; } if(points.GetSize() <= 2) { continue; } int kInsert = index1; for(int kk = 0; kk <= points.GetSize() - 1; kk++) { output[kInsert++] = points[kk]; } } }
/****************************************************************************** Function Name : OnBnClickedCbtnDissociate Input(s) : Output : Functionality : Call the functions to remove the selected Databases Member of : CDatabaseDissociateDlg Friend of : - Author(s) : Anish Kumar Date Created : 06.12.2006 Modifications : ******************************************************************************/ void CDatabaseDissociateDlg::OnBnClickedCbtnDissociate() { //TO store the path of files dissociated CStringArray aomStrFilesDissociated; CMainFrame* pMainFrame = (CMainFrame*)theApp.m_pMainWnd; // Get the indexes of all the selected items. int nCount = m_omDissociateDbLst.GetSelCount(); if(nCount > 0) { // Array of selected item's position CArray<int,int> aomListBoxSel; aomListBoxSel.SetSize(nCount); //Pass the array pointer to get the selected item's positions m_omDissociateDbLst.GetSelItems(nCount, aomListBoxSel.GetData()); aomStrFilesDissociated.RemoveAll(); for(int nTempCnt = 0 ; nTempCnt < nCount ; nTempCnt++) { BOOL bDBDeleted = FALSE; CString omstrDBPath ; //Selected file's index int nSelectedPos = aomListBoxSel.GetAt(nTempCnt); //Find the length of string to pass the buffer to have the selected File path int nBufferSize = m_omDissociateDbLst.GetTextLen(nSelectedPos); m_omDissociateDbLst.GetText(nSelectedPos,omstrDBPath.GetBuffer(nBufferSize)); bDBDeleted = (*(CMsgSignal**)(m_sDbParams.m_ppvImportedDBs))->bDeAllocateMemory(omstrDBPath.GetBuffer(0)); if(TRUE == bDBDeleted) { aomStrFilesDissociated.Add(omstrDBPath.GetBuffer(0)); } } //To remove from theApp class CStringArray aomstrDBFiles; (*(CMsgSignal**)(m_sDbParams.m_ppvImportedDBs))->vGetDataBaseNames(&aomstrDBFiles); //Delete the file path from the List box int nTotalCount = aomStrFilesDissociated.GetSize(); CString omStrTempFile; for(int nCount=0 ; nCount<nTotalCount ; nCount++) { omStrTempFile = aomStrFilesDissociated.GetAt(nCount); int nIndex = 0; if( (nIndex = m_omDissociateDbLst.FindString(0, omStrTempFile)) != LB_ERR ) { //Delete the file path from the list box m_omDissociateDbLst.DeleteString(nIndex); int nStoredFile = aomstrDBFiles.GetSize(); CString omStrTemp; BOOL bRemoved = FALSE; for(int nTemp = 0 ; nTemp < nStoredFile && bRemoved != TRUE; nTemp++) { omStrTemp = aomstrDBFiles.GetAt(nTemp); if(!(omStrTemp.Compare(omStrTempFile))) { aomstrDBFiles.RemoveAt(nTemp); bRemoved = TRUE; } } } } //Set the new file name array (*(CMsgSignal**)(m_sDbParams.m_ppvImportedDBs))->vSetDataBaseNames(&aomstrDBFiles); // Send a message to Tx Window about database change if( pMainFrame != NULL) { eUSERSELCTION eUserSel = eDATABASEIMPORTCMD; pMainFrame->m_objTxHandler.vPostMessageToTxWnd(WM_USER_CMD, (WPARAM)eUserSel,0); } ////Delete Signal watch list and Graph window list //// Check for Signal Watch & DLL load Condition // BOOL bUserOption = FALSE; if(pMainFrame->m_psSignalWatchList != NULL) { if(theApp.m_bFromAutomation == FALSE) bUserOption = AfxMessageBox(defIMPORT_WARNING, MB_YESNO | MB_DEFBUTTON1 | MB_ICONQUESTION) == IDYES; // If user wants to clear if(bUserOption == TRUE ) { // Clear Signal Watch List pMainFrame->vUpdateSWList(); } } //Added by Arun to update Data Handler Main entry list. //pMainFrame->vUpdateMainEntryListInWaveDataHandler(); //pMainFrame->vClearSignalInfoList(); //if(!pMainFrame->m_ouWaveTransmitter.bIsBlockEnabled()) // theApp.pouGetFlagsPtr()->vSetFlagStatus( SEND_SIGNAL_MSG, FALSE ); //Update Message windows pMainFrame->vUpdateAllMsgWndInterpretStatus(FALSE); // Check for Graph list for(register int nBusID = CAN; nBusID < AVAILABLE_PROTOCOLS; nBusID++) { if( pMainFrame->m_odGraphList[nBusID].m_omElementList.GetSize() > 0 ) { // Get the delete confirmation from the user if(theApp.m_bFromAutomation == FALSE) bUserOption = AfxMessageBox(defIMPORT_WARNING_GRAPH, MB_YESNO | MB_DEFBUTTON1 | MB_ICONQUESTION) == IDYES; // If user wants to clear if(bUserOption == TRUE ) { // Clear Graph List for all buses. for(register int nID = CAN; nID < AVAILABLE_PROTOCOLS; nID++) pMainFrame->m_odGraphList[nID].m_omElementList.RemoveAll(); // Send the Message to the Left View to Update List for all buses if( pMainFrame != NULL ) { pMainFrame->vPostConfigChangeCmdToSigGrphWnds(); } } break; } } } }
void CLimnStream::LoadFeed() { if (!m_bCalculate || m_pFeed==NULL) return; MVector Vec = Vector; if (0) { Dbg.PrintLn("Vector @ LoadFeed"); MVector V=Vector; for (int i=0; i<V.Count(); i++) Dbg.PrintLn("M[%-25s] : %10.4f", gs_MVDefn[i].Symbol(), V.M[i]); Dbg.PrintLn(""); } double OreMass=0; for (int iSG=0; iSG<gs_DWCfg.nSGs(); iSG++) OreMass += Vec.M[gs_DWCfg.OreSpIds(iSG)]; CArray <double, double> OreMasses; OreMasses.SetSize(gs_DWCfg.OreBlockCount()); OreMassFromDensimetricDistribution(&gs_DWCfg, &m_pFeed->m_Densimetrics[0], &m_pFeed->m_OreSizeFeed[0], OreMass,//double totalFlow, &OreMasses[0] ) ; CArray <double, double> DmdDeport; DmdDeport.SetSize(gs_DWCfg.DataBlockCount());//DiamondBlockCount()); DiamondDeportmentFromSGDistribution(&gs_DWCfg, &m_pFeed->m_Densimetrics[0], &m_pFeed->m_OreSizeFeed[0], &m_pFeed->m_DmdSGFeed[0], &m_pFeed->m_DmdSizeFeed[0], Vec.M[gs_DWCfg.DiamondSpId()], &DmdDeport[0]) ; m_Data[gs_DWCfg.iWaterLimnStreamIndex()] = Vec.M[gs_DWCfg.WaterSpId()]; m_Data[gs_DWCfg.iFeSiLimnStreamIndex()] = Vec.M[gs_DWCfg.FeSiSpId()]; //for (int iSz= 0; iSz< gs_DWCfg.nOreSizes(); iSz++ ) // { // Dbg.Print("Densimetrics:"); // for (int iSG= 0 ; iSG< gs_DWCfg.nSGs(); iSG++ ) // Dbg.Print(" %10.4f", m_pFeed->m_Densimetrics[xlIndex(iSz, iSG, gs_DWCfg.nSGs())]); // Dbg.PrintLn(""); // } //Dbg.PrintLn(""); //for (int i= 0 ; i< m_pFeed->m_OreSizeFeed.GetCount(); i++ ) // Dbg.PrintLn("m_OreSizeFeed[%3i] %10.4f", i, m_pFeed->m_OreSizeFeed[i]); //Dbg.PrintLn(""); //for (int i= 0 ; i< m_pFeed->m_DmdSGFeed.GetCount(); i++ ) // Dbg.PrintLn("m_DmdSGFeed[%3i] %10.4f", i, m_pFeed->m_DmdSGFeed[i]); //Dbg.PrintLn(""); //for (int i= 0 ; i< m_pFeed->m_DmdSizeFeed.GetCount(); i++ ) // Dbg.PrintLn("m_DmdSizeFeed[%3i] %10.4f", i, m_pFeed->m_DmdSizeFeed[i]); //Dbg.PrintLn(""); for (int iOSz = 0 ; iOSz < nOreSizes() ; iOSz++ ) { for (int iSG = 0 ; iSG < nSGs(); iSG++ ) { Ore(iOSz, iSG) = OreMasses[xlIndex( iOSz, iSG, nSGs() )] ; } } for (int iDSz = 0 ; iDSz< nDiamondSizes(); iDSz++ ) { for (int iOSz = 0 ; iOSz < nOreSizes() ; iOSz++ ) { for (int iSG = 0 ; iSG < nSGs(); iSG++ ) { Diamond(iDSz, iOSz, iSG)=DmdDeport[gs_DWCfg.iDDIndex(iDSz, iOSz, iSG)]; } } } m_bIsMassForm = true; if (DoDbg) Dump("LoadFeed", DoDbg); ConvertToFracForm(Vector, false); if (DoDbg) Dump("LoadFeed", DoDbg); };