bool ConnectThree::CanDoMove(const int x, const int y) const
{
  return (
       x >= 0
    && x <  GetCols()
    && y >= 0
    && y <  GetCols()
    && m_area[x][y] == no_player);
}
// 获得数据
bool NFCRecord::QueryRow(const int nRow, NFIDataList& varList)
{
    if (!ValidRow(nRow))
    {
        return false;
    }

    if (!IsUsed(nRow))
    {
        return false;
    }

    varList.Clear();
    for (int i = 0; i < GetCols(); ++i)
    {
        NF_SHARE_PTR<NFIDataList::TData> pVar = mtRecordVec.at(GetPos(nRow, i));
        if (pVar.get())
        {
            varList.Append(*pVar);
        }
        else
        {
            switch (GetColType(i))
            {
                case TDATA_INT:
                    varList.Add(NFINT64(0));
                    break;

                case TDATA_FLOAT:
                    varList.Add(0.0f);
                    break;

                case TDATA_STRING:
                    varList.Add(NULL_STR.c_str());
                    break;

                case TDATA_OBJECT:
                    varList.Add(NFGUID());
                    break;
                default:
                    return false;
                    break;
            }
        }
    }

    if (varList.GetCount() != GetCols())
    {
        return false;
    }

    return true;
}
Exemple #3
0
bool NFCRecord::SwapRowInfo(const int nOriginRow, const int nTargetRow)
{
    if (!IsUsed(nOriginRow))
    {
        return false;
    }

    if (ValidRow(nOriginRow)
        && ValidRow(nTargetRow))
    {
        for (int i = 0; i < GetCols(); ++i)
        {
            NF_SHARE_PTR<NFData> pOrigin = mtRecordVec.at(GetPos(nOriginRow, i));
            mtRecordVec[GetPos(nOriginRow, i)] = mtRecordVec.at(GetPos(nTargetRow, i));
            mtRecordVec[GetPos(nTargetRow, i)] = pOrigin;
        }

        int nOriginUse = mVecUsedState[nOriginRow];
        mVecUsedState[nOriginRow] = mVecUsedState[nTargetRow];
        mVecUsedState[nTargetRow] = nOriginUse;

        RECORD_EVENT_DATA xEventData;
        xEventData.nOpType = RECORD_EVENT_DATA::Swap;
        xEventData.nRow = nOriginRow;
        xEventData.nCol = nTargetRow;
        xEventData.strRecordName = mstrRecordName;

        NFData xData;
        OnEventHandler(mSelf, xEventData, xData, xData);

        return true;
    }

    return false;
}
Exemple #4
0
wxString pgView::GetSelectSql(ctlTree *browser)
{
	wxString qms;
	wxString sql =
	    wxT("SELECT ") + GetCols(browser, 7, qms, false) + wxT("\n")
	    wxT("  FROM ") + GetQuotedFullIdentifier() + wxT(";\n");
	return sql;
}
Exemple #5
0
bool NFCRecord::ValidCol(int nCol) const
{
    if (nCol >= GetCols() || nCol < 0)
    {
        return false;
    }

    return true;
}
Exemple #6
0
wxString pgView::GetInsertSql(ctlTree *browser)
{
	wxString qms;
	wxString sql =
	    wxT("INSERT INTO ") + GetQuotedFullIdentifier() + wxT("(\n")
	    wxT("            ") + GetCols(browser, 12, qms, false) + wxT(")\n")
	    wxT("    VALUES (") + qms + wxT(");\n");
	return sql;
}
Exemple #7
0
wxString pgView::GetUpdateSql(ctlTree *browser)
{
	wxString qms;
	wxString sql =
	    wxT("UPDATE ") + GetQuotedFullIdentifier() + wxT("\n")
	    wxT("   SET ") + GetCols(browser, 7, qms, true) + wxT("\n")
	    wxT(" WHERE <condition>;\n");
	return sql;
}
Exemple #8
0
bool NFCRecord::SetRow(const int nRow, const NFDataList & var)
{
	if (var.GetCount() != GetCols())
	{
		return false;
	}

	if (!IsUsed(nRow))
	{
		return false;
	}

	for (int i = 0; i < GetCols(); ++i)
	{
		if (var.Type(i) != GetColType(i))
		{
			return false;
		}
	}

	for (int i = 0; i < GetCols(); ++i)
	{
		NF_SHARE_PTR<NFData>& pVar = mtRecordVec.at(GetPos(nRow, i));
		if (nullptr == pVar)
		{
			pVar = NF_SHARE_PTR<NFData>(NF_NEW NFData(var.Type(i)));
		}

		NFData oldValue = *pVar;

		pVar->variantData = var.GetStack(i)->variantData;

		RECORD_EVENT_DATA xEventData;
		xEventData.nOpType = RECORD_EVENT_DATA::Update;
		xEventData.nRow = nRow;
		xEventData.nCol = i;
		xEventData.strRecordName = mstrRecordName;

		OnEventHandler(mSelf, xEventData, oldValue, *pVar);
	}

	return false;
}
Exemple #9
0
CMotion2DImage<Type> CMotion2DImage<Type>::operator-(const CMotion2DImage<Type> &image)
{

  CMotion2DImage<Type> D(GetRows(),GetCols());

  for (unsigned i=0; i<npixels; i++) {
    D.bitmap[i] = bitmap[i] - image.bitmap[i];
  }
  return D;
}
HTMLTextAreaElement::GetWrapCols() {
  // wrap=off means -1 for wrap width no matter what cols is
  nsHTMLTextWrap wrapProp;
  nsITextControlElement::GetWrapPropertyEnum(this, wrapProp);
  if (wrapProp == nsITextControlElement::eHTMLTextWrap_Off) {
    // do not wrap when wrap=off
    return 0;
  }

  // Otherwise we just wrap at the given number of columns
  return GetCols();
}
Exemple #11
0
// Result = A' * B(:,ColId)
void TNGraphMtx::PMultiplyT(const TFltVV& B, int ColId, TFltV& Result) const {
  const int ColN = GetCols();
  Assert(B.GetRows() >= ColN && Result.Len() >= ColN);
  const THash<TInt, TNGraph::TNode>& NodeH = Graph->NodeH;
  for (int i = 0; i < ColN; i++) Result[i] = 0.0;
  for (int j = 0; j < ColN; j++) {
    const TIntV& RowV = NodeH[j].OutNIdV;
    for (int i = 0; i < RowV.Len(); i++) {
      Result[RowV[i]] += B(j, ColId);
    }
  }
}
Exemple #12
0
	CBasicAnimation::CBasicAnimation(ALLEGRO_BITMAP* sheet, size_t rows, size_t cols, double fps)
		: IAnimationBase(rows, cols, fps)
		, m_animationSheet(sheet)
		, m_frame()
		, m_frameW(DEFAULTFRAMEW)
		, m_frameH(DEFAULTFRAMEH)
	{
		assert(m_animationSheet.IsValid() == true);
		assert(rows > 0);
		assert(cols > 0);
		assert(fps > 0.0);

		if (!m_animationSheet || !GetRows() || !GetCols() || (GetFPS() <= 0))
			abort();

		if (m_animationSheet)
		{
			m_frameW = m_animationSheet.GetWidth() / GetCols();
			m_frameH = m_animationSheet.GetHeight() / GetRows();
			FrameChanged();
		}
	}
