Пример #1
0
// Num is number of pixels leftmost column (col 0) is shifted down
static void shiftFrameVertical(CamFrame frame, int num) {

    int shift, half_width, i, width, height;        
    
    height = (int) DS_IMAGE_ROWS; // frame->num_rows;
    width = (int) DS_IMAGE_COLS; // frame->num_cols;
    half_width = (int) width/2;
    
    for(i = 0; i < width; i++) {
                    
        shift = ((i - half_width)*num)/half_width;
        
        if(shift == 0) {
            // Do nothing
        } else if(shift > 0) {
            
            shiftColumn(frame, i, 0, shift, height - shift);
            setColumn(frame, i, height - shift, 0, shift); 
            
        } else { // shift < 0
        
            shift = -shift;
            shiftColumn(frame, i, shift, 0, height - shift); 
            setColumn(frame, i, 0, 0, shift);
            
        }

        int j;
        j = 0;

    }

}
Пример #2
0
void copyVirtualToLCD(bool refreshLCD){
    int _page;
    int _col;

    if(refreshLCD)
    {
        _page = 0;
        _col = 0;
    }
    else
    {
        _page = current_page;
        _col = 0;
    }
    setPage(_page);
    setColumn(_col);

    for (int i = _page; i <= written_pages; i++)
    {
		for (int j = _col; j < current_col; j++){
            setPage(i);
            setColumn(j);
			LCD_writeData(&virtual_memory_lcd[i][j],1);
		}
    }
}
Пример #3
0
void TodoView::adjustColumns() {
  // resizing the columns, such that the Description (3) is the elastic field
  setColumn(0, "", 0);
  setColumn(1, "", 25, KTabListBox::PixmapColumn);
  setColumn(2, i18n("Pri"), 25);
  if (columnWidth(4)!=0) {
      setColumn(4, i18n("Due"), 40);
      //setColumnWidth(4, 40);
  }
  int descrwidth = width() - 90;
  if (descrwidth < 120) {
      descrwidth = 120;
  }
  setColumn(3, i18n("Todo Descrip."), descrwidth); 
}
Пример #4
0
/*****************************************************************************************************
 *  setEach -> seta o token each
 *
 ****************************************************************************************************/
