LogMessagesViewer::LogMessagesViewer( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name )
        : wxGrid( parent, id, pos, size, style, name ),
        _timer( this )
{
    // grid
    CreateGrid( 0, 4 );
    EnableEditing( false );
    EnableGridLines( false );
    EnableDragGridSize( false );
    SetMargins( 0, 0 );
    // columns
    //EnableDragColMove( false );
    EnableDragColSize( true );
    SetColLabelSize( 20 );
    SetColLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
    // rows
    EnableDragRowSize( true );
    SetRowLabelSize( 40 );
    SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
    // label appearance
    SetColLabelValue( 0, _T( "description" ) );
    SetColLabelValue( 1, _T( "source" ) );
    SetColLabelValue( 2, _T( "line" ) );
    SetColLabelValue( 3, _T( "clock" ) );
    // cell defaults
    SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP );

    coca::getLogger().addHandler( *this );

    _timer.Start( 200 );
}
ctlResultGrid::ctlResultGrid( wxWindow * parent, wxWindowID id )
    : wxGrid( parent, id )
{
    wxWindowBase::SetFont(settings->GetSystemFont());

    CreateGrid( 0, 0 );
}
示例#3
0
void CGridLabThresholds::_CreateGrid(int nRows, int nCols)
{
  int nPrevCols = 0;
  int nPrevRows = 0;
  int nCol;
  if(!m_bCreated)
  {
    m_bCreated = true;
    CreateGrid(nRows,nCols);
    SetRowLabelAlignment(wxALIGN_LEFT, wxALIGN_CENTRE);
    EnableDragColSize(false);
    EnableDragRowSize(false);
    SetDefaultCellAlignment(wxALIGN_RIGHT,wxALIGN_CENTRE);
  }
  else
  {
    nPrevRows = GetNumberRows();
    nPrevCols = GetNumberCols();
    nwxGrid::SetRowColCount(this,nRows,nCols);
  }
  for(nCol = nPrevCols; nCol < nCols; nCol++)
  {
    // set alignment for Channel row
    SetCellAlignment(0,nCol,wxALIGN_CENTRE, wxALIGN_CENTRE);
  }
}
示例#4
0
Maze::Maze(int grid_size)
{
	m_gridSize = grid_size;

	// construct and fill the grid
	CreateGrid(); 
}
CGridAnalysis::CGridAnalysis(wxWindow *pParent) :
  wxGrid(pParent,IDgrid),
  m_bgBold(255,255,160),
  m_bgNormal(255,255,255),
  m_bgRowHasAlert(255,255,218),
  m_fgBold(192,0,0),
  m_fgNormal(0,0,0),
  m_pDC(NULL),
  m_nLabelSize(0),
  m_nLabelType(-1),
  m_nXScroll(0),
  m_nYScroll(0),
  m_nIDmenuSort(IDmenuSortFileName)
{
  CreateGrid(1,1);
  SetRowLabelValue(0,wxEmptyString);
  SetColLabelValue(0,wxEmptyString);
  SetReadOnly(0,0,true);
  SetRowLabelAlignment(wxALIGN_LEFT,wxALIGN_CENTRE);
  m_fontNormal = GetDefaultCellFont();
  m_fontItalic = m_fontNormal;
  m_fontBold = m_fontNormal;
  m_fontBold.SetWeight(wxFONTWEIGHT_BOLD);
  m_fontBoldItalic = m_fontBold;
  m_fontBoldItalic.SetStyle(wxFONTSTYLE_ITALIC);
  m_fontItalic.SetStyle(wxFONTSTYLE_ITALIC);
#if USE_WINGDINGS
  g_fontStatus.SetPointSize(m_fontNormal.GetPointSize());
#else
  // X11 if ever implemented
  g_fontStatus = m_fontBold;
#endif

}
示例#6
0
ctlVarWindow::ctlVarWindow( wxWindow *parent, wxWindowID id )
	: wxGrid( parent, id ),
	  m_cells( NULL ),
	  m_nameFont( GetDefaultCellFont())
{
	wxWindowBase::SetFont(settings->GetSystemFont());

	// Create the grid control
	CreateGrid( 0, 0 );
	SetRowLabelSize( 0 );	// Turn off the row labels

	// Set up three columns: name, value, and data type
	AppendCols( 3 );
	SetColLabelValue( COL_NAME,  _( "Name" ));
	SetColLabelValue( COL_TYPE,  _( "Type" ));
	SetColLabelValue( COL_VALUE, _( "Value" ));

	EnableDragGridSize( true );

	// EDB wants to hide certain PL variables.  To do that, we
	// keep a hash of hidden names and a hash of hidden types...
	m_hiddenNames.insert( wxT( "found" ));
	m_hiddenNames.insert( wxT( "rowcount" ));
	m_hiddenNames.insert( wxT( "sqlcode" ));
	m_hiddenNames.insert( wxT( "sqlerrm" ));
	m_hiddenNames.insert( wxT( "_found" ));
	m_hiddenNames.insert( wxT( "_rowcount" ));
	m_hiddenNames.insert( wxT( "sqlstate" ));

	m_hiddenTypes.insert( wxT( "refcursor" ));

}
BOOL CTWenUGCtrlEx::CreateTable(CWnd *pcParent, CRect rect)
{
	if(!CreateGrid(WS_CHILD|WS_VISIBLE,rect, pcParent, 1234)) return FALSE;

	if(!m_bDislplayFirstColumn) SetColWidth(-1, 0);

	return TRUE;
}
示例#8
0
GameOfLife::GameOfLife(int noOfXCells, int noOfYCells)
           :GameGrid(0),
            noOfXCells(noOfXCells),
            noOfYCells(noOfYCells)
            
