Ejemplo n.º 1
0
void CustomGrid::DrawColLabel( wxDC& dc, int col )
{
    //init dc font and colours
	dc.SetFont(m_labelFont);
    if(col == m_gParent->m_pIndex){
        dc.SetBrush(wxBrush(m_greenColour, wxBRUSHSTYLE_SOLID));
        dc.SetPen(wxPen(m_greenColour, 1));
    }else {
        dc.SetBrush(wxBrush(m_labelBackgroundColour, wxBRUSHSTYLE_SOLID));
        dc.SetPen(wxPen(m_labelBackgroundColour, 1));
    }
    //draw retangle
	wxRect tRect( GetColLeft(col), 1, GetColWidth(col)-2,  m_colLabelHeight -2);
    dc.DrawRectangle(tRect);
    //draw lines aroud label
    dc.SetPen(GetDefaultGridLinePen());
    dc.DrawLine( GetColLeft(col) -1, 0, GetColRight(col), 0 );
    if( col > -1 && (col == 0 || GetColLabelValue( col ).BeforeFirst('-') != GetColLabelValue( col - 1 ).BeforeFirst('-')) )
        dc.SetPen(wxPen(*wxBLACK, 4));
    dc.DrawLine( GetColLeft(col) -1, 0, GetColLeft(col) - 1, m_colLabelHeight);
    if( col == m_numCols - 1 ){
        dc.SetPen(wxPen(*wxBLACK, 4));
        dc.DrawLine( GetColRight(col), 0, GetColRight(col), m_colLabelHeight);
    }
    //then draw label
    dc.DrawLabel(GetColLabelValue(col), tRect, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL);
}
/* handles left mouse click on column header */
void CBOINCGridCtrl::OnLabelLClick(wxGridEvent& ev) {
	if(ev.GetCol() != -1) {
        //same column as last time, then change only sort direction
        if(sortColumn == ev.GetCol()) {
			sortAscending = ! sortAscending;
		} else {
            int tmpOldColumn = sortColumn;

            sortColumn = ev.GetCol();
			sortAscending = true;

            // Force a repaint of the label
			if ( -1 != tmpOldColumn ) {
				SetColLabelValue(tmpOldColumn, GetColLabelValue(tmpOldColumn));
			}
		}

        // Force a repaint of the label
        SetColLabelValue(ev.GetCol(), GetColLabelValue(ev.GetCol()));
		//
		sortNeededByLabelClick=true;
		// Update and sort data
		wxTimerEvent tEvent;
		wxDynamicCast(GetParent(),CBOINCBaseView)->FireOnListRender(tEvent);
	}
        // The base class calls ClearSelection(), so do NOT call ev.Skip();
}
Ejemplo n.º 3
0
bool CGridLabThresholdsLadder::_GetColumn(
  int nCol, CLabLocusThreshold *pLocus)
{
  wxString s;
  pLocus->Init();
  pLocus->SetLocusName(GetColLabelValue(nCol));
  pLocus->SetFractionMaxPeak(
    GetCellValueDouble(ROW_FRACTION_MAX_PEAK,nCol));
  pLocus->SetPullupFractionFilter(
    GetCellValueDouble(ROW_PULLUP_FRACTIONAL_FILTER,nCol));
  pLocus->SetStutter(
    GetCellValueDouble(ROW_STUTTER_THRESHOLD,nCol));
  pLocus->SetAdenylation(
    GetCellValueDouble(ROW_ADENYLATION_THRESHOLD,nCol));

  // need validation code here

  return true;
}
/* not virtual in wxGrid, so code copied and modified her for painting sorting icons */
void CBOINCGridCtrl::DrawColLabel( wxDC& dc, int col )
{
    if ( GetColWidth(col) <= 0 || m_colLabelHeight <= 0 )
        return;

    int colLeft = GetColLeft(col);

    wxRect rect;
    int colRight = GetColRight(col) - 1;

    dc.SetPen( wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DDKSHADOW),1, wxSOLID) );
    dc.DrawLine( colRight, 0,
                 colRight, m_colLabelHeight-1 );

    dc.DrawLine( colLeft, 0, colRight, 0 );

    dc.DrawLine( colLeft, m_colLabelHeight-1,
                 colRight+1, m_colLabelHeight-1 );

    dc.SetPen( *wxWHITE_PEN );
    dc.DrawLine( colLeft, 1, colLeft, m_colLabelHeight-1 );
    dc.DrawLine( colLeft, 1, colRight, 1 );
    dc.SetBackgroundMode( wxTRANSPARENT );
    dc.SetTextForeground( GetLabelTextColour() );
    dc.SetFont( GetLabelFont() );

    int hAlign, vAlign, orient;
    GetColLabelAlignment( &hAlign, &vAlign );
    orient = GetColLabelTextOrientation();

    rect.SetX( colLeft + 2 );
    rect.SetY( 2 );
    rect.SetWidth( GetColWidth(col) - 4 );
    rect.SetHeight( m_colLabelHeight - 4 );
    DrawTextRectangle( dc, GetColLabelValue( col ), rect, hAlign, vAlign, orient );
	//paint sorting indicators, if needed
	if(col == sortColumn) {
		int x = rect.GetRight() - ascBitmap.GetWidth() - 2;
		int y = rect.GetY();
		dc.DrawBitmap(this->sortAscending ? descBitmap : ascBitmap,x,y,true);
	}
}
Ejemplo n.º 5
0
const std::string wex::grid::build_page()
{
  wxString text;

  text << "<TABLE ";

  if (GridLinesEnabled())
    text << "border=1";
  else
    text << "border=0";

  text << " cellpadding=4 cellspacing=0 >\n";
  text << "<tr>\n";

  // Add the col labels only if they are shown.
  if (GetColLabelSize() > 0)
  {
    for (int c = 0 ; c < GetNumberCols(); c++)
    {
      text << "<td><i>" << GetColLabelValue(c) << "</i>\n";
    }
  }

  for (int i = 0 ; i < GetNumberRows(); i++)
  {
    text << "<tr>\n";

    for (int j = 0 ; j < GetNumberCols(); j++)
    {
      text << "<td>" <<
        (GetCellValue(i, j).empty() ? "&nbsp": GetCellValue(i, j)) << "\n";
    }
  }

  text << "</TABLE>\n";

  // This can be useful for testing, paste in a file and
  // check in your browser (there indeed rules are okay).
  // clipboard_add(text);

  return text;
}
Ejemplo n.º 6
0
bool CGridLabThresholdsLadder::TransferDataToWindow()
{
  bool bRtn = m_pData != NULL;
  if(bRtn)
  {

    wxString sLocus;
    CLabLocusThreshold locus;
    const CLabLocusThreshold *pLocus;
    int nILS = GetNumberCols() - 1;
    int nCol;
    const CLabRFU &rfu(*m_pData->GetRFUladder());
    const CLabRFU &rfuILS(*m_pData->GetRFUls());
    const CLabRFU *pRFU = &rfu;

    for(nCol = 0; nCol <= nILS; nCol += nILS)
    {
      // setup defaults
      locus.SetFractionMaxPeak(pRFU->GetFractionMaxPeak());
      locus.SetPullupFractionFilter(pRFU->GetPullupFractionFilter());
      locus.SetStutter(pRFU->GetStutterThreshold());
      locus.SetAdenylation(pRFU->GetAdenylationThreshold());
      _SetColumn(nCol,locus);
      pRFU = &rfuILS;
    }

    for(nCol = 1; nCol < nILS; nCol++)
    {
      sLocus = GetColLabelValue(nCol);
      pLocus = rfu.GetLabLocusThreshold(sLocus);
      if(pLocus != NULL)
      {
        _SetColumn(nCol,*pLocus);
      }
      else
      {
        _ClearColumn(nCol);
      }
    }
  }
  return bRtn;
}
Ejemplo n.º 7
0
bool CGridAllele::_TransferDataFromWindow1(vector<CLabLocus *> *pvpLocus)
{
  wxString sLocusName;
  wxString sAllele;

  vector<CLabLocus *> vpLocus;
  int nRows = GetNumberRows();
  int nCols = GetNumberCols();
  int nRow;
  int nCol;
  size_t nSize = pvpLocus->size();
  bool bAmel;
  vpLocus.reserve((nSize + 2) << 1);
  CLabLocus *plc;
  for(nCol = 0; nCol < nCols; nCol++)
  {
    plc = NULL;
    sLocusName = GetColLabelValue(nCol);
    bAmel = CLabLocus::IsAmel(sLocusName);
    for(nRow = 1; nRow < nRows; nRow++)
    {
      sAllele = GetCellValueTrimmed(nRow,nCol);
      if(CLabLocus::ValidateAllele(&sAllele,bAmel))
      {
        if(plc == NULL)
        {
          plc = _NewLabLocus(pvpLocus,sLocusName);
          vpLocus.push_back(plc);
          plc->SetName(sLocusName);
        }
        plc->AddAllele(sAllele);
      }
    }
    if(plc != NULL)
    {
      plc->SortAlleles();
    }
  }
  vectorptr<CLabLocus>::cleanup(pvpLocus);
  *pvpLocus = vpLocus;
  return true;
}
Ejemplo n.º 8
0
bool CGridAllele::_TransferDataFromWindow3(
  vector<CLabLocus *> *pvpLocus,
  int nStartCol, bool bRequire3)
{
  wxString sLocusName;
  wxString sAllele;
  vector<CLabLocus *> vpLocus;
  int nRows = GetNumberRows();
  int nCols = GetNumberCols();
  int nRow;
  int nCol;
  size_t nSize = pvpLocus->size();
  bool bRtn = true;
  vpLocus.reserve((nSize + 2) << 1);
  CLabLocus *plc;
  for(nCol = nStartCol; nCol < nCols; nCol++)
  {
    sLocusName = GetColLabelValue(nCol);
    for(nRow = 1; nRow < nRows; nRow++)
    {
      sAllele = GetCellValueTrimmed(nRow,nCol);
      if(sAllele.IsEmpty()) {}
      else if(
        (plc = _BuildLabLocus(
          pvpLocus,
          sLocusName,
          sAllele,
          bRequire3)) != NULL)
      {
        vpLocus.push_back(plc);
      }
      else
      {
        bRtn = false;
      }
    }
  }
  vectorptr<CLabLocus>::cleanup(pvpLocus);
  *pvpLocus = vpLocus;
  return bRtn;
}
/* restores column widths and sorting attributes */
bool CBOINCGridCtrl::OnRestoreState(wxConfigBase* pConfig) {
    wxString    strBaseConfigLocation = wxEmptyString;
    wxInt32     iIndex = 0;
    wxInt32     iTempValue = 0;
	wxInt32		iColumnCount = GetCols();

    wxASSERT(pConfig);

    // Retrieve the base location to store configuration information
    // Should be in the following form: "/Projects/"
    strBaseConfigLocation = pConfig->GetPath() + wxT("/");

    // Cycle through the columns recording anything interesting
    for (iIndex = 0; iIndex < iColumnCount; iIndex++) {
        wxString label = GetColLabelValue(iIndex);
        // Don't restore width for hidden / invisible columns
        if (label.IsEmpty()) {
            continue;
        }
        pConfig->SetPath(strBaseConfigLocation + label);

        pConfig->Read(wxT("Width"), &iTempValue, -1);
        if (-1 != iTempValue) {
			SetColSize(iIndex, iTempValue);
        }
    }
	//read sorting
	pConfig->SetPath(strBaseConfigLocation);
	pConfig->Read(wxT("SortColumn"),&iTempValue,-1);
	if(-1 != iTempValue) {
		sortColumn = iTempValue;
	}
	pConfig->Read(wxT("SortAscending"),&iTempValue,-1);
	if(-1 != iTempValue) {
		sortAscending = iTempValue != 0 ? true : false;
	}

    return true;
}
Ejemplo n.º 10
0
bool CGridLabThresholdsSample::TransferDataToWindow()
{
  int n = GetNumberCols();
  bool bRtn = (m_pData != NULL) && (n > 1);
  if(bRtn)
  {
    wxString sLocus;
    CLabLocusThreshold locus;
    const CLabRFU &rfu(*m_pData->GetRFUsample());
    const CLabLocusThreshold *pLocus;
    
    // setup defaults
    locus.SetFractionMaxPeak(rfu.GetFractionMaxPeak());
    locus.SetPullupFractionFilter(rfu.GetPullupFractionFilter());
    locus.SetStutter(rfu.GetStutterThreshold());
    locus.SetPlusStutter(rfu.GetPlusStutterThreshold());
    locus.SetAdenylation(rfu.GetAdenylationThreshold());
    locus.SetHeterozygousImbalanceLimit(
      m_pData->GetHeterozygousImbalanceLimit());
    locus.SetMinBoundForHomozygote(
      m_pData->GetMinBoundForHomozygote());
    _SetColumn(0,locus);
    locus.Init();
    for(int i = 1; i < n; i++)
    {
      sLocus = GetColLabelValue(i);
      pLocus = rfu.GetLabLocusThreshold(sLocus);
      if(pLocus != NULL)
      {
        _SetColumn(i,*pLocus);
      }
      else
      {
        _ClearColumn(i);
      }
    }
  }
  return bRtn;
}
Ejemplo n.º 11
0
bool CGridAlleleBase::SetupKit(
  const wxString &sKitName, bool bAllowAmel)
{
  bool bRtn = CGridLocusColumns::SetupKit(
    this,sKitName,m_vsLeftColumns,
    false,bAllowAmel,true);
  m_mapLocusColumn.clear();
  m_nAmelColumn = -1;
  EnableDragRowSize(false);
  if(bRtn)
  {
    wxString s;
    int nCols = GetNumberCols();
    int nCol;
    for(nCol = (int)m_vsLeftColumns.size(); nCol < nCols; nCol++)
    {
      s = GetColLabelValue(nCol);
      nwxString::Trim(&s);
      if(!s.IsEmpty())
      {
        m_mapLocusColumn.insert(
          map<wxString,int,nwxStringLessNoCase>::value_type(
            s,nCol));
        if(CLabLocus::IsAmel(s))
        {
          m_nAmelColumn = nCol;
        }
      }
    }
    nCols = (int)m_vsLeftColumns.size();
    wxColour sClr = GetDisabledColour();
    for(nCol = 0; nCol < nCols; nCol++)
    {
      SetCellBackgroundColour(0,nCol,
        sClr);
    }
  }
  return bRtn;
}
Ejemplo n.º 12
0
bool CGridLabThresholdsSample::_GetColumn(int nCol, CLabLocusThreshold *pLocus)
{
  wxString s;
  pLocus->Init();
  pLocus->SetLocusName(GetColLabelValue(nCol));
  pLocus->SetFractionMaxPeak(
    GetCellValueDouble(ROW_FRACTION_MAX_PEAK,nCol));
  pLocus->SetPullupFractionFilter(
    GetCellValueDouble(ROW_PULLUP_FRACTIONAL_FILTER,nCol));
  pLocus->SetStutter(
    GetCellValueDouble(ROW_STUTTER_THRESHOLD,nCol));
  pLocus->SetPlusStutter(
    GetCellValueDouble(ROW_PLUS_STUTTER_THRESHOLD,nCol));
  pLocus->SetAdenylation(
    GetCellValueDouble(ROW_ADENYLATION_THRESHOLD,nCol));
  pLocus->SetHeterozygousImbalanceLimit(
    GetCellValueDouble(ROW_HETEROZYGOUS_IMBALANCE_LIMIT,nCol));
  pLocus->SetMinBoundForHomozygote(
    GetCellValueDouble(ROW_MIN_BOUND_HOMOZYGOTE,nCol));

  // need validation code here

  return true;
}
Ejemplo n.º 13
0
wxString ctlSQLGrid::GetColKeyValue(int col)
{
	wxString colKey = wxString::Format(wxT("%d:"), col) + GetColLabelValue(col);
	return colKey;
}
Ejemplo n.º 14
0
void ctlSQLGrid::AutoSizeColumns(bool setAsMin)
{
	wxCoord newSize, oldSize;
	wxCoord maxSize, totalSize = 0, availSize;
	int col, nCols = GetNumberCols();
	int row, nRows = GetNumberRows();
	colMaxSizes.Empty();

	/* We need to check each cell's width to choose best. wxGrid::AutoSizeColumns()
	 * is good, but looping through long result sets gives a noticeable slowdown.
	 * Thus we'll check every first 500 cells for each column.
	 */

	// First pass: auto-size columns
	for (col = 0 ; col < nCols; col++)
	{
		ColKeySizeHashMap::iterator it = colSizes.find(GetColKeyValue(col));
		if (it != colSizes.end()) // Restore user-specified size
		{
			newSize = it->second;
			colMaxSizes.Add(-1);
		}
		else
		{
			wxClientDC dc(GetGridWindow());
			newSize = 0;
			// get cells's width
			for (row = 0 ; row < wxMin(nRows, 500) ; row++)
			{
				wxSize size = GetBestSize(row, col);
				if ( size.x > newSize )
					newSize = size.x;
			}
			// get column's label width
			wxCoord w, h;
			dc.SetFont( GetLabelFont() );
			dc.GetMultiLineTextExtent( GetColLabelValue(col), &w, &h );
			if ( GetColLabelTextOrientation() == wxVERTICAL )
				w = h;

			if ( w > newSize )
				newSize = w;

			if (!newSize)
				newSize = GetRowLabelSize();
			else
				// leave some space around text
				newSize += 6;

			colMaxSizes.Add(newSize);
		}
		SetColSize(col, newSize);
		totalSize += newSize;
	}

	availSize = GetClientSize().GetWidth() - GetRowLabelSize();

	// Second pass: shrink wide columns if exceeded available width
	if (totalSize > availSize)
	{
		// A wide column shouldn't take up more than 50% of the visible space
		maxSize = availSize / 2;
		for (col = 0 ; col < nCols ; col++)
		{
			oldSize = GetColSize(col);
			// Is too wide and no user-specified size
			if (oldSize > maxSize && !(col < (int)colMaxSizes.GetCount() && colMaxSizes[col] == -1))
			{
				totalSize -= oldSize;
				/* Shrink wide column to maxSize.
				 * If the rest of the columns are short, make sure to use all the remaining space,
				 *   but no more than oldSize (which is enough according to first pass)
				 */
				newSize = wxMin(oldSize, wxMax(maxSize, availSize - totalSize));
				SetColSize(col, newSize);
				totalSize += newSize;
			}
		}
	}
}
Ejemplo n.º 15
0
wxString ctlSQLGrid::GetColumnName(int colNum)
{
	wxString columnName = GetColLabelValue(colNum);
	columnName = columnName.Left(columnName.find(wxT("\n")));
	return columnName;
}
Ejemplo n.º 16
0
bool CGridAllelePosCtrl::TransferDataFromWindow()
{
  bool bRtn = (m_pData != NULL);
  if(bRtn)
  {
    wxString sName;
    wxString sFileString;
    wxString sAlleles;
    vector<wxString> vsAlleles;
    vector<CLabLocus *> vpNewLoci;
    vector<CLabPositiveControl *> vpNewPosCtrl;

    vector<CLabLocus *> *pvpLoci(NULL);
    CLabPositiveControl *pCtrl;
    CLabLocus *pLocus;

    int nRows = GetNumberRows();
    int nRow;
    int nCols = GetNumberCols();
    int nCol;

    for(nRow = 1; nRow < nRows; nRow++)
    {
      sName = GetCellValueTrimmed(nRow,0);
      if(!sName.IsEmpty())
      {
        sFileString = GetCellValueTrimmed(nRow,1);
        pCtrl = NULL;
        for(nCol = 2; nCol < nCols; nCol++)
        {
          sAlleles = GetCellValueTrimmed(nRow,nCol);
          if(!sAlleles.IsEmpty())
          {
            if(CLabLocus::BuildList(
              sAlleles,&vsAlleles,nCol == m_nAmelColumn))
            {
              if(pCtrl == NULL)
              {
                pCtrl = _GetPosCtrl();
                pCtrl->SetName(sName);
                pCtrl->SetFileNameString(sFileString);
                vpNewPosCtrl.push_back(pCtrl);
                pvpLoci = pCtrl->Get();
                vpNewLoci.clear();
              }
              pLocus = _NewLabLocus(pvpLoci,GetColLabelValue(nCol)); // recycle loci or create new
              pLocus->SetAlleles(vsAlleles);
              vpNewLoci.push_back(pLocus);
            }
          }
        } //end nCol loop
        if(pCtrl != NULL)
        {
          // clean up remaining old loci in this positive control
          // if any
          vectorptr<CLabLocus>::cleanup(pvpLoci);
          // copy the new loci to the new positive control
          (*pvpLoci) = vpNewLoci; // copy pointers
          vpNewLoci.clear();
        }
      }
    } // end nRow loop
    m_pData->SetPositiveControls(&vpNewPosCtrl);
  }
  return bRtn;
}