ConnectThree::ConnectThree(
  const int n_cols,
  const int n_rows)
  : m_area(n_cols, std::vector<int>(n_rows,no_player)),
    m_player(ConnectThree::player1)
{
  Restart();
  //assert(m_is_player_human.size() == 3);
  assert(player1 == 0);
  assert(player2 == 1);
  assert(player3 == 2);
  assert(GetCols() == n_cols);
  assert(GetRows() == n_rows);
}
Exemple #14
0
int Raster::Uniform(const char * pOutputRaster, double fValue)
{

    // Open up the Input File
    GDALDataset * pInputDS = (GDALDataset*) GDALOpen(m_sFilePath, GA_ReadOnly);
    if (pInputDS == NULL)
        throw RasterManagerException( INPUT_FILE_ERROR, "Input file could not be opened");

    GDALRasterBand * pRBInput = pInputDS->GetRasterBand(1);

    // Create the output dataset for writing
    GDALDataset * pOutputDS = CreateOutputDS(pOutputRaster, this);
    GDALRasterBand * pOutputRB = pOutputDS->GetRasterBand(1);

    // Assign our buffers
    double * pInputLine = (double*) CPLMalloc(sizeof(double) * GetCols());
    double * pOutputLine = (double*) CPLMalloc(sizeof(double) * GetCols());

    // Loop over rows
    for (int i=0; i < GetRows(); i++)
    {
        // Populate the buffer
        pRBInput->RasterIO(GF_Read, 0,  i, GetCols(), 1, pInputLine, GetCols(), 1, GDT_Float64, 0, 0);

        // Loop over columns
        for (int j=0; j < GetCols(); j++)
        {
            if (pInputLine[j] != GetNoDataValue()){
                pOutputLine[j] = fValue;
            }
            else {
                pOutputLine[j] = GetNoDataValue();
            }

        }
        // Write the row
        pOutputRB->RasterIO(GF_Write, 0, i, GetCols(), 1, pOutputLine, GetCols(), 1, GDT_Float64, 0, 0 );
    }

    CPLFree(pOutputLine);
    CPLFree(pInputLine);

    CalculateStats(pOutputDS->GetRasterBand(1));

    if ( pInputDS != NULL)
        GDALClose(pInputDS);
    if ( pOutputDS != NULL)
        GDALClose(pOutputDS);

    return PROCESS_OK;

}
Exemple #15
0
/*
     * Initializes the object, assuming that filename, origin, size, etc are already set on the
     * member variables. Makes sure the raster can be opened, sets the block size, NODATA value,
     * pixel size, and the extent of the raster. If not using the full image then makes sure that
     * the subset chosen (based on origin and size) is valid. If using the full image then sets the
     * size and origin is assumed to be 0,0 and is set in the constructor.
     * @param fullImage True if using the full image, False if using a subset.
     */