void Each::setEach(TokenType *each){
    setClasse(each->getClasse());
    setToken(each->getToken());
    setColumn(each->getColumn());
    setLine(each->getLine());
    setType(each->getType());
}
Пример #5
0
void SpriteAnimator::setAtlasSize(int atlasWidth, int atlasHeight)
{
	const flat::video::Texture* texture = m_sprite->getTexture().get();
	FLAT_ASSERT(texture != nullptr);
	const flat::Vector2& textureSize = texture->getSize();
	FLAT_ASSERT(0 < atlasWidth  && atlasWidth  < textureSize.x);
	FLAT_ASSERT(0 < atlasHeight && atlasHeight < textureSize.y);
	if (textureSize.x / atlasWidth != floor(textureSize.x / atlasWidth)
		|| textureSize.y / atlasHeight != floor(textureSize.y / atlasHeight))
	{
		const flat::video::FileTexture* fileTexture = dynamic_cast<const flat::video::FileTexture*>(texture);
		std::cerr << "Invalid atlas size (" << atlasWidth << ", " << atlasHeight << ") "
			<< "for texture "
			<< ((fileTexture != nullptr) ? fileTexture->getFileName() + " " : "")
			<< "of size (" << static_cast<int>(textureSize.x) << ", " << static_cast<int>(textureSize.y) << ")" << std::endl;
	}
	m_tileSizeRatio.x = 1.f / atlasWidth;
	m_tileSizeRatio.y = 1.f / atlasHeight;
	setLine(0);
	setColumn(0);

	const float atlasTileWidth = textureSize.x / atlasWidth;
	const float atlasTileHeight = textureSize.y / atlasHeight;
	BaseSprite::VertexPositions& vertexPositions = m_sprite->getVertexPositions();
	vertexPositions[1].x = atlasTileWidth;
	vertexPositions[2].y = atlasTileHeight;
	vertexPositions[3].x = atlasTileWidth;
	vertexPositions[3].y = atlasTileHeight;
	vertexPositions[4].y = atlasTileHeight;
	vertexPositions[5].x = atlasTileWidth;
}
Пример #6
0
void SpriteAnimator::update(float currentTime)
{
	if (m_animated)
	{
		if (!m_animationStarted)
		{
			m_animationStarted = true;
			m_lastUpdateTime = currentTime;
		}
		
		if (currentTime - m_lastUpdateTime > m_frameDuration)
		{
			int nextColumn = m_currentColumn + 1;
			if (nextColumn >= m_numFrames)
			{
				nextColumn = 0;
				if (m_numLoops != INFINITE_LOOP)
				{
					--m_numLoops;
					if (m_numLoops == 0)
					{
						nextColumn = m_currentColumn;
						setAnimated(false);
					}
				}
			}
			setColumn(nextColumn);
			m_lastUpdateTime += m_frameDuration;
		}
	}
	else
	{
		m_lastUpdateTime = currentTime;
	}
}
void ReportSectionDetailGroup::initFromXML( const QDomElement &element )
{
    if ( element.hasAttribute( "report:group-column" ) ) {
        setColumn( element.attribute( "report:group-column" ) );
    }
    
    if ( element.hasAttribute( "report:group-page-break" ) ) {
        QString s = element.attribute( "report:group-page-break" );
        if ( s == "after-footer" ) {
            setPageBreak( ReportSectionDetailGroup::BreakAfterGroupFooter );
        } else if ( s == "before-header" ) {
            setPageBreak( ReportSectionDetailGroup::BreakBeforeGroupHeader );
        }
    }
    
    if (element.attribute("report:group-sort", "ascending") == "ascending") {
        setSort(Qt::AscendingOrder);
    }
    else {
        setSort(Qt::DescendingOrder);
    }
    
    for ( QDomElement e = element.firstChildElement( "report:section" ); ! e.isNull(); e = e.nextSiblingElement( "report:section" ) ) {
        QString s = e.attribute( "report:section-type" );
        if ( s == "group-header" ) {
            setGroupHeaderVisible( true );
            m_groupHeader->initFromXML( e );
        } else if ( s == "group-footer" ) {
            setGroupFooterVisible( true );
            m_groupFooter->initFromXML( e );
        }
    }
}
void PreprocessorCompletionModel::executeCompletionItem2(
    KTextEditor::Document* const doc
  , const KTextEditor::Range& word
  , const QModelIndex& index
  ) const
{
    assert("Invalid index is not expected here!" && index.isValid());
    assert("Parent index is not valid" && index.parent().isValid());
    assert("Parent index must be GROUP" && index.parent().internalId() == Level::GROUP);
    assert("Index points to invalid item" && unsigned(index.row()) < COMPLETIONS.size());

    auto text = COMPLETIONS[index.row()].text;
    const auto column = text.indexOf('|');
    if (column != -1)
        text.remove(column, 1);

    doc->replaceText(word, text);

    // Try to reposition a cursor inside a current view
    if (column != -1)
    {
        auto pos = word.start();
        pos.setColumn(pos.column() + column);
        doc->activeView()->setCursorPosition(pos);
    }
}
Пример #9
0
	void setZeroes(vector<vector<int> > &matrix) {
		int row = matrix.size();
		if(row == 0)
		  return;

		int col = matrix[0].size();
		bool first = false;
		for(int i = 0; i < col; i++){
			if(matrix[0][i] == 0){
				first = true;
				break;
			}
		}

		for(int i = 1; i < row; i++){
			bool zero = false;
			for(int j = 0; j < col; j++){
				if(matrix[i][j] == 0){
					zero = true;
					matrix[0][j] = 0;
				}
			}
			if(zero)
			  setRow(matrix, i, col);
		}

		for(int i = 0; i < col; i++){
			if(matrix[0][i] == 0)
			  setColumn(matrix, i, row);
		}

		if(first)
		  setRow(matrix, 0, col);
	}