{
  CreateGrid();
}
示例#9
0
void Cmd_ComputeNodes_f (edict_t *ent)
{
	if (!ent->myskills.administrator)
		return;

	CreateGrid(true);
	safe_cprintf(ent, PRINT_HIGH, "Computing nodes...\n");
}
CGridSampleLimits::CGridSampleLimits(wxWindow *parent, wxWindowID id) :
  _CGridEdit(parent,id), 
  m_pValidatePct(NULL), 
  m_pData(NULL),
  m_pMessageBook(NULL)
  //,m_bReadOnly(false)
{
  wxString PEAKS(_T("peaks"));
  CreateGrid(ROW_MESSAGE_BOOK_OFFSET,2);
  EnableDragColSize(false);
  EnableDragRowSize(false);

  EnableScrolling(false,true);

  SetRowLabelValue(ROW_PULLUP,_T("Max. No. of pullups peaks per sample"));
  SetCellValue(ROW_PULLUP,1,PEAKS);

  SetRowLabelValue(ROW_STUTTER,_T("Max. No. of stutter peaks per sample"));
  SetCellValue(ROW_STUTTER,1,PEAKS);

  SetRowLabelValue(ROW_ADENYLATION,_T("Max. No. of adenylation peaks per sample"));
  SetCellValue(ROW_ADENYLATION,1,PEAKS);

  SetRowLabelValue(ROW_OFF_LADDER,_T("Max. off-ladder alleles per sample:"));
  SetCellValue(ROW_OFF_LADDER,1,PEAKS);
  
  SetRowLabelValue(ROW_RESIDUAL,_T("Max. residual for allele (<0.5 bp):"));
  SetCellValue(ROW_RESIDUAL,1,_T("Sample/Ladder BP alignment"));
  SetCellEditor(ROW_RESIDUAL,0,new wxGridCellFloatEditor(-1,4));
  SetDefaultCellValidator(new nwxGridCellUIntRangeValidator(0,1000000,true));
  SetCellValidator(
    new nwxGridCellDoubleRangeValidator(0.0,0.5,true),
    ROW_RESIDUAL,0);
  
  SetRowLabelValue(ROW_EXCESSIVE_RESIDUAL,_T("Max. No. of peaks with excessive residual:"));
  SetCellValue(ROW_EXCESSIVE_RESIDUAL,1,PEAKS);

  SetRowLabelValue(ROW_RFU_INCOMPLETE_SAMPLE,_T("Incomplete profile threshold for Reamp More/Reamp Less:"));
  SetCellValue(ROW_RFU_INCOMPLETE_SAMPLE,1,_T("RFU"));

  SetRowLabelValue(ROW_MIN_BPS_ARTIFACTS,_T("Ignore artifacts smaller than:"));
  SetCellValue(ROW_MIN_BPS_ARTIFACTS,1,_T("bps"));
  m_clrBackground = GetLabelBackgroundColour();
  wxFont fnLabel = GetLabelFont();
  for(int nRow = 0; nRow < ROW_MESSAGE_BOOK_OFFSET; nRow++)
  {
    SetCellBackgroundColour(nRow,1,m_clrBackground);
    SetReadOnly(nRow,1,true);
    SetCellFont(nRow,1,fnLabel);
    SetCellAlignment(nRow,0,wxALIGN_RIGHT, wxALIGN_CENTRE);
  }
  SetDefaultEditor(new wxGridCellFloatEditor(1,0));
  SetColLabelValue(0,_T("Value"));
  SetColLabelValue(1,_T("Units"));
  SetRowLabelAlignment(wxALIGN_LEFT, wxALIGN_CENTRE);
  SetColLabelAlignment(wxALIGN_CENTRE, wxALIGN_CENTRE);
}
示例#11
0
void UiPropertyGrid::DisplayPropertyGrid( SceneManager::Component* object )
{
	DeleteGrid();

	if (object)
	{
		m_component = object;
		CreateGrid();
	}
}
示例#12
0
CGridRFURunBase::CGridRFURunBase(wxWindow *parent,wxWindowID id) :
  CGridRFUbase(parent,id),
  m_nROW_SAMPLE(0),
  m_nROW_CHANNEL_START(1),
  m_nROW_AFTER_CHANNEL(-1),
  m_nROW_LADDER(-1),
  m_nROW_ILS(-1),
  m_nROW_COUNT(-1)
{
  CreateGrid(7,COL_COUNT);
}
示例#13
0
bool Water::Initialise(float height, float spacing, int size)
{
    m_height = height;

    if (CreateGrid(Float2(1.0f, 1.0f), spacing, size, size, false, false))
    {
        InitialiseMeshData();
        return true;
    }
    return false;
}
示例#14
0
BOOL CGridChartWnd::Create (DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID)
{
	// TODO: 在此添加专用代码和/或调用基类
	m_pParentWnd = pParentWnd;
	m_pGrid = CreateGrid ();
	m_pChart = CreateChart ();

	BOOL bResult = CWnd::Create (globalData.RegisterWindowClass (_T("GridChartCntnr")), _T(""), dwStyle, rect, pParentWnd, nID);
	return bResult && m_pGrid != NULL && m_pChart != NULL;

	//	return CWnd::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, nID, pContext);
}
示例#15
0
CGridRFULimits::CGridRFULimits(wxWindow *parent, wxWindowID id) :
  CGridRFUbase(parent,id),
  m_nCOL_SAMPLE(0),
  m_nCOL_CHANNEL_START(1),
  m_nCOL_AFTER_CHANNEL(-1),
  m_nCOL_LADDER(-1),
  m_nCOL_ILS(-1),
  m_pData(NULL)
{
  CreateGrid(ROW_COUNT,7); 
  // 7 columns = sample + ils + ladder + 4 channels (guess)
  //  adjusted in _Build();
}
示例#16
0
文件: t39.cpp 项目: osom8979/example
MyGrid::MyGrid(wxNotebook * parent) :
        wxGrid(parent, wxID_ANY)
{
    CreateGrid(30, 30);
    SetRowLabelSize(50);
    SetColLabelSize(25);
    SetRowLabelAlignment(wxALIGN_RIGHT, wxALIGN_CENTRE);
    SetLabelFont(wxFont(9, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD));

    for (int i = 0; i < 30; i++) {
        this->SetRowSize(i, 25);
    }
}
示例#17
0
// place a triangle mesh in the grid
void TXGrid3D::PlaceIntoGrid(TXGeometry *geom) 
{
	m_min = CVector3f(FLT_MAX, FLT_MAX, FLT_MAX);
	m_max = CVector3f(-FLT_MAX, -FLT_MAX, -FLT_MAX);

	// compute bounding box
	int totalTriangles = 0;

	TXTriangle* tp;
	CVector3f p;

	for(ULONG t=0;t<geom->m_triangles.size();t++)
	{
		tp = geom->m_triangles[t];
		totalTriangles++;
		for(int i=0;i<3;i++)
		{
			p = tp->m_v[i]->m_pos;
			m_min.Set(
				MIN(m_min.GetX(),p.GetX()),
				MIN(m_min.GetY(),p.GetY()),
				MIN(m_min.GetZ(),p.GetZ())
			);
			m_max.Set(MAX(m_max.GetX(),p.GetX()),
				MAX(m_max.GetY(),p.GetY()),
				MAX(m_max.GetZ(),p.GetZ())
			);
		}
	}

	Application().LogMessage(L"Total Triangles : "+(CString)totalTriangles);

	// select grid size
	int grid_size;
	if (totalTriangles <= 10000) grid_size = 10;
	else if (totalTriangles <= 40000) grid_size = 15;
	else grid_size = 20;

	// create grid
	CreateGrid(grid_size);

	m_xstep = (m_max.GetX() - m_min.GetX()) / m_size;
	m_ystep = (m_max.GetY() - m_min.GetY()) / m_size;
	m_zstep = (m_max.GetZ() - m_min.GetZ()) / m_size;

	for(ULONG t=0;t<geom->m_triangles.size();t++)
	{
		PlaceTriangle(geom->m_triangles[t]);
	}
	 
}
示例#18
0
GameOfLife::GameOfLife(const GameOfLife& rhs)
            :GameGrid(0),
            noOfXCells(rhs.noOfXCells),
            noOfYCells(rhs.noOfYCells)
{
  CreateGrid();
  for (int x = 0; x < noOfXCells; x++)
  {
    for (int y = 0; y < noOfYCells; y++)
    {
      GameGrid[x * y] = rhs.GameGrid[x * y];
    }
  }
}
//---------------------------------------------------------
CActive_Attributes_Control::CActive_Attributes_Control(wxWindow *pParent)
	: wxGrid(pParent, -1, wxDefaultPosition, wxDefaultSize, wxWANTS_CHARS)
{
	m_pTable	= new CSG_Table;
	m_bEditing	= false;

	SetRowLabelAlignment(wxALIGN_RIGHT, wxALIGN_CENTRE);

	Set_Row_Labeling(false);

	CreateGrid(0, m_pTable->Get_Field_Count());

	Update_Table();
}
//---------------------------------------------------------
CVIEW_Table_Control::CVIEW_Table_Control(wxWindow *pParent, CSG_Table *pTable, int Constraint)
	: wxGrid(pParent, -1, wxDefaultPosition, wxDefaultSize, wxWANTS_CHARS|wxSUNKEN_BORDER)
{
	m_pTable		= pTable;
	m_pRecords		= NULL;
	m_Constraint	= Constraint;
	m_bSelOnly		= false;
	m_bEditing		= false;

	Set_Labeling(false);

	CreateGrid(m_pTable->Get_Record_Count(), m_pTable->Get_Field_Count(), wxGrid::wxGridSelectRows);

	Update_Table();
}
示例#21
0
CGridLocus::CGridLocus(
    COARlocus *pLocusEdit,
    wxWindow *parent,
    wxWindowID id,
    bool bReadOnly) :
    _CGridEdit(parent,id,bReadOnly),
    m_pLocusEdited(pLocusEdit)
{
    wxSize sz;
    size_t nCount = m_pLocusEdited->AlleleCount();
    size_t j;
    int nCol = nCount ? (int) nCount : 1;
    int nRow = nCount ? nLABELS : 1;
    int i;
    int k;

    CreateGrid(nRow,nCol);
    if(!nCount)
    {
        SetRowLabelValue(0,wxEmptyString);
        SetColLabelValue(0,wxEmptyString);
        SetReadOnly(0,0,true);
        SetReadOnly(0,1,true);
        SetReadOnly(1,0,true);
        SetReadOnly(1,1,true);
    }
    else
    {
        bool bAmel = m_pLocusEdited->IsAmel();
        for(i = 0; i < nRow; i++)
        {
            s = _T(labels[i]);
            SetRowLabelValue(i,s);
            SetRowLabelAlignment(wxALIGN_LEFT, wxALIGN_CENTRE);
        }
        for(j = 0; j < nCount; j++)
        {
            k = (int)j;
            _ImplementColumn(k,bAmel);
        }
        TransferDataToWindow();
        nwxGrid::UpdateLabelSizes(this);
    }
    DisableDragRowSize();
    DisableDragColSize();
    SetColLabelSize(GetRowSize(0));
    s.Empty();
}
示例#22
0
void Display() {
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glColor4f(0.75f, 0.75f, 0.75f, 1.0f);

	gluLookAt(
		g_Camera.c_vPosition.getXcoord(), g_Camera.c_vPosition.getYcoord(), g_Camera.c_vPosition.getZcoord(),
		g_Camera.c_vTarget.getXcoord(), g_Camera.c_vTarget.getYcoord(), g_Camera.c_vTarget.getZcoord(),
		g_Camera.c_vUpVector.getXcoord(), g_Camera.c_vUpVector.getYcoord(), g_Camera.c_vUpVector.getZcoord()
		);

	RenderManager::getInstance()->DrawList();
	CreateGrid();
	glutSwapBuffers();
}
void PezInitialize()
{
    const PezConfig cfg = PezGetConfig();

    // Assign the vertex attributes to integer slots:
    GLuint* pAttr = (GLuint*) &Attr;
    for (int a = 0; a < sizeof(Attr) / sizeof(GLuint); a++) {
        *pAttr++ = a;
    }

    // Compile shaders
    Globals.SimpleProgram = LoadProgram("Simple.VS", 0, "Simple.FS");
    Globals.QuadProgram = LoadProgram("Quad.VS", 0, "Quad.FS");
    Globals.GridProgram = LoadProgram("Grid.VS", 0, "Grid.FS");
    Globals.LitProgram = LoadProgram("Lit.VS", "Lit.GS", "Lit.FS");

    // Set up viewport
    float fovy = 16 * TwoPi / 180;
    float aspect = (float) cfg.Width / cfg.Height;
    float zNear = 0.1, zFar = 300;
    Globals.Projection = M4MakePerspective(fovy, aspect, zNear, zFar);
    Point3 eye = {0, 1, 4};
    Point3 target = {0, 0, 0};
    Vector3 up = {0, 1, 0};
    Globals.View = M4MakeLookAt(eye, target, up);

    // Create offscreen buffer:
    Globals.FboHandle = CreateRenderTarget(&Globals.FboTexture);
    glUseProgram(Globals.QuadProgram);
    Globals.QuadVao = CreateQuad();
    Globals.Grid = CreateGrid(GridRows, GridCols);

    // Create geometry
    Globals.Cylinder = CreateCylinder();

    // Misc Initialization
    Globals.Theta = 0;
    glClearColor(0.9, 0.9, 1.0, 1);
    glLineWidth(1.5);
    glEnable(GL_LINE_SMOOTH);
    glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    glEnable(GL_POLYGON_OFFSET_FILL);
    glPolygonOffset(1,1);
}
void TerrainTilesPanel::InitPanel(int numCols, int numRows)
{
	//Recreate canvas
	CreateCanvas(numCols, numRows);

	//Fill with invalid TerrainTile
	FillTerrainTiles(InvalidTerrainTileId, ion::Vector2i(0, 0), ion::Vector2i(numCols - 1, numRows - 1));

	//Redraw TerrainTiles on canvas
	PaintCollisionTerrainTiles();

	//Recreate grid
	CreateGrid(numCols, numRows, numCols, numRows);

	//Centre camera and reset zoom
	ResetZoomPan();
}
示例#25
0
void Editor::Init( HGE *aHGE )
{
	myPositionInGridX = 0;
	myPositionInGridY = 0;
	myHGE = aHGE;
	myWidth = 10;
	myHeight = 10;
	myTileSize = 32;
	myTiles.Init( myWidth * myHeight );
	myBlocks.Init(64);
	
	myFont = new hgeFont( "font1.fnt" );
	myFont->SetColor(ARGB(255,0,255,0));
	//myFont->SetScale(.f);
	
	LoadBlockTypes();
	CreateGrid();
}
示例#26
0
DataGrid::DataGrid(wxWindow* parent, wxWindowID id)
: wxGrid(parent, id)
, m_data(NULL)
{
	SetColMinimalAcceptableWidth(70);
	DisableDragRowSize();
	CreateGrid(0, ColumnNum);
	SetColLabelValue(IncomeIndex, HaStrings::strIncome);
	SetColLabelValue(OutlayIndex, HaStrings::strOutlay);
	SetColLabelValue(BalanceIndex, HaStrings::strBalance);
	SetColLabelValue(DescIndex, HaStrings::strDesc);
	SetColLabelValue(CommentIndex, HaStrings::strComment);
	SetColFormatFloat(IncomeIndex, MONEY_LEN, 2);
	SetColFormatFloat(OutlayIndex, MONEY_LEN, 2);
	SetColFormatFloat(BalanceIndex, MONEY_LEN, 2);
	AppendRows(2);
	for (int i = 0; i < ColumnNum; i++) SetReadOnly(0, i);
}
TerrainTileEditorPanel::TerrainTileEditorPanel(MainWindow* mainWindow, Project& project, ion::render::Renderer& renderer, wxGLContext* glContext, RenderResources& renderResources, wxWindow *parent, wxWindowID winid, const wxPoint& pos, const wxSize& size, long style, const wxString& name)
	: ViewPanel(mainWindow, project, renderer, glContext, renderResources, parent, winid, pos, size, style, name)
{
	//No panning
	EnablePan(false);

	const int tileWidth = m_project.GetPlatformConfig().tileWidth;
	const int tileHeight = m_project.GetPlatformConfig().tileHeight;

	m_canvasSize.x = tileWidth;
	m_canvasSize.y = tileHeight;

	//Create rendering primitives
	m_tilePrimitive = new ion::render::Quad(ion::render::Quad::xy, ion::Vector2(tileWidth * 4.0f, tileHeight * 4.0f));
	m_collisionPrimitive = new ion::render::Quad(ion::render::Quad::xy, ion::Vector2(tileWidth * 4.0f, tileHeight * 4.0f));

	//Create 8x8 grid
	CreateGrid(tileWidth, tileHeight, tileWidth, tileHeight);
}
GLIDebugVariableGrid::GLIDebugVariableGrid(wxWindow *parent,
                                           wxWindowID id,
                                           uint displayFlags,
                                           const wxPoint& pos,
                                           const wxSize& size,
                                           long style,
                                           const wxString& name):