void Raster::Init(bool bFullImage)
{
    Init();
    GDALDataset * ds = (GDALDataset*) GDALOpen(m_sFilePath, GA_ReadOnly);

    if (ds == NULL)
        throw RasterManagerException(INPUT_FILE_NOT_VALID, CPLGetLastErrorMsg());

    GDALRasterBand * band = ds->GetRasterBand(1);

    double dRMin, dRMax, dRMean, dRStdDev;

    // Get some easy stats that GDAL gives us
    band->GetStatistics( 0 , true, &dRMin, &dRMax, &dRMean, &dRStdDev );
    m_dRasterMax = dRMax;
    m_dRasterMin = dRMin;

    m_dRasterMean = dRMean;
    m_dRasterStdDev = dRStdDev;

    OGRLinearRing ring = OGRLinearRing();
    if (bFullImage)
    {
        SetCols( band->GetXSize() );
        SetRows( band->GetYSize() );

        ring.addPoint(GetLeft(), GetTop());
        ring.addPoint(GetLeft(), GetTop() + (GetCellHeight() * GetRows()));
        ring.addPoint(GetLeft() + (GetCellWidth() * GetCols()), GetTop() + (GetCellHeight() * GetRows()));
        ring.addPoint(GetLeft() + (GetCellWidth() * GetCols()), GetTop());
        ring.closeRings();
    }
    else
    {
        if ((GetLeft() + GetCols() > band->GetXSize()) || (GetTop() + GetRows() > band->GetYSize()))
        {
            QString sErr = QString("Invalid origin ( %1, %2 ) and size ( %5, %6 ) for file: %7")
                    .arg(GetLeft())
                    .arg(GetTop())
                    .arg(GetCols())
                    .arg(GetRows())
                    .arg(FilePath());
            throw RasterManagerException(INPUT_FILE_NOT_VALID, sErr);
        }
        double xMapOrigin = GetLeft() + (GetLeft() * GetCellWidth());
        double yMapOrigin = GetTop() + (GetTop() * GetCellHeight());
        ring.addPoint(xMapOrigin, yMapOrigin);
        ring.addPoint(xMapOrigin, yMapOrigin + (GetCellHeight() * GetRows()));
        ring.addPoint(xMapOrigin + (GetCellWidth() * GetCols()), yMapOrigin + (GetCellHeight() * GetRows()));
        ring.addPoint(xMapOrigin + (GetCellWidth() * GetCols()), yMapOrigin);
        ring.closeRings();
    }
    GDALClose(ds);

}
Exemple #16
0
bool CMotion2DImage<Type>::MedianFilter(unsigned filterRowSize,
					unsigned filterColSize)
{
  // Subsampled image size
  unsigned _nrows = GetRows();
  unsigned _ncols = GetCols();
  int ik, jl;
  Type *tab;

  if (filterRowSize < 1)
    return false;
  if (filterColSize < 1)
    return false;

  if ((filterRowSize * filterColSize) == 1)
    return true;

  int halfFilterRowSize = filterRowSize / 2;
  int halfFilterColSize = filterColSize / 2;

  CMotion2DImage<Type> I;
  I.Resize(_nrows, _ncols);

  tab = new Type[filterRowSize*filterColSize];
  for (unsigned i=0; i < _nrows; i++) {
    for (unsigned j=0; j < _ncols; j++) {

      unsigned co=0;
      for (int k = -halfFilterRowSize;
	   k < (int)(filterRowSize-halfFilterRowSize); k++) {
	for (int l = -halfFilterColSize;
	     l < (int)(filterColSize-halfFilterColSize); l++) {
	  ik=i+k;
	  jl=j+l;
	  if (ik >= 0 & ik < (int) _nrows & jl >= 0 &jl < (int) _ncols)
	    tab[co++] = (*this)[ik][jl];
	}
      }
      sort(co, tab-1);
      I[i][j] = tab[(co >> 1) + 1];
    }
  }

  (*this) = I;
  delete [] tab;
  return true;
}
IMAGE *AdjustValue(IMAGE *image, double percent)
	{
	// To be completed by student ...
	// This function adjusts the value (perceived luminance of all pixels in an image by a certain percent
	unsigned row = GetRows(image);
	unsigned col = GetCols(image);
	unsigned i, j;
	double hue, sat, val; 

		for (i=0; i<row; i++) {
			for (j=0; j<col; j++) { //these for loops traverses through the 2D image
				GetHSV( image, i, j, &hue, &sat, &val); //retreives the values
				PutHSV( image, i, j, hue, sat, val*(percent/100)); //changes the value by the parameter percent
			}		
		}
	return image;
	}
