bool Graph::Init() { double Margin; if(m_bIsPrinting) { Margin = 1500; } else { Margin = m_iMargin; } //graph width and height m_w = m_rCltRect.width() -2*Margin; m_h = m_rCltRect.height() -2*Margin; SetXScale(); SetYScale(); if(m_bXAutoMinGrid) m_XMinorUnit = xunit/5.0; if(m_bYAutoMinGrid) m_YMinorUnit = yunit/5.0; return true; }
void CSkyBox::Initialize(LPDIRECT3DDEVICE9 pDevice, float fWidth, float fRotSpeed, D3DXVECTOR3 vecPos) { m_pDevice = pDevice; m_fRotateSpeed = fRotSpeed; SetXScale(fWidth); SetYScale(fWidth); SetZScale(fWidth); SetXPosition(vecPos.x); SetYPosition(vecPos.y); SetZPosition(vecPos.z); SKYBOXVERTEX skyboxVertex[] = { {0.5f, -0.5f, 0.5f, 0.0f, 1.0f}, //Right {0.5f, 0.5f, 0.5f, 0.0f, 0.0f}, {0.5f, -0.5f, -0.5f, 1.0f, 1.0f}, {0.5f, 0.5f, -0.5f, 1.0f, 0.0f}, {0.5f, -0.5f, -0.5f, 0.0f, 1.0f}, //Back {0.5f, 0.5f, -0.5f, 0.0f, 0.0f}, {-0.5f, -0.5f, -0.5f, 1.0f, 1.0f}, {-0.5f, 0.5f, -0.5f, 1.0f, 0.0f}, {-0.5f, -0.5f, -0.5f, 0.0f, 1.0f}, //Left {-0.5f, 0.5f, -0.5f, 0.0f, 0.0f}, {-0.5f, -0.5f, 0.5f, 1.0f, 1.0f}, {-0.5f, 0.5f, 0.5f, 1.0f, 0.0f}, {-0.5f, -0.5f, 0.5f, 0.0f, 1.0f}, //Front {-0.5f, 0.5f, 0.5f, 0.0f, 0.0f}, {0.5f, -0.5f, 0.5f, 1.0f, 1.0f}, {0.5f, 0.5f, 0.5f, 1.0f, 0.0f}, {0.5f, 0.5f, 0.5f, 0.0f, 0.0f}, //up {-0.5f, 0.5f, 0.5f, 1.0f, 0.0f}, {0.5f, 0.5f, -0.5f, 0.0f, 1.0f}, {-0.5f, 0.5f, -0.5f, 1.0f, 1.0f}, {-0.5f, -0.5f, 0.5f, 0.0f, 0.0f}, //down {0.5f, -0.5f, 0.5f, 0.0f, 1.0f}, {-0.5f, -0.5f, -0.5f, 1.0f, 0.0f}, {0.5f, -0.5f, -0.5f, 1.0f, 1.0f}, }; m_pDevice->CreateVertexBuffer(sizeof(skyboxVertex), 0, D3DFVF_SKYBOX, D3DPOOL_MANAGED, &m_pVertexBuffer,NULL); void * pVertices; m_pVertexBuffer->Lock(0, 0, &pVertices, 0); memcpy(pVertices,(void *)skyboxVertex,sizeof(skyboxVertex)); m_pVertexBuffer->Unlock(); }
void CGelView::OnRungel() { // TODO: Add your control notification handler code here CGenedocDoc *pDoc = GetDocument(); // MakeGel(m_listSequences, m_listEnzymes); // pDoc->SetModifiedFlag(); // CListBox int iSeqCount, iEnzCount; iSeqCount = m_listSequences.GetSelCount(); iEnzCount = m_listEnzymes.GetSelCount(); if ( iSeqCount < 1 || iEnzCount < 1 ) { return; } BeginWaitCursor(); int *arrSeq = new int[iSeqCount]; int *arrEnz = new int[iEnzCount]; m_listSequences.GetSelItems( iSeqCount, arrSeq ); m_listEnzymes.GetSelItems( iEnzCount, arrEnz ); POSITION sPos = m_listGel.GetHeadPosition(); while ( sPos != NULL ) { delete (SGel*)m_listGel.GetNext(sPos); } m_listGel.RemoveAll(); int s, e; for ( s=0; s < iSeqCount; ++s ) { POSITION aPos = pDoc->pGSFiller->SegDataList.FindIndex( arrSeq[s] + 2 ); CGeneSegment *tCGSeg = (CGeneSegment *)pDoc->pGSFiller->SegDataList.GetAt(aPos); GeneStor *pGS = (GeneStor *)GlobalLock( tCGSeg->GetTextHandle() ); // CList NewBand(tCGSeg); for ( e=0; e < iEnzCount; ++e ) { POSITION ePos = pDoc->m_UserVars.listSearch.FindIndex( arrEnz[e] ); stcSearch *Enzyme = (stcSearch *)pDoc->m_UserVars.listSearch.GetAt(ePos); SearchRebaseGel( Enzyme, pGS, tCGSeg->GetTextLength() ); } GlobalUnlock( tCGSeg->GetTextHandle() ); } CUIntArray arrFrags; DWORD MaxLength = 0; sPos = m_listGel.GetHeadPosition(); while ( sPos != NULL ) { SGel *pSGel = (SGel *)m_listGel.GetNext(sPos); DWORD iLen = pSGel->Sequence->GetLastResidue(); if ( iLen > MaxLength ) MaxLength = iLen; } SetYScale ( 0, MaxLength ); sPos = m_listGel.GetHeadPosition(); while ( sPos != NULL ) { SGel *pSGel = (SGel *)m_listGel.GetNext(sPos); int iArr = pSGel->arrCutLoc.GetSize(); // This code sorts the cut locations for ( int ti=0; ti < iArr - 1; ++ti ) { for ( int tj=0; tj < iArr - 1; ++tj ) { if ( pSGel->arrCutLoc[tj] > pSGel->arrCutLoc[tj+1] ) { int t = pSGel->arrCutLoc[tj]; pSGel->arrCutLoc[tj] = pSGel->arrCutLoc[tj+1]; pSGel->arrCutLoc[tj+1] = t; } } } // Calculate Fragment lengths .. DWORD LastCutLoc = 0; int i; for ( i=0; i < iArr; ++i ) { if ( pSGel->arrCutLoc[i] == LastCutLoc ) continue; int cl = pSGel->arrCutLoc[i] - LastCutLoc; arrFrags.Add( cl ); LastCutLoc = pSGel->arrCutLoc[i]; } arrFrags.Add( pSGel->Sequence->GetLastResidue() - LastCutLoc ); // This code sorts the fragment lengths in case that is useful. // for ( ti=0; ti < arrFrags.GetSize() - 1; ++ti ) { // for ( int tj=0; tj < arrFrags.GetSize()-1; ++tj ) { // if ( arrFrags[tj] > arrFrags[tj+1] ) { // int t = arrFrags[tj]; // arrFrags[tj] = arrFrags[tj+1]; // arrFrags[tj+1] = t; // } // } // } iArr = arrFrags.GetSize(); for ( i=0; i < iArr; ++i ) { int iFragLength = arrFrags[i]; // Normalize fragments to 0 to 1.0 // double GelLocPerc = 1.0 - (log((double)iFragLength) / log((double)MaxLength)); // double GelLocPerc = 1.0 - ((double)iFragLength / (double)MaxLength); DWORD GelLocPerc = (DWORD)(((double)iFragLength / (double)MaxLength) * 100000000.0); // Put Normalized resuls into array for GelObject to draw. pSGel->arrGelLoc.Add(GelLocPerc); } arrFrags.RemoveAll(); } delete arrSeq; delete arrEnz; EndWaitCursor(); Invalidate(); }