Пример #1
0
BOOL CDrawInfo::SetRect( CRect rc )
{
	//////////////////////////////////////////////////////////////////////////
	// 设置列宽
	SetColCount(INFO_COL_COUNT);
	if (GetColCount() > 1)
	{
		ColInfoStruct sColInfo;
		sColInfo.nWidth = (rc.Width() - INFO_LAST_COL_WIDTH) / (GetColCount() - 1);	
		for (int i = 0; i < GetColCount() - 1; i++)
		{
			SetColInfo(i, &sColInfo);
		}

		sColInfo.nWidth = rc.Width() - sColInfo.nWidth * (GetColCount() - 1);
		SetColInfo(GetColCount()-1, &sColInfo);
	}
	//////////////////////////////////////////////////////////////////////////
	CDrawTableBase::SetRect(rc);

	rc.top = rc.top + GetRowCount() * INFO_ROW_HEIGHT + 1;
	m_pViewInfo->SetRect(rc);

	return TRUE;
}
Пример #2
0
void MSA::ToFASTAFile(TextFile &File) const
	{
	const unsigned uColCount = GetColCount();
	assert(uColCount > 0);
	const unsigned uLinesPerSeq = (GetColCount() - 1)/FASTA_BLOCK + 1;
	const unsigned uSeqCount = GetSeqCount();

	for (unsigned uSeqIndex = 0; uSeqIndex < uSeqCount; ++uSeqIndex)
		{
		File.PutString(">");
		File.PutString(GetSeqName(uSeqIndex));
		File.PutString("\n");

		unsigned n = 0;
		for (unsigned uLine = 0; uLine < uLinesPerSeq; ++uLine)
			{
			unsigned uLetters = uColCount - uLine*FASTA_BLOCK;
			if (uLetters > FASTA_BLOCK)
				uLetters = FASTA_BLOCK;
			for (unsigned i = 0; i < uLetters; ++i)
				{
				char c = GetChar(uSeqIndex, n);
				File.PutChar(c);
				++n;
				}
			File.PutChar('\n');
			}
		}
	}
Пример #3
0
void GridViewGridControl::UpdateGridData()
{
    for (int i = 1; i < GetRowCount(); i++)
    {
        for (int j = 1; j < GetColCount(); j++)
        {
            CGridCell* pCell = GetCell(i, j);
            pCell->UpdateText();
        }
    }


    AutoSize();
    int maxSize = GetColSize(1);
    for (int i = 2; i < GetColCount(); i++)
    {
        int colSize = GetColSize(i);
        if (colSize > maxSize)
            maxSize= colSize;
    }

    maxSize += 5;
    for (int i = 1; i < GetColCount(); i++)
        SetColSize(i, maxSize);

    InvalidateAll();
}
Пример #4
0
BOOL CDrawInfo::DrawSelf( CDC* pDC, CPoint pos, int nItemID, CRect& rcItem )
{
	int nAyIndex = GetArrayIndexFromPoint(pos);
	int nCellIndex = PointToIndex(pos);
	if (nAyIndex != -1)
	{// 当前鼠标所在的资讯索引单元格  
		
		if (m_nActiveCellID == nCellIndex)
		{
			// 画激活背景
			rcItem.DeflateRect(1,1,1,1);
			pDC->FillSolidRect(&rcItem, m_pColor->GetDiagramLayoutActiveFillColor());

			// 设置激活前景色
			SetCellText(nCellIndex, nItemID, NULL, TEXT_COLOR_ACTIVEFIXEDNAME);
		}
		else
		{
			// 设置默认前景色
			SetCellText(nCellIndex, nItemID, NULL, TEXT_COLOR_FIXEDNAME);
		}	
	}
	else
	{// 不是资讯索引单元格
		if (pos == CPoint(GetColCount()-1, 0))
		{// 如果是第一行,最后一列

			//////////////////////////////////////////////////////////////////////////
			// 计算全屏或者还原图标区域
			CalcImageRect(&m_rcMaxScreen, &rcItem, TRUE);
			// 绘制图片
			if (!m_bSizeMax)
				m_lstImage.Draw(pDC, 0, CPoint(m_rcMaxScreen.left, m_rcMaxScreen.top), ILD_TRANSPARENT);
			else
				m_lstImage.Draw(pDC, 4, CPoint(m_rcMaxScreen.left, m_rcMaxScreen.top), ILD_TRANSPARENT);
			//////////////////////////////////////////////////////////////////////////
			// 计算关闭图标区域
			CalcImageRect(&m_rcClose, &rcItem, FALSE);
			// 绘制图片
			m_lstImage.Draw(pDC, 1, CPoint(m_rcClose.left, m_rcClose.top), ILD_TRANSPARENT);
			return TRUE;
		}
		else if (pos == CPoint(GetColCount()-1, 1))
		{
			//////////////////////////////////////////////////////////////////////////
			// 计算向上翻屏图标区域
			CalcImageRect(&m_rcUp, &rcItem, TRUE);
			// 绘制图片
			m_lstImage.Draw(pDC, 2, CPoint(m_rcUp.left, m_rcUp.top), ILD_TRANSPARENT);

			//////////////////////////////////////////////////////////////////////////
			// 计算向下翻屏图标区域
			CalcImageRect(&m_rcDown, &rcItem, FALSE);
			// 绘制图片
			m_lstImage.Draw(pDC, 3, CPoint(m_rcDown.left, m_rcDown.top), ILD_TRANSPARENT);
			return TRUE;
		}
	}
	return FALSE;
}
Пример #5
0
int CDrawInfo::GetArrayIndexFromPoint(CPoint pos)
{
	if (pos.x < 1 || pos.x >= GetColCount() - 1 || pos.y < 0 || pos.y >= GetRowCount())
	{
		return -1;
	}
	return pos.y * (GetColCount() - 2) + pos.x - 1;
}
Пример #6
0
    void  ColorMapGridControl::UpdateColSize()
    {
        AutoSize();
        int maxSize = GetColSize(1);
        int i;
        for (i = 2; i < GetColCount(); i++)
            {
                int colSize = GetColSize(i);
                if (colSize > maxSize)
                    maxSize= colSize;
            }

        maxSize += 5;
        for (i = 1; i < GetColCount(); i++)
            SetColSize(i, maxSize);
    }
