Пример #1
0
NS_IMETHODIMP
InsertTextTransaction::DoTransaction()
{
  if (NS_WARN_IF(!mEditorBase) || NS_WARN_IF(!mTextNode)) {
    return NS_ERROR_NOT_AVAILABLE;
  }

  ErrorResult rv;
  mTextNode->InsertData(mOffset, mStringToInsert, rv);
  if (NS_WARN_IF(rv.Failed())) {
    return rv.StealNSResult();
  }

  // Only set selection to insertion point if editor gives permission
  if (mEditorBase->GetShouldTxnSetSelection()) {
    RefPtr<Selection> selection = mEditorBase->GetSelection();
    if (NS_WARN_IF(!selection)) {
      return NS_ERROR_FAILURE;
    }
    DebugOnly<nsresult> rv =
      selection->Collapse(mTextNode, mOffset + mStringToInsert.Length());
    NS_ASSERTION(NS_SUCCEEDED(rv),
                 "Selection could not be collapsed after insert");
  } else {
    // Do nothing - DOM Range gravity will adjust selection
  }
  mEditorBase->RangeUpdaterRef().
                 SelAdjInsertText(*mTextNode, mOffset, mStringToInsert);

  return NS_OK;
}
Пример #2
0
Файл: BZDoc.cpp Проект: tnzk/bz
DWORD CBZDoc::DoUndo()
{
    DWORD dwSize = *((DWORD*)(m_pUndo+m_dwUndo-4));
    m_dwUndo -= dwSize;
    dwSize -= 9;
    LPBYTE p = m_pUndo + m_dwUndo;
    DWORD dwPtr = *((DWORD*&)p)++;
    UndoMode mode = (UndoMode)*p++;
#ifdef FILE_MAPPING
    QueryMapView(m_pData, dwPtr);
#endif //FILE_MAPPING
    if(mode == UNDO_DEL) {
        DeleteData(dwPtr, *((DWORD*)p));
    } else {
        InsertData(dwPtr, dwSize, mode == UNDO_INS);
        memcpy(m_pData+dwPtr, p, dwSize);
    }
    if(m_dwUndo)
        m_pUndo = (LPBYTE)MemReAlloc(m_pUndo, m_dwUndo);
    else {				// ### 1.54
        MemFree(m_pUndo);
        m_pUndo = NULL;
        if(m_dwUndoSaved)
            m_dwUndoSaved = UINT_MAX;
    }
    // if(!m_pUndo)
    TouchDoc();
    return dwPtr;
}
Пример #3
0
int main()
{
    printf("Enter the queue size: ");
    scanf("%d", &iMax);
    int iChoice;
    while(1)
    {
        printf("\n1. Enqueue\n2. Dequeue\n3. Display\n4. Exit\nEnter your choice:");
        scanf("%d", &iChoice);
        switch(iChoice)
        {
            case 1:
                InsertData();
                break;
            case 2:
                DeleteValue();
                break;
            case 3:
                DisplayQueue();
                break;
            case 4:
                return 0;
        }
    }
    return 0;
}
Пример #4
0
//******************************************************************************************************************************************************
//******************************************************************************************************************************************************
ierr Processor::ProcessDataTsRange(mxArray *plhs[])
{
	int numRecs = mDataBucket.GetDataSourceNumRecs(0);
	if( numRecs <= 0 ) { return(0); }

	if( mModeParameters[0] > mModeParameters[1] ) {
		mexPrintf("\tError Processing File, Timestamp Range Values are not in Increasing Order.\n");
		return(-1);
	}

	EventRec* rec = NULL;
	int recs2Process = 0;
	int initialRecIndex = -1;
	for( int i = 0; i < numRecs; i++ ) {
		mDataBucket.GetData(i, 0, (void**)(&rec));
		if( (rec->qwTimeStamp >= mModeParameters[0]) && (rec->qwTimeStamp <= mModeParameters[1]) ) {
			if( initialRecIndex == -1 ) {
				initialRecIndex = i;
			}
			recs2Process++;
		}
	}

	if( AllocateOuputVariables(plhs, recs2Process ) != Nlx2MatOK ) { return(-1); }

	int index = 0;
	for( int i = initialRecIndex; i < initialRecIndex+recs2Process; i++ ) {
		mDataBucket.GetData(i, 0, (void**)(&rec));
		InsertData(rec, index);
		index++;
	}

	return(0);
}
Пример #5
0
//******************************************************************************************************************************************************
//******************************************************************************************************************************************************
ierr Processor::ProcessDataRecRange(mxArray *plhs[])
{
	int numRecs = mDataBucket.GetDataSourceNumRecs(0);
	if( numRecs <= 0 ) { return(0); }

	if( mModeParameters[0] > mModeParameters[1] ) {
		mexPrintf("\tError Processing File, Record Range Values are not in Increasing Order.\n");
		return(-1);
	}

	if( mModeParameters[1] >= numRecs ) {
		mModeParameters[1] = numRecs - 1;
	}

	int recs2Process = (int)(mModeParameters[1] - mModeParameters[0] + 1);
	if( recs2Process <= 0 ) { return(-1); }

	if( AllocateOuputVariables(plhs, recs2Process ) != Nlx2MatOK ) { return(-1); }

	EventRec* rec = NULL;
	int index = 0;
	for( int i = (int)(mModeParameters[0]); i <= (int)(mModeParameters[1]); i++ ) {
		mDataBucket.GetData(i, 0, (void**)(&rec));
		InsertData(rec, index);
		index++;
	}
	return(0);
}
Пример #6
0
void CViewData::InsertData(int index, const CString& sLine, DiffStates state, int linenumber, EOL ending)
{
	viewdata data;
	data.sLine = sLine;
	data.state = state;
	data.linenumber = linenumber;
	data.ending = ending;
	return InsertData(index, data);
}
//XXX: We may want to store the selection state and restore it properly.  Was
//     it an insertion point or an extended selection?
NS_IMETHODIMP
DeleteTextTransaction::UndoTransaction()
{
  if (NS_WARN_IF(!mCharData)) {
    return NS_ERROR_NOT_INITIALIZED;
  }
  ErrorResult rv;
  mCharData->InsertData(mOffset, mDeletedText, rv);
  return rv.StealNSResult();
}
Пример #8
0
void CViewData::InsertData(int index, const CString& sLine, DiffStates state, int linenumber, EOL ending, HIDESTATE hide, int movedIndex)
{
    viewdata data;
    data.sLine = sLine;
    data.state = state;
    data.linenumber = linenumber;
    data.ending = ending;
    data.hidestate = hide;
    data.movedIndex = movedIndex;
    return InsertData(index, data);
}
Пример #9
0
float sizePrint(int bound)
{
	//printf("The PhoneBook size Before : %lu\n",sizeof(PhoneOrigin));
	//printf("The PhoneBook size After : %lu\n",sizeof(PhoneBook));
	init();
	int x,y;
	InsertData("John");
	for(x = 0;x<bound;x++)
	{
		InsertData(randData());
	}
	
	//Show();
	float startTime = 0 , endTime = 0;
	startTime = (float)clock()/CLOCKS_PER_SEC;
	find();
	endTime = (float)clock()/CLOCKS_PER_SEC;
	//printf("The split struct time \n%f\n",endTime-startTime);
	empty();
	return endTime-startTime;
}
NS_IMETHODIMP
CompositionTransaction::DoTransaction() {
  if (NS_WARN_IF(!mEditorBase)) {
    return NS_ERROR_NOT_INITIALIZED;
  }

  // Fail before making any changes if there's no selection controller
  nsCOMPtr<nsISelectionController> selCon;
  mEditorBase->GetSelectionController(getter_AddRefs(selCon));
  NS_ENSURE_TRUE(selCon, NS_ERROR_NOT_INITIALIZED);

  // Advance caret: This requires the presentation shell to get the selection.
  if (mReplaceLength == 0) {
    ErrorResult rv;
    mTextNode->InsertData(mOffset, mStringToInsert, rv);
    if (NS_WARN_IF(rv.Failed())) {
      return rv.StealNSResult();
    }
    mEditorBase->RangeUpdaterRef().SelAdjInsertText(*mTextNode, mOffset,
                                                    mStringToInsert);
  } else {
    uint32_t replaceableLength = mTextNode->TextLength() - mOffset;
    ErrorResult rv;
    mTextNode->ReplaceData(mOffset, mReplaceLength, mStringToInsert, rv);
    if (NS_WARN_IF(rv.Failed())) {
      return rv.StealNSResult();
    }
    mEditorBase->RangeUpdaterRef().SelAdjDeleteText(mTextNode, mOffset,
                                                    mReplaceLength);
    mEditorBase->RangeUpdaterRef().SelAdjInsertText(*mTextNode, mOffset,
                                                    mStringToInsert);

    // If IME text node is multiple node, ReplaceData doesn't remove all IME
    // text.  So we need remove remained text into other text node.
    if (replaceableLength < mReplaceLength) {
      int32_t remainLength = mReplaceLength - replaceableLength;
      nsCOMPtr<nsINode> node = mTextNode->GetNextSibling();
      while (node && node->IsText() && remainLength > 0) {
        Text* text = static_cast<Text*>(node.get());
        uint32_t textLength = text->TextLength();
        text->DeleteData(0, remainLength, IgnoreErrors());
        mEditorBase->RangeUpdaterRef().SelAdjDeleteText(text, 0, remainLength);
        remainLength -= textLength;
        node = node->GetNextSibling();
      }
    }
  }

  nsresult rv = SetSelectionForRanges();
  NS_ENSURE_SUCCESS(rv, rv);

  return NS_OK;
}
Пример #11
0
BOOL CFoulerDoc::OpenCCA(HANDLE hFileRead)
{
	char cHeader[32];
	double dData = 0;
	DWORD nCount;
	DWORD dwHighSize, dwLowSize;
	int i;
	ZeroMemory( cHeader, sizeof(cHeader) );
	dwLowSize = GetFileSize( hFileRead, &dwHighSize );
	SetFilePointer( hFileRead, 0, NULL, FILE_BEGIN);
	ReadFile( hFileRead, cHeader, 32, &nCount, NULL );
	if( strcmp( cHeader, "Control Chart Analyzer File" ) != 0 ) return FALSE;
	int itemno = 0;
	ReadFile( hFileRead, &itemno, sizeof(itemno), &nCount, NULL );
	if( itemno < 0 ) return FALSE;
	if( dwLowSize < itemno*sizeof(dData)+32+sizeof(itemno)+sizeof(m_histogram)+sizeof(m_shewart)+sizeof(m_cusum)+sizeof(m_sprt) ) return FALSE;
	ClearData();
	ReadFile( hFileRead, &m_histogram, sizeof(m_histogram), &nCount, NULL );
	ReadFile( hFileRead, &m_shewart, sizeof(m_shewart), &nCount, NULL );
	ReadFile( hFileRead, &m_cusum, sizeof(m_cusum), &nCount, NULL );
	ReadFile( hFileRead, &m_sprt, sizeof(m_sprt), &nCount, NULL );
	double* pData;
	pData = new double[itemno];
	ReadFile( hFileRead, pData, sizeof(dData)*itemno, &nCount, NULL );
	double *dp;
	dp = pData;
	CProgressBar* pBar = new CProgressBar();
	InsertData( itemno );
	for( i=0 ; i<itemno ; i++ )
	{
		m_pOrgData[i]->SetItem( *dp );
		m_iSubGroupIndex++;
		if( m_iSubGroupIndex >= m_iSubGroupSize )
		{
			m_iSubGroupIndex = 0;
			dData = 0;
			for( int j=i+1-m_iSubGroupSize ; j<i+1 ; j++ )
			{
				dData += m_pOrgData[j]->GetItem();
			}
			m_pData[i/m_iSubGroupSize]->SetItem(dData/m_iSubGroupSize);
			AnalysisData();
		}
		dp++;
		pBar->SetPos( (i<<8)/itemno );
	}
	delete[] pData;
	delete pBar;
	return TRUE;
}
Пример #12
0
//******************************************************************************************************************************************************
//******************************************************************************************************************************************************
ierr Processor::ProcessDataAll(mxArray *plhs[])
{
	int numRecs = mDataBucket.GetDataSourceNumRecs(0);
	if( numRecs <= 0 ) { return(0); }

	if( AllocateOuputVariables(plhs, numRecs ) != Nlx2MatOK ) { return(-1); }

	EventRec* rec = NULL;
	for( int i = 0; i < numRecs; i++ ) {
		mDataBucket.GetData(i, 0, (void**)(&rec));
		InsertData(rec, i);
	}
	return(0);
}
Пример #13
0
void CFoulerDoc::AddDataFromText(DWORD dwSize, char *pHeader)
{
	char seps[] = "abcdfghijklmnopqrstuvwxyzABCDFGHIJKLMNOPQRSTUVWXYZ= ,\t\n:()";
	char *token, *cpTextData;
	int i, iOrg, iData, itemno, iIndex;
	double dData;
	BeginWaitCursor();
	for (DWORD dw = 0; dw < dwSize; dw++)
	{
		if (pHeader[dw] == NULL) pHeader[dw] = ' ';
	}
	cpTextData = new char[dwSize];
	memcpy( cpTextData, pHeader, dwSize );
	itemno = GetItemNo( cpTextData );
	delete[] cpTextData;
	if( itemno < 1 ) return;
	CProgressBar* pBar = new CProgressBar();
	iData = m_iNo;
	iOrg = m_iOriginNo;
	InsertData( itemno );
	iIndex = 0;
	token = strtok( pHeader, seps );
	while( token!= NULL )
	{
		dData = atof(token);
		if( dData != 0 )
		{
			m_pOrgData[iOrg]->SetItem( dData );
			m_iSubGroupIndex++;
			if( m_iSubGroupIndex >= m_iSubGroupSize )
			{
				m_iSubGroupIndex = 0;
				dData = 0;
				for( i=iOrg+1-m_iSubGroupSize ; i<iOrg+1 ; i++ )
				{
					dData += m_pOrgData[i]->GetItem();
				}
				m_pData[iData]->SetItem(dData/m_iSubGroupSize);
				iData++;
				AnalysisData();
			}
			iOrg++;
			iIndex++;
			pBar->SetPos((iIndex<<8)/itemno);
		}
		token = strtok( NULL, seps );
	}
	delete pBar;
	EndWaitCursor();
}
Пример #14
0
void ProcessForm::ProcessData(WPARAM wp)
{
	DispatchData* data = (DispatchData*)wp;
	control_header* header = data->recvData.header;
	unsigned short cmd = header->command;
	unsigned short resp = header->response;
	int dataLen = header->dataLen;
	int seq = header->seq;
	void* body = data->recvData.body;
	
	if(cmd == CONTROL_ENUM_PROCS)
	{
		if(resp != 0)	OnOperationFailed(cmd, resp);
		else			InsertData(body, dataLen, seq);
	}
	else if(resp != 0)	OnOperationFailed(cmd, resp);
}
Пример #15
0
Файл: BZDoc.cpp Проект: tnzk/bz
DWORD CBZDoc::PasteFromClipboard(DWORD dwPtr, BOOL bIns)
{
    AfxGetMainWnd()->OpenClipboard();
    HGLOBAL hMem;
    DWORD dwSize;
    LPBYTE pMem;
    if(hMem = ::GetClipboardData(RegisterClipboardFormat("BinaryData2"))) {
        pMem = (LPBYTE)::GlobalLock(hMem);
        dwSize = *((DWORD*)(pMem));
        pMem += sizeof(DWORD);
    } else if(hMem = GetClipboardData(CF_TEXT)) {
        pMem = (LPBYTE)::GlobalLock(hMem);
        dwSize = lstrlen((LPCSTR)pMem);
    } else {
        /*		UINT uFmt = 0;
        		while(uFmt = ::EnumClipboardFormats(uFmt)) {
        			CString sName;
        			::GetClipboardFormatName(uFmt, sName.GetBuffer(MAX_PATH), MAX_PATH);
        			sName.ReleaseBuffer();
        			TRACE("clip 0x%X:%s\n", uFmt, sName);
        		}

        		return 0;
        */		if(!(hMem = ::GetClipboardData(::EnumClipboardFormats(0))))
            return 0;
        pMem = (LPBYTE)::GlobalLock(hMem);
        dwSize = ::GlobalSize(hMem);
    }
    if(!dwSize) return 0;
#ifdef FILE_MAPPING
    if(IsFileMapping()) {
        int nGlow = dwSize - (m_dwTotal - dwPtr);
        if(nGlow > 0)
            dwSize -= nGlow;
    }
#endif //FILE_MAPPING
    if(bIns || dwPtr == m_dwTotal)
        StoreUndo(dwPtr, dwSize, UNDO_DEL);
    else
        StoreUndo(dwPtr, dwSize, UNDO_OVR);
    InsertData(dwPtr, dwSize, bIns);
    memcpy(m_pData+dwPtr, pMem, dwSize);
    ::GlobalUnlock(hMem);
    ::CloseClipboard();
    return dwPtr+dwSize;
}
Пример #16
0
//******************************************************************************************************************************************************
//******************************************************************************************************************************************************
ierr Processor::ProcessDataTsList(mxArray *plhs[])
{
	int numRecs = mDataBucket.GetDataSourceNumRecs(0);
	if( numRecs <= 0 ) { return(0); }

	if( AllocateOuputVariables(plhs, mNumModeParameters ) != Nlx2MatOK ) { return(-1); }

	EventRec* rec = NULL;
	int index = 0;
	for( int i = 0; i < mNumModeParameters; i++ ) {
		mDataBucket.GetData((unsigned __int64)(mModeParameters[i]), 0, (void**)(&rec));
		if( rec->qwTimeStamp == mModeParameters[i]) {
			InsertData(rec, index);
			index++;
		}
	}
	return(0);
}
Пример #17
0
//******************************************************************************************************************************************************
//******************************************************************************************************************************************************
ierr Processor::ProcessDataRecList(mxArray *plhs[])
{
	int numRecs = mDataBucket.GetDataSourceNumRecs(0);
	if( numRecs <= 0 ) { return(0); }

	if( AllocateOuputVariables(plhs, mNumModeParameters ) != Nlx2MatOK ) { return(-1); }

	EventRec* rec = NULL;
	int index = 0;
	for( int i = 0; i < mNumModeParameters; i++ ) {
		if( (mModeParameters[i] >= 0) && (mModeParameters[i] < numRecs) ) {
			mDataBucket.GetData((int)(mModeParameters[i]), 0, (void**)(&rec));
			InsertData(rec, index);
			index++;
		}
	}
	return(0);
}
bool D3DVertexBufferCache::InitBuffer(D3DDevice *d3d, BYTE *data, int size, CacheEntryInfo &info)
{
   assert(d3d != NULL);
   assert(data != NULL);
   assert(size > 0);

   int best = FindBestEntry(size);
   CacheEntry *ce = NULL;

   // Reallocate
   if (best >= 0 && _cache[best].size < size)
   {
      DeleteEntry(best);
      best = -1;
   }

   // New
   if (best < 0)
   {
      CacheEntry new_entry;
      if (!CreateEntry(d3d, new_entry, size))
      {
	WRN("Failed to create new vbcache entry");
         return false;
      }
      _cache.Add(new_entry);
      info.id = _cache.Length() - 1;
      ce = _cache.Last();
   }
   else
   {
      info.id = best;
      ce = &_cache[best];
   }

   assert(ce != NULL);
   if (!InsertData(*ce, data, size))
   {
      WRN("Failed to insert vbcache data");
      return false;
   }
   return true;
}
Пример #19
0
uint32 BinaryParser_Private::DecodingFromBinary(const uint8 * buffer)
{
	uint32 ret = 0;
	std::string tag = "";
	DataType tp;
	uint32 len = 0;
	while(buffer[ret] != 0)
	{
		tag = "";
		while(buffer[ret] != 0)
			tag += char(buffer[ret++]);
		tp = DataType(buffer[ret++]);
		len = *reinterpret_cast<uint32*>(buffer[++ret]);
		ret += 8;
		InsertData(tag, tp, len, buffer + ret);
		ret += len;
	}
	return ret + 1;
}
  bool MTDownloader::Download(CefString &url , CefString &file) {

      ThNode thNode;          
      YTD_PAIR &fileInfo = thNode.fileInfo;
      
      YTD_PAIR_KEY(fileInfo) = url;
      YTD_PAIR_VALUE(fileInfo) = file;

      thNode.interrupt = 0;

      DWORD thId;
      
      thNode.handle = CreateThread(NULL, 0, SpawnDownload,
          this, 0, &thId);
      if(NULL == thNode.handle) {
          return false;
      }
      
      InsertData(thId, thNode);
      return true;
  }