Пример #10
0
void MaxMatrix::writeSprite(int X, int Y, const byte* Sprite)
{
	int SpriteWidth = Sprite[ASCII_TABLE_SPRITE_WIDTH];
	int SpriteHeight = Sprite[ASCII_TABLE_SPRITE_HEIGHT];
	
	if(SpriteHeight == MAXMATRIX_ROW_NUMBER_OF_MODULE && Y == 0) {
		for(int i = 0; i < SpriteWidth; i++)
		{
			int Column = X + i;
			if(Column >= 0 && Column < MAXMATRIX_NUMBER_OF_COLUMNS)
			setColumn(Column, Sprite[i + ASCII_TABLE_SPRITE_COLUMN1]);
		} 
	} else {
		for(int i = 0; i < SpriteWidth; i++)
		{
			for(int j = 0; j < SpriteHeight; j++)
			{
				int Column = X + i;
				int Row = Y + j;
				if(Column >= 0 && Column < MAXMATRIX_NUMBER_OF_COLUMNS && Row >= 0 && Row < MAXMATRIX_ROW_NUMBER_OF_MODULE)
				setDot(Column, Row, bitRead(Sprite[i + ASCII_TABLE_SPRITE_COLUMN1], j));
			}
		}
	}
}
Пример #11
0
/*****************************************************************************************************
 *  setIF -> seta token if
 *
 ****************************************************************************************************/
void IFElse::setIF(TokenType *_if){
    setClasse(_if->getClasse());
    setToken(_if->getToken());
    setColumn(_if->getColumn());
    setLine(_if->getLine());
    setType(_if->getType());
}
Пример #12
0
// Orthogonalise rotation matrix column w.r.t. one (or two) other columns)
void Matrix4::orthogonaliseColumn(int targetcol, int orthocol1, int orthocol2)
{
	// Grab target column
	Vec3<double> v = columnAsVec3(targetcol);
	// Orthogonalising w.r.t one or two other vectors?
	if (orthocol2 == -1)
	{
		Vec3<double> source = columnAsVec3(orthocol1);
		double sourcemag = source.magnitude();
		double dpovermagsq = v.dp(source) / (sourcemag * sourcemag);
		v.x -= dpovermagsq * source.x;
		v.y -= dpovermagsq * source.y;
		v.z -= dpovermagsq * source.z;
	}
	else
	{
		// This routine actually generates the orthogonal vector via the cross-product
		// We also calculate the scalar resolute (dp) to ensure the new vector points in the same direction
		Vec3<double> source1 = columnAsVec3(orthocol1), source2 = columnAsVec3(orthocol2);
		Vec3<double> newvec = source1 * source2;
		newvec.normalise();
		double dp = newvec.dp(v);
		if (dp < 0.0) newvec *= -1.0;
		v = newvec;
	}
	setColumn(targetcol, v, matrix_[targetcol*4+3]);
}
Пример #13
0
/*****************************************************************************************************
 *  setList -> seta informaçoes da lista
 *
 ****************************************************************************************************/
