int GLIDebugVariableGrid::AddRowType(RowType addType, uint typeIndex)
{
  //Add the row and get the index
  AppendRows(1);

  //Add to the type array
  rowTypeDataArray.push_back(RowTypeData(addType, typeIndex));

  //Check that the array sizes match
  wxASSERT(rowTypeDataArray.size() == GetNumberRows());

  //Set the default properties for the different types
  int addIndex = GetNumberRows() - 1;
  switch(addType)
  {
    case(RT_Header):
      SetCellSize(addIndex, NAME_COLUMN_INDEX, 1, 3);
      SetReadOnly(addIndex, NAME_COLUMN_INDEX);
      SetCellBackgroundColour(addIndex, NAME_COLUMN_INDEX, gridGrey);
      SetCellFont(addIndex, NAME_COLUMN_INDEX, GetLabelFont());
      break;

    case(RT_WatchValue):
      SetCellRenderer(addIndex, NAME_COLUMN_INDEX, new OffsetStringGridCellRenderer(CELL_RENDER_OFFSET));  
      SetReadOnly(addIndex, VALUE_COLUMN_INDEX);
      break;

    case(RT_Uniform):
      SetReadOnly(addIndex, NAME_COLUMN_INDEX);
      SetReadOnly(addIndex, VALUE_COLUMN_INDEX);
      SetReadOnly(addIndex, TYPE_COLUMN_INDEX);

      SetCellRenderer(addIndex, NAME_COLUMN_INDEX, new OffsetStringGridCellRenderer(CELL_RENDER_OFFSET));  
      break;

    case(RT_UniformArray):
      SetReadOnly(addIndex, NAME_COLUMN_INDEX);
      SetReadOnly(addIndex, VALUE_COLUMN_INDEX);
      SetReadOnly(addIndex, TYPE_COLUMN_INDEX);

      SetCellRenderer(addIndex, NAME_COLUMN_INDEX, new OffsetStringGridCellRenderer(CELL_RENDER_OFFSET*2));  
      break;

  };


  //Return the index
  return addIndex;
}
示例#2
0
void CustomGrid::OnLabeClick( wxGridEvent& event)
{
    int row = event.GetRow();
    int col = event.GetCol();
    wxPoint p = event.GetPosition();
    ClearSelection();
    if( row == wxNOT_FOUND && event.GetCol() == wxNOT_FOUND ){              //corner label
        //find the first visible row/col
        int frow = 0, fcol = 0;
        GetFirstVisibleCell(frow, fcol);
        //then scroll as requested;
        MakeCellVisible(frow, m_numCols - 1);
        MakeCellVisible(frow, m_gParent->m_pIndex);
    } else if( row != wxNOT_FOUND && col == wxNOT_FOUND ){ //numerical row label
        int idx = GetRowIndex(row);
        if( idx != wxNOT_FOUND ){
            if(m_IsDigit.GetChar(idx) == 'X' )
                m_IsDigit.SetChar(idx, '.');
            else
                m_IsDigit.SetChar(idx, 'X');
            for( int c = 0; c < m_numCols; c++){
                double value = m_NumRowVal[idx][c];
                /*Current direction is generally reported as the "flow" direction, which is opposite from wind convention. So, adjust.*/
                if( idx == R_CURRENT && m_IsDigit.GetChar(idx) == 'X' && value != GRIB_NOTDEF){
                    value += 180;
                    if(value >= 360) value -= 360;
                    if( value < 0 ) value += 360;
                }
                SetCellRenderer( row, c, new CustomRenderer(value, m_IsDigit.GetChar(idx) == 'X') );
            }
            m_tRefreshTimer.Start( 10, wxTIMER_ONE_SHOT );
        }
    }
}
示例#3
0
int wxPropertyList::AddPropertyToGrid(wxPropertyItem *pItem, int order)
{
    int row = 0;
    if(order == 1)
        InsertRows(0,1);
    else 
    {
        AppendRows(1);    
        row = GetNumberRows() - 1;
    }
    
    // initialise the type of renderer
    if(pItem->GetItemType() == wxPropertyList::CHECKBOX)
    {
        SetCellRenderer(row, 1, new wxGridCellBoolRenderer);
        SetCellEditor(row, 1, new wxGridCellBoolEditor);
    }

#ifdef __LINUX__
    // fix to make sure scrollbars are drawn properly
    wxGrid::AdjustScrollbars();
#endif
    
    // the property display is read only
    UpdatePropertyItem(pItem, row);
    return row;
}
示例#4
0
void CGridLocus::_ImplementColumn(int nCol,bool bAmel)
{
    int nStart = nCol;
    int nStop = nCol;
    int i;
    int k;
    int n = GetNumberCols();
    if(nCol >= n)
    {
        AppendCols(nCol - n + 1);
        nStart = n;
    }
    for(k = nStart; k <= nStop; ++k)
    {
        s.Printf("Peak %d",k+1);
        SetColLabelValue(k,s);
        for(i = ROW_RO_FIRST; i <= ROW_RO_LAST; i++)
        {
            DisableEdit(i,k);
        }
        SetBoolCell(ROW_HOMOZYGOUS,k);
        SetBoolCell(ROW_OFF_LADDER,k);
        SetBoolCell(ROW_DISABLE,k);

        SetCellEditor(ROW_BPS,k,new wxGridCellFloatEditor(12,7));
        SetCellRenderer(ROW_BPS,k,new wxGridCellFloatRenderer(12,7));
        if(!bAmel)
        {
            wxGridCellFloatEditor *pfe1(new wxGridCellFloatEditor(5,1));
            wxGridCellFloatRenderer *pfr1(new wxGridCellFloatRenderer(5,1));
            SetCellEditor(ROW_ALLELE,k,pfe1);
            SetCellRenderer(ROW_ALLELE,k,pfr1);
        }
        else
        {
            wxGridCellTextEditor *pe(new wxGridCellTextEditor);
            pe->SetParameters(_T("1"));
            SetCellEditor(ROW_ALLELE,k,pe);
        }

        SetCellAlignment(wxALIGN_RIGHT,  ROW_ALLELE,k);
        SetCellAlignment(wxALIGN_RIGHT,  ROW_BPS,k);
        SetCellAlignment(wxALIGN_RIGHT,  ROW_RFU,k);
        SetCellAlignment(wxALIGN_RIGHT,  ROW_TIME,k);
        SetCellAlignment(wxALIGN_RIGHT,  ROW_PEAK_AREA,k);
    }
}
void CatheterGrid::formatDefaultRow(int row) {
    if (row >= GetNumberRows())
        return;
    const wxString direction_opts[] = { DIRNEGSTR, DIRPOSSTR };

    wxString channel_opts[NCHANNELS + 1];
    channel_opts[0] = GLOBALSTR;
    for (int i = 1; i <= NCHANNELS; i++)
        channel_opts[i] = wxString::Format("%d", i);

    SetCellEditor(row, CHANNEL_COL, new wxGridCellChoiceEditor(WXSIZEOF(channel_opts), (const wxString*)channel_opts));
    SetCellEditor(row, CURRENT_COL, new wxGridCellFloatEditor(3, 3));
    SetCellRenderer(row, CURRENT_COL, new wxGridCellFloatRenderer());
    SetCellEditor(row, DIRECTION_COL, new wxGridCellChoiceEditor(WXSIZEOF(direction_opts), direction_opts));
    SetCellEditor(row, DELAY_COL, new wxGridCellNumberEditor(0, MAX_DELAY));
    SetCellRenderer(row, DELAY_COL, new wxGridCellNumberRenderer());
	SetCellValue(row, DELAY_COL, wxT("0"));
    setRowReadOnly(row, true);
}
示例#6
0
void CustomGrid::SetNumericalRow( int row, int col, int datatype, double value )
{
    m_NumRow[datatype] = row;
    m_NumRowVal[datatype].push_back(value);
    /*Current direction is generally reported as the "flow" direction,which is opposite from wind convention. So, adjust.*/
    if( datatype == R_CURRENT && m_IsDigit.GetChar(datatype) == 'X' && value != GRIB_NOTDEF){
        value += 180;
        if(value >= 360) value -= 360;
        if( value < 0 ) value += 360;
    }
    SetCellRenderer( row, col, new CustomRenderer(value, m_IsDigit.GetChar(datatype) == 'X') );
}
void GLIDebugVariableGrid::AddUniformDisplay(const UniformRowData &uniformValue, uint uniformOffset)
{
  //Create the initial static item  
  int uniformRowIndex = AddRowType(RT_Uniform, uniformOffset);  

  //Assign the name
  SetCellValue(uniformRowIndex, NAME_COLUMN_INDEX, uniformValue.name);

  //Assign the type
  SetCellValue(uniformRowIndex, TYPE_COLUMN_INDEX, GetGLSLStringType(uniformValue.type));

  //Get the array size
  if(uniformValue.arrayCount == 0)
  {
    SetCellValue(uniformRowIndex, VALUE_COLUMN_INDEX, wxT("<empty>"));
    return;
  }

  //If there is more than one array item, nest them
  if(uniformValue.arrayCount > 1)
  {
    //Update the main label name
    wxString labelName;
    labelName.Printf("%s[%u]", uniformValue.name.c_str(), uniformValue.arrayCount); 
    SetCellValue(uniformRowIndex, NAME_COLUMN_INDEX, labelName);
    SetCellRenderer(uniformRowIndex, NAME_COLUMN_INDEX, new ExpandGridCellRenderer(CELL_RENDER_OFFSET, uniformValue.isExpanded));
    SetCellValue(uniformRowIndex, VALUE_COLUMN_INDEX, wxT("...."));

    //If the array is expanded
    if(uniformValue.isExpanded)
    {
      //Loop an add each item as a sub item
      for(uint i=0; i<uniformValue.arrayCount; i++)
      {
        int arrayRowIndex = AddRowType(RT_UniformArray, i);  

        //Set the name
        labelName.Printf("%s[%u]", uniformValue.name.c_str(), i); 
        SetCellValue(arrayRowIndex, NAME_COLUMN_INDEX, labelName);
        SetCellValue(arrayRowIndex, TYPE_COLUMN_INDEX, GetGLSLStringType(uniformValue.type));

        //Add the description
        if(uniformValue.isFloatType)
        {
          SetItemValue(arrayRowIndex, uniformValue.type, uniformValue.numTypeElements, &uniformValue.floatUniformData[i*uniformValue.numTypeElements]);
        }
        else
        {
          SetItemValue(arrayRowIndex, uniformValue.type, uniformValue.numTypeElements, &uniformValue.intUniformData[i*uniformValue.numTypeElements]);
        }
      }
    }
  }
  else
  {
    //Add the single value
    if(uniformValue.isFloatType)
    {
      SetItemValue(uniformRowIndex, uniformValue.type, uniformValue.floatUniformData.size(), &uniformValue.floatUniformData[0]);
    }
    else
    {
      SetItemValue(uniformRowIndex, uniformValue.type, uniformValue.intUniformData.size(), &uniformValue.intUniformData[0]);
    }
  }
 
}
void GLIDebugVariableGrid::SetItemValue(int rowIndex, GLenum glType, unsigned int floatCount, const float *floatData)
{
  wxString setText;

  //Determine if the color block is rendered
  bool renderColor = false;
  if(floatCount == 3 ||
     floatCount == 4)
  {
    renderColor = true;
  }

  //Determine if it is a matrix type
  bool isMatrix = false;
  uint numMatrixElemPerRow = 1;
  if(glType == GL_FLOAT_MAT2 || 
     glType == GL_FLOAT_MAT3 ||
     glType == GL_FLOAT_MAT4 ||
     glType == GL_FLOAT_MAT2x3 ||
     glType == GL_FLOAT_MAT2x4 ||
     glType == GL_FLOAT_MAT3x2 ||
     glType == GL_FLOAT_MAT3x4 ||
     glType == GL_FLOAT_MAT4x2 ||
     glType == GL_FLOAT_MAT4x3)
  {
    isMatrix = true;
    renderColor = false;

    //Get the number of matrix rows
    switch(glType)
    {
      case(GL_FLOAT_MAT2):
      case(GL_FLOAT_MAT2x3):
      case(GL_FLOAT_MAT2x4):
        numMatrixElemPerRow = 2;
        break;
      case(GL_FLOAT_MAT3):
      case(GL_FLOAT_MAT3x2):
      case(GL_FLOAT_MAT3x4):
        numMatrixElemPerRow = 3;
        break;
      case(GL_FLOAT_MAT4):
      case(GL_FLOAT_MAT4x2):
      case(GL_FLOAT_MAT4x3):
        numMatrixElemPerRow = 4;
        break;
    };

    switch(glType)
    {
      case(GL_FLOAT_MAT2):
      case(GL_FLOAT_MAT3x2):
      case(GL_FLOAT_MAT4x2):
        SetRowSize(rowIndex, GetRowSize(rowIndex) * 2);
        break;
      case(GL_FLOAT_MAT3):
      case(GL_FLOAT_MAT2x3):
      case(GL_FLOAT_MAT4x3):

        SetRowSize(rowIndex, GetRowSize(rowIndex) * 3);
        break;
      case(GL_FLOAT_MAT4):
      case(GL_FLOAT_MAT2x4):
      case(GL_FLOAT_MAT3x4):
        SetRowSize(rowIndex, GetRowSize(rowIndex) * 4);
        break;
    };
  }

  //Add an opening brace
  if(floatCount > 1)
  {
    setText += "("; 
  }

  //Copy the data
  for(unsigned int i=0; i<floatCount; i++)
  {
    wxString newStr;
    newStr.Printf(wxT("%g"), floatData[i]); // TODO: Transpose
    
    //Ensure there is a trailing .0
    if(newStr.Find('.') < 0 &&
       newStr.Find('e') < 0)
    {
      newStr += ".0";
    }

    //Append to the string
    setText += newStr;

    //Add a comma if necessary
    if(i != floatCount-1)
    {
      setText += ", "; 
    }

    //If this is the end of a matrix row, add a newline
    if(isMatrix && 
       (i != floatCount-1) && 
       ((i+1) % numMatrixElemPerRow == 0))
    {
      setText += "\n ";
    }
  }

  //Add a closing brace
  if(floatCount > 1)
  {
    setText += ")"; 
  }


  //If rendering a color
  if(renderColor)
  {
    //Assign a color box render to the value
    wxColor assignColour = wxColor(FloatClamp(floatData[0]), 
                                   FloatClamp(floatData[1]),
                                   FloatClamp(floatData[2]));

    SetCellRenderer(rowIndex, VALUE_COLUMN_INDEX, new ColourGridCellRenderer(assignColour));
  }

  //Assign the data to the row
  SetCellValue(rowIndex, VALUE_COLUMN_INDEX, setText);
}