Exemplo n.º 1
0
void QGkhyMdiArea::paintEvent(QPaintEvent * paintEvent)
{
	QBrush bk = background();
	if (0 == m_bkPic || m_bkPic->size() != size())
	{
		m_bkPic.clear();
		m_bkPic = QSharedPointer<QPixmap>(new QPixmap(size()));
		
		QPainter painter(m_bkPic.data());

		QImage img(":/Resources/gkhy_gray_banner.png");		
		
		QFont font("Verdana", 10);
		
		painter.setFont(font);		
		// We will do something just as a doctor does in his O.R. when he
		// gets a pot from a pig's face and then paints it onto a man's whole
		// face.
		painter.fillRect(m_bkPic->rect(), QColor(img.pixel(0, 0)));
		painter.drawText(m_bkPic->rect(), Qt::AlignCenter,
			"Beijing Transuniverse Space Technology Co., Ltd");
		
		QRect imgSrcRect = img.rect();
		QPoint offset = m_bkPic->rect().center() - imgSrcRect.center();
		QRect imgDestRect = imgSrcRect.translated(offset);
		painter.drawImage(imgDestRect, img);

	}
	
	bk.setTexture(*m_bkPic);
	setBackground(bk);
	
	QMdiArea::paintEvent(paintEvent);
}
Exemplo n.º 2
0
BoxWidget::BoxWidget(QWidget *parent, BasicBox *box)
  : QWidget(parent)
{
  _curveMap = new QMap<std::string, CurveWidget *>();

  QBrush brush;
  QPixmap pix(200, 70);
  pix.fill(Qt::transparent);
  brush.setTexture(pix);
  QPalette palette;
  palette.setColor(QPalette::Background, QColor(255, 0, 0, 127));
  setPalette(palette);
  setWindowFlags(Qt::Widget);

  update();

  _box = box;
  _comboBox = new QComboBox;
  _curveWidget = new CurveWidget(NULL);
  _tabWidget = new QTabWidget;
  _tabWidget->lower();
  _tabWidget->setAttribute(Qt::WA_TranslucentBackground, true);
  _stackedLayout = new QStackedLayout;
  _stackedLayout->setStackingMode(QStackedLayout::StackAll);

  _curvePageLayout = new QGridLayout;
  setLayout(_stackedLayout);

  _parentWidget = parent;
  _curveWidgetList = new QList<CurveWidget *>;

  _startMenu = NULL;
  _endMenu = NULL;
}
bool readBrushNode( const QDomElement& element, QBrush& brush )
{
    bool ok = true;
    QColor tempColor;
    Qt::BrushStyle tempStyle = Qt::NoBrush;
    QPixmap tempPixmap;
    QDomNode node = element.firstChild();
    while( !node.isNull() ) {
        QDomElement element = node.toElement();
        if( !element.isNull() ) { // was really an element
            QString tagName = element.tagName();
            if( tagName == "Color" ) {
                ok = ok & readColorNode( element, tempColor );
            } else if( tagName == "Style" ) {
		QString value;
                ok = ok & readStringNode( element, value );
		tempStyle = stringToBrushStyle( value );
            } else if( tagName == "Pixmap" ) {
                ok = ok & readPixmapNode( element, tempPixmap );
            } else {
                qDebug( "Unknown tag in brush" );
            }
        }
        node = node.nextSibling();
    }

    if( ok ) {
	brush.setColor( tempColor );
	brush.setStyle( tempStyle );
        if( !tempPixmap.isNull() )
            brush.setTexture( tempPixmap );
    }

    return ok;
}
Exemplo n.º 4
0
TListPanel::TListPanel(QWidget* parent, Qt::WindowFlags)
: QGraphicsView(parent)
{
    QPixmap *brushPixmap = new QPixmap("TListPanel/brush.png", "PNG");
	QBrush *backgroundBrush = new QBrush();
	backgroundBrush->setTexture(*brushPixmap);
    this->setBackgroundBrush(*backgroundBrush);
	this->setCacheMode(QGraphicsView::CacheBackground);
	
    this->setAlignment(Qt::AlignLeft | Qt::AlignTop);
    this->setVisible(true);
    scene = new QGraphicsScene(this);
	this->setScene(scene);
    //infoText = new QGraphicsTextItem("");

	this->currentIndex = 0;
	
    countItems = 0;
    x = 0;
    y = 0;
    h = 60;
    otst = 10;
    inc = 0;
	
	listItems = new QList<frameStruct*>();
	frameItems = new QList<TFrameItem*>();
}
Exemplo n.º 5
0
void LevelBase::drawLevelBase(QPainter &painter)
{
    rect = new QRect(0, floorStart, gameWindow, 40);
    painter.drawRect(*rect);
    QBrush brush;
    brush.setTexture(*floor);
    painter.fillRect(*rect, brush);
}//Draws the floor
Exemplo n.º 6
0
void GraphicalRobotElement::tagVisionObservations (QGraphicsEllipseItem *post, QRectF rect, QString text) {
	QBrush brush;
	QPixmap pix (700, 700);
	pix.fill (Qt::yellow);
	QPainter paint (&pix);
	paint.setPen ("black");
	paint.drawText (rect, Qt::AlignCenter , text);
	brush.setTexture (pix);
	post->setBrush (brush);
}
Exemplo n.º 7
0
void LvlScene::setCircleDrawer()
{
    if(cursor)
        {delete cursor;
        cursor=NULL;}

    QPen pen;
    QBrush brush;

    switch(placingItem)
    {
    case PLC_Block:
    case PLC_BGO:
    default:
        pen = QPen(Qt::gray, 2);
        brush = QBrush(Qt::darkGray);
        break;
    }

    //Align width and height to fit into item aligning
    long addW=LvlPlacingItems::gridSz-LvlPlacingItems::itemW%LvlPlacingItems::gridSz;
    long addH=LvlPlacingItems::gridSz-LvlPlacingItems::itemH%LvlPlacingItems::gridSz;
    if(addW==LvlPlacingItems::gridSz) addW=0;
    if(addH==LvlPlacingItems::gridSz) addH=0;
    LvlPlacingItems::itemW = LvlPlacingItems::itemW+addW;
    LvlPlacingItems::itemH = LvlPlacingItems::itemH+addH;

    if((placingItem != PLC_Water) && (!LvlPlacingItems::sizableBlock))
    {
        QPixmap oneCell(LvlPlacingItems::itemW, LvlPlacingItems::itemH);
        oneCell.fill(QColor(0xFF, 0xFF, 0x00, 128));
        QPainter p(&oneCell);
        p.setBrush(Qt::NoBrush);
        p.setPen(QPen(Qt::yellow, 2, Qt::SolidLine));
        p.drawRect(0,0, LvlPlacingItems::itemW, LvlPlacingItems::itemH);
        brush.setTexture(oneCell);
    }

    cursor = addEllipse(0,0,1,1, pen, brush);

    //set data flags
    foreach(dataFlag flag, LvlPlacingItems::flags)
        cursor->setData(flag.first, flag.second);

    cursor->setData(ITEM_TYPE, "Circle");

    cursor->setData(ITEM_IS_CURSOR, "CURSOR");
    cursor->setZValue(7000);
    cursor->setOpacity( 0.5 );
    cursor->setVisible(false);
    cursor->setEnabled(true);

    SwitchEditingMode(MODE_DrawCircle);
    DrawMode=true;
}
Exemplo n.º 8
0
void MainWindow::paintEvent(QPaintEvent *){

    auto map = QPixmap(QString(":/other/bg-chess.xcf"));//":/other/bg-chess.jpg"));


    QPainter paint;
    paint.begin(this);
    QBrush brush;
    brush.setTexture(map);
    //brush.setStyle(Qt::RadialGradientPattern);
    paint.setBrush(brush);//(QBrush (QColor (255, 255, 255, 200)));
    paint.setPen (Qt::NoPen);
    paint.drawRect (0, 0, width(), height());
    paint.end();
}
Exemplo n.º 9
0
QGraphicsRectItem *Board::CreateBoard()
{
    QGraphicsRectItem *item = new QGraphicsRectItem;
    QPixmap *pixmap = new QPixmap("D:\\programmieren\\RealChess\\ChessBoard.PNG");
    QBrush *brush = new QBrush();

    if(pixmap->isNull()) {
        item->setBrush(Qt::green);
    }
    else {
        brush->setTexture(*pixmap);
        item->setBrush(*pixmap);
    }
    item->setRect(0,0,600,600);


    return item;

}
Exemplo n.º 10
0
QBrush DesktopBackgroundDialog::background()
{
    QBrush background;
    switch (m_type)
    {
        case (RazorWorkSpaceManager::BackgroundPixmap):
        {
            QPixmap pm(m_wallpaper);
            pm = pm.scaled(m_desktopSize,
                           keepAspectCheckBox->isChecked() ? Qt::KeepAspectRatio : Qt::IgnoreAspectRatio,
                           Qt::SmoothTransformation);
            background.setTexture(pm);
            break;
        }
        default:
            background.setColor(m_color);
            background.setStyle(Qt::SolidPattern);
    }
    save();
    return background;
}
Exemplo n.º 11
0
imageViewer::imageViewer(QWidget *parent): QLabel(parent)
{
  addToLog("image creation",LOGIMAG);
  validImage=false;
  setFrameStyle(QFrame::Sunken | QFrame::Panel);
  QBrush b;
  QPalette palette;
  b.setTexture(QPixmap::fromImage(QImage(":/icons/transparency.png")));
  palette.setBrush(QPalette::Active,QPalette::Base,b);
  palette.setBrush(QPalette::Inactive,QPalette::Base,b);
  palette.setBrush(QPalette::Disabled,QPalette::Base,b);
  setPalette(palette);
  setBackgroundRole(QPalette::Base);
  setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);

  setBackgroundRole(QPalette::Dark);

  popup=new QMenu (this);
  newAct = new QAction(tr("&New"),this);
  connect(newAct, SIGNAL(triggered()), this, SLOT(slotNew()));
  loadAct = new QAction(tr("&Load"), this);
  connect(loadAct, SIGNAL(triggered()), this, SLOT(slotLoad()));
  toTXAct = new QAction(tr("&To TX"), this);
  connect(toTXAct, SIGNAL(triggered()), this, SLOT(slotToTX()));
  editAct = new QAction(tr("&Edit"), this);
  connect(editAct, SIGNAL(triggered()), this, SLOT(slotEdit()));
  printAct = new QAction(tr("&Print"), this);
  connect(printAct, SIGNAL(triggered()), this, SLOT(slotPrint()));
  deleteAct = new QAction(tr("&Delete"), this);
  connect(deleteAct, SIGNAL(triggered()), this, SLOT(slotDelete()));
  viewAct = new QAction(tr("&View"), this);
  connect(viewAct, SIGNAL(triggered()), this, SLOT(slotView()));
  propertiesAct = new QAction(tr("Propert&ies"), this);
  connect(propertiesAct, SIGNAL(triggered()), this, SLOT(slotProperties()));
  connect(configDialogPtr,SIGNAL(bgColorChanged()), SLOT(slotBGColorChanged()));

  init(RXIMG);
  activeMovie=false;
  //
}
Exemplo n.º 12
0
void ThumbnailCanvas::paintEvent(QPaintEvent* event)
{
	QWidget::paintEvent(event);
	
	//paint grid
	if (m_pixmap.isNull())
	{
		return;
	}

	QPainter painter(this);
	QSize pixSize = m_pixmap.size();
	QPoint topleft;

	QBrush brush;
	brush.setTexture(m_gridPixmap);

	QPixmap scaledPix = m_pixmap.scaled(event->rect().size(), Qt::KeepAspectRatio);

	if (event->rect().width() > event->rect().height())
	{
		topleft.setX((event->rect().width() - scaledPix.width()) / 2);
	}
	else
	{
		topleft.setY((event->rect().height() - scaledPix.height()) / 2);
	}

	painter.fillRect(topleft.x(), topleft.y(), scaledPix.width(), scaledPix.height(), brush);
	if (needFitCanvas)
	{
		painter.drawPixmap(topleft, scaledPix);
	}
	else{
		qDebug() << m_pixmap.size();
		painter.drawPixmap(topleft, m_pixmap);
	}

}
Exemplo n.º 13
0
void Board::initializeBoard()
{
/* WHITE CHIPS ---------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------*/
    QPixmap *w_chipPixmapTower = new QPixmap("D:\\programmieren\\RealChess\\chip_w_t.JPG");
    if(w_chipPixmapTower->isNull()) {
    }
    else {
            QBrush *brush = new QBrush(*w_chipPixmapTower);
            brush->setTexture(*w_chipPixmapTower);
            //qDebug() <<"Chip: Brush Image Available";         //check if  brush image is available
    }

    QPixmap *w_chipPixmapHorse = new QPixmap("D:\\programmieren\\RealChess\\chip_w_h.JPG");
    if(w_chipPixmapHorse->isNull()) {
    }
    else {
            QBrush *brush = new QBrush(*w_chipPixmapHorse);
            brush->setTexture(*w_chipPixmapHorse);
            //qDebug() <<"Chip: Brush Image Available";         //check if  brush image is available
    }

    QPixmap *w_chipPixmapBishop = new QPixmap("D:\\programmieren\\RealChess\\chip_w_l.JPG");
    if(w_chipPixmapBishop->isNull()) {
    }
    else {
            QBrush *brush = new QBrush(*w_chipPixmapBishop);
            brush->setTexture(*w_chipPixmapBishop);
            //qDebug() <<"Chip: Brush Image Available";         //check if  brush image is available
    }

    QPixmap *w_chipPixmapQueen = new QPixmap("D:\\programmieren\\RealChess\\chip_w_q.JPG");
    if(w_chipPixmapQueen->isNull()) {
    }
    else {
            QBrush *brush = new QBrush(*w_chipPixmapQueen);
            brush->setTexture(*w_chipPixmapQueen);
            //qDebug() <<"Chip: Brush Image Available";         //check if  brush image is available
    }

    QPixmap *w_chipPixmapKing = new QPixmap("D:\\programmieren\\RealChess\\chip_w_k.JPG");
    if(w_chipPixmapKing->isNull()) {
    }
    else {
            QBrush *brush = new QBrush(*w_chipPixmapKing);
            brush->setTexture(*w_chipPixmapKing);
            //qDebug() <<"Chip: Brush Image Available";         //check if  brush image is available
    }

    QPixmap *w_chipPixmapBauer = new QPixmap("D:\\programmieren\\RealChess\\chip_w_b.JPG");
    if(w_chipPixmapBauer->isNull()) {
    }
    else {
            QBrush *brush = new QBrush(*w_chipPixmapBauer);
            brush->setTexture(*w_chipPixmapBauer);
            //qDebug() <<"Chip: Brush Image Available";         //check if  brush image is available
    }

/* BLACK CHIPS -------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------*/
    QPixmap *b_chipPixmapTower = new QPixmap("D:\\programmieren\\RealChess\\chip_b_t.JPG");
        if(b_chipPixmapTower->isNull()) {
        }
        else {
                QBrush *brush = new QBrush(*b_chipPixmapTower);
                brush->setTexture(*b_chipPixmapTower);
                //qDebug() <<"Chip: Brush Image Available";         //check if  brush image is available
        }

        QPixmap *b_chipPixmapHorse = new QPixmap("D:\\programmieren\\RealChess\\chip_b_h.JPG");
        if(b_chipPixmapHorse->isNull()) {
        }
        else {
                QBrush *brush = new QBrush(*b_chipPixmapHorse);
                brush->setTexture(*b_chipPixmapHorse);
                //qDebug() <<"Chip: Brush Image Available";         //check if  brush image is available
        }

        QPixmap *b_chipPixmapBishop = new QPixmap("D:\\programmieren\\RealChess\\chip_b_l.JPG");
        if(b_chipPixmapBishop->isNull()) {
        }
        else {
                QBrush *brush = new QBrush(*b_chipPixmapBishop);
                brush->setTexture(*b_chipPixmapBishop);
                //qDebug() <<"Chip: Brush Image Available";         //check if  brush image is available
        }

        QPixmap *b_chipPixmapQueen = new QPixmap("D:\\programmieren\\RealChess\\chip_b_q.JPG");
        if(b_chipPixmapQueen->isNull()) {
        }
        else {
                QBrush *brush = new QBrush(*b_chipPixmapQueen);
                brush->setTexture(*b_chipPixmapQueen);
                //qDebug() <<"Chip: Brush Image Available";         //check if  brush image is available
        }

        QPixmap *b_chipPixmapKing = new QPixmap("D:\\programmieren\\RealChess\\chip_b_k.JPG");
        if(b_chipPixmapKing->isNull()) {
        }
        else {
                QBrush *brush = new QBrush(*b_chipPixmapKing);
                brush->setTexture(*b_chipPixmapKing);
                //qDebug() <<"Chip: Brush Image Available";         //check if  brush image is available
        }

        QPixmap *b_chipPixmapBauer = new QPixmap("D:\\programmieren\\RealChess\\chip_b_b.JPG");
        if(b_chipPixmapBauer->isNull()) {
        }
        else {
                QBrush *brush = new QBrush(*b_chipPixmapBauer);
                brush->setTexture(*b_chipPixmapBauer);
                //qDebug() <<"Chip: Brush Image Available";         //check if  brush image is available
        }

///* WHITE CHIPS ---------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------*/
//    Chip *w_Chip_1 = new Chip();
//    w_Chip_1->chipType = w_chBauer;
//    w_Chip_1->playerNumber = playerWhite;
//    w_Chip_1->initialBoardOffset_x = 0;
//    w_Chip_1->setPos( (x()+BoardOffset) + SQUAREWIDTH*w_Chip_1->initialBoardOffset_x , y()+BoardOffset+SQUAREWIDTH );
//    w_Chip_1->currentSquare = 8;
//    w_Chip_1->setBrush(*w_chipPixmapBauer);

//    bBoardState[w_Chip_1->currentSquare] = w_Chip_1->chipType;
//    scene()->addItem(w_Chip_1);

//    Chip *w_Chip_2 = new Chip();
//    w_Chip_2->initialBoardOffset_x = 1;
//    w_Chip_2->setPos( (x()+BoardOffset) + SQUAREWIDTH*w_Chip_2->initialBoardOffset_x,y()+BoardOffset+SQUAREWIDTH);
//    scene()->addItem(w_Chip_2);
//    w_Chip_2->currentSquare = 9;
//    w_Chip_2->chipType = w_chBauer;
//    w_Chip_2->playerNumber = playerWhite;
//    w_Chip_2->setBrush(*w_chipPixmapBauer);
//    bBoardState[w_Chip_2->currentSquare] = w_Chip_2->chipType;

//    Chip *w_Chip_3 = new Chip();
//    w_Chip_3->initialBoardOffset_x = 2;
//    w_Chip_3->setPos( (x()+BoardOffset) + SQUAREWIDTH*w_Chip_3->initialBoardOffset_x,y()+BoardOffset+SQUAREWIDTH);
//    scene()->addItem(w_Chip_3);
//    w_Chip_3->currentSquare = 10;
//    w_Chip_3->chipType = w_chBauer;
//    w_Chip_3->playerNumber = playerWhite;
//    w_Chip_3->setBrush(*w_chipPixmapBauer);
//    bBoardState[w_Chip_3->currentSquare] = w_Chip_3->chipType;

//    Chip *w_Chip_4 = new Chip();
//    w_Chip_4->initialBoardOffset_x = 3;
//    w_Chip_4->setPos( (x()+BoardOffset) + SQUAREWIDTH*w_Chip_4->initialBoardOffset_x,y()+BoardOffset+SQUAREWIDTH);
//    scene()->addItem(w_Chip_4);
//    w_Chip_4->currentSquare = 11;
//    w_Chip_4->chipType = w_chBauer;
//    w_Chip_4->playerNumber = playerWhite;
//    w_Chip_4->setBrush(*w_chipPixmapBauer);
//    bBoardState[w_Chip_4->currentSquare] = w_Chip_4->chipType;

//    Chip *w_Chip_5 = new Chip();
//    w_Chip_5->initialBoardOffset_x = 4;
//    w_Chip_5->setPos( (x()+BoardOffset) + SQUAREWIDTH*w_Chip_5->initialBoardOffset_x,y()+BoardOffset+SQUAREWIDTH);
//    scene()->addItem(w_Chip_5);
//    w_Chip_5->currentSquare = 12;
//    w_Chip_5->chipType = w_chBauer;
//    w_Chip_5->playerNumber = playerWhite;
//    w_Chip_5->setBrush(*w_chipPixmapBauer);
//    bBoardState[w_Chip_5->currentSquare] = w_Chip_5->chipType;

//    Chip *w_Chip_6 = new Chip();
//    w_Chip_6->initialBoardOffset_x = 5;
//    w_Chip_6->setPos( (x()+BoardOffset) + SQUAREWIDTH*w_Chip_6->initialBoardOffset_x,y()+BoardOffset+SQUAREWIDTH);
//    scene()->addItem(w_Chip_6);
//    w_Chip_6->currentSquare = 13;
//    w_Chip_6->chipType = w_chBauer;
//    w_Chip_6->playerNumber = playerWhite;
//    w_Chip_6->setBrush(*w_chipPixmapBauer);
//    bBoardState[w_Chip_6->currentSquare] = w_Chip_6->chipType;

//    Chip *w_Chip_7 = new Chip();
//    w_Chip_7->initialBoardOffset_x = 6;
//    w_Chip_7->setPos( (x()+BoardOffset) + SQUAREWIDTH*w_Chip_7->initialBoardOffset_x,y()+BoardOffset+SQUAREWIDTH);
//    scene()->addItem(w_Chip_7);
//    w_Chip_7->currentSquare = 14;
//    w_Chip_7->chipType = w_chBauer;
//    w_Chip_7->playerNumber = playerWhite;
//    w_Chip_7->setBrush(*w_chipPixmapBauer);
//    bBoardState[w_Chip_7->currentSquare] = w_Chip_7->chipType;

//    Chip *w_Chip_8 = new Chip();
//    w_Chip_8->initialBoardOffset_x = 7;
//    w_Chip_8->setPos( (x()+BoardOffset) + SQUAREWIDTH*w_Chip_8->initialBoardOffset_x,y()+BoardOffset+SQUAREWIDTH);
//    scene()->addItem(w_Chip_8);
//    w_Chip_8->currentSquare = 15;
//    w_Chip_8->chipType = w_chBauer;
//    w_Chip_8->playerNumber = playerWhite;
//    w_Chip_8->setBrush(*w_chipPixmapBauer);
//    bBoardState[w_Chip_8->currentSquare] = w_Chip_8->chipType;

//    Chip *w_Chip_Tower_1 = new Chip();
//    w_Chip_Tower_1->chipType = w_chTower;
//    w_Chip_Tower_1->playerNumber = playerWhite;
//    w_Chip_Tower_1->initialBoardOffset_x = 0;
//    w_Chip_Tower_1->setPos( (x()+BoardOffset) + SQUAREWIDTH*w_Chip_Tower_1->initialBoardOffset_x,y()+BoardOffset);
//    scene()->addItem(w_Chip_Tower_1);
//    w_Chip_Tower_1->currentSquare = 0;
//    w_Chip_Tower_1->setBrush(*w_chipPixmapTower);
//    bBoardState[w_Chip_Tower_1->currentSquare] = w_Chip_Tower_1->chipType;

//    Chip *w_Chip_Horse_1 = new Chip();
//    w_Chip_Horse_1->chipType = w_chHorse;
//    w_Chip_Horse_1->playerNumber = playerWhite;
//    w_Chip_Horse_1->initialBoardOffset_x = 1;
//    w_Chip_Horse_1->setPos( (x()+BoardOffset) + SQUAREWIDTH*w_Chip_Horse_1->initialBoardOffset_x,y()+BoardOffset);
//    scene()->addItem(w_Chip_Horse_1);
//    w_Chip_Horse_1->currentSquare = 1;
//    w_Chip_Horse_1->setBrush(*w_chipPixmapHorse);
//    bBoardState[w_Chip_Horse_1->currentSquare] = w_Chip_Horse_1->chipType;

//    Chip *w_Chip_Bishop_1 = new Chip();
//    w_Chip_Bishop_1->chipType = w_chBishop;
//    w_Chip_Bishop_1->playerNumber = playerWhite;
//    w_Chip_Bishop_1->initialBoardOffset_x = 2;
//    w_Chip_Bishop_1->setPos( (x()+BoardOffset) + SQUAREWIDTH*w_Chip_Bishop_1->initialBoardOffset_x,y()+BoardOffset);
//    scene()->addItem(w_Chip_Bishop_1);
//    w_Chip_Bishop_1->currentSquare = 2;
//    w_Chip_Bishop_1->setBrush(*w_chipPixmapBishop);
//    bBoardState[w_Chip_Bishop_1->currentSquare] = w_Chip_Bishop_1->chipType;

//    Chip *w_Chip_Queen = new Chip();
//    w_Chip_Queen->chipType = w_chQueen;
//    w_Chip_Queen->playerNumber = playerWhite;
//    w_Chip_Queen->initialBoardOffset_x = 3;
//    w_Chip_Queen->setPos( (x()+BoardOffset) + SQUAREWIDTH*w_Chip_Queen->initialBoardOffset_x,y()+BoardOffset);
//    scene()->addItem(w_Chip_Queen);
//    w_Chip_Queen->currentSquare = 3;
//    w_Chip_Queen->setBrush(*w_chipPixmapQueen);
//    bBoardState[w_Chip_Queen->currentSquare] = w_Chip_Queen->chipType;

//    Chip *w_Chip_King = new Chip();
//    w_Chip_King->chipType = w_chKing;
//    w_Chip_King->playerNumber = playerWhite;
//    w_Chip_King->initialBoardOffset_x = 4;
//    w_Chip_King->setPos( (x()+BoardOffset) + SQUAREWIDTH*w_Chip_King->initialBoardOffset_x,y()+BoardOffset);
//    scene()->addItem(w_Chip_King);
//    w_Chip_King->currentSquare = 4;
//    w_Chip_King->setBrush(*w_chipPixmapKing);
//    bBoardState[w_Chip_King->currentSquare] = w_Chip_King->chipType;



//    Chip *w_Chip_Bishop_2 = new Chip();
//    w_Chip_Bishop_2->chipType = w_chBishop;
//    w_Chip_Bishop_2->playerNumber = playerWhite;
//    w_Chip_Bishop_2->initialBoardOffset_x = 5;
//    w_Chip_Bishop_2->setPos( (x()+BoardOffset) + SQUAREWIDTH*w_Chip_Bishop_2->initialBoardOffset_x,y()+BoardOffset);
//    scene()->addItem(w_Chip_Bishop_2);
//    w_Chip_Bishop_2->currentSquare = 5;
//    w_Chip_Bishop_2->setBrush(*w_chipPixmapBishop);
//    bBoardState[w_Chip_Bishop_2->currentSquare] = w_Chip_Bishop_2->chipType;

//    Chip *w_Chip_Horse_2 = new Chip();
//    w_Chip_Horse_2->chipType = w_chHorse;
//    w_Chip_Horse_2->playerNumber = playerWhite;
//    w_Chip_Horse_2->initialBoardOffset_x = 6;
//    w_Chip_Horse_2->setPos( (x()+BoardOffset) + SQUAREWIDTH*w_Chip_Horse_2->initialBoardOffset_x,y()+BoardOffset);
//    scene()->addItem(w_Chip_Horse_2);
//    w_Chip_Horse_2->currentSquare = 6;
//    w_Chip_Horse_2->setBrush(*w_chipPixmapHorse);
//    bBoardState[w_Chip_Horse_2->currentSquare] = w_Chip_Horse_2->chipType;

//    Chip *w_Chip_Tower_2 = new Chip();
//    w_Chip_Tower_2->chipType = w_chTower;
//    w_Chip_Tower_2->playerNumber = playerWhite;
//    w_Chip_Tower_2->initialBoardOffset_x = 7;
//    w_Chip_Tower_2->setPos( (x()+BoardOffset) + SQUAREWIDTH*w_Chip_Tower_2->initialBoardOffset_x,y()+BoardOffset);
//    scene()->addItem(w_Chip_Tower_2);
//    w_Chip_Tower_2->currentSquare = 7;
//    w_Chip_Tower_2->setBrush(*w_chipPixmapTower);
//    bBoardState[w_Chip_Tower_2->currentSquare] = w_Chip_Tower_2->chipType;





///* BLACK CHIPS -------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------------------*/
//    Chip *b_Chip_1 = new Chip();
//    b_Chip_1->chipType = b_chBauer;
//    b_Chip_1->playerNumber = playerBlack;
//    b_Chip_1->initialBoardOffset_x = 1-1;
//    b_Chip_1->setPos( (x()+BoardOffset) + SQUAREWIDTH*b_Chip_1->initialBoardOffset_x , y()+BoardOffset+SQUAREWIDTH*6 );
//    b_Chip_1->currentSquare = 48;
//    b_Chip_1->setBrush(*b_chipPixmapBauer);
//    bBoardState[b_Chip_1->currentSquare] = b_Chip_1->chipType;
//    scene()->addItem(b_Chip_1);

//    Chip *b_Chip_2 = new Chip();
//    b_Chip_2->initialBoardOffset_x = 2-1;
//    b_Chip_2->setPos( (x()+BoardOffset) + SQUAREWIDTH*b_Chip_2->initialBoardOffset_x,y()+BoardOffset+SQUAREWIDTH*6);
//    scene()->addItem(b_Chip_2);
//    b_Chip_2->currentSquare = 49;
//    b_Chip_2->chipType = b_chBauer;
//    b_Chip_2->playerNumber = playerBlack;
//    b_Chip_2->setBrush(*b_chipPixmapBauer);
//    bBoardState[b_Chip_2->currentSquare] = b_Chip_2->chipType;

//    Chip *b_Chip_3 = new Chip();
//    b_Chip_3->initialBoardOffset_x = 3-1;
//    b_Chip_3->setPos( (x()+BoardOffset) + SQUAREWIDTH*b_Chip_3->initialBoardOffset_x,y()+BoardOffset+SQUAREWIDTH*6);
//    scene()->addItem(b_Chip_3);
//    b_Chip_3->currentSquare = 50;
//    b_Chip_3->chipType = b_chBauer;
//    b_Chip_3->playerNumber = playerBlack;
//    b_Chip_3->setBrush(*b_chipPixmapBauer);
//    bBoardState[b_Chip_3->currentSquare] = b_Chip_3->chipType;

//    Chip *b_Chip_4 = new Chip();
//    b_Chip_4->initialBoardOffset_x = 4-1;
//    b_Chip_4->setPos( (x()+BoardOffset) + SQUAREWIDTH*b_Chip_4->initialBoardOffset_x,y()+BoardOffset+SQUAREWIDTH*6);
//    scene()->addItem(b_Chip_4);
//    b_Chip_4->currentSquare = 51;
//    b_Chip_4->chipType = b_chBauer;
//    b_Chip_4->playerNumber = playerBlack;
//    b_Chip_4->setBrush(*b_chipPixmapBauer);
//    bBoardState[b_Chip_4->currentSquare] = b_Chip_4->chipType;

//    Chip *b_Chip_5 = new Chip();
//    b_Chip_5->initialBoardOffset_x = 5-1;
//    b_Chip_5->setPos( (x()+BoardOffset) + SQUAREWIDTH*b_Chip_5->initialBoardOffset_x,y()+BoardOffset+SQUAREWIDTH*6);
//    scene()->addItem(b_Chip_5);
//    b_Chip_5->currentSquare = 52;
//    b_Chip_5->chipType = b_chBauer;
//    b_Chip_5->playerNumber = playerBlack;
//    b_Chip_5->setBrush(*b_chipPixmapBauer);
//    bBoardState[b_Chip_5->currentSquare] = b_Chip_5->chipType;

//    Chip *b_Chip_6 = new Chip();
//    b_Chip_6->initialBoardOffset_x = 6-1;
//    b_Chip_6->setPos( (x()+BoardOffset) + SQUAREWIDTH*b_Chip_6->initialBoardOffset_x,y()+BoardOffset+SQUAREWIDTH*6);
//    scene()->addItem(b_Chip_6);
//    b_Chip_6->currentSquare = 53;
//    b_Chip_6->chipType = b_chBauer;
//    b_Chip_6->playerNumber = playerBlack;
//    b_Chip_6->setBrush(*b_chipPixmapBauer);
//    bBoardState[b_Chip_6->currentSquare] = b_Chip_6->chipType;

//    Chip *b_Chip_7 = new Chip();
//    b_Chip_7->initialBoardOffset_x = 7-1;
//    b_Chip_7->setPos( (x()+BoardOffset) + SQUAREWIDTH*b_Chip_7->initialBoardOffset_x,y()+BoardOffset+SQUAREWIDTH*6);
//    scene()->addItem(b_Chip_7);
//    b_Chip_7->currentSquare = 54;
//    b_Chip_7->chipType = b_chBauer;
//    b_Chip_7->playerNumber = playerBlack;
//    b_Chip_7->setBrush(*b_chipPixmapBauer);
//    bBoardState[b_Chip_7->currentSquare] = b_Chip_7->chipType;

//    Chip *b_Chip_8 = new Chip();
//    b_Chip_8->initialBoardOffset_x = 8-1;
//    b_Chip_8->setPos( (x()+BoardOffset) + SQUAREWIDTH*b_Chip_8->initialBoardOffset_x,y()+BoardOffset+SQUAREWIDTH*6);
//    scene()->addItem(b_Chip_8);
//    b_Chip_8->currentSquare = 55;
//    b_Chip_8->chipType = b_chBauer;
//    b_Chip_8->playerNumber = playerBlack;
//    b_Chip_8->setBrush(*b_chipPixmapBauer);
//    bBoardState[b_Chip_8->currentSquare] = b_Chip_8->chipType;

//    Chip *b_Chip_Tower_1 = new Chip();
//    b_Chip_Tower_1->chipType = b_chTower;
//    b_Chip_Tower_1->playerNumber = playerBlack;
//    b_Chip_Tower_1->initialBoardOffset_x = 0;
//    b_Chip_Tower_1->setPos( (x()+BoardOffset) + SQUAREWIDTH*b_Chip_Tower_1->initialBoardOffset_x,y()+BoardOffset+7*SQUAREWIDTH);
//    scene()->addItem(b_Chip_Tower_1);
//    b_Chip_Tower_1->currentSquare = 56;
//    b_Chip_Tower_1->setBrush(*b_chipPixmapTower);
//    bBoardState[b_Chip_Tower_1->currentSquare] = b_Chip_Tower_1->chipType;

//    Chip *b_Chip_Horse_1 = new Chip();
//    b_Chip_Horse_1->chipType = b_chHorse;
//    b_Chip_Horse_1->playerNumber = playerBlack;
//    b_Chip_Horse_1->initialBoardOffset_x = 1;
//    b_Chip_Horse_1->setPos( (x()+BoardOffset) + SQUAREWIDTH*b_Chip_Horse_1->initialBoardOffset_x,y()+BoardOffset+7*SQUAREWIDTH);
//    scene()->addItem(b_Chip_Horse_1);
//    b_Chip_Horse_1->currentSquare = 57;
//    b_Chip_Horse_1->setBrush(*b_chipPixmapHorse);
//    bBoardState[b_Chip_Horse_1->currentSquare] = b_Chip_Horse_1->chipType;

//    Chip *b_Chip_Bishop_1 = new Chip();
//    b_Chip_Bishop_1->chipType = b_chBishop;
//    b_Chip_Bishop_1->playerNumber = playerBlack;
//    b_Chip_Bishop_1->initialBoardOffset_x = 2;
//    b_Chip_Bishop_1->setPos( (x()+BoardOffset) + SQUAREWIDTH*b_Chip_Bishop_1->initialBoardOffset_x,y()+BoardOffset+7*SQUAREWIDTH);
//    scene()->addItem(b_Chip_Bishop_1);
//    b_Chip_Bishop_1->currentSquare = 58;
//    b_Chip_Bishop_1->setBrush(*b_chipPixmapBishop);
//    bBoardState[b_Chip_Bishop_1->currentSquare] = b_Chip_Bishop_1->chipType;

//    Chip *b_Chip_Queen = new Chip();
//    b_Chip_Queen->chipType = b_chQueen;
//    b_Chip_Queen->playerNumber = playerBlack;
//    b_Chip_Queen->initialBoardOffset_x = 3;
//    b_Chip_Queen->setPos( (x()+BoardOffset) + SQUAREWIDTH*b_Chip_Queen->initialBoardOffset_x,y()+BoardOffset+7*SQUAREWIDTH);
//    scene()->addItem(b_Chip_Queen);
//    b_Chip_Queen->currentSquare = 59;
//    b_Chip_Queen->setBrush(*b_chipPixmapQueen);
//    bBoardState[b_Chip_Queen->currentSquare] = b_Chip_Queen->chipType;

//    Chip *b_Chip_King = new Chip();
//    b_Chip_King->chipType = b_chKing;
//    b_Chip_King->playerNumber = playerBlack;
//    b_Chip_King->initialBoardOffset_x = 4;
//    b_Chip_King->setPos( (x()+BoardOffset) + SQUAREWIDTH*b_Chip_King->initialBoardOffset_x,y()+BoardOffset+7*SQUAREWIDTH);
//    scene()->addItem(b_Chip_King);
//    b_Chip_King->currentSquare = 60;
//    b_Chip_King->setBrush(*b_chipPixmapKing);
//    bBoardState[b_Chip_King->currentSquare] = b_Chip_King->chipType;



//    Chip *b_Chip_Bishop_2 = new Chip();
//    b_Chip_Bishop_2->chipType = b_chBishop;
//    b_Chip_Bishop_2->playerNumber = playerBlack;
//    b_Chip_Bishop_2->initialBoardOffset_x = 5;
//    b_Chip_Bishop_2->setPos( (x()+BoardOffset) + SQUAREWIDTH*b_Chip_Bishop_2->initialBoardOffset_x,y()+BoardOffset+7*SQUAREWIDTH);
//    scene()->addItem(b_Chip_Bishop_2);
//    b_Chip_Bishop_2->currentSquare = 61;
//    b_Chip_Bishop_2->setBrush(*b_chipPixmapBishop);
//    bBoardState[b_Chip_Bishop_2->currentSquare] = b_Chip_Bishop_2->chipType;

//    Chip *b_Chip_Horse_2 = new Chip();
//    b_Chip_Horse_2->chipType = b_chHorse;
//    b_Chip_Horse_2->playerNumber = playerBlack;
//    b_Chip_Horse_2->initialBoardOffset_x = 6;
//    b_Chip_Horse_2->setPos( (x()+BoardOffset) + SQUAREWIDTH*b_Chip_Horse_2->initialBoardOffset_x,y()+BoardOffset+7*SQUAREWIDTH);
//    scene()->addItem(b_Chip_Horse_2);
//    b_Chip_Horse_2->currentSquare = 62;
//    b_Chip_Horse_2->setBrush(*b_chipPixmapHorse);
//    bBoardState[b_Chip_Horse_2->currentSquare] = b_Chip_Horse_2->chipType;

//    Chip *b_Chip_Tower_2 = new Chip();
//    b_Chip_Tower_2->chipType = b_chTower;
//    b_Chip_Tower_2->playerNumber = playerBlack;
//    b_Chip_Tower_2->initialBoardOffset_x = 7;
//    b_Chip_Tower_2->setPos( (x()+BoardOffset) + SQUAREWIDTH*b_Chip_Tower_2->initialBoardOffset_x,y()+BoardOffset+7*SQUAREWIDTH);
//    scene()->addItem(b_Chip_Tower_2);
//    b_Chip_Tower_2->currentSquare = 63;
//    b_Chip_Tower_2->setBrush(*b_chipPixmapTower);
//    bBoardState[b_Chip_Tower_2->currentSquare] = b_Chip_Tower_2->chipType;




}
Exemplo n.º 14
0
// ////////////////////////Apply section background/////////////////////////////
void LvlScene::setSectionBG(LevelSection section, bool forceTiled)
{
    //QGraphicsPixmapItem * item=NULL;
    QGraphicsRectItem * itemRect=NULL;
    QBrush brush;
    QPen pen;
    QPixmap image = Themes::Image(Themes::dummy_bg);
    QPixmap nullimage;
    obj_BG *bgConfig=NULL;
    QPixmap *img=NULL;
    QPixmap *img2=NULL; //Second image buffer
    //need a BGitem

    bool noimage=false, wrong=false;
    long x,y,h,w;

    if(
        (section.size_left!=0) ||
        (section.size_top!=0)||
        (section.size_bottom!=0)||
        (section.size_right!=0)
      )
    { //Don't draw on unallocated section entry
        x=section.size_left;
        y=section.size_top;
        w=section.size_right;
        h=section.size_bottom;

        #ifdef _DEBUG_
        WriteToLog(QtDebugMsg, "SetSectionBG-> Check for user images");
        #endif

        noimage=true;
        if(section.background != 0 )
        {
            //Find user image
            if(uBGs.contains(section.background))
            {
                noimage=false;
                obj_BG &bgx = uBGs[section.background];
                bgConfig=&bgx;
                img =&bgx.image;
                img2=&bgx.second_image;
            } else //If not exist, will be used default
            if(pConfigs->main_bg.contains(section.background))
            {
                noimage=false;
                obj_BG &bgx = pConfigs->main_bg[section.background];
                bgConfig=&bgx;
                img =&bgx.image;
                img2=&bgx.second_image;
            }
            if(noimage)
            {
                #ifdef _DEBUG_
                WriteToLog(QtWarningMsg, "SetSectionBG-> Image not found");
                #endif
                img=&image;
                img2=&nullimage;
                wrong=true;
            }
        }
        else noimage=true;

        brush = QBrush(QColor(0, 0, 0));
        pen = QPen(Qt::NoPen);

        if((!noimage)&&(!img->isNull()))
        {
            DrawBG(x, y, w, h, section.id, *img, *img2, *bgConfig, forceTiled);
        }
        else
        {
            if(wrong)
                brush.setTexture(image);
            itemRect = new QGraphicsRectItem;
            itemRect->setPen(pen);
            itemRect->setBrush(brush);
            itemRect->setRect(x, y, labs(x-w), labs(y-h));
            addItem(itemRect);
        }

        #ifdef _DEBUG_
        WriteToLog(QtDebugMsg, QString("SetSectionBG-> Item placed to x=%1 y=%2 h=%3 w=%4").arg(x).arg(y)
                   .arg((long)fabs(x-w)).arg((long)fabs(y-h)));
        #endif
        //

        if(itemRect!=NULL)
        {
            itemRect->setData(ITEM_TYPE, QString("BackGround%1").arg(section.id) );
            itemRect->setZValue(Z_backImage);
        }

    } //Don't draw on reserved section entry

}
Exemplo n.º 15
0
// ////////////////////////Apply section background/////////////////////////////
void LvlScene::setSectionBG(LevelSection section, bool forceTiled)
{
    //QGraphicsPixmapItem * item=NULL;
    QGraphicsRectItem * itemRect=NULL;
    QBrush brush;
    QPen pen;
    QPixmap image = Themes::Image(Themes::dummy_bg);
    QPixmap img;
    QPixmap img2; //Second image buffer
    //need a BGitem

    bool isUser1=false, isUser2=false, noimage=false, wrong=false;
    long x,y,h,w, j;

    if(
        (section.size_left!=0) ||
        (section.size_top!=0)||
        (section.size_bottom!=0)||
        (section.size_right!=0)
      )
    { //Don't draw on unallocated section entry
        x=section.size_left;
        y=section.size_top;
        w=section.size_right;
        h=section.size_bottom;

        #ifdef _DEBUG_
        WriteToLog(QtDebugMsg, "SetSectionBG-> Check for user images");
        #endif

        isUser1=false; // user's images are exist
        isUser2=false; // user's images are exist
        noimage=true;
        j = 0;
        if(section.background != 0 )
        {
            //Find user image
            for(j=0;j<uBGs.size();j++)
            {
                if(uBGs[j].id==section.background)
                {
                    noimage=false;
                    if((uBGs[j].q==0)||(uBGs[j].q==2)) //set first image
                        {img = uBGs[j].image; isUser1=true;}
                    if((uBGs[j].q>=1)){ // set Second image
                        img2 = uBGs[j].second_image; isUser2=true;}
                    break;
                }
            } //If not exist, will be used default

            j=pConfigs->getBgI(section.background);
            if(j>=0)
            {
                noimage=false;
                  if(!isUser1)
                      img = pConfigs->main_bg[j].image;
                  if(!isUser2)
                      img2 = pConfigs->main_bg[j].second_image;
            }

            if((noimage)&&(!isUser1))
            {
                #ifdef _DEBUG_
                WriteToLog(QtWarningMsg, "SetSectionBG-> Image not found");
                #endif
                img=image;
                wrong=true;
            }
        }
        else noimage=true;

        //pConfigs->main_bg[j].type;

        brush = QBrush(QColor(0, 0, 0));
        //QBrush brush(QColor(255, 255, 255));
        pen = QPen(Qt::NoPen);
        //for (int i = 0; i < 11; i++) {

        //item = addRect(QRectF(x, y, , ), pen, brush);

        if((!noimage)&&(!img.isNull()))
        {
            //item = addPixmap(image);
            //item = new QGraphicsPixmapItem;
            DrawBG(x, y, w, h, section.id, img, img2, pConfigs->main_bg[j], forceTiled);
            //BgItem[section.id]->setParentItem(item);
            //addItem(item);
            //item->setData(ITEM_TYPE, "BackGround"+QString::number(section.id) );
            //item->setPos(x, y);
        }
        else
        {
            if(wrong)
                brush.setTexture(image);
            itemRect = new QGraphicsRectItem;
            itemRect->setPen(pen);
            itemRect->setBrush(brush);
            itemRect->setRect(x, y, (long)fabs(x-w), (long)fabs(y-h));
            addItem(itemRect);
        }

        #ifdef _DEBUG_
        WriteToLog(QtDebugMsg, QString("SetSectionBG-> Item placed to x=%1 y=%2 h=%3 w=%4").arg(x).arg(y)
                   .arg((long)fabs(x-w)).arg((long)fabs(y-h)));
        #endif
        //

        if(itemRect!=NULL)
        {
            itemRect->setData(ITEM_TYPE, QString("BackGround%1").arg(section.id) );
            itemRect->setZValue(Z_backImage);
        }

    } //Don't draw on reserved section entry

}