void TList::setList(TokenType *list){
    setClasse(list->getClasse());
    setToken(list->getToken());
    setLine(list->getLine());
    setColumn(list->getColumn());
    setType(list->getType());
}
Пример #14
0
void TileBoard::slideRow(int row, Direction direction) {
    row--;
    auto tileToDelete = getTile(row, 3);
    int newTileColumn = -1;
    int tileOffset = 1;
    int moveByX = tileWidthPadding + tileWidth;
    if(direction == Direction::LEFT) {
        newTileColumn = 4;
        moveByX = -moveByX;
        tileOffset = -1;
        tileToDelete = getTile(row, 0);
    }
    GameTile* newTile = GameTile::create(TileType::WHITE, Point(getTileColumnPosition(newTileColumn), getTileRowPosition(row)), row + 1, newTileColumn + tileOffset + 1);
    addChild(newTile);
    
    for(int column = 0; column < BOARD_COLUMNS; column++) {
        auto currentTile = getTile(row, column);
        currentTile->runAction(Sequence::create(MoveBy::create(0.5f, Point(moveByX, 0)), CallFunc::create([=](){
            currentTile->setColumn(column + tileOffset + 1);
            currentTile->setTag(tileTagFor(row, column + tileOffset));
        }), NULL) );
        currentTile->move();
    }


    newTile->runAction(Sequence::create(MoveBy::create(0.5f, Point(moveByX, 0)), CallFunc::create([=]() {
        newTile->setTag(tileTagFor(row, newTileColumn + tileOffset));
        tileToDelete->removeFromParent();
    }), NULL));
    newTile->move();
}
void GMMaxMatrix::reload()
{

	for (int i = 0; i< numMatrixes * 8; i++)
	{
		setColumn(i, buffer[i]);
	}
}
Пример #16
0
LegsModel::LegsModel(QObject *parent)
	: Super(parent)
{
	clearColumns(col_COUNT);
	setColumn(col_runs_leg, ColumnDefinition("runs.leg", tr("Leg", "relays.leg")).setToolTip(tr("Leg")));
	setColumn(col_competitorName, ColumnDefinition("competitorName", tr("Name")).setReadOnly(true));
	setColumn(col_runs_registration, ColumnDefinition("competitors.registration", tr("Reg")));
	setColumn(col_runs_siId, ColumnDefinition("runs.siid", tr("SI")).setReadOnly(false).setCastType(qMetaTypeId<quickevent::core::si::SiId>()));
	setColumn(col_runs_startTimeMs, ColumnDefinition("runs.startTimeMs", tr("Start")).setCastType(qMetaTypeId<quickevent::core::og::TimeMs>()));
	setColumn(col_runs_timeMs, ColumnDefinition("runs.timeMs", tr("Time")).setCastType(qMetaTypeId<quickevent::core::og::TimeMs>()).setReadOnly(true));
	setColumn(col_runs_notCompeting, ColumnDefinition("runs.notCompeting", tr("NC", "runs.notCompeting")).setToolTip(tr("Not competing")));
	setColumn(col_runs_disqualified, ColumnDefinition("runs.disqualified", tr("D", "runs.disqualified")).setToolTip(tr("Disqualified")));
	setColumn(col_runs_misPunch, ColumnDefinition("runs.misPunch", tr("E", "runs.misPunch")).setToolTip(tr("Card mispunch")));
}
void ClangCodeCompletionModel::executeCompletionItem2(
    KTextEditor::Document* const doc
  , const KTextEditor::Range& word
  , const QModelIndex& index
  ) const
{
    assert("Active view expected to be equal to the stored one" && doc->activeView() == m_current_view);
    assert("Invalid index is not expected here!" && index.isValid());
    assert("Parent index is not valid" && index.parent().isValid());
    assert("Parent index must be GROUP" && index.parent().internalId() == Level::GROUP);
    assert(
        "Parent index points to invalid group"
      && 0 <= index.internalId()
      && unsigned(index.internalId()) < m_groups.size()
      );
    assert(
        "Index points to invalid item"
      && 0 <= index.row()
      && unsigned(index.row()) < m_groups[index.internalId()].second.m_completions.size()
      );

    auto* const template_iface = qobject_cast<KTextEditor::TemplateInterface2*>(m_current_view);
    if (template_iface)
    {
        kDebug(DEBUG_AREA) << "TemplateInterface available for a view" << m_current_view;
        const auto result = m_groups[index.internalId()]
          .second.m_completions[index.row()]
          .getCompletionTemplate();
        kDebug(DEBUG_AREA) << "Template:" << result.m_tpl;
        kDebug(DEBUG_AREA) << "Values:" << result.m_values;
        // Check if current template is a function and there is a '()' right after cursor
        auto range = word;
        if (result.m_is_function)
        {
            const auto next_word_range = DocumentProxy(doc).firstWordAfterCursor(word.end());
            kDebug(DEBUG_AREA) << "OK THIS IS FUNCTION TEMPLATE: next word range" << next_word_range;
            kDebug(DEBUG_AREA) << "replace range before:" << range;
            if (next_word_range.isValid() && doc->text(next_word_range).startsWith(QLatin1String("()")))
            {
                range.end().setColumn(next_word_range.start().column() + 2);
                kDebug(DEBUG_AREA) << "replace range after:" << range;
            }
        }
        doc->removeText(range);
        template_iface->insertTemplateText(range.start(), result.m_tpl, result.m_values, nullptr);
    }
    else
    {
        kDebug(DEBUG_AREA) << "No TemplateInterface for a view" << m_current_view;
        const auto p = m_groups[index.internalId()].second.m_completions[index.row()].executeCompletion();
        doc->replaceText(word, p.first);
        // Try to reposition a cursor inside a current (hope it still is) view
        auto pos = word.start();
        pos.setColumn(pos.column() + p.second);
        m_current_view->setCursorPosition(pos);
    }
}
Пример #18
0
bool KCalls::WriteHeader(const char *entry, int index)
{
	if (index < 0 || index >= numCols() || entry == NULL)
		return FALSE;

	setColumn(index, entry, (strlen(entry)+1) * 10, TextColumn);

	return TRUE;
}
Пример #19
0
// for map, -c is the column upon which to operate
bool ContextMap::handle_c()
{
    if ((_i+1) < _argc) {
        setColumn(atoi(_argv[_i + 1]));
        markUsed(_i - _skipFirstArgs);
        _i++;
        markUsed(_i - _skipFirstArgs);
    }
    return true;
}
Пример #20
0
static void cvNonMaximumElimination(CamFrame frame) {

    unsigned int i, j, atan_result;
    unsigned char val;
    
    // Set outside border to 0
    memset(frame->pixels[0], 0x00, DS_IMAGE_COLS);
    memset(frame->pixels[DS_IMAGE_ROWS - 1], 0x00, DS_IMAGE_COLS);
    setColumn(frame, 0, 0, 0x00, DS_IMAGE_ROWS);
    setColumn(frame, DS_IMAGE_COLS - 1, 0, 0x00, DS_IMAGE_ROWS);
    
    for(i = 1; i < DS_IMAGE_ROWS - 1; i++) {
        for(j = 1; j < DS_IMAGE_COLS - 1; j++) {
            val = frame->pixels[i][j];
            
        }
    }

}
Пример #21
0
void MaxMatrix::writeSprite(const byte* sprite) //dizi olarak gelen yazdırılacak karakterin ilgili verilerini alıp yazdırmayı sağlayan fonksiyon.
{
  int w = sprite[0]; //kaç sütunu kullanacaksa ilk değerden sütun sayısı alınır.
  int h = sprite[1];

  for (int i=0; i<w; i++) //sütun sayısı for döngüsü ile veriler ilgili sütunlara gönderilir yazdırılmak üzere.
  {
    setColumn(i, sprite[i+2]);
  }
}
Пример #22
0
void SpriteAnimator::playAnimation(int line, int numFrames, float frameDuration, int numLoops)
{
	setLine(line);
	setColumn(0);
	FLAT_ASSERT(numFrames <= getAtlasWidth());
	setNumFrames(numFrames);
	setFrameDuration(frameDuration);
	setNumLoops(numLoops);
	setAnimated(true);
	m_animationStarted = false;
}
Пример #23
0
void TableView::setColumns(std::initializer_list<ColumnProperties> columnList)
{
    auto numCol = columns();        // save column count since we are changing it
    if( numCol >= columnList.size() ) {
        int c = 0;
        for( auto it = columnList.begin(); it != columnList.end(); ++it,++c ) {
            setColumn(c,*it);
        }
        for( ; c < numCol; ++c ) {
            deleteColumn(c);
        }
    } else {
        auto it = columnList.begin();
        for( int c = 0; c < numCol; ++c, ++it ) {
            setColumn(c,*it);
        }
        for( ; it != columnList.end(); ++it ) {
            addColumn(*it);
        }
    }
}
Пример #24
0
void cleanPage(uint8_t page)
{	
	setPage(page);
	setColumn(0);
	uint8_t cmd[LCD_MAX_WIDTH];
	int i;
	for(i = 0; i< LCD_MAX_WIDTH;i++)
	{
		cmd[i] = 0;
        virtual_memory_lcd[page][i]=0;
	}
	LCD_writeData(cmd, LCD_MAX_WIDTH);
}
Пример #25
0
ContextMap::ContextMap()
{
	// map requires sorted input
	setSortedInput(true);
	setLeftJoin(true);

	// default to BED score column
	setColumn(5);
	// default to "sum"
	setColumnOperation("sum");
	// default to "." as a NULL value
	setNullValue('.');
}
/**
 * Initiate completion when there is \c #include on a line (\c m_range
 * in a result of \c parseIncludeDirective() not empty -- i.e. there is some file present)
 * and cursor placed within that range... despite of completeness of the whole line.
 */
