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
CGridCMF::CGridCMF(
  CDialogCMF *parent,
  wxWindowID id,
  COARfile *pFile,
  COARsampleSort *pSort)
  : _CGridEdit(parent,id,false),
    m_pParent(parent),
    m_pFile(pFile),
    m_pSort(pSort)
{
  wxString s;
  vector<int> vnSample;
  COARsample *pSample;
  size_t n = m_pFile->GetSampleCount();
  size_t i;
  int j = 0;

  m_vpSample.reserve(n);
  vnSample.reserve(n);
    // a little overkill because of ladders and controls
  for(i = 0; i < n; i++)
  {
    j++;
    pSample = m_pSort->GetSample(i);
    if(pSample->IsSampleType() && !pSample->IsDisabled())
    {
      m_vpSample.push_back(pSample);
      vnSample.push_back(j);
    }
  }

  n = m_vpSample.size();
  if(!n)
  {
    CreateGrid(1,1);
    SetCellValue(0,0,"There are no samples");
    SetReadOnly(0,0,true);
    AutoSize();
  }
  else
  {
    int ii;
    CreateGrid((int)n, (int)COLUMN_COUNT);
    SetRowLabelAlignment(wxALIGN_LEFT,wxALIGN_CENTRE);
    for(i = 0; i < n; i++)
    {
      ii = (int)i;
      pSample = m_vpSample.at(i);
      s = CGridAnalysis::FormatRowLabel(
        vnSample.at(i), (int)n, pSample->GetName());
      SetRowLabelValue((int)i,s);
      SetBoolCell(ii,EXCLUDE);
      SetBoolCell(ii,PARTIAL);
      SetCellEditor(ii,SPECIMEN_TYPE,_CreateTypeEditor());
      SetReadOnly(ii,EMPTY_LOCI,true);
    }
    for(i = 0; i < (size_t) COLUMN_COUNT; i++)
    {
      s = COL_LABELS[i];
      SetColLabelValue((int)i,s);
    }
    SetColLabelAlignment(wxALIGN_LEFT,wxALIGN_CENTRE);
  }
}