void CGridAnalysis::UpdateGrid(
  COARfile *pFile, COARsampleSort *pSort,
  int nLabelType, 
  int nLabelTypeName,
  const wxDateTime *pHistory, 
  wxDC *pDC)
{
  nwxGridBatch xBatch(this);
  wxDC *pDCuse = (pDC != NULL) ? pDC : GetDC();
  DCholder xx(this,pDCuse);

  wxString sChannel;
  wxString sCell;
  int iRow;
  int nCol;
  int nReviewCount;
  int nAcceptCount;
  int nReviewNeeded;
  int nAcceptNeeded;
  size_t nRowCount = pSort->GetCount();
  size_t nAlleleColCount = pFile->GetLocusCount();
  size_t i;
  COARlocus *pLocus;
  COARsample *pSample;
  const COARmessages *pMsgs = pFile->GetMessages();
  GRID_FLAG flagBase;
  GRID_FLAG flag;
  bool bAlert;
  bool bEdited;
  bool bSampleHasAlert;
  bool bSampleEdited;
  bool bNeedsAttention;
  bool bSampleDisabled;
  m_nLabelSize = 0;
  m_nLabelType = nLabelTypeName;

  

#if 0
  // moved to next loop
  // Set up row labels
  for(iRow = 0; iRow < (int)nRowCount; ++iRow)
  {
    pSample = pSort->GetSample((size_t)iRow);
    sName = pSample->GetName();
    if(pSample->IsSampleLevelEdited(pFile->GetMessages(),pHistory))
    {
      sName.Append(COARsample::g_sCellChannelEdited);
    }
    SetRowLabel(iRow,sName);
  }
#endif

  // set up cells
  pFile->GetReviewerCounts(&nReviewNeeded,&nAcceptNeeded,CLabReview::REVIEW_SAMPLE);

  for(iRow = 0; iRow < (int)nRowCount; ++iRow)
  {
    // setup sample info
    flagBase = GRID_NORMAL;
    bNeedsAttention = false;
    pSample = pSort->GetSample((size_t)iRow);
    bSampleHasAlert = pSample->HasAnyAlerts(pMsgs,pHistory);
    bSampleEdited = pSample->IsEdited(pMsgs,pHistory);
    bSampleDisabled = pSample->IsDisabled(pHistory);
    const COARsampleReviewAccept &accept(pSample->GetAcceptance());
    const COARsampleReviewAccept &review(pSample->GetReviews());

    if(bSampleDisabled)
    {
      flagBase |= GRID_DISABLED;
    }
    else 
    {
      if(bSampleHasAlert)
      {
        flagBase |= GRID_ALERT_SAMPLE;
      }
      if(bSampleEdited)
      {
        flagBase |= GRID_EDITED_SAMPLE;
      }
    }
    //  Setup Row Label for sample
    bEdited = pSample->IsSampleLevelEdited(pMsgs,pHistory);
    bAlert = pSample->HasSampleAlert(pMsgs,pHistory);
    nAcceptCount = accept.GetSampleCount(pHistory);
    nReviewCount = review.GetSampleCount(pHistory);
    _SetupCellFlag(
      flagBase,
      bSampleDisabled,bEdited,bAlert,
      nAcceptCount, nAcceptNeeded,
      nReviewCount, nReviewNeeded,
      &flag,&bNeedsAttention);
    SetupRowLabel(pSample,iRow,nLabelTypeName,bEdited,bNeedsAttention);


    // ILS alert column

    bAlert = bSampleHasAlert && pSample->HasILSAlert(pMsgs,pHistory);
    bEdited = pSample->IsCellILSEdited(pMsgs,pHistory);
    nAcceptCount = accept.GetILSCount(pHistory);
    nReviewCount = review.GetILSCount(pHistory);
    pFile->GetReviewerCounts(&nReviewNeeded,&nAcceptNeeded,CLabReview::REVIEW_ILS);
    _SetupCellFlag(
      flagBase,
      bSampleDisabled,bEdited,bAlert,
      nAcceptCount, nAcceptNeeded,
      nReviewCount, nReviewNeeded,
      &flag,&bNeedsAttention);
    SetCellValue(iRow,CFrameAnalysis::ILS_COLUMN,pSample->GetCellILS(pMsgs,pHistory));
    SetCellStyle(
      iRow,CFrameAnalysis::ILS_COLUMN,flag);

    // channel alert column

    sChannel = pSample->GetCellChannel(pMsgs,pHistory);
    bAlert = bSampleHasAlert && COARsample::HasChannelAlert(sChannel);
    bEdited = bSampleEdited && pSample->IsCellChannelEdited(pMsgs,pHistory);
    nAcceptCount = accept.GetChannelCount(pHistory);
    nReviewCount = review.GetChannelCount(pHistory);
    pFile->GetReviewerCounts(&nReviewNeeded,&nAcceptNeeded,CLabReview::REVIEW_CHANNEL);

    _SetupCellFlag(
      flagBase,
      bSampleDisabled,bEdited,bAlert,
      nAcceptCount, nAcceptNeeded,
      nReviewCount, nReviewNeeded,
      &flag,&bNeedsAttention);
    SetCellValue(iRow,CFrameAnalysis::CHANNEL_ALERT_COLUMN,sChannel);
    SetCellStyle(iRow,CFrameAnalysis::CHANNEL_ALERT_COLUMN,flag);

    SetReadOnly(iRow,CFrameAnalysis::ILS_COLUMN,true);
    SetReadOnly(iRow,CFrameAnalysis::CHANNEL_ALERT_COLUMN,true);
    SetReadOnly(iRow,CFrameAnalysis::STATUS_COLUMN,true);

    pFile->GetReviewerCounts(&nReviewNeeded,&nAcceptNeeded,CLabReview::REVIEW_LOCUS);
    for(i = 0, nCol = CFrameAnalysis::FIRST_LOCUS_COLUMN;
        i < nAlleleColCount;
        ++i, ++nCol)
    {
      SetReadOnly(iRow,nCol,true);
      pLocus = pSample->FindLocus(pFile->GetLocusName(i));
      if(pLocus != NULL)
      {
        sCell = pLocus->GetCell(nLabelType,pHistory);
        bAlert = bSampleHasAlert && pLocus->HasAlerts(pMsgs,pHistory);
        const COARchannel *pChannel =
          pFile->GetChannelFromLocus(pLocus->GetName());
        int nChannel = pChannel->GetChannelNr();
        nAcceptCount = pLocus->GetAcceptanceCount(pHistory);
        nReviewCount = pLocus->GetReviewCount(pHistory);
        bEdited = pLocus->HasBeenEdited(
          pMsgs,pSample,nChannel,pHistory);
        _SetupCellFlag(flagBase,
          bSampleDisabled,bEdited,bAlert,
          nAcceptCount,nAcceptNeeded,
          nReviewCount,nReviewNeeded,
          &flag,&bNeedsAttention);
        if(sCell.IsEmpty())
        {
          if(bAlert)
          {
            sCell = _T("?");
          }
          else if(bEdited)
          {
            sCell = COARsample::g_sCellChannelEdited;
          }
        }
        SetCellValue(iRow,nCol,sCell);
        SetCellStyle(iRow,nCol,flag);
      }
      else
      {
        SetCellValue(iRow,nCol,wxEmptyString);
        SetCellStyle(iRow,nCol,flagBase);
      }
    }
    // setup control cell

    SetReadOnly(iRow,nCol,true);
    SetCellValue(iRow,nCol,pSample->GetPositiveControl());
    SetCellStyle(iRow,nCol,flagBase);

    // setup status cell
    SetReadOnly(iRow,CFrameAnalysis::STATUS_COLUMN,true);
    if(bSampleDisabled)
    {
      SetCellValue(iRow,CFrameAnalysis::STATUS_COLUMN,_T(""));
      SetCellStyle(iRow,CFrameAnalysis::STATUS_COLUMN,flagBase);
    }
    else 
    {
      CParmOsirisGlobal parm;
      const wxColour &clFg(parm->GetStatusForeground(bNeedsAttention));
      const wxColour &clBg(parm->GetStatusBackground(bNeedsAttention));
      const wxString &s(
        bNeedsAttention ? g_sStatusNeedsAttention : g_sStatusOK);
      SetCellValue(iRow,CFrameAnalysis::STATUS_COLUMN,s);
      SetCellFont(iRow,CFrameAnalysis::STATUS_COLUMN,g_fontStatus);
      SetCellBackgroundColour(iRow,CFrameAnalysis::STATUS_COLUMN,clBg);
      SetCellTextColour(iRow,CFrameAnalysis::STATUS_COLUMN,clFg);
      SetCellAlignment(
        iRow,CFrameAnalysis::STATUS_COLUMN,
        wxALIGN_CENTRE,wxALIGN_CENTRE);
      SetCellAlignment(
        iRow,CFrameAnalysis::ILS_COLUMN,
        wxALIGN_CENTRE,wxALIGN_CENTRE);
    }
  }
  AutoSize();
  UpdateLabelSize();
}
Пример #2
0
void CGridCMF::UpdateEmptyLoci()
{
  size_t nRows = m_vpSample.size();
  if(nRows)
  {
    wxFont fnBold = GetDefaultCellFont();
    wxString sEmptyLoci;
    wxString COMMA(", ");
    size_t i;
    size_t j;
    size_t nLocusCount;
    bool bPartial;
    bool bEmpty;
    COARlocus *pLocus;
    COARsample *pSample;
    fnBold.SetWeight(wxFONTWEIGHT_BOLD);

    if(m_vsLocus.empty())
    {
        // setup locus names

      size_t nChannelCount = m_pFile->GetChannelCount();
      size_t nLocusCount;
      const COARchannel *pChannel;

      m_vsLocus.reserve(24);
      for(i = 0; i < nChannelCount; i++)
      {
        pChannel = m_pFile->GetChannel(i);
        nLocusCount = pChannel->GetLocusCount();
        for(j = 0; j < nLocusCount; j++)
        {
          m_vsLocus.push_back(pChannel->GetLocusName(j));
        }
      }
    }

    nLocusCount = m_vsLocus.size();
    for(i = 0; i < nRows; i++)
    {
      // now look for empty loci
      bPartial = false;
      bEmpty = true;
      sEmptyLoci.Empty();
      pSample = m_vpSample.at(i);
      for(j = 0; j < nLocusCount; j++)
      {
        pLocus = pSample->FindLocus(m_vsLocus.at(j));
        if( (pLocus == NULL) ||
            (!pLocus->EnabledAlleleCount()) )
        {
          // this is an empty locus

          if(!sEmptyLoci.IsEmpty())
          {
            sEmptyLoci.Append(COMMA);
          }
          sEmptyLoci.Append(pLocus->GetName());
          bPartial = true;
        }
        else
        {
          bEmpty = false;
        }
      }
      if(bEmpty)
      {
        SetBoolValue((int)i,EXCLUDE,bEmpty);
        sEmptyLoci = "ALL LOCI";
        SetCellFont((int)i,EMPTY_LOCI,fnBold);
      }
      else
      {
        //
        // may need to be restored if user pressed
        // 'finish later' and then edited alleles
        //
        SetCellFont((int)i,EMPTY_LOCI,GetDefaultCellFont());
      }
      SetCellValue((int)i,EMPTY_LOCI,sEmptyLoci);
      if(bPartial)
      {
        SetBoolValue((int)i,PARTIAL,bPartial);
      }
      DisableEditRow((int) i,bEmpty);
      SetReadOnly((int)i,EMPTY_LOCI,true);
    }
    AutoSizeColumn(EMPTY_LOCI,false);
  }
}