bool IncludeHelperCompletionModel::shouldStartCompletion(
    KTextEditor::View* view
  , const QString& inserted_text
  , bool user_insertion
  , const KTextEditor::Cursor& position
  )
{
    kDebug(DEBUG_AREA) << "position=" << position << ", inserted_text=" << inserted_text << ", ui=" << user_insertion;

    m_should_complete = false;
    auto* doc = view->document();                           // get current document
    auto line = doc->line(position.line());                 // get current line
    auto* iface = qobject_cast<KTextEditor::HighlightInterface*>(doc);
    // Do nothing if no highlighting interface or not suitable document or
    // a place within it... (we won't to complete smth in non C++ files or comments for example)
    if (!iface || !isSuitableDocumentAndHighlighting(doc->mimeType(), iface->highlightingModeAt(position)))
        return m_should_complete;

    // Try to parse it...
    auto r = parseIncludeDirective(line, false);
    m_should_complete = r.m_range.isValid();
    if (m_should_complete)
    {
        kDebug(DEBUG_AREA) << "range=" << r.m_range;
        m_should_complete = position.column() >= r.m_range.start().column()
          && position.column() <= r.m_range.end().column();
        if (m_should_complete)
        {
            m_closer = r.close_char();
            kDebug(DEBUG_AREA) << "closer=" << m_closer;
        }
    }
    else if (position.column() == line.length())
    {
        auto text = tryToCompleteIncludeDirective(line.mid(0, position.column()).trimmed());
        m_should_complete = !text.isEmpty();
        if (m_should_complete)
        {
            /// \todo Hardcoded angle bracket! Better to check what file was selected
            /// (from system path or session specific) and replace it accordingly...
            text += QLatin1String(" <");
            auto start = position;
            start.setColumn(0);
            auto range = KTextEditor::Range{start, position};
            view->document()->replaceText(range, text);
        }
    }
    return m_should_complete;
}
Пример #27
0
	bool Piece::movePrivate(Direction dir)
	{
		bool out = hitOnMove(dir);

		if(!out)
		{
			turnOff();

			int dRow, dColumn;
			getMovementVariations(dir, dRow, dColumn);
			setRow(getRow() + dRow);
			setColumn(getColumn() + dColumn);

			turnOn();
		}

		return out;
	}