void
JXTreeListWidget::AdjustColWidths()
{
	if (itsAdjustToTreeTask != NULL)
		{
		return;
		}

	const JSize colCount = GetColCount();
	if (itsMinColWidths->GetElementCount() != colCount)
		{
		NeedsAdjustToTree();
		return;
		}

	for (JIndex i=1; i<=colCount; i++)
		{
		SetColWidth(i, itsMinColWidths->GetElement(i));
		}

	if (ColIndexValid(itsElasticColIndex))
		{
		const JCoordinate minReqWidth = itsMinColWidths->GetElement(itsElasticColIndex);
		if (minReqWidth > 0)
			{
			const JCoordinate availWidth =
				GetApertureWidth() - (GetBoundsWidth() - GetColWidth(itsElasticColIndex));
			SetColWidth(itsElasticColIndex, JMax(minReqWidth, availWidth));
			}
		}
}
Пример #8
0
void MSA::SetHenikoffWeights() const
	{
	const unsigned uColCount = GetColCount();
	const unsigned uSeqCount = GetSeqCount();

	if (0 == uSeqCount)
		return;
	else if (1 == uSeqCount)
		{
		m_Weights[0] = (WEIGHT) 1.0;
		return;
		}
	else if (2 == uSeqCount)
		{
		m_Weights[0] = (WEIGHT) 0.5;
		m_Weights[1] = (WEIGHT) 0.5;
		return;
		}

	for (unsigned uSeqIndex = 0; uSeqIndex < uSeqCount; ++uSeqIndex)
		m_Weights[uSeqIndex] = 0.0;

	for (unsigned uColIndex = 0; uColIndex < uColCount; ++uColIndex)
		CalcHenikoffWeightsCol(uColIndex);

// Set all-gap seqs weight to 0
	for (unsigned uSeqIndex = 0; uSeqIndex < uSeqCount; ++uSeqIndex)
		if (IsGapSeq(uSeqIndex))
			m_Weights[uSeqIndex] = 0.0;

	Normalize(m_Weights, uSeqCount);
	}
