Ejemplo n.º 1
0
// 绘制棋盘
void Board::paintEvent(QPaintEvent *)
{
    DrawBackground(); // 绘制背景颜色

    int r = height() / 20;
    _r = r;
    _off = QPoint(r + 1, r + 1);

    QPainter p(this);
    p.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing);

    p.save();
    drawPlate(p);
    p.restore();

    p.save();
    drawPlace(p);
    p.restore();

    p.save();
    drawInitPosition(p);
    p.restore();

    p.save();
    drawStone(p);
    p.restore();
}
Ejemplo n.º 2
0
void MainWindow::createActions()
{
    QPixmap saveImagePix("starblue.png");
    QPixmap saveCoordsPix("Save.png");
    QPixmap saveCoordsAsPix("SaveAs.png");
    QPixmap openCoordsPix("Open.png");
    QPixmap drawPlate("DrawPlate.png");

    drawPlateAct=new QAction(tr("&draw Plate"), this);
    connect(drawPlateAct, SIGNAL(triggered()), this, SLOT(assgnCnvsPrpsPlate()));
    connect(drawPlateAct, SIGNAL(triggered()), canvas, SLOT(drawPlateBtn_clicked()));
    connect(drawPlateAct, SIGNAL(triggered()), this, SLOT(updateStatusBar()));
    speckleAct=new QAction(tr("&Speckle"), this);
    connect(speckleAct, SIGNAL(triggered()), this, SLOT(assgnCnvsPrpsSpeckle()));
    connect(speckleAct, SIGNAL(triggered()), canvas, SLOT(speckPlateBtn_clicked()));
    connect(speckleAct, SIGNAL(triggered()), this, SLOT(updateStatusBar()));
    drawRBTAct = new QAction(tr("&Draw RBT"), this);
    connect(drawRBTAct, SIGNAL(triggered()), this, SLOT(assgnCnvsPrpsRBT()));
    connect(drawRBTAct, SIGNAL(triggered()), canvas, SLOT(drawRBT_clicked()));
    connect(drawPlateAct, SIGNAL(triggered()), this, SLOT(updateStatusBar()));
    drawUEAct=new QAction(tr("&Draw UE"), this);
    connect(drawUEAct, SIGNAL(triggered()), this, SLOT(assgnCnvsPrpsUE()));
    connect(drawUEAct, SIGNAL(triggered()), canvas, SLOT(drawUE_clicked()));
    connect(drawPlateAct, SIGNAL(triggered()), this, SLOT(updateStatusBar()));

    readSpeckCoordsAct = new QAction(tr("&Read Speckles"), this);
    connect(readSpeckCoordsAct, SIGNAL(triggered()), canvas, SLOT(readSpeckCoords_clicked()));
    connect(readSpeckCoordsAct, SIGNAL(triggered()), this, SLOT(updateStatusBar()));

    openAct = new QAction(tr("&Open..."), this);
    openAct->setShortcuts(QKeySequence::Open);
    connect(openAct, SIGNAL(triggered()), this, SLOT(open()));

    foreach (QByteArray format, QImageWriter::supportedImageFormats()) {
        QString text = tr("%1...").arg(QString(format).toUpper());

        QAction *action = new QAction(text, this);
        action->setData(format);
        connect(action, SIGNAL(triggered()), this, SLOT(save()));
        saveAsActs.append(action);
    }