Пример #21
0
void open_list(LIST* plist,FILE* fp){
	char ch = 'a';
	int col = 0;
	int i = 0;

	ListNode* line = plist->head;

	while(ch != '\0'){
		while(col < max_col){
			ch = fgetc(fp);
			if(ch == '\0')
				break;
			if(ch != 94)
				printf("%c",ch);
			else
				printf(" ");
			InsertData(plist,line->key,col,ch);
			col++;
		}
		if(ch == '\0'){
//			DeleteLine(plist,line->key);//if don't delete line, add 1 line
//			return;
			break;
		}
		if((ch = fgetc(fp)) == ' '){
			line->data[max_col] = ' ';
		}
		printf("\n");
		line = InsertLine(plist,line->key);

		col = 0;
	}//end while '\0'
	DeleteLine_N(plist,line->next);
//	printf("tail %d",plist->tail->key);
//	KEY_view(plist);
	return ;
}
Пример #22
0
LRESULT CMemoryView::OnInfoProc(WPARAM wParam, LPARAM lParam){
	
	
	ePipeline* Info = (ePipeline*)wParam;
	
	int64 Type = Info->PopInt();
	int64 Cmd  = Info->PopInt();
	
	if (Type == INSTANCE_OBJECT)
	{
		if(Cmd == CREATE_INSTANCE){
			ePipeline* ObjData = (ePipeline*)Info->GetData(0);
			CreateObjectInstance(ObjData);
		}else if (Cmd == NAME_INSTANCE)
		{
			tstring SrceObjectName = Info->PopString();
			int64 InstanceID = Info->PopInt();
			tstring InstanceName = Info->PopString();
			NameObjectInstance(SrceObjectName,InstanceID,InstanceName);

		}else if (Cmd == CLOSE_INSTANCE)
		{
			tstring SrceObjectName = Info->PopString();
			int64 InstanceID = Info->PopInt();
			CloseObjectInstance(SrceObjectName,InstanceID);
		}
	} 
	else if(Type == INSTANCE_DATA)
	{
		switch(Cmd){
		case CREATE_INSTANCE:
			{
				tstring InstanceName = Info->PopString();
				CreateDataInstance(InstanceName);
			}
			break;
		case INSERT_DATA:
			{
				tstring InstanceName = Info->PopString();
				int32 Index = Info->PopInt();

				ePipeline* Data = (ePipeline*)Info->GetData(0);

				InsertData(InstanceName,Index,Data);
			}
			break;
		case MODIFY_DATA:
			{
				tstring InstanceName = Info->PopString();
				int32 Index = Info->PopInt();

				ePipeline* Data = (ePipeline*)Info->GetData(0);

				ModifyData(InstanceName,Index,Data);

			}
			break;
		case REMOVE_DATA:
			{
				tstring InstanceName = Info->PopString();
				int32 Index = Info->PopInt();
				RemoveData(InstanceName,Index);
			}
			break;
		case CLOSE_INSTANCE:
			{
				tstring InstanceName = Info->PopString();
				CloseDataInstance(InstanceName);
			}
			break;
		case IMPORT_DATA:
			{
				tstring InstanceName = Info->PopString();
				ePipeline* DataList = (ePipeline*)Info->GetData(0);
				ImportData(InstanceName,DataList);
			}
			break;
		case EXPORT_DATA:
			{
				tstring InstanceName = Info->PopString();
				ExportData(InstanceName);
			}
			break;
		default:
			assert(0);
			break;
		}
	}
	m_Toolbar.m_Owner = NULL;
	m_SpaceSelected = NULL;
	m_SpaceFocused  = NULL;
	Layout();
	return 0;	
}
bool CDeveloperListDataManager::AddData( CDeveloperData newData, QString *errStr )
{
  return InsertData( newData, ULONG_MAX, errStr );
}
Пример #24
0
void CharacterData::AppendData(const nsAString& aData, ErrorResult& aRv) {
  InsertData(mText.GetLength(), aData, aRv);
}
Пример #25
0
void CFoulerDoc::OnEditNewdata() 
{
	double dAverage=0, dDeviation=0, dMoveRate=0;
	int i=0, iNo = 0;
	char cStr[64];
	if( m_generator.GetReady() )
	{
		iNo = 0;
		dAverage = m_generator.GetAverage();
		dDeviation = m_generator.GetDeviation();
		dMoveRate = m_generator.GetMoveRate();
	}
	else
	{
		iNo = 0;
		dAverage = 0;
		dDeviation = 1;
		dMoveRate = 0;
	}
	CNewData dlg( dAverage, iNo, dDeviation, dMoveRate );
	if( dlg.DoModal() == IDCANCEL ) return;
	BeginWaitCursor();
	m_generator.SetReady(TRUE);
	m_generator.SetAverage(dlg.m_average);
	m_generator.SetDeviation(dlg.m_deviation);
	m_generator.SetGenMode(dlg.m_iGenMode);
	m_generator.SetMoveRate(dlg.m_moverate);
	CMainFrame *pFrame = (CMainFrame*)AfxGetMainWnd();
	ZeroMemory( cStr, sizeof(cStr) );
	sprintf( cStr, "%f", m_generator.GetAverage() );
	if( pFrame != NULL ) pFrame->m_edit.SetWindowText( cStr );
	m_dIndex += dlg.m_datano;
	CProgressBar* pBar = new CProgressBar();
	iNo = m_iNo;
	InsertData( dlg.m_datano );
	for( i=iNo ; i<m_iNo ; i++ )
	{
		m_pOrgData[i]->SetItem( m_generator.Gen() );
		m_iSubGroupIndex++;
		if( m_iSubGroupIndex >= m_iSubGroupSize )
		{
			m_iSubGroupIndex = 0;
			dAverage = 0;
			for( int j=i+1-m_iSubGroupSize ; j<i+1 ; j++ )
			{
				dAverage += m_pOrgData[j]->GetItem();
			}
			m_pData[i/m_iSubGroupSize]->SetItem(dAverage/m_iSubGroupSize);
			AnalysisData();
		}
		pBar->SetPos( ((i-iNo)<<8)/dlg.m_datano );
	}
	delete pBar;

	if( m_histogram.GetReady() == FALSE )
	{
		EndWaitCursor();
		OnEditAnalysis();
		BeginWaitCursor();
	}
	m_pRightView->Refresh();
	ChangeViewMode(m_iViewMode);
	EndWaitCursor();
}
Пример #26
0
BOOL CFoulerDoc::OpenXLS(CString sFile)
{
	int i;
	double dData;
	CDatabase db;
	CString sSql;
	CString sItem;
	CString sDsn;
	CODBCFieldInfo fieldinfo;
	CMainFrame *pFrame = (CMainFrame*)AfxGetMainWnd();
	if( pFrame->m_strExcelDriver.IsEmpty() ) return FALSE;
	sDsn.Format("ODBC;DRIVER={%s};DSN='';DBQ=%s",pFrame->m_strExcelDriver,sFile);
	TRY
	{
		db.Open(NULL,FALSE,TRUE,sDsn);// Open the db using the former created pseudo DSN
		CRecordset rs( &db );// Allocate the recordset
		sSql = "SELECT * FROM Data";// Build the SQL string
		rs.Open(CRecordset::forwardOnly,sSql,CRecordset::readOnly);// Execute that query (implicitly by opening the recordset)
		CFieldSelect dlg(&rs);
		if( dlg.DoModal() == IDCANCEL )
		{
			rs.Close();
			db.Close();
			return FALSE;
		}
		BeginWaitCursor();
		while( !rs.IsEOF() ) rs.MoveNext();
		int iRecCount = (int)(rs.GetRecordCount());
		rs.Close();
		rs.Open(CRecordset::forwardOnly,sSql,CRecordset::readOnly);

		CProgressBar* pBar = new CProgressBar();
		ClearData();
		InsertData( iRecCount );
		for( i=0 ; i<iRecCount ; i++ )
		{
			rs.GetFieldValue(dlg.m_sField0,sItem);
			dData = atof(sItem)+dlg.m_dCo0;
			if( dlg.m_sField1 >= 0 && dlg.m_dCo1 != 0)
			{
				rs.GetFieldValue(dlg.m_sField1,sItem);
				dData += atof(sItem)*dlg.m_dCo1;
			}
			if( dlg.m_sField2 >= 0 && dlg.m_dCo2 != 0)
			{
				rs.GetFieldValue(dlg.m_sField2,sItem);
				dData += atof(sItem)*dlg.m_dCo2;
			}
			if( dlg.m_sField3 >= 0 && dlg.m_dCo3 != 0)
			{
				rs.GetFieldValue(dlg.m_sField3,sItem);
				dData += atof(sItem)*dlg.m_dCo3;
			}
			
			m_pOrgData[i]->SetItem( dData );
			m_iSubGroupIndex++;
			if( m_iSubGroupIndex >= m_iSubGroupSize )
			{
				m_iSubGroupIndex = 0;
				dData = 0;
				for( int j=i+1-m_iSubGroupSize ; j<i+1 ; j++ )
				{
					dData += m_pOrgData[j]->GetItem();
				}
				m_pData[i/m_iSubGroupSize]->SetItem(dData/m_iSubGroupSize);
			}
			rs.MoveNext();
			pBar->SetPos( (i<<8)/iRecCount );
		}
		delete pBar;
		rs.Close();
		db.Close();
		EndWaitCursor();
		return TRUE;
	}
	CATCH(CDBException, e)
	{
		return FALSE;// A db exception occured. Pop out the details...
	}
	END_CATCH;
}