Пример #9
0
// Perecent group identity of a pair of sequences.
// Positions with one or both gapped are ignored.
double MSA::GetPctGroupIdentityPair(unsigned uSeqIndex1,
  unsigned uSeqIndex2) const
	{

	const unsigned uColCount = GetColCount();
	unsigned uPosCount = 0;
	unsigned uSameCount = 0;
	for (unsigned uColIndex = 0; uColIndex < uColCount; ++uColIndex)
		{
		if (IsGap(uSeqIndex1, uColIndex))
			continue;
		if (IsGap(uSeqIndex2, uColIndex))
			continue;
		if (IsWildcard(uSeqIndex1, uColIndex))
			continue;
		if (IsWildcard(uSeqIndex2, uColIndex))
			continue;

		const unsigned uLetter1 = GetLetter(uSeqIndex1, uColIndex);
		const unsigned uLetter2 = GetLetter(uSeqIndex2, uColIndex);
		const unsigned uGroup1 = ResidueGroup[uLetter1];
		const unsigned uGroup2 = ResidueGroup[uLetter2];
		if (uGroup1 == uGroup2)
			++uSameCount;
		++uPosCount;
		}
	if (0 == uPosCount)
		return 0;
	return (double) uSameCount / (double) uPosCount;
	}
Пример #10
0
    void ColorMapGridControl::FinishEdit(const char* szText, int nValue, int nLastChar)
    {
        int rowIndex = m_cellActive.m_nRow - 1;
        int colIndex = m_cellActive.m_nCol - 1;

        double val;
        if ((!IsValidReal(szText, val)) || (val < 0.0) || (val > 1.0))
            val = 0.0;

        SC_ColorSpec& currSpec = gColorMap.colorMapColors[rowIndex];

        switch (colIndex )
            {
            case 0 : {currSpec.RH = val; break;}
            case 1 : {currSpec.GS = val; break;}
            case 2 : {currSpec.BV = val; break;}
            case 3 : {break;}
            }

        if (rowIndex >= gColorMap.ncolorMap)
            {
                for (int i = gColorMap.ncolorMap; i < rowIndex; i++)
                    gColorMap.colorMapColors[i] = SC_ColorSpec(0.0, 0.0, 0.0);
                m_nCurrRow = gColorMap.ncolorMap - 1;
                gColorMap.ncolorMap = rowIndex + 1;
                UpdateModifiedRows();
            }
        else
            {
                for (int j = 1; j < GetColCount(); j++)
                    {
                        CGridCell* pCell = GetCell(rowIndex + 1, j);
                        pCell->UpdateText();
                        InvalidateCell(rowIndex + 1, j);
                    }
            }

        ResetCell(m_cellActive.m_nRow, m_cellActive.m_nCol);

        StopEdit(false);

        // if the right key continue editing on next cell
        switch (nLastChar) {
        case VK_TAB:
        case VK_DOWN:
        case VK_UP:
        case VK_RIGHT:
        case VK_LEFT:
        case VK_NEXT:
        case VK_PRIOR:
        case VK_HOME:
        case VK_END:
            OnKeyDown(nLastChar, 0, 0);
            UpdateWindow();
            if (m_cellActive != m_cellActiveOld)
                StartEdit(nLastChar);
            break;
        }
    }