Exemple #18
0
	CBasicAnimation::CBasicAnimation(const std::string& filename, size_t rows, size_t cols, double fps)
		: IAnimationBase(rows, cols, fps)
		, m_animationSheet()
		, m_frame()
		, m_frameW(DEFAULTFRAMEW)
		, m_frameH(DEFAULTFRAMEH)
	{
		m_animationSheet = CBitmap(al_load_bitmap(filename.c_str()));

		if (m_animationSheet)
		{
			m_frameW = m_animationSheet.GetWidth() / GetCols();
			m_frameH = m_animationSheet.GetHeight() / GetRows();
			// Create the bitmap for the initial frame
			FrameChanged();
		}
	}
IMAGE *AdjustSaturation(IMAGE *image, double percent)
	{
	// To be completed by student ...
	// this function adjusts the saturation of all pixels by a certain percent 
	unsigned row = GetRows(image);
	unsigned col = GetCols(image);
	unsigned i, j;
	double hue, sat, val;

		for(i=0; i<row; i++) {
			for (j=0; j<col; j++) { //these loops traverses the image
				GetHSV( image, i, j, &hue, &sat, &val); 	//retreives the values
				PutHSV( image, i, j, hue, sat*(percent/100), val);	//adjusts the sat value
			}
		}
	return image;
	}
IMAGE *AdjustHue(IMAGE *image, double degrees)
	{
	// To be completed by student ...
	//This function adjusts the hue in all pixels of an image by a certain amount of degrees
	unsigned row = GetRows(image);
	unsigned col = GetCols(image);
	unsigned i, j;
	double hue, sat, val;
	
	for (i=0; i<row; i++) {
		for (j=0; j<col; j++) {		//traverses the array
			GetHSV(image, i, j, &hue, &sat, &val); 	//retreives the values
			PutHSV(image, i, j, hue + degrees, sat, val);		//adjusts the hue value
	
		}
	}
	return image;
	}