//
// ReportSectionDetailGroup
//
ReportSectionDetailGroup::ReportSectionDetailGroup(const QString & column, ReportSectionDetail * rsd,
                                                   QWidget * parent)
        : QObject(parent)
{
    m_pageBreak = BreakNone;
    m_sort = Qt::AscendingOrder;
    KoReportDesigner * rd = 0;
    m_reportSectionDetail = rsd;
    if (m_reportSectionDetail) {
        rd = rsd->reportDesigner();
    } else {
        kWarning() << "Error: ReportSectionDetail is null";
    }
    m_groupHeader = new ReportSection(rd /*, _rsd*/);
    m_groupFooter = new ReportSection(rd /*, _rsd*/);
    setGroupHeaderVisible(false);
    setGroupFooterVisible(false);

    setColumn(column);
}
Пример #29
0
void printImage(uint8_t * image)
{
        int column;
        int row;
        int imageWidth = image[0];
        int imageHeight = image[1];
        
        for(row = 0; row < imageHeight; row++)
        {
                setColumn(0);
                setPage(row);
        
                uint8_t imageRow[imageWidth];
                for(column = 0; column < imageWidth; column++)
                {
                        imageRow[column] = image[2 + imageWidth*row + column];
                }
            LCD_writeData(imageRow,imageWidth);        
        }
}
Пример #30
0
uint8_t MD_MAX72XX::setChar(uint16_t col, uint8_t c)
{
  PRINT("\nsetChar: '", c);
  PRINT("' column ", col);
  boolean	b = _updateEnabled;

  uint16_t offset = getFontCharOffset(c);
  uint8_t size = pgm_read_byte(_fontData+offset);

  offset++;	// skip the size byte  

  _updateEnabled = false;
  for (int8_t i=0; i<size; i++) 
  {
    uint8_t colData = pgm_read_byte(_fontData+offset+i);
	setColumn(col--, colData);
  }
  _updateEnabled = b;

  if (_updateEnabled) flushBufferAll();

  return(size);
}