Пример #11
0
const int EdiDocument::GetColumnIdx(const wxString& name) const {
    for (int i = 0; i<GetColCount(); i++) {
        if ( 0 == GetColumnDescriptor(i).GetName().CmpNoCase(name) ) {
            return i;
        }
    }
    THROW_COMPOSER_EXCEPTION(wxString::Format(ADVPCS_UNKNOWN_FIELD_NAME_ERR_MSG, name));
};
Пример #12
0
void DbRow::ClearDirty()
{
    for (int i=GetColCount()-1; i>=0; i--)
    {
        Variant& var = (Variant&)this->GetAt(i);
        if (var.IsDirty())
            var.SetDirty(false);
    }
}
Пример #13
0
void CDrawInfo::CreateSelf()
{
	// 第一行第一列为股票名称 第二行第二列为股票代码
	int nCellCount = m_ayInfoIndex.GetCount() + 2;
	int nRowCount = nCellCount / INFO_COL_COUNT + ((nCellCount%INFO_COL_COUNT)==0?0:1); // 向上取整
	SetColCount(INFO_COL_COUNT);
	SetRowCount(nRowCount);
	SetRowHeight(INFO_ROW_HEIGHT);
	nCellCount = INFO_COL_COUNT * nRowCount;
	SetCellCount(nCellCount);

	int nCellIndex(0);
	int nAyIndex(0);
	CString str;
	InfoIndex* pInfoIndex = NULL;
	//////////////////////////////////////////////////////////////////////////
	// 第一列
	str = m_stkInfo.m_cStockName;   // 股票名称
	CreateCell(str, TEXT_COLOR_STOCKCODE, TEXT_FONT_FIXED, ITEM_TEXT_CENTER, CELL_BORDER_RIGHT | CELL_BORDER_BOTTOM, 0, nCellIndex++);
	
	str = m_stkInfo.m_ciStockCode.GetCode(); // 代码名称
	CreateCell(str, TEXT_COLOR_STOCKNAME, TEXT_FONT_FIXED, ITEM_TEXT_CENTER, CELL_BORDER_RIGHT | CELL_BORDER_BOTTOM, 0, nCellIndex++);
	
	//////////////////////////////////////////////////////////////////////////
	// 添加返回的数据
	for (int y = 0; y < GetRowCount(); y++)
	{
		for (int x = 1; x < GetColCount() - 1; x++)
		{
			nCellIndex = PointToIndex(CPoint(x,y));
			str = "";
			if (nAyIndex < m_ayInfoIndex.GetCount())
			{
				pInfoIndex = m_ayInfoIndex.GetAt(nAyIndex++);
				str = pInfoIndex->m_cTitle;
			}
			CreateCell(str, TEXT_COLOR_FIXEDNAME, TEXT_FONT_FIXED, ITEM_TEXT_CENTER, CELL_BORDER_RIGHT | CELL_BORDER_BOTTOM, 0, nCellIndex);
		}
		// 每一行最后一列单元格是按钮
		nCellIndex = PointToIndex(CPoint(GetColCount()-1, y));
		CreateCell("", TEXT_COLOR_FIXEDNAME, TEXT_FONT_FIXED, ITEM_TEXT_CENTER, CELL_BORDER_RIGHT | CELL_BORDER_BOTTOM, 0, nCellIndex);
	}
}
Пример #14
0
bool DbRow::IsDirty() const
{
    for (int i=GetColCount()-1; i>=0; i--)
    {
        Variant& var = (Variant&)this->GetAt(i);
        if (var.IsDirty())
            return true;
    }
    return false;
}
Пример #15
0
BOOL CGXGridCellData::SetColCount(ROWCOL nCols )
{
	ROWCOL nOldCols = GetColCount();
	if (nCols < nOldCols)
		return StoreRemoveCols(nCols+1, nOldCols );
	else if (nCols > nOldCols)
		return StoreInsertCols(nOldCols+1, nCols-nOldCols );
	return TRUE;

}
Пример #16
0
void RenderTarget::Write(const Fragment& inFragment, int inX, int inY)
{
	bool isNotAlpha0	= ((inFragment.mColour & EColour_Alpha0) == 0);
	bool isInRange		= (inX >= 0 && inX < GetColCount() && inY >= 0 && inY < GetRowCount());

	if (isNotAlpha0 && isInRange)
	{
		mFragments.Set(inX, inY, inFragment);
	}
}
Пример #17
0
void DataCaptureGridCtrl::UpdateModifiedRows()
{
  for (int i = m_currDCap + 1; i < GetRowCount(); i++)
    for (int j = 1; j < GetColCount(); j++)
    {
      CGridCell* pCell = GetCell(i, j);
      pCell->UpdateText();
    }
  InvalidateAll();
}
Пример #18
0
void TestZoneCurveGridCtrl::UpdateModifiedRows()
{
    for (int i = m_currTZC + 1; i < GetRowCount(); i++)
        for (int j = 1; j < GetColCount(); j++)
        {
            CGridCell* pCell = GetCell(i, j);
            pCell->UpdateText();
        }
    InvalidateAll();
}
Пример #19
0
void XYGridControl::UpdateModifiedRows()
{
    for (int i = m_nCurrent + 1; i < GetRowCount(); i++) {
        for (int j = 1; j < GetColCount(); j++) {
            CGridCell* pCell = GetCell(i, j);
            pCell->UpdateText();
        }
    }
    InvalidateAll();
}
///////////////////////////////////////////////////////////////////////////
// Set the highlighted selection
///////////////////////////////////////////////////////////////////////////
void CStreetSegmentBrowseGrid::SetRowSelection(int selStart_, int selEnd_)
{
	int oldSelStart = selStart;
	int oldSelEnd = selEnd;

	selStart = selStart_;
	selEnd = selEnd_;

	if (oldSelStart <= oldSelEnd) {
		// Unhilight previous selection
		RedrawRowCol(oldSelStart, 1, oldSelEnd, GetColCount());
	}

	if (selStart <= selEnd) {
		// Hilight new selection
		RedrawRowCol(selStart, 1, selEnd, GetColCount());
		// Put top of select at top row
		SetTopRow(selStart);
	}
}
Пример #21
0
void MSA::ToPhyInterleavedFile(TextFile &File) const
	{
	const unsigned SeqCount = GetSeqCount();
	const unsigned ColCount = GetColCount();

	File.PutFormat("%d %d\n", SeqCount, ColCount);

	if (0 == ColCount)
		return;

        unsigned Col = 0;
	for (;;)
		{
		const unsigned ColBlockStart = Col;
		const unsigned MaxCols = (ColBlockStart == 0) ? (BLOCKSIZE - 10) : BLOCKSIZE;

		for (unsigned Seq = 0; Seq < SeqCount; ++Seq)
			{
			if (0 == ColBlockStart)
				{
				char Name[11];
				const char *ptrName = GetSeqName(Seq);
				size_t n = strlen(ptrName);
				if (n > 10)
					n = 10;
				memcpy(Name, ptrName, n);
				Name[n] = 0;
				FixName(Name);
				File.PutFormat("%-10.10s", Name);
				}

			Col = ColBlockStart;
			for (unsigned ColsThisBlock = 0; ColsThisBlock < MaxCols; ++ColsThisBlock)
				{
				if (Col == ColCount)
					break;
				if (ColsThisBlock%10 == 0 && (0 == ColBlockStart || ColsThisBlock > 0))
					File.PutChar(' ');
				char c = GetChar(Seq, Col);
				if (isalpha(c))
					c = toupper(c);
				File.PutChar(c);
				++Col;
				}
			File.PutChar('\n');
			}
		if (Col == ColCount)
			break;
		File.PutChar('\n');
		}
	}