const ConnectThree::Move ConnectThree::CheckTwoVerticalOwn() const
{
  const int n_rows = GetRows();
  for (int y=0; y!=n_rows-1; ++y) //-1 to prevent out of range
  {
    const int n_cols = GetCols();
    for (int x=0; x!=n_cols; ++x)
    {
      //Two consequtive selfs?
      if (m_area[x][y] == m_player && m_area[x][y+1] == m_player)
      {
        if (y >= 1)
        {
          if (m_area[x][y-1] == no_player)
          {
            const Move p(x,y-1);
            assert(CanDoMove(p));
            return p;
          }
        }
        if (y < n_rows-2)
        {
          if (m_area[x][y+2] == no_player)
          {
            const Move p(x,y+2);
            assert(CanDoMove(p));
            return p;
          }
        }
      }
      //Perhaps a gap?
      if (y < n_rows-2)
      {
        if (m_area[x][y] == m_player && m_area[x][y+1] == no_player && m_area[x][y+2] == m_player)
        {
          const Move p(x,y+1);
          assert(CanDoMove(p));
          return p;
        }
      }
    }
  }
  return CreateInvalidMove();
}
Exemple #22
0
	void CBasicAnimation::FrameChanged(void)
	{
		if (!m_animationSheet)
			return;

		ColRow cr = GetColRow(GetCols(), GetCurrentFrame());
		size_t x((cr.col - 1) * m_frameW);
		size_t y((cr.row - 1) * m_frameH);

		if (m_frame)
		{
			m_frame.Reset();
			//al_destroy_bitmap(m_frame);
			//m_frame = nullptr;
		}

		m_frame = CBitmap(m_animationSheet, x, y, m_frameW, m_frameH);
		//m_frame = al_create_sub_bitmap(m_animationSheet, x, y, m_frameW, m_frameH);
	}