wxGrid(parent, id, pos, size, style, name),
gridFlags(displayFlags),
internalCellEditCounter(0)
{
  //Create a drag target
  SetDropTarget(new GridDnDText(this));

  //Create the grid of 3 columns
  CreateGrid(0, 3, wxGrid::wxGridSelectRows);

  //Set the label values
  SetColLabelValue(NAME_COLUMN_INDEX,  wxT("Name"));
  SetColLabelValue(VALUE_COLUMN_INDEX, wxT("Value"));
  SetColLabelValue(TYPE_COLUMN_INDEX,  wxT("Type"));
  SetColLabelAlignment(wxALIGN_CENTRE, wxALIGN_TOP);
  SetColLabelSize(17);

  //Set the column sizes
  SetColSize(NAME_COLUMN_INDEX,  125);
  SetColSize(VALUE_COLUMN_INDEX, 200);
  SetColSize(TYPE_COLUMN_INDEX,  115);

  //Turn off row labels
  SetRowLabelSize(0);

  //Turn off cell overflowing
  SetDefaultCellOverflow(false);

  //Setup default colours
  SetDefaultCellBackgroundColour(*wxWHITE);
  SetDefaultCellTextColour      (*wxBLACK);
  SetGridLineColour       (gridGrey);
  SetLabelBackgroundColour(gridGrey);
  SetLabelTextColour      (*wxBLACK);
}
示例#29
0
Tree::Tree(
    Rng& rng,
    const int area_width,
    const int area_length,
    const double min_speciation_rate,
    const int dispersal_distance,
    const double tolerance,
    const DispersalKernel dispersal_kernel
)
    :
    m_active{},
    m_area_width{area_width},
    m_area_length{area_length},
    m_dispersal_distance{dispersal_distance},
    m_dispersal_kernel{dispersal_kernel},
    m_grid{},
    m_min_speciation_rate{min_speciation_rate},
    m_nodes{},
    m_richness{0.0},
    m_rnd(rng),
    m_tolerance{tolerance}
{

#ifndef NDEBUG
    Test();
#endif

    if (m_dispersal_distance == 0)
    {
        throw std::logic_error("Tree::Tree: dispersal distance must be non-zero");
    }
    if (m_dispersal_distance < 0)
    {
        throw std::logic_error("Tree::Tree: dispersal distance must be positive");
    }
    //Reserving m_nodes is important: due to pointer,
    //we must prevent a copy of the nodes
    m_nodes.reserve(2*area_width*area_length+1); //These are reserved
    m_nodes.resize(area_width*area_length+1); //These are used
    m_active = CreateActive(area_width,area_length,m_nodes);
    m_grid = CreateGrid(area_width,area_length,m_active);
}
CatheterCmdGrid::CatheterCmdGrid(const CatheterCmdGrid& C) :
    wxGrid(C.GetParent(), wxID_ANY),
    cmd_count(C.cmd_count),
    dir_choices{ wxT("neg"), wxT("pos") } {

    dir_choices[DIR_POS] = wxT("pos");
    dir_choices[DIR_NEG] = wxT("neg");

    CreateGrid(NCHANNELS, NFIELDS);

    SetColLabelValue(CHANNEL_COL, wxT("Channel"));
    SetColLabelValue(CURRENT_COL, wxT("Current (MA)"));
    SetColLabelValue(DIR_COL, wxT("Direction"));
    SetColLabelValue(DELAY_COL, wxT("Delay (ms)"));
    //HideRowLabels();

    // set column attributes
    GetTable()->SetAttrProvider(new wxGridCellAttrProvider());
    for (int i = 0; i < NFIELDS; i++)
        GetTable()->GetAttrProvider()->SetColAttr(new wxGridCellAttr(), i);

    SetColFormatNumber(CHANNEL_COL); //channel address
    SetColFormatFloat(CURRENT_COL); // MA current
    SetColFormatNumber(DELAY_COL); //delay

    wxGridCellAttr* dirAttr = GetTable()->GetAttrProvider()->GetAttr(0, DIR_COL, wxGridCellAttr::Col);
    wxGridCellAttr* channelAttr = GetTable()->GetAttrProvider()->GetAttr(0, CHANNEL_COL, wxGridCellAttr::Col);
    if (channelAttr == NULL || dirAttr == NULL) {
        printf("attribute is NULL\n");
        exit(EXIT_FAILURE);
    }
    dirAttr->SetEditor(new wxGridCellChoiceEditor(2, dir_choices));
    channelAttr->SetEditor(new wxGridCellNumberEditor(1, NCHANNELS));
    SetColAttr(DIR_COL, dirAttr);
    SetColAttr(CHANNEL_COL, channelAttr);

    for (int i = 1; i < GetNumberRows(); i++) {
        setRowReadOnly(i, true);
    }
    appendCommandRow();
}