Пример #22
0
bool RenderTarget::operator==(const RenderTarget& inRHS)
{
	if (GetColCount() != inRHS.GetColCount()) return false;
	if (GetRowCount() != inRHS.GetRowCount()) return false;

	bool isEqual = true;

	mFragments.ForEach( [&] (size_t inCol, size_t inRow, const Fragment& inFragment)
	{
		isEqual &= inRHS.mFragments.Get(inCol, inRow) == inFragment;
	} );

	return true;
}
Пример #23
0
void nsTableColGroupFrame::Dump(PRInt32 aIndent)
{
  char* indent = new char[aIndent + 1];
  if (!indent) return;
  for (PRInt32 i = 0; i < aIndent + 1; i++) {
    indent[i] = ' ';
  }
  indent[aIndent] = 0;

  printf("%s**START COLGROUP DUMP**\n%s startcolIndex=%d  colcount=%d span=%d coltype=",
    indent, indent, GetStartColumnIndex(),  GetColCount(), GetSpan());
  nsTableColGroupType colType = GetColType();
  switch (colType) {
  case eColGroupContent:
    printf(" content ");
    break;
  case eColGroupAnonymousCol: 
    printf(" anonymous-column  ");
    break;
  case eColGroupAnonymousCell: 
    printf(" anonymous-cell ");
    break;
  }
  // verify the colindices
  PRInt32 j = GetStartColumnIndex();
  nsTableColFrame* col = GetFirstColumn();
  while (col) {
    NS_ASSERTION(j == col->GetColIndex(), "wrong colindex on col frame");
    col = col->GetNextCol();
    j++;
  }
  NS_ASSERTION((j - GetStartColumnIndex()) == GetColCount(),
               "number of cols out of sync");
  printf("\n%s**END COLGROUP DUMP** ", indent);
  delete [] indent;
}
Пример #24
0
void CCombAnalysisReport::InitReport()
{
	SetRowCount(10);
	ColInfoStruct sInfo;
	sInfo.nWidth = 100;
	sInfo.nID = 0;
	for(int i = 0; i < 7; i ++)
	{
		CString str;
		str.Format("column_%d",i+1);
		InsertCol(GetColCount(),FALSE,str,TEXT_COLOR_TIME,TEXT_FONT_FIXED);
		SetColInfo(i, &sInfo);
	}
	SetFixRowCount(1);
	SetFixColCount(1);
}
Пример #25
0
bool EdiDocument::IsValid(bool doLog) const {
    bool result = IsHeaderValid(doLog); 
    if (result || doLog) {
        for ( size_t row = 0; row < GetNumberRows(); row++ ) {
            for ( size_t col = 0; col < GetColCount(); col++ ) {
                if ( !IsValidValue(row, col, doLog) ) {
                    if ( !doLog )  {
                      return false;
                    } else {
                      result = false;
                    }
                } 
            }
        }
    }
    return result;
};
Пример #26
0
/* virtual */ void
nsTableColGroupFrame::DidSetStyleContext(nsStyleContext* aOldStyleContext)
{
  if (!aOldStyleContext) //avoid this on init
    return;
     
  nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
  if (tableFrame->IsBorderCollapse() &&
      tableFrame->BCRecalcNeeded(aOldStyleContext, GetStyleContext())) {
    PRInt32 colCount = GetColCount();
    if (!colCount)
      return; // this is a degenerated colgroup 
    nsIntRect damageArea(GetFirstColumn()->GetColIndex(), 0, colCount,
                         tableFrame->GetRowCount());
    tableFrame->AddBCDamageArea(damageArea);
  }
}
void
GRaggedFloatTableData::RemoveAllCols()
{
	itsCols->DeleteAll();

	const JSize count	= GetColCount();
	SetColCount(0);
	if (itsBroadcast)
		{
		Broadcast(JTableData::ColsRemoved(1, count));
		}
	ColsAdded(1);
	if (itsBroadcast)
		{
		Broadcast(JTableData::ColsInserted(1, 1));
		}
}
Пример #28
0
double MSA::GetAvgCons() const
	{
	assert(GetSeqCount() > 0);
	double dSum = 0;
	unsigned uNonGapColCount = 0;
	for (unsigned uColIndex = 0; uColIndex < GetColCount(); ++uColIndex)
		{
		if (!IsGapColumn(uColIndex))
			{
			dSum += GetCons(uColIndex);
			++uNonGapColCount;
			}
		}
	assert(uNonGapColCount > 0);
	double dAvg = dSum / uNonGapColCount;
	assert(dAvg > 0 && dAvg <= 1);
	return dAvg;
	}