Exemple #23
0
bool NFCRecord::PreAllocMemoryForRow(const int nRow)
{
	if (!IsUsed(nRow))
	{
		return false;
	}

	for (int i = 0; i < GetCols(); ++i)
	{
		NF_SHARE_PTR<NFData>& pVar = mtRecordVec.at(GetPos(nRow, i));
		if (nullptr == pVar)
		{
			pVar = NF_SHARE_PTR<NFData>(NF_NEW NFData(mVarRecordType->Type(i)));
		}

		pVar->variantData = mVarRecordType->GetStack(i)->variantData;
	}
	return true;
}
//---------------------------------------------------------------------------
bool IValue::operator!=(const IValue &a_Val) const
{
    char_type type1 = GetType(),
        type2 = a_Val.GetType();

    if (type1 == type2 || (IsScalar() && a_Val.IsScalar()))
    {
        switch (GetType())
        {
        case 's': return GetString() != a_Val.GetString();
        case 'i':
        case 'f': return GetFloat() != a_Val.GetFloat();
        case 'c': return (GetFloat() != a_Val.GetFloat()) || (GetImag() != a_Val.GetImag());
        case 'b': return GetBool() != a_Val.GetBool();
        case 'v': return true;
        case 'm': if (GetRows() != a_Val.GetRows() || GetCols() != a_Val.GetCols())
        {
            return true;
        }
                  else
                  {
                      for (int i = 0; i < GetRows(); ++i)
                      {
                          if (const_cast<IValue*>(this)->At(i) != const_cast<IValue&>(a_Val).At(i))
                              return true;
                      }

                      return false;
                  }
        default:
            ErrorContext err;
            err.Errc = ecINTERNAL_ERROR;
            err.Pos = -1;
            err.Type2 = GetType();
            err.Type1 = a_Val.GetType();
            throw ParserError(err);
        } // switch this type
    }
    else
    {
        return true;
    }
}
const ConnectThree::Move ConnectThree::CheckTwoHorizontalOwn() const
{
  const int n_rows = GetRows();
  for (int y=0; y!=n_rows; ++y)
  {
    const int n_cols = GetCols();
    for (int x=0; x!=n_cols-1; ++x) //-1 to prevent out of range
    {
      //Two consequtive selfs
      if (m_area[x][y] == m_player && m_area[x+1][y] == m_player)
      {
        if (x >= 1)
        {
          if (m_area[x-1][y] == no_player)
          {
            const Move p(x-1,y);
            assert(CanDoMove(p));
            return p;
          }
        }
        if (x < n_cols-2 && m_area[x+2][y] == no_player)
        {
          const Move p(x+2,y);
          assert(CanDoMove(p));
          return p;
        }
      }
      //Perhaps a gap?
      if (x < n_cols-2)
      {
        if (m_area[x][y] == m_player && m_area[x+1][y] == no_player && m_area[x+2][y] == m_player)
        {
          const Move p(x+1,y);
          assert(CanDoMove(p));
          return p;
        }
      }
    }
  }
  return CreateInvalidMove();
}
Exemple #26
0
NFCRecord::NFCRecord(const NFGUID& self, const std::string& strRecordName, const NF_SHARE_PTR<NFDataList>& valueList, const NF_SHARE_PTR<NFDataList>& tagList, const int nMaxRow)
{
	mVarRecordType = valueList;
    mVarRecordTag = tagList;

    mSelf = self;

    mbSave = false;
    mbPublic = false;
    mbPrivate = false;
    mbCache = false;
	mbUpload = false;

    mstrRecordName = strRecordName;

    mnMaxRow = nMaxRow;
    
    mVecUsedState.resize(mnMaxRow);

    for (int i = 0; i < mnMaxRow; i++)
    {
        mVecUsedState[i] = 0;
    }

	//init share_pointer for all data
    for (int i = 0; i < GetRows() * GetCols(); i++)
    {
        mtRecordVec.push_back(NF_SHARE_PTR<NFData>());
    }

	//optimize would be better, it should be applied memory space only once
    for (int i = 0; i < mVarRecordTag->GetCount(); ++i)
    {
        if (!mVarRecordTag->String(i).empty())
        {
            mmTag[mVarRecordTag->String(i)] = i;
        }
    }
}
/* 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;
}
///GetWinner returns the index of the winner.
int ConnectThree::GetWinner() const
{
  const int n_rows = GetRows();
  for (int y=0; y!=n_rows; ++y)
  {
    const int n_cols = GetCols();
    for (int x=0; x!=n_cols; ++x)
    {
      if (m_area[x][y] == no_player) continue;
      //Horizontal
      if (x + 2 < n_cols
        && m_area[x  ][y] == m_area[x+1][y]
        && m_area[x+1][y] == m_area[x+2][y])
      {
        return m_area[x][y];
      }
      //Vertical
      if (y + 2 < n_rows
        && m_area[x][y  ] == m_area[x][y+1]
        && m_area[x][y+1] == m_area[x][y+2])
      {
        return m_area[x][y];
      }
    }
  }
  //Check for draw
  {
    const Move m1 = MakeRandomMove();
    const Move m2 = CreateInvalidMove();
    if ( m1.get<0>() == m2.get<0>()
      && m1.get<1>() == m2.get<1>()
      && m1.get<2>() == m2.get<2>())
    {
      return draw;
    }
  }
  return no_player;
}
Exemple #29
0
wxSizerItem* wxGridBagSizer::Add( wxGBSizerItem *item )
{
    wxCHECK_MSG( !CheckForIntersection(item), NULL,
                 wxT("An item is already at that position") );
    m_children.Append(item);
    item->SetGBSizer(this);
    if ( item->GetWindow() )
        item->GetWindow()->SetContainingSizer( this );

    // extend the number of rows/columns of the underlying wxFlexGridSizer if
    // necessary
    int row, col;
    item->GetEndPos(row, col);
    row++;
    col++;

    if ( row > GetRows() )
        SetRows(row);
    if ( col > GetCols() )
        SetCols(col);

    return item;
}
Exemple #30
0
void CMotion2DImage<Type>::Subsample()
{
  // Subsampled image size
  unsigned _nrows = GetRows() >> 1;
  unsigned _ncols = GetCols() >> 1;

  CMotion2DImage<Type> I;
  I.Resize(_nrows, _ncols);

  for (unsigned i=0; i < _nrows; i++) {
    for (unsigned j=0; j < _ncols; j++) {
      int u=0;
      for (unsigned k= 0; k <= 1;k++)
	for (unsigned l=0; l<= 1;l++) {
	  u += (*this)[k+(i<<1)][l+(j<<1)];
	}
      u = (u / 4);
      I[i][j] = u;
    }
  }

  (*this) = I;
}