Пример #29
0
// Perecent identity of a pair of sequences.
// Positions with one or both gapped are ignored.
double MSA::GetPctIdentityPair(unsigned uSeqIndex1, unsigned uSeqIndex2) const
	{
	const unsigned uColCount = GetColCount();
	unsigned uPosCount = 0;
	unsigned uSameCount = 0;
	for (unsigned uColIndex = 0; uColIndex < uColCount; ++uColIndex)
		{
		const char c1 = GetChar(uSeqIndex1, uColIndex);
		const char c2 = GetChar(uSeqIndex2, uColIndex);
		if (IsGapChar(c1) || IsGapChar(c2))
			continue;
		if (c1 == c2)
			++uSameCount;
		++uPosCount;
		}
	if (0 == uPosCount)
		return 0;
	return (double) uSameCount / (double) uPosCount;
	}
Пример #30
0
void
JXColHeaderWidget::SetColTitle
	(
	const JIndex		index,
	const JCharacter*	title
	)
{
	if (itsTitles == NULL)
		{
		itsTitles = new JPtrArray<JString>(JPtrArrayT::kDeleteAll);
		assert( itsTitles != NULL );

		const JSize colCount = GetColCount();
		for (JIndex i=1; i<=colCount; i++)
			{
			itsTitles->Append(NULL);
			}
		}

	itsTitles->SetElement(index, title, JPtrArrayT::kDelete);
}