Ejemplo n.º 1
0
MainWindow::MainWindow() : QMainWindow()
{
    // Create network view
    nView = new NetworkView();
    QGraphicsScene *scene = new QGraphicsScene();
    scene->setBackgroundBrush(QBrush(QColor(192, 192, 192)));
    nView->setScene(scene);
    setCentralWidget(nView);

    // Create tree view
    tView = new QTreeView(this);
    QDockWidget *treeDockWidget = new QDockWidget(tr("Tree"), this);
    treeDockWidget->setWidget(tView);
    addDockWidget(Qt::LeftDockWidgetArea, treeDockWidget);

    // Create controls view
    controls = new Controls();
    controlWidget = new QDockWidget(tr("Controls"), this);
    controlWidget->setWidget(controls);
    addDockWidget(Qt::LeftDockWidgetArea, controlWidget);
    controlWidget->hide();

    // Create properties view
    pView = new PropsView(this);
    propsWidget = new QDockWidget(tr("Properties"), this);
    propsWidget->setWidget(pView);
    addDockWidget(Qt::RightDockWidgetArea, propsWidget);
    propsWidget->hide();

    // Create edit view
    eView = new EditView(this);
    editWidget = new QDockWidget(tr("Edit Properties"), this);
    editWidget->setWidget(eView);
    addDockWidget(Qt::RightDockWidgetArea, editWidget);
    editWidget->hide();

    // Create menu
    fileMenu = menuBar()->addMenu(tr("&File"));
    fileMenu->addAction(tr("&Open..."), this, SLOT(openFile()), QKeySequence::Open);
    fileMenu->addAction(tr("Save &As..."), this, SLOT(saveAsFile()), QKeySequence::Save/*As*/);
    fileMenu->addSeparator();
    fileMenu->addAction(tr("Open in SUMO-GUI"), this, SLOT(openSUMO()));
    fileMenu->addAction(tr("Locate SUMO-GUI..."), this, SLOT(locateSUMO()));
    fileMenu->addSeparator();
    fileMenu->addAction(tr("E&xit"), this, SLOT(close()), QKeySequence::Quit);

    viewMenu = menuBar()->addMenu(tr("&View"));
    viewMenu->addAction(treeDockWidget->toggleViewAction());
    viewMenu->addAction(controlWidget->toggleViewAction());
    viewMenu->addAction(propsWidget->toggleViewAction());
    viewMenu->addAction(editWidget->toggleViewAction());

    specialEditorsMenu = menuBar()->addMenu(tr("&Special Editors"));
    nmlJuncIcon = QPixmap(":/icons/nmlJunc1616.png");
    tlLogicIcon = QPixmap(":/icons/tllogic1616.png");
    specialEditorsMenu->addAction(nmlJuncIcon, tr("&Junction Editor"), this, SLOT(openJunctionEditor()));
    specialEditorsMenu->addAction(tlLogicIcon, tr("&tlLogic Editor"), this, SLOT(openTLEditor()));

    // Read settings from the nefs.ini file
    QSettings settings(QCoreApplication::applicationDirPath() + "/nefs.ini", QSettings::IniFormat);
    xmlPath = settings.value("paths/work").toString();
    sumoguiPath = settings.value("paths/sumo").toString();

    // Status bar
    statusBar()->showMessage(tr("Ready"));

    // Title and icon
    setWindowTitle(tr("Network Editor for SUMO"));
    setWindowIcon(QIcon(QPixmap(":/icons/NE4S128.png")));

    modelLoaded = false;
}
ribi::QtFunctionPlotterMainDialog::QtFunctionPlotterMainDialog(QWidget *parent)
  : QtHideAndShowDialog(parent),
    ui(new Ui::QtFunctionPlotterMainDialog),
    m_curve(new QwtPlotCurve),
    m_plot(new QwtPlot)
{
  #ifndef NDEBUG
  Test();
  #endif
  ui->setupUi(this);

  //Create plot
  {
    assert(!ui->plot_contents->layout());
    QGridLayout * const layout = new QGridLayout;
    ui->plot_contents->setLayout(layout);

    layout->addWidget(m_plot);

    #ifdef _WIN32
    m_plot->setCanvasBackground(QBrush(QColor(255,255,255)));
    #else
    m_plot->setCanvasBackground(QColor(255,255,255));
    #endif

    m_curve->attach(m_plot);
    m_curve->setStyle(QwtPlotCurve::Lines);
    m_curve->setPen(QPen(QColor(128,128,128)));
  }

  QObject::connect(
    this->ui->edit_equation,
    &QLineEdit::textChanged,
    this,
    &ribi::QtFunctionPlotterMainDialog::OnAnyChange
  );
  QObject::connect(
    this->ui->box_minx,
    SIGNAL(valueChanged(QString)),
    this,
    SLOT(OnAnyChange())
  );
  QObject::connect(
    this->ui->box_maxx,
    SIGNAL(valueChanged(QString)),
    this,
    SLOT(OnAnyChange())
  );


  ui->box_minx->setValue(-1.0);
  ui->box_maxx->setValue(1.0);

  ui->edit_equation->setText("cos(x)");


  {
    //Put the dialog in the screen center at 50% x 50% of its size
    const QRect screen = QApplication::desktop()->screenGeometry();
    this->setGeometry(0,0,screen.width() / 2,screen.height() /2 );
    this->move( screen.center() - this->rect().center() );
  }
}
Ejemplo n.º 3
0
MainWidget::MainWidget(QWidget *parent)
    : DropShadowWidget(parent)
{
	initLocalConnection();
    setMinimumSize(900, 600);
	setWindowIcon(QIcon(":/img/safe"));

	statked_widget = new QStackedWidget();
    title_widget = new TitleWidget();
    content_widget = new ContentWidget();
	kill_mummy_widget = new KillMummyWidget();
	main_menu = new MainMenu();
	character_widget = new CharacterWidget();
	about_us_dialog = new AboutUsDialog(this);
	setting_dialog = new SettingDialog(this);
	login_dialog = new LoginDialog(this);
	register_widget = new RegisterWidget(this); 
	skin_widget = new SkinWidget(this);
	system_tray = new SystemTray(this);

	QPalette palette;
	palette.setBrush(QPalette::Window, QBrush(Qt::white));
    statked_widget->setPalette(palette);
    statked_widget->setAutoFillBackground(true);

	statked_widget->addWidget(content_widget);
	statked_widget->addWidget(kill_mummy_widget);

	QVBoxLayout *center_layout = new QVBoxLayout();
	center_layout->addWidget(statked_widget);
	center_layout->setSpacing(0);
	center_layout->setContentsMargins(0, 0, 0, 0);

    QVBoxLayout *main_layout = new QVBoxLayout();
    main_layout->addWidget(title_widget);
    main_layout->addLayout(center_layout);
	main_layout->setSpacing(0);
	main_layout->setContentsMargins(SHADOW_WIDTH, SHADOW_WIDTH, SHADOW_WIDTH, SHADOW_WIDTH);

    setLayout(main_layout);

	connect(title_widget, SIGNAL(showSkin()), this, SLOT(showSkinWidget()));
	connect(title_widget, SIGNAL(showMainMenu()), this, SLOT(showMainMenu()));
	connect(title_widget, SIGNAL(showMin()), this, SLOT(showMinimized()));
	connect(title_widget, SIGNAL(closeWidget()), this, SLOT(hide()));
	connect(title_widget, SIGNAL(turnPage(int)), this, SLOT(turnPage(int)));

	connect(main_menu, SIGNAL(showSettingDialog()), this, SLOT(showSettingDialog()));
	connect(main_menu, SIGNAL(showNewCharacter()), this, SLOT(showNewCharacter()));
	connect(main_menu, SIGNAL(showAboutUs()), this, SLOT(showAboutUs()));

	connect(content_widget, SIGNAL(showLoginDialog()), this, SLOT(showLoginDialog()));
	connect(content_widget, SIGNAL(showRegisterDialog()), this, SLOT(showRegisterDialog()));

	connect(setting_dialog, SIGNAL(changeLanguage(LANGUAGE)), this, SLOT(changeLanguage(LANGUAGE)));

	connect(skin_widget, SIGNAL(changeSkin(QString)), this, SLOT(changeSkin(QString)));

	connect(system_tray, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(iconIsActived(QSystemTrayIcon::ActivationReason)));
	connect(system_tray, SIGNAL(showWidget()), this, SLOT(showWidget()));
	
	system_tray->show();

	title_widget->turnPage("0");

	skin_name = Util::getSkinName();
	if( QString::compare(skin_name, QString("")) == 0)
	{
		this->changeSkin(DEFAULT_SKIN);
	}
}
Ejemplo n.º 4
0
void SkyQPainter::drawDeepSkySymbol(const QPointF &pos, int type, float size, float e, float positionAngle)
{
    float x = pos.x();
    float y = pos.y();
    float zoom = Options::zoomFactor();

    int isize = int(size);

    float dx1 = -0.5*size;
    float dx2 =  0.5*size;
    float dy1 = -1.0*e*size/2.;
    float dy2 = e*size/2.;
    float x1 = x + dx1;
    float x2 = x + dx2;
    float y1 = y + dy1;
    float y2 = y + dy2;

    float dxa = -size/4.;
    float dxb =  size/4.;
    float dya = -1.0*e*size/4.;
    float dyb = e*size/4.;
    float xa = x + dxa;
    float xb = x + dxb;
    float ya = y + dya;
    float yb = y + dyb;

    QString color;

    float psize;

    QBrush tempBrush;

    std::function<void( float, float, float, float )> lambdaDrawEllipse;
    std::function<void( float, float, float, float )> lambdaDrawLine;
    std::function<void( float, float, float, float )> lambdaDrawCross;

    if ( Options::useAntialias() ) {
        lambdaDrawEllipse = [this]( float x, float y, float width, float height ) {
            drawEllipse( QRectF( x, y, width, height ) );
        };
        lambdaDrawLine = [this]( float x1, float y1, float x2, float y2 ) {
            drawLine( QLineF( x1, y1, x2, y2 ) );
        };
        lambdaDrawCross = [this]( float centerX, float centerY, float sizeX, float sizeY ) {
            drawLine( QLineF( centerX - sizeX/2., centerY, centerX + sizeX/2., centerY ) );
            drawLine( QLineF( centerX, centerY - sizeY/2., centerX, centerY + sizeY/2. ) );
        };
    }
    else {
        lambdaDrawEllipse = [this]( float x, float y, float width, float height ) {
            drawEllipse( QRect( x, y, width, height ) );
        };
        lambdaDrawLine = [this]( float x1, float y1, float x2, float y2 ) {
            drawLine( QLine( x1, y1, x2, y2 ) );
        };
        lambdaDrawCross = [this]( float centerX, float centerY, float sizeX, float sizeY ) {
            drawLine( QLine( centerX - sizeX/2., centerY, centerX + sizeX/2., centerY ) );
            drawLine( QLine( centerX, centerY - sizeY/2., centerX, centerY + sizeY/2. ) );
        };
    }

    switch ( type ) {
    case 0:
    case 1: //catalog star
        //Some NGC/IC objects are stars...changed their type to 1 (was double star)
        if (size<2.) size = 2.;
        lambdaDrawEllipse( x1, y1, size/2., size/2. );
        break;
    case 2: //Planet
        break;
    case 3: //Open cluster; draw circle of points
    case 13: { // Asterism
        tempBrush = brush();
        color = pen().color().name();
        setBrush( pen().color() );
        psize = 2.;
        if ( size > 50. )  psize *= 2.;
        if ( size > 100. ) psize *= 2.;
        auto putDot = [this, psize, &lambdaDrawEllipse]( float x, float y ) {
            lambdaDrawEllipse( x, y, psize, psize );
        };
        putDot( xa, y1 );
        putDot( xb, y1 );
        putDot( xa, y2 );
        putDot( xb, y2 );
        putDot( x1, ya );
        putDot( x1, yb );
        putDot( x2, ya );
        putDot( x2, yb );
        setBrush( tempBrush );
        break;
    }
    case 4: //Globular Cluster
        if (size<2.) size = 2.;
        save();
        translate( x, y );
        color = pen().color().name();
        rotate( positionAngle );  //rotate the coordinate system
        lambdaDrawEllipse( dx1, dy1, size, e*size );
        lambdaDrawCross( 0, 0, size, e*size );
        restore(); //reset coordinate system
        break;

    case 5: //Gaseous Nebula
    case 15: // Dark Nebula
        if (size <2.) size = 2.;
        save();
        translate( x, y );
        rotate( positionAngle );  //rotate the coordinate system
        color = pen().color().name();
        lambdaDrawLine( dx1, dy1, dx2, dy1 );
        lambdaDrawLine( dx2, dy1, dx2, dy2 );
        lambdaDrawLine( dx2, dy2, dx1, dy2 );
        lambdaDrawLine( dx1, dy2, dx1, dy1 );
        restore(); //reset coordinate system
        break;
    case 6: //Planetary Nebula
        if (size<2.) size = 2.;
        save();
        translate( x, y );
        rotate( positionAngle );  //rotate the coordinate system
        color = pen().color().name();
        lambdaDrawEllipse( dx1, dy1, size, e*size );
        lambdaDrawLine( 0., dy1, 0., dy1 - e*size/2. );
        lambdaDrawLine( 0., dy2, 0., dy2 + e*size/2. );
        lambdaDrawLine( dx1, 0., dx1 - size/2., 0. );
        lambdaDrawLine( dx2, 0., dx2 + size/2., 0. );
        restore(); //reset coordinate system
        break;
    case 7: //Supernova remnant // FIXME: Why is SNR drawn different from a gaseous nebula?
        if (size<2) size = 2;
        save();
        translate( x, y );
        rotate( positionAngle );  //rotate the coordinate system
        color = pen().color().name();
        lambdaDrawLine( 0., dy1, dx2, 0. );
        lambdaDrawLine( dx2, 0., 0., dy2 );
        lambdaDrawLine( 0., dy2, dx1, 0. );
        lambdaDrawLine( dx1, 0., 0., dy1 );
        restore(); //reset coordinate system
        break;
    case 8: //Galaxy
    case 16: // Quasar
        color = pen().color().name();
        if ( size <1. && zoom > 20*MINZOOM ) size = 3.; //force ellipse above zoomFactor 20
        if ( size <1. && zoom > 5*MINZOOM ) size = 1.; //force points above zoomFactor 5
        if ( size>2. ) {
            save();
            translate( x, y );
            rotate( positionAngle );  //rotate the coordinate system
            lambdaDrawEllipse( dx1, dy1, size, e*size );
            restore(); //reset coordinate system

        } else if ( size>0. ) {
            drawPoint( QPointF(x, y) );
        }
        break;
    case 14: { // Galaxy cluster - draw a dashed circle
        tempBrush = brush();
        setBrush( QBrush() );
        psize = 1.;
        if ( size > 50. )  psize *= 2.;
        color = pen().color().name();
        save();
        translate( x, y );
        rotate( positionAngle );  //rotate the coordinate system
        QPen newPen = pen();
        newPen.setStyle( Qt::DashLine );
        setPen( newPen );
        lambdaDrawEllipse( dx1, dy1, size, e*size );
        restore();
        setBrush( tempBrush );
        break;
    }
    default: // Unknown object or something we don't know how to draw. Just draw an ellipse with a ?-mark
        color = pen().color().name();
        if ( size <1. && zoom > 20*MINZOOM ) size = 3.; //force ellipse above zoomFactor 20
        if ( size <1. && zoom > 5*MINZOOM ) size = 1.; //force points above zoomFactor 5
        if ( size>2. ) {
            save();
            QFont f = font();
            const QString qMark = " ? ";
            double scaleFactor = 0.8 * size / fontMetrics().width( qMark );
            f.setPointSizeF( f.pointSizeF() * scaleFactor );
            setFont( f );
            translate( x, y );
            rotate( positionAngle );  //rotate the coordinate system
            lambdaDrawEllipse( dx1, dy1, size, e*size );
            if ( Options::useAntialias() )
                drawText( QRectF(dx1, dy1, size, e*size), Qt::AlignCenter, qMark );
            else {
                int idx1 = int(dx1); int idy1 = int(dy1);
                drawText( QRect(idx1, idy1, isize, int(e*size)), Qt::AlignCenter, qMark );
            }
            restore(); //reset coordinate system (and font?)
        }
        else if ( size>0. ) {
            if ( Options::useAntialias() )
                drawPoint( QPointF(x, y) );
            else
                drawPoint( QPoint( x, y ) );
        }
    }

}
Ejemplo n.º 5
0
void DiasporaClusterGraphicsItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
    QColor borderColor = QColor(192,192,192);
    QColor starColor = QColor (255,255,192);
    QColor techColor = QColor (255,255,0);
    QColor textColor = QColor(0,0,0);
    QColor borderSelectedColor = QColor(255,0,0);

    QBrush starBrush = QBrush(starColor,Qt::SolidPattern);
    QBrush techBrush = QBrush(techColor,Qt::SolidPattern);
    QBrush textBrush = QBrush(textColor, Qt::SolidPattern);

    QPen borderPen;

    if (!this->isSelected()) {
        borderPen= QPen(borderColor);
        borderPen.setWidthF(2.0);
    } else {
        borderPen= QPen(borderSelectedColor);
        borderPen.setWidthF(2.0);

    }

    QPen textPen = QPen(textColor);

    painter->setPen(borderPen);
    painter->setBrush(_clusterItem.technology() >= 2 ? techBrush : starBrush);

    QRectF boundingRect = this->boundingRect();

    painter->drawEllipse(boundingRect);

    QFont fontMain = Preferences::prefs().fontAspectTitle();
    QFont fontStat = Preferences::prefs().fontBody();

    QFontMetricsF fmMain = QFontMetrics(fontMain);
    QFontMetricsF fmStat = QFontMetrics(fontStat);

    float hMain = fmMain.height() * 1.1;
    float wMain = fmMain.width(_initials);

    QString t1 = QString("Env: %1")
                 .arg(_clusterItem.environment());
    QString t2 = QString("Tech: %1").arg(_clusterItem.technology());
    QString t3 = QString("Res: %1").arg(_clusterItem.resources());


    float hStat = fmStat.height() * 1.1;
    float w1 = fmStat.width(t1);
    float w2 = fmStat.width(t2);
    float w3 = fmStat.width(t3);

    float wRect = boundingRect.width();

    wMain = (wRect- wMain)/2;
    w1 = (wRect- w1)/2;
    w2 = (wRect- w2)/2;
    w3 = (wRect- w3)/2;


    QPoint p1 = QPoint (_corner.x()+wMain, boundingRect.top()+hMain);
    QPoint p2 = QPoint (_corner.x()+w1, _corner.y()+hMain+hStat);
    QPoint p3 = QPoint (_corner.x()+w2, _corner.y()+hMain+2*hStat);
    QPoint p4 = QPoint (_corner.x()+w3, _corner.y()+hStat*3+hMain);

    painter->setFont(fontMain);
    painter->setBrush(textBrush);
    painter->setPen(textPen);
    painter->drawText(p1,_initials );
    painter->setFont(fontStat);
    painter->drawText(p2,t1 );
    painter->drawText(p3,t2 );
    painter->drawText(p4,t3 );

    //painter->setPen(borderPen);
    //painter->drawPoint(QPointF(_x,_y));

}
Ejemplo n.º 6
0
QVariant RoomsListModel::data(const QModelIndex &index, int role) const
{
    int column = index.column();
    int row = index.row();

    // invalid index
    if (!index.isValid())
        return QVariant();

    // invalid row
    if ((row < 0) || (row >= m_data.size()))
        return QVariant();

    // invalid column
    if ((column < 0) || (column >= c_nColumns))
        return QVariant();

    // not a role we have data for
    if (role != Qt::DisplayRole)
        // only custom-align counters
        if ((role != Qt::TextAlignmentRole)
            || ((column != PlayerCountColumn) && (column != TeamCountColumn)))
                // only decorate name column
                if ((role != Qt::DecorationRole) || (column != NameColumn))
                    // only dye map column
                    if ((role != Qt::ForegroundRole) || (column != MapColumn))
                        return QVariant();

    // decorate room name based on room state
    if (role == Qt::DecorationRole)
    {
        const QIcon roomBusyIcon(":/res/iconDamage.png");
        const QIcon roomWaitingIcon(":/res/iconTime.png");

        if (m_data.at(row).at(0).isEmpty())
            return QVariant(roomWaitingIcon);
        else
            return QVariant(roomBusyIcon);
    }

    QString content = m_data.at(row).at(column);

    if (role == Qt::DisplayRole)
    {
        // supply in progress flag as bool
        if (column == 0)
            return QVariant(QString(!content.isEmpty()));

        // display room names
        if (column == 5)
        {
            // special names
            if (content[0] == '+')
            {
                if (content == "+rnd+") return tr("Random Map");
                if (content == "+maze+") return tr("Random Maze");
                if (content == "+perlin+") return tr("Random Perlin");
                if (content == "+drawn+") return tr("Hand-drawn");
            }

            // prefix ? if map not available
            if (!m_staticMapModel->mapExists(content) &&
                !m_missionMapModel->mapExists(content))
                return QString ("? %1").arg(content);
        }

        return content;
    }

    // dye map names red if map not available
    if (role == Qt::ForegroundRole)
    {
        if (content == "+rnd+" ||
            content == "+maze+" ||
            content == "+perlin+" ||
            content == "+drawn+" ||
            m_staticMapModel->mapExists(content) ||
            m_missionMapModel->mapExists(content))
            return QVariant();
        else
            return QBrush(QColor("darkred"));
    }

    if (role == Qt::TextAlignmentRole)
    {
        return (int)(Qt::AlignHCenter | Qt::AlignVCenter);
    }

    Q_ASSERT(false);
    return QVariant();
}
Ejemplo n.º 7
0
void QgsPaperGrid::paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget )
{
    Q_UNUSED( itemStyle );
    Q_UNUSED( pWidget );

    //draw grid
    if ( mComposition )
    {
        if ( mComposition->gridVisible() && mComposition->plotStyle() ==  QgsComposition::Preview
                && mComposition->snapGridResolution() > 0 )
        {
            int gridMultiplyX = static_cast< int >( mComposition->snapGridOffsetX() / mComposition->snapGridResolution() );
            int gridMultiplyY = static_cast< int >( mComposition->snapGridOffsetY() / mComposition->snapGridResolution() );
            double currentXCoord = mComposition->snapGridOffsetX() - gridMultiplyX * mComposition->snapGridResolution();
            double currentYCoord;
            double minYCoord = mComposition->snapGridOffsetY() - gridMultiplyY * mComposition->snapGridResolution();

            painter->save();
            //turn of antialiasing so grid is nice and sharp
            painter->setRenderHint( QPainter::Antialiasing, false );

            if ( mComposition->gridStyle() == QgsComposition::Solid )
            {
                painter->setPen( mComposition->gridPen() );

                //draw vertical lines
                for ( ; currentXCoord <= rect().width(); currentXCoord += mComposition->snapGridResolution() )
                {
                    painter->drawLine( QPointF( currentXCoord, 0 ), QPointF( currentXCoord, rect().height() ) );
                }

                //draw horizontal lines
                currentYCoord = minYCoord;
                for ( ; currentYCoord <= rect().height(); currentYCoord += mComposition->snapGridResolution() )
                {
                    painter->drawLine( QPointF( 0, currentYCoord ), QPointF( rect().width(), currentYCoord ) );
                }
            }
            else //'Dots' or 'Crosses'
            {
                QPen gridPen = mComposition->gridPen();
                painter->setPen( gridPen );
                painter->setBrush( QBrush( gridPen.color() ) );
                double halfCrossLength = 1;
                if ( mComposition->gridStyle() == QgsComposition::Dots )
                {
                    //dots are actually drawn as tiny crosses a few pixels across
                    //check QGraphicsView to get current transform
                    if ( scene() )
                    {
                        QList<QGraphicsView*> viewList = scene()->views();
                        if ( !viewList.isEmpty() )
                        {
                            QGraphicsView* currentView = viewList.at( 0 );
                            if ( currentView->isVisible() )
                            {
                                //set halfCrossLength to equivalent of 1 pixel
                                halfCrossLength = 1 / currentView->transform().m11();
                            }
                        }
                    }
                }
                else if ( mComposition->gridStyle() == QgsComposition::Crosses )
                {
                    halfCrossLength = mComposition->snapGridResolution() / 6;
                }

                for ( ; currentXCoord <= rect().width(); currentXCoord += mComposition->snapGridResolution() )
                {
                    currentYCoord = minYCoord;
                    for ( ; currentYCoord <= rect().height(); currentYCoord += mComposition->snapGridResolution() )
                    {
                        painter->drawLine( QPointF( currentXCoord - halfCrossLength, currentYCoord ), QPointF( currentXCoord + halfCrossLength, currentYCoord ) );
                        painter->drawLine( QPointF( currentXCoord, currentYCoord - halfCrossLength ), QPointF( currentXCoord, currentYCoord + halfCrossLength ) );
                    }
                }
            }
            painter->restore();
        }
    }
}
Ejemplo n.º 8
0
void AudioEchoWidget::paintEvent(QPaintEvent *) {
	QPainter paint(this);

	paint.scale(width(), height());
	paint.fillRect(rect(), Qt::black);

	AudioInputPtr ai = g.ai;
	if (! ai || ! ai->sesEcho)
		return;

	ai->qmSpeex.lock();

	spx_int32_t sz;
	speex_echo_ctl(ai->sesEcho, SPEEX_ECHO_GET_IMPULSE_RESPONSE_SIZE, &sz);

	STACKVAR(spx_int32_t, w, sz);
	STACKVAR(float, W, sz);

	speex_echo_ctl(ai->sesEcho, SPEEX_ECHO_GET_IMPULSE_RESPONSE, w);

	ai->qmSpeex.unlock();

	int N = 160;
	int n = 2 * N;
	int M = sz / n;

	drft_lookup d;
	mumble_drft_init(&d, n);

	for (int j=0;j<M;j++) {
		for (int i=0;i<n;i++)
			W[j*n+i] = static_cast<float>(w[j*n+i]) / static_cast<float>(n);
		mumble_drft_forward(&d, & W[j*n]);
	}

	mumble_drft_clear(&d);

	float xscale = 1.0f / static_cast<float>(N);
	float yscale = 1.0f / static_cast<float>(M);

	for (int j = 0; j < M; j++) {
		for (int i=1;i < N; i++) {
			float xa = static_cast<float>(i) * xscale;
			float ya = static_cast<float>(j) * yscale;

			float xb = xa + xscale;
			float yb = ya + yscale;

			const QColor &c = mapEchoToColor(sqrtf(W[j*n+2*i]*W[j*n+2*i]+W[j*n+2*i-1]*W[j*n+2*i-1]) / 65536.f);
			paint.fillRect(QRectF(QPointF(xa, ya), QPointF(xb, yb)), c);
		}
	}

	QPolygonF poly;
	xscale = 1.0f / (2.0f * static_cast<float>(n));
	yscale = 1.0f / (200.0f * 32767.0f);
	for (int i = 0; i < 2 * n; i++) {
		poly << QPointF(static_cast<float>(i) * xscale, 0.5f + static_cast<float>(w[i]) * yscale);
	}
	
	paint.setPen(QPen(QBrush(QColor::fromRgbF(1.0f, 0.0f, 1.0f)), 0));
	paint.drawPolyline(poly);
}
Ejemplo n.º 9
0
void AudioBar::paintEvent(QPaintEvent *) {
	QPainter p(this);

	if (isEnabled()) {
		qcBelow.setAlphaF(1.0f);
		qcAbove.setAlphaF(1.0f);
		qcInside.setAlphaF(1.0f);
	} else {
		qcBelow.setAlphaF(0.5f);
		qcAbove.setAlphaF(0.5f);
		qcInside.setAlphaF(0.5f);
	}

	if (iBelow > iAbove)
		iBelow = iAbove;

	if (iValue < iMin)
		iValue = iMin;
	else if (iValue > iMax)
		iValue = iMax;

	float scale = static_cast<float>(width()) / static_cast<float>(iMax - iMin);
	int h = height();

	int val = iroundf(static_cast<float>(iValue) * scale + 0.5f);
	int below = iroundf(static_cast<float>(iBelow) * scale + 0.5f);
	int above = iroundf(static_cast<float>(iAbove) * scale  + 0.5f);
	int max = iroundf(static_cast<float>(iMax) * scale + 0.5f);
	int min = iroundf(static_cast<float>(iMin) * scale + 0.5f);
	int peak = iroundf(static_cast<float>(iPeak) * scale + 0.5f);

	if (g.s.bHighContrast) {
		// Draw monochrome representation
		QColor fg = QPalette().foreground().color();

		p.fillRect(0, 0, below, h, QBrush(fg, qlReplacementBrushes.value(qlReplacableColors.indexOf(qcBelow), Qt::CrossPattern)));
		p.fillRect(below, 0, above - below, h, QBrush(fg, qlReplacementBrushes.value(qlReplacableColors.indexOf(qcInside), Qt::NoBrush)));
		p.fillRect(above, 0, max - above, h, QBrush(fg, qlReplacementBrushes.value(qlReplacableColors.indexOf(qcAbove), Qt::CrossPattern)));
		p.fillRect(0, 0, val, h, QBrush(fg, Qt::SolidPattern));

		p.drawRect(0, 0, max - 1, h - 1);
		p.drawLine(below, 0, below, h);
		p.drawLine(above, 0, above, h);
	} else {
		if (val <= below) {
			p.fillRect(0, 0, val, h, qcBelow);
			p.fillRect(val, 0, below-val, h, qcBelow.darker(300));
			p.fillRect(below, 0, above-below, h, qcInside.darker(300));
			p.fillRect(above, 0, max-above, h, qcAbove.darker(300));
		} else if (val <= above) {
			p.fillRect(0, 0, below, h, qcBelow);
			p.fillRect(below, 0, val-below, h, qcInside);
			p.fillRect(val, 0, above-val, h, qcInside.darker(300));
			p.fillRect(above, 0, max-above, h, qcAbove.darker(300));
		} else {
			p.fillRect(0, 0, below, h, qcBelow);
			p.fillRect(below, 0, above-below, h, qcInside);
			p.fillRect(above, 0, val-above, h, qcAbove);
			p.fillRect(val, 0, max-val, h, qcAbove.darker(300));
		}

		if ((peak >= min) && (peak <= max))  {
			if (peak <= below)
				p.setPen(qcBelow.lighter(150));
			else if (peak <= above)
				p.setPen(qcInside.lighter(150));
			else
				p.setPen(qcAbove.lighter(150));
			p.drawLine(peak, 0, peak, h);
		}
	}

}
void DataPlot::addLineSeries(QList<QPointF*>* v,QString series_name, QColor color, bool progressive_show){
    if(!available_class_colors_for_line.contains(color)&&available_class_colors_for_line.size()>0)
        color = available_class_colors_for_line.at(0);

    available_class_colors_for_line.removeOne(color);

    if(!progressive_show){
        for(int i=1;i<v->length();i++)
            paintLineSeg(i,color,v);
    }
    else{
        incomplete_series.append(v);
        incomplete_series_colors.append(color);
        incomplete_series_isPointSeries.append(false);

        if(current_progressive_show_ind>=0)
            for(int i=1;i<=current_progressive_show_ind && i<v->size();i++)
                paintLineSeg(i,color,v);
    }


    QGraphicsTextItem *t_item = scene->addText(series_name);
    t_item->setPos(initial_width+40,(initial_height/2)-(40-class_labels_offset));
    scene->addLine(QLineF(QPointF(initial_width+33,(initial_height/2)-(28-class_labels_offset)),QPointF(initial_width+37,(initial_height/2)-(28-class_labels_offset))),QPen(QBrush(color),3.0));

    class_labels_offset+=15;
}
DataPlot::DataPlot(QString plot_name, qreal max_yy, qreal max_xx, QString yyLabel,  QWidget *parent):
    QWidget(parent)
{

    setMouseTracking(true);

    this->max_xx=max_xx;
    this->max_yy=max_yy;

    QHBoxLayout * layout = new QHBoxLayout();
    this->setLayout(layout);
    scene = new ClickableQGraphicsScene(this);
    scene->setMouseTracking(true);

    connect(scene,SIGNAL(mouseMoved(QPointF)),SLOT(mouseMovedInScene(QPointF)));

    view = new QGraphicsView(scene);
    layout->addWidget(view);

    QVBoxLayout * v_layout = new QVBoxLayout();

    layout->addLayout(v_layout);

    QPushButton* btn = new QPushButton("Export");
    btn->setMaximumSize(55,25);
    v_layout->addWidget(btn,0,Qt::AlignTop);
    connect(btn,SIGNAL(clicked()),SLOT(exportToImage()));

    btn = new QPushButton("Show all");
    btn->setMaximumSize(55,25);
    v_layout->addWidget(btn,0,Qt::AlignTop);
    connect(btn,SIGNAL(clicked()),SLOT(showAllInds()));

    btn = new QPushButton("Zoom in");
    btn->setMaximumSize(55,25);
    v_layout->addWidget(btn,0,Qt::AlignTop);
    connect(btn,SIGNAL(clicked()),SLOT(zoomIn()));

    btn = new QPushButton("Zoom out");
    btn->setMaximumSize(55,25);
    v_layout->addWidget(btn,0,Qt::AlignTop);
    connect(btn,SIGNAL(clicked()),SLOT(zoomOut()));

    currentCoordXLabel = new QLabel("x: 0");
    v_layout->addWidget(currentCoordXLabel,0,Qt::AlignTop);

    currentCoordYLabel = new QLabel("y: 0");
    v_layout->addWidget(currentCoordYLabel,0,Qt::AlignTop);

    v_layout->addSpacing(330);

    view->setRenderHint(QPainter::Antialiasing);
    view->setCacheMode(QGraphicsView::CacheBackground);
    view->setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);

    view->setCursor(Qt::CrossCursor);

    //Offsets para os labels dos eixos
    x_offset = y_offset = 20;

    //Tamanho real do plot
    plot_height = height()-y_offset;
    plot_width = width()-x_offset;

    //Inicializa a lista de cores disponíveis
    available_class_colors.append(Qt::red);
    available_class_colors.append(Qt::blue);
    available_class_colors.append(Qt::green);
    available_class_colors.append(Qt::yellow);
    available_class_colors.append(Qt::cyan);
    available_class_colors.append(Qt::magenta);
    available_class_colors.append(QColor(122,27,224));
    available_class_colors.append(Qt::lightGray);
    available_class_colors.append(Qt::darkBlue);
    available_class_colors.append(Qt::darkGray);
    available_class_colors.append(Qt::darkRed);
    available_class_colors.append(Qt::darkGreen);
    available_class_colors.append(Qt::darkMagenta);
    available_class_colors.append(Qt::darkCyan);
    available_class_colors.append(Qt::darkYellow);
    available_class_colors_for_line = available_class_colors;

    //Inicializa a lista de indices yy disponíveis para séries sem coordenada do y
    for(qreal i=0.05;i<=1.0;i+=0.05)
        availabel_yy_inds.append(i);

    QGraphicsTextItem * t_item;

    title_text_item = scene->addText(plot_name);
    title_text_item->setPos(width()/2,-10);

    if(yyLabel.length()>0){
        t_item = scene->addText(QString().number(max_yy));
        t_item->setPos(0,y_offset-10);
    }

    t_item = scene->addText(QString().number(max_xx));
    t_item->setPos(width()-x_offset+10,height()-y_offset);

    t_item = scene->addText("Seconds");
    t_item->setPos(width()/2,height()-y_offset);

    t_item = scene->addText(yyLabel);
    t_item->setPos(0,height()/2);
    t_item->setRotation(-90);

    t_item = scene->addText(QString().number(0));
    t_item->setPos(0,height()-y_offset);

    scene->addLine(x_offset,y_offset,x_offset,plot_height,QPen(QBrush(Qt::black),2));
    scene->addLine(x_offset,plot_height,width(),plot_height,QPen(QBrush(Qt::black),2));

    setWindowTitle(plot_name);

    class_labels_offset=0;

    current_progressive_show_ind=-1;

    initial_width = width();
    initial_height = height();

    this->yyLabel=yyLabel;
}
Ejemplo n.º 12
0
DebuggerUI::DebuggerUI(QWidget* parent, const char *name)
  : KTabWidget(parent, name)
{  
  setGeometry(0,0,0,height()/15);
  QWidget* globalVarTab = new QWidget(this);
  QVBoxLayout* globalVarTabLayout = new QVBoxLayout(globalVarTab, 1, 1);

  m_globalVariableListView = new VariableListView(DebuggerUI::GlobalVarListID, globalVarTab);
  globalVarTabLayout->addWidget(m_globalVariableListView);
  insertTab(globalVarTab, i18n("Global"));

  m_localTab = new LocalTab(this);
  insertTab(m_localTab, i18n("Local"));

  m_watchTab = new WatchTab(this);
  insertTab(m_watchTab, i18n("Watch"));

  QWidget* breakpointTab = new QWidget(this);
  QVBoxLayout* breakpointTabLayout = new QVBoxLayout(breakpointTab, 1, 1);

  m_breakpointListView = new BreakpointListView(breakpointTab);
  breakpointTabLayout->addWidget(m_breakpointListView);
  insertTab(breakpointTab, i18n("Breakpoints"));

  QWidget* messageTab = new QWidget(this);
  QVBoxLayout* logTabLayout = new QVBoxLayout(messageTab, 1, 1);

  m_messageListView = new MessageListView(messageTab);
  logTabLayout->addWidget(m_messageListView);
  insertTab(messageTab, i18n("Messages"));

  QWidget* outputTab = new QWidget(this);
  QVBoxLayout* outputTabLayout = new QVBoxLayout(outputTab, 1, 1);

  m_edOutput = new KTextEdit(outputTab);
  outputTabLayout->addWidget(m_edOutput);
  m_edOutput->setReadOnly(true);
  m_edOutput->setTextFormat(Qt::PlainText);
  m_edOutput->setPaper(QBrush(QColor("white")));
  insertTab(outputTab, i18n("Output"));

//   m_console = new ConsoleWidget(this);
//   insertTab(m_console, i18n("Console"));


  connect(m_globalVariableListView, SIGNAL(sigVarModified(Variable*)),
    this, SIGNAL(sigGlobalVarModified(Variable*)));

  connect(m_globalVariableListView, SIGNAL(sigNeedChildren(int, Variable*)),
    this, SLOT(slotNeedChildren( int, Variable* )));

  connect(m_localTab->localVarList(), SIGNAL(sigVarModified(Variable*)),
    this, SIGNAL(sigLocalVarModified(Variable*)));

  connect(m_localTab->localVarList(), SIGNAL(sigNeedChildren(int, Variable*)),
    this, SLOT(slotNeedChildren( int, Variable* )));

  connect(m_localTab->comboStack(), 
      SIGNAL(changed(DebuggerExecutionPoint*, DebuggerExecutionPoint*)),
      this, SIGNAL(sigStackchanged(DebuggerExecutionPoint*, DebuggerExecutionPoint*)));

  connect(m_watchTab, SIGNAL(sigWatchAdded(const QString&)),
    this, SIGNAL(sigWatchAdded(const QString&)));

  connect(m_watchTab->watchListView(), SIGNAL(sigVarModified(Variable*)),
    this, SIGNAL(sigWatchModified(Variable*)));

  connect(m_watchTab->watchListView(), SIGNAL(sigWatchRemoved(Variable*)),
    this, SIGNAL(sigWatchRemoved(Variable*)));

  connect(m_watchTab->watchListView(), SIGNAL(sigNeedChildren(int, Variable*)),
    this, SLOT(slotNeedChildren( int, Variable* )));

  connect(m_breakpointListView, SIGNAL(sigBreakpointChanged(DebuggerBreakpoint*)),
    this, SIGNAL(sigBreakpointChanged(DebuggerBreakpoint*)));

  connect(m_breakpointListView, SIGNAL(sigBreakpointCreated(DebuggerBreakpoint*)),
    this, SIGNAL(sigBreakpointCreated(DebuggerBreakpoint*)));

  connect(m_breakpointListView, SIGNAL(sigBreakpointRemoved(DebuggerBreakpoint*)),
    this, SIGNAL(sigBreakpointRemoved(DebuggerBreakpoint*)));

  connect(m_breakpointListView, SIGNAL(sigDoubleClick(const KURL&, int)),
    this, SIGNAL(sigGotoFileAndLine(const KURL&, int)));

  connect(m_messageListView, SIGNAL(sigDoubleClick(const KURL&, int)),
    this, SIGNAL(sigGotoFileAndLine(const KURL&, int)));

// //   connect(m_console, SIGNAL(sigExecuteCmd(const QString&)),
// //     this, SIGNAL(sigExecuteCmd(const QString&)));
}
Ejemplo n.º 13
0
QString UBSettings::trashedDocumentGroupNamePrefix = QString("_Trash:");

QString UBSettings::uniboardDocumentNamespaceUri = "http://uniboard.mnemis.com/document";
QString UBSettings::uniboardApplicationNamespaceUri = "http://uniboard.mnemis.com/application";


const int UBSettings::sDefaultFontPixelSize = 36;
const char *UBSettings::sDefaultFontFamily = "Arial";

QString UBSettings::currentFileVersion = "4.6.0";

QColor UBSettings::crossDarkBackground = QColor(44, 44, 44, 200);
QColor UBSettings::crossLightBackground = QColor(165, 225, 255);

QBrush UBSettings::eraserBrushLightBackground = QBrush(QColor(255, 255, 255, 30));
QBrush UBSettings::eraserBrushDarkBackground = QBrush(QColor(127, 127, 127, 30));

QPen UBSettings::eraserPenDarkBackground = QPen(QColor(255, 255, 255, 63));
QPen UBSettings::eraserPenLightBackground = QPen(QColor(0, 0, 0, 63));

QColor UBSettings::documentSizeMarkColorDarkBackground = QColor(44, 44, 44, 200);
QColor UBSettings::documentSizeMarkColorLightBackground = QColor(241, 241, 241);

QColor UBSettings::paletteColor = QColor(127, 127, 127, 127);
QColor UBSettings::opaquePaletteColor = QColor(66, 66, 66, 200);

QColor UBSettings::documentViewLightColor = QColor(241, 241, 241);

QPointer<QSettings> UBSettings::sAppSettings = 0;
Ejemplo n.º 14
0
MainWindow::MainWindow(AppListInterface * pList,QWidget *parent) : QWidget(parent),
    m_bInVideoStream(false)
{
	m_pList = pList;
	int title_height=40;
    int status_height=ui_res_width/9;
    int center_height=ui_res_height-status_height-title_height;
    int margin=10;
    int inter=5;
    setWindowFlags(Qt::FramelessWindowHint);//
    setGeometry(0,0,ui_res_width,ui_res_height);
    this->setAutoFillBackground(true);
    QPixmap pixmap(":/images/mainmenu.png");
    QPixmap fitpixmap=pixmap.scaled(this->width(),this->height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
    QPalette palette;
    palette.setBrush(QPalette::Background, QBrush(fitpixmap));
    this->setPalette(palette);

    m_pIcon=new QLabel(this);
    m_pIcon->setGeometry(margin*2,inter,title_height-inter*2,title_height-inter*2);
    m_pIcon->setStyleSheet(QString::fromUtf8("border-image:url(:/images/home.png)"));
    m_pTime=new QLabel(this);
    m_pTime->setGeometry(ui_res_width*1/3,inter,ui_res_width/3,title_height-inter*2);
    m_pTime->setAlignment(Qt::AlignCenter);
	
    m_pTime->setStyleSheet("font: 32px \"Liberation Serif\";color:rgb(255,255,255);background:transparent;border: 0px");
	m_pTime->setText(QTime::currentTime().toString("HH:mm"));

    m_pNetStatus=new QLabel(this);
    m_pNetStatus->setGeometry(ui_res_width-title_height-margin,inter,title_height-2*inter,title_height-inter*2);
    m_pNetStatus->setStyleSheet(QString::fromUtf8("border-image:url(:/images/wifi.png)"));

    m_pCenter=new QWidget(this);
    m_pCenter->setGeometry(margin,title_height,ui_res_width-2*margin,center_height);
    //m_pCenter->setStyleSheet(QString::fromUtf8("border-image:url(:/images/applinkmain.png)"));

    int y=title_height+center_height;
    m_pMainMenu=new QWidget(this);
    m_pMainMenu->setGeometry(margin,y,ui_res_width-2*margin,status_height-inter);
    m_pMainMenu->setStyleSheet(QString::fromUtf8("border-image:url(:/images/downmenu.png)"));
    QString sheet_on[MENU_MAX]={":/images/music_on.png",":/images/key_on.png",":/images/phone_on.png",
                                ":/images/link_on.png",":/images/list_on.png",
                               ":/images/setting_on.png"};
    QString sheet_off[MENU_MAX]={":/images/music_off.png",":/images/key_off.png",":/images/phone_off.png",
                                 ":/images/link_off.png",":/images/list_off.png",
                                ":/images/setting_off.png"};
    //QString text[MENU_MAX]={"Music","Keys","Phone","Navigation","AppList","Settings"};
    QString text[MENU_MAX]={"音频","空调","电话","导航","应用程序","设置"};
    for(int i=0;i<MENU_MAX;i++){
        m_pMenuTab[i]=new MenuButton(m_pMainMenu);
        m_pMenuTab[i]->setGeometry((ui_res_width-2*margin)/MENU_MAX*i,0,(ui_res_width-2*margin)/MENU_MAX,status_height);
        m_pMenuTab[i]->setIcon(sheet_on[i],sheet_off[i]);
        m_pMenuTab[i]->setText(text[i]);
        connect(m_pMenuTab[i],SIGNAL(clicked()),SLOT(onMenuSelected()));
    }
    m_pMenuTab[4]->setActive(true);

    m_AppWidth=(ui_res_width-2*margin)/4;
    m_AppHeight=center_height/2;
    /*
    QString appsheet_on[2]={":/images/phonechild_on.png",":/images/listchild_on.png"};
    QString appsheet_off[2]={":/images/phonechild_off.png",":/images/listchild_off.png"};
    QString childText[2]={"Find New App","App Setting"};
    int funcId[2]={-1,-2};
    for(int i=0;i<2;i++){
        InsertChildApp(i,funcId[i],childText[i],appsheet_on[i],appsheet_off[i]);
    }
    */

    m_pTimer=new QTimer(this);
    m_pTimer->start(1000);//分钟
    connect(m_pTimer,SIGNAL(timeout()),SLOT(onUpdateTime()));

    //videoWidget = new VideoStream(ui_res_width,ui_res_height,this);
    //connect(videoWidget,SIGNAL(ClickMenuBtn()),this,SLOT(OnVideoStreamMenuBtnClicked()));
}
Ejemplo n.º 15
0
// This takes a very naive approach to producing at 'C' in a contrasting
// color. For a much more effective technique, see:
// http://qt.nokia.com/doc/qq/qq26-adaptivecoloring.html
QPixmap colorSwatch(const QColor &color, const QSize &size)
{
    QString key = QString("COLORSWATCH:%1:%2x%3").arg(color.name())
        .arg(size.width()).arg(size.height());
    QPixmap pixmap(size);
#if QT_VERSION >= 0x040600
    if (!QPixmapCache::find(key, &pixmap)) {
#else
    if (!QPixmapCache::find(key, pixmap)) {
#endif
        pixmap.fill(Qt::transparent);
        QPainter painter(&pixmap);
        painter.setRenderHints(QPainter::Antialiasing|
                               QPainter::TextAntialiasing);
        painter.setPen(Qt::NoPen);
        painter.setBrush(color);
        painter.drawEllipse(0, 0, size.width(), size.height());
        if (size.width() > 32) {
            painter.setFont(QFont("Helvetica",
                    qMax(8, size.height() - 6), QFont::Black));
            QColor textColor(color.darker());
            if (color.red() == color.green() &&
                color.red() == color.blue())
                textColor = (color.red() > 90 ? Qt::black
                                              : Qt::white);
            painter.setPen(textColor);
            painter.drawText(
                    QRectF(0, 0, size.width(), size.height()),
                    QObject::tr("C"), QTextOption(Qt::AlignCenter));
        }
        painter.end();
        QPixmapCache::insert(key, pixmap);
    }
    return pixmap;
}


QPixmap brushSwatch(const Qt::BrushStyle style, const QColor &color,
                    const QSize &size)
{
    QString key = QString("BRUSHSTYLESWATCH:%1:%2:%3x%4")
        .arg(static_cast<int>(style)).arg(color.name())
        .arg(size.width()).arg(size.height());
    QPixmap pixmap(size);
#if QT_VERSION >= 0x040600
    if (!QPixmapCache::find(key, &pixmap)) {
#else
    if (!QPixmapCache::find(key, pixmap)) {
#endif
        pixmap.fill(Qt::transparent);
        QPainter painter(&pixmap);
        painter.setRenderHint(QPainter::Antialiasing);
        painter.setPen(Qt::NoPen);
        painter.setBrush(QBrush(color, style));
        painter.drawRect(0, 0, size.width(), size.height());
        painter.end();
        QPixmapCache::insert(key, pixmap);
    }
    return pixmap;
}


QPixmap penStyleSwatch(const Qt::PenStyle style, const QColor &color,
                       const QSize &size)
{
    QString key = QString("PENSTYLESWATCH:%1:%2:%3x%4")
        .arg(static_cast<int>(style)).arg(color.name())
        .arg(size.width()).arg(size.height());
    QPixmap pixmap(size);
#if QT_VERSION >= 0x040600
    if (!QPixmapCache::find(key, &pixmap)) {
#else
    if (!QPixmapCache::find(key, pixmap)) {
#endif
        pixmap.fill(Qt::transparent);
        QPainter painter(&pixmap);
        QPen pen(style);
        pen.setColor(color);
        pen.setWidth(2);
        painter.setPen(pen);
        const int Y = size.height() / 2;
        painter.drawLine(0, Y, size.width(), Y);
        painter.end();
        QPixmapCache::insert(key, pixmap);
    }
    return pixmap;
}


QPixmap penCapSwatch(const Qt::PenCapStyle capStyle,
                     const QColor &color, const QSize &size)
{
    QString key = QString("PENCAPSTYLESWATCH:%1:%2:%3x%4")
        .arg(static_cast<int>(capStyle)).arg(color.name())
        .arg(size.width()).arg(size.height());
    QPixmap pixmap(size);
#if QT_VERSION >= 0x040600
    if (!QPixmapCache::find(key, &pixmap)) {
#else
    if (!QPixmapCache::find(key, pixmap)) {
#endif
        pixmap.fill(Qt::transparent);
        QPainter painter(&pixmap);
        painter.setRenderHint(QPainter::Antialiasing);
        QPen pen;
        pen.setCapStyle(Qt::SquareCap);
        pen.setWidthF(size.height() / 2.5);
        pen.setColor(Qt::white);
        painter.setPen(pen);
        const int Y = size.height() / 2;
        painter.drawLine(0, Y, size.width(), Y);
        pen.setColor(color);
        pen.setCapStyle(capStyle);
        painter.setPen(pen);
        painter.drawLine(size.width() / 2.5, Y, size.width(), Y);
        painter.end();
        QPixmapCache::insert(key, pixmap);
    }
    return pixmap;
}


QPixmap penJoinSwatch(const Qt::PenJoinStyle joinStyle,
                      const QColor &color, const QSize &size)
{
    QString key = QString("PENJOINSTYLESWATCH:%1:%2:%3x%4")
        .arg(static_cast<int>(joinStyle)).arg(color.name())
        .arg(size.width()).arg(size.height());
    QPixmap pixmap(size);
#if QT_VERSION >= 0x040600
    if (!QPixmapCache::find(key, &pixmap)) {
#else
    if (!QPixmapCache::find(key, pixmap)) {
#endif
        const double Indent = size.width() / 5.0;
        QPolygonF polygon;
        polygon << QPointF(Indent, Indent)
                << QPointF(Indent, size.height() - Indent)
                << QPointF(size.width() - Indent,
                           size.height() - Indent);
        pixmap.fill(Qt::transparent);
        QPainter painter(&pixmap);
        painter.setRenderHint(QPainter::Antialiasing);
        QPen pen;
        pen.setJoinStyle(joinStyle);
        pen.setColor(color);
        pen.setWidthF(size.height() / 2.5);
        painter.setPen(pen);
        painter.drawPolyline(polygon);
        painter.end();
        QPixmapCache::insert(key, pixmap);
    }
    return pixmap;
}
Ejemplo n.º 16
0
#include "AnimationEventsTimeline.h"
#include "BTAEventItem.h"
#include <QtWidgets\QSlider>
#include <QtGui\QPainter>
#include <QtGui\QPainterPath>


///////////////////////////////////////////////////////////////////////////////

QPen AnimationEventsTimeline::s_markerPen( QBrush( QColor( 26, 184, 246 ) ), 3.0f, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin );
QPen AnimationEventsTimeline::s_primaryTimeLinesPen( QColor( 64, 64, 64, 64 ), 2 );
QPen AnimationEventsTimeline::s_secondaryTimeLinesPen( QColor( 64, 64, 64, 64 ), 1 );
QPen AnimationEventsTimeline::s_timeValuesPen( QColor( 0, 0, 0 ), 1, Qt::SolidLine );
QFont AnimationEventsTimeline::s_font( "Arial" );

///////////////////////////////////////////////////////////////////////////////

AnimationEventsTimeline::AnimationEventsTimeline( QWidget* parentWidget )
   : QGraphicsView( parentWidget )
   , m_slider( NULL )
   , m_timeBarPos( 0.0f )
{
   this->setMinimumHeight( 40 );
   this->setMaximumHeight( 40 );

   setViewportUpdateMode( QGraphicsView::FullViewportUpdate );

   // allow the widget to display custom context menus
   setContextMenuPolicy( Qt::CustomContextMenu );
}
Ejemplo n.º 17
0
/*!
    \fn PartsWidget::paintEvent( QPaintEvent* )
 */
void PartsWidget::paintEvent( QPaintEvent* )
{
    if ( partList.empty() ) {
        return;
    }
    int BLOCK_ROWS = Convert::max(1,height() / 30);
    double size = partList.getSize();

    blockHeight = this->height() / BLOCK_ROWS;
    numPixels = this->width() * BLOCK_ROWS;
    pixelPerByte = numPixels / size;
    
    QListIterator<Part> it ( partList );
    
    QPainter painter ( this );
    
    int fromPixel, toPixel;
    Part fromPart, toPart;
    
    QColor color;
    
    int fromRow;
    int toRow;
    
    qulonglong bytesReady, bytesAvailable, bytesMissing, bytesLessSources;
    qulonglong partSize;
    bytesReady = bytesAvailable = bytesMissing = bytesLessSources = 0;

    toPart = it.next();
    while ( it.hasNext() )
    {
        fromPart = toPart;
        toPart = it.next();

        fromPixel = ( int ) ( fromPart.fromPosition * pixelPerByte );
        toPixel = ( int ) ( (toPart.fromPosition) * pixelPerByte );
        partSize = (toPart.fromPosition) - fromPart.fromPosition;
    
        if ( fromPart.fromPosition != toPart.fromPosition )
        {
            switch ( fromPart.type )
            {
                case -1:
                    color.setRgb(READY_COLOR);
                    bytesReady += partSize;
                    break;
                case 0:
                    color.setRgb(MISSING_COLOR);
                    bytesMissing += partSize;
                    break;
                default:
                    if ( fromPart.type < 5 )
                    {
                        color.setRgb ( 255 - fromPart.type * 20, 255 - fromPart.type * 20, fromPart.type * 20 );
                        bytesLessSources += partSize;
                    }
                    else
                    {
                        int blue = 100 + fromPart.type * 10;
                        if ( blue > 255 ) {
                            blue = 255;
                        }
                        color.setRgb ( 0, 0, blue );
                    }
                    bytesAvailable += partSize;
                    break;
            }
    
            fromRow = fromPixel / width();
            fromPixel = fromPixel % width();
            toRow = toPixel / width();
            toPixel = toPixel % width();
            
            while ( fromRow < toRow )
            {
                // -- fill until the end of the col --
                painter.fillRect ( fromPixel, fromRow*blockHeight, width() - fromPixel, blockHeight, QBrush ( color ) );
                fromPixel = 0;
                fromRow++;
            }
            painter.fillRect ( fromPixel, fromRow*blockHeight, toPixel - fromPixel, blockHeight, QBrush ( color ) );
        }
    }
    painter.end();
    ready = bytesReady / size * 100.0;
    available = bytesAvailable / size * 100.0;
    lessSources = bytesLessSources / size * 100.0;
    missing = bytesMissing / size * 100.0;
    painted();
}
Ejemplo n.º 18
0
Creator::Creator(QApplication &app)
{
    //播放音乐文件
    media = new Phonon::MediaObject();
    audioOutput = new Phonon::AudioOutput(Phonon::VideoCategory);//声音
    Phonon::createPath(media, audioOutput);
    sourceList.append(QString("music/infinity.wma"));


    //建立pad
    pad = new RoundRectItem(QRectF(QPointF(0,0),QPointF(0,0)),QColor(0,0,255,0));
    pad->setZValue(0);

    //设置backwindow
    backWindow = new QGraphicsProxyWidget(pad);
    backWidget = new BackWidget();
    backWindow->setX(0);
    backWindow->setY(0);
 //   backWindow->widget()->setWindowOpacity(1);
    backWindow->setWidget(backWidget);
    backWindow->setZValue(0);


    //设置开始窗口按钮
    beginWindow = new QGraphicsProxyWidget(pad);
    beginWidget = new BeginBottum;
    beginWindow->setWidget(beginWidget);
    beginWindow->setX(backWindow->x()+400);
    beginWindow->setY(backWindow->y()+200);
    beginWindow->widget()->setWindowOpacity(1);
    beginWindow->setZValue(0.5);

    //设置音乐按键
    musicWindow = new QGraphicsProxyWidget(pad);
    musicWidget = new ClickBottum;
    musicWindow->setWidget(musicWidget);
    musicWindow->setX(backWindow->widget()->width()-120);
    musicWindow->setY(backWindow->y()+20);
    musicWindow->widget()->setWindowOpacity(1);
    musicWindow->setZValue(0.9);


    //设置AI对战窗口
    aiWindow = new QGraphicsProxyWidget(pad);
    aiWidget = new AIvsAI();
    aiWindow->setWidget(aiWidget);
    aiWindow->setX(backWindow->x());
    aiWindow->setY(backWindow->y());
    aiWindow->widget()->setWindowOpacity(0);
    aiWindow->setZValue(0.5);

    //按钮控件
    singleWindow = new QGraphicsProxyWidget(pad);
    singleWidget = new widgetssingle;
    singleWindow->setWidget(singleWidget);
    singleWindow->setX(backWindow->x()+400);
    singleWindow->setY(backWindow->y()+200);
    singleWindow->widget()->setWindowOpacity(0);
    singleWindow->setZValue(0.5);

    //回放器
    replayerWindow = new QGraphicsProxyWidget(pad);
    replayerWidget = new ReplayWindow();
    replayerWindow->setWidget(replayerWidget);
    replayerWindow->setX(backWindow->x());
    replayerWindow->setY(backWindow->y());
    replayerWindow->widget()->setWindowOpacity(0);
    replayerWindow->setZValue(0.5);

    //地图编辑器
    mapEditWindow = new QGraphicsProxyWidget(pad);
    mapWideget = new MapEditor();
    mapEditWindow->setWidget(mapWideget);
    mapEditWindow->setX(backWindow->x());
    mapEditWindow->setY(backWindow->y());
    mapEditWindow->widget()->setWindowOpacity(0);
    mapEditWindow->setZValue(0.5);

    //人机对战
    humanaiWindow = new QGraphicsProxyWidget(pad);
    humanaiWidget = new humanai();
    humanaiWindow->setX(backWindow->x());
    humanaiWindow->setY(backWindow->y());
    humanaiWindow->setWidget(humanaiWidget);
    humanaiWindow->widget()->setWindowOpacity(0);
    humanaiWindow->setZValue(0.5);

    //制作团队
    teamMeneWindow = new QGraphicsProxyWidget(pad);
    teamMeneWideget = new TeamMenu();
    teamMeneWindow->setWidget(teamMeneWideget);
    teamMeneWindow->setX(backWindow->x());
    teamMeneWindow->setY(backWindow->y());
    teamMeneWindow->widget()->setWindowOpacity(1);
    teamMeneWindow->setZValue(0.5);

    teamWindow = new QGraphicsProxyWidget(pad);
    teamWideget = new ProductionTeam();
    teamWindow->setWidget(teamWideget);
    teamWindow->widget()->setWindowOpacity(1);
    teamWindow->setZValue(0.5);
    teamWideget->setAutoFillBackground(true);
    QPalette Tpalette = teamWindow->palette();
    Tpalette.setBrush(QPalette::Window,
                      QBrush(Qt::black));
    teamWindow->setPalette(Tpalette);

//登陆
    LogInWindow = new QGraphicsProxyWidget(pad);
    logInwidget = new LogInWidget();
    LogInWindow->setWidget(logInwidget);
    LogInWindow->widget()->setWindowOpacity(0);
    LogInWindow->setZValue(0.5);
    LogInWindow->setX(0);
    LogInWindow->setY(0);

//测试赛
    TestWindow = new QGraphicsProxyWidget(pad);
    testwidget = new TestWidget();
    TestWindow->setWidget(testwidget);
    TestWindow->widget()->setWindowOpacity(0);
    TestWindow->setZValue(0.5);
    TestWindow->setX(0);
    TestWindow->setY(0);


//  beginWindow->close();
    aiWindow->close();
    singleWindow->close();
    replayerWindow->close();
    teamMeneWindow->close();
    teamWindow->close();
    mapEditWindow->close();
    humanaiWindow->close();
    LogInWindow->close();
    TestWindow->close();

    QObject::connect(beginWidget->returnUi()->exitmain,SIGNAL(clicked()),this,SLOT(close()));
    QObject::connect(beginWidget->returnUi()->startsingle,SIGNAL(clicked()),this,SLOT(BeginToSingle()));
    connect(this->singleWidget->ui->returnpre,SIGNAL(clicked()),this,SLOT(SingleToBegin()));
    connect(this->singleWidget->ui->aivsai,SIGNAL(clicked()),this,SLOT(SingleToAi()));
    connect(this->aiWidget->ui->ReturnPre,SIGNAL(clicked()),this,SLOT(AiToSingle()));
    connect(this->singleWidget->ui->replay,SIGNAL(clicked()),this,SLOT(SingleToReplayer()));
    connect(this->replayerWidget->returnUi()->pushButton,SIGNAL(clicked()),this,SLOT(ReplayerToSingle()));
    connect(this->beginWidget->returnUi()->team,SIGNAL(clicked()),this,SLOT(BeginToTeam()));
    connect(this->teamMeneWideget->returnUi()->pushButton,SIGNAL(clicked()),this,SLOT(TeamToBegin()));
    connect(this->musicWidget->ui->checkBox,SIGNAL(clicked()),this,SLOT(Music()));
    connect(this->replayerWidget->returnUi()->pushButton,SIGNAL(clicked()),this->replayerWidget,SLOT(GoInto()));
    connect(this->mapWideget->returnUi()->pushButton_5,SIGNAL(clicked()),this,SLOT(MapToSingle()));
    connect(this->singleWidget->ui->mapedit,SIGNAL(clicked()), this, SLOT(SingLeToMap()));
    connect(this->singleWidget->ui->playervsai,SIGNAL(clicked()),this,SLOT(SingleToHumanai()));
    connect(this->singleWidget->ui->playervsai, SIGNAL(clicked()), humanaiWidget, SLOT(initEmpty()));
    connect(this->humanaiWidget->returnUi()->Button_back, SIGNAL(clicked()), this, SLOT(HumanaiToSingle()));
    connect(this->media,SIGNAL(aboutToFinish()),this,SLOT(continueMusic()));
    connect(this->singleWidget->ui->levelmode,SIGNAL(clicked()),this,SLOT(SingleToLogIn()));
    connect(this->logInwidget->returnUi()->pushButton_2,SIGNAL(clicked()),this,SLOT(LogInToSingle()));
    connect(this->logInwidget,SIGNAL(login_success(QString)),this,SLOT(LogInToTest(QString)));
    connect(this->testwidget->returnUi()->pushButton,SIGNAL(clicked()),this,SLOT(TestToLogIn()));

//    connect(this->singleWidget->ui->replay,SIGNAL(clicked()),this->replayerWidget,SLOT(GoInto()));

    //设置界面背景
    QGraphicsScene *scene = new QGraphicsScene(this);
    scene->addItem(pad);
    scene->setBackgroundBrush(QBrush(QColor(0,0,0,255)));
    scene->setSceneRect(scene->itemsBoundingRect());

    setScene(scene);
    showFullScreen();

    //建立状态
    stateMachine = new QStateMachine(this);
    MainState = new QState(stateMachine);
    TeamState = new QState(stateMachine);
    BeginState = new QState(stateMachine);
    TestState = new QState(stateMachine);
    ReplayerState = new QState(stateMachine);
    WebState = new QState(stateMachine);
    MapState = new QState(stateMachine);
    HumanaiState = new QState(stateMachine);
    ChatState = new QState(stateMachine);
    WidState = new QState(stateMachine);

    BeginMenuState= new QState(stateMachine);
    SingleState= new QState(stateMachine);
    OldMenuState = new QState(stateMachine);
    CheckMenuState = new QState(stateMachine);
    TeamMenuState = new QState(stateMachine);
    LogState = new QState(stateMachine);

    MainState->assignProperty(MainState, "z", 0);
    MainState->assignProperty(beginWindow->widget(), "windowOpacity", 1);

    stateMachine->setInitialState(MainState);
    stateMachine->start();
}
Ejemplo n.º 19
0
void Junk::draw(QGraphicsScene *scene) const {
    Point corner = asPoint();
    scene->addEllipse(QRectF(corner.x * UNIT_WIDTH, corner.y * UNIT_HEIGHT,
                             JUNK_RADIUS, JUNK_RADIUS), QPen(), QBrush(JUNK_COLOR));
}
Ejemplo n.º 20
0
void GridWidget::paintEvent(QPaintEvent *event)
{
    Q_UNUSED(event);
    QPainter painter(this);

    qreal wantedHeight = CELL_HEIGHT * (ROW_COUNT + 1);
    qreal wantedWidth = FIRST_COL_WIDTH + CELL_WIDTH * COL_COUNT;

    qreal scaleWidth = width()/wantedWidth;
    qreal scaleHeight = height()/ wantedHeight;
    qreal minScale = qMin(scaleWidth, scaleHeight);

    painter.setRenderHint(QPainter::Antialiasing, true);
    painter.translate((width()-minScale*wantedWidth) /2,0);
    painter.scale(minScale,minScale);

    painter.fillRect(QRectF(0,0, wantedWidth, wantedHeight), QBrush(QColor("#FFF")));

    painter.setPen(textColor);
    painter.setFont(QFont("Segoe UI", 8));
    for(int row=1; row<ROW_COUNT+1; row++)
    {
        QRect textRect(0, row*CELL_HEIGHT, FIRST_COL_WIDTH, CELL_HEIGHT);
        QString rowLabel = QString("%1 - %2")
                .arg(1+(row-1)*32)
                .arg((row)*32);
        painter.drawText(textRect, rowLabel, QTextOption(Qt::AlignHCenter | Qt::AlignVCenter));
    }
    for(int col=0; col<COL_COUNT; col++)
    {
        QRect textRect(FIRST_COL_WIDTH + col*CELL_WIDTH, 0, CELL_WIDTH, CELL_HEIGHT);
        QString rowLabel = QString("%1")
                .arg(col+1);
        painter.drawText(textRect, rowLabel, QTextOption(Qt::AlignHCenter | Qt::AlignVCenter));
    }
    for(int row=0; row<ROW_COUNT; row++)
        for(int col=0; col<COL_COUNT; col++)
        {
            int address = row*COL_COUNT + col;
            QRect textRect(FIRST_COL_WIDTH + col*CELL_WIDTH, (row+1)*CELL_HEIGHT, CELL_WIDTH, CELL_HEIGHT);
            QString value = m_values[address];

            if(!value.isEmpty())
            {
                QColor fillColor = m_colors[address];

                QString rowLabel = value;
                painter.fillRect(textRect, fillColor);
                painter.drawText(textRect, rowLabel, QTextOption(Qt::AlignHCenter | Qt::AlignVCenter));
            }

        }

    painter.setPen(gridLineColor);

    for(int row=0; row<ROW_COUNT + 1; row++)
    {
        QPoint start(0, row*CELL_HEIGHT);
        QPoint end(wantedWidth, row*CELL_HEIGHT);
        painter.drawLine(start, end);
    }
    for(int col=0; col<COL_COUNT + 1; col++)
    {
        QPoint start(FIRST_COL_WIDTH + col*CELL_WIDTH, 0);
        QPoint end(FIRST_COL_WIDTH + col*CELL_WIDTH, wantedHeight);
        painter.drawLine(start, end);
    }

    // Draw the highlight for the selected one
    if(m_selectedAddress>-1)
    {
        int col = m_selectedAddress % 32;
        int row = m_selectedAddress / 32;
        QRect textRect(FIRST_COL_WIDTH + col*CELL_WIDTH, (row+1)*CELL_HEIGHT, CELL_WIDTH, CELL_HEIGHT);
        painter.setPen(QColor(Qt::black));
        painter.drawRect(textRect);
    }
}
void StorgeSelect::selectFun()
{
    createList();
    clearTableView();
    QSqlQuery query;
    QString select_sql;
    int i=0;

    int  condition=selectComboBox->currentIndex();
    QString conditionStr1;

    switch(condition)
    {
    case 0:
    {
        //goodsstorage  storagecount storagprice  storagetotal  goodsid goodsname
        //goodsid goodsname  goodsformat  goodsclass  goodsunit   goodssave  goodsprice   goodsremarks   goodsstatus   goodsstatusid
        conditionStr1=selectLineEdit->text();
        select_sql = "select   goodsstorage.goodsid,goodsstorage.goodsname,goodsstorage.storagecount,\
                goodsstorage.storagprice,goodsstorage.storagetotal,\
                goods.goodssave,goods.goodsstatus from goodsstorage,goods  where goods.goodsname in(select goodsname from goodsstorage \
                 where goodsname=:conditionStr1 ) and goods.goodsname=goodsstorage.goodsname";
        if(conditionStr1.isEmpty())
        {
            QMessageBox::warning(this,"警告","请输入查询的商品名字!");
            return ;
        }
        query.prepare(select_sql);
        query.bindValue(":conditionStr1",conditionStr1);
        break;
    }

    case 1:
    {
        conditionStr1=selectLineEdit->text();

        select_sql = "select   goodsstorage.goodsid,goodsstorage.goodsname,goodsstorage.storagecount,\
                goodsstorage.storagprice,goodsstorage.storagetotal,\
                goods.goodssave,goods.goodsstatus from goodsstorage,goods  where goods.goodsid in(select goodsid from goodsstorage \
                 where goodsname=:conditionStr1 ) and goods.goodsid=goodsstorage.goodsid";

        if(conditionStr1.isEmpty())
        {
            QMessageBox::warning(this,"警告","请输入查询的商品编号!");
            return ;
        }
        query.prepare(select_sql);
        query.bindValue(":conditionStr1",conditionStr1);
        break;
    }

    }
    if(!query.exec())
    {
        qDebug()<<query.lastError();
    }
    else
    {
        //goodsid ,goodsname,inputcount,inputprice,inputtotal,inputtype,inputtime,customsid
        storgeList.clear();
        storgeList.append("产品编号");
        storgeList.append("产品名称");
        storgeList.append("库存量");
        storgeList.append("产品单价");
        storgeList.append("产品总价");
        storgeList.append("安全库存");
        storgeList.append("产品状态");
        while(query.next())
        {

            tableModel->setItem(i,0,new QStandardItem(query.value("goodsid").toString()));
            storgeList.append(query.value("goodsid").toString());

            tableModel->setItem(i,1,new QStandardItem(query.value("goodsname").toString()));
            storgeList.append(query.value("goodsname").toString());

            tableModel->setItem(i,2,new QStandardItem(query.value("storagecount").toString()));
            storgeList.append(query.value("storagecount").toString());


            tableModel->setItem(i,3,new QStandardItem(query.value("storagprice").toString()));
            storgeList.append(query.value("storagprice").toString());

            tableModel->setItem(i,4,new QStandardItem(query.value("storagetotal").toString()));
            storgeList.append(query.value("storagetotal").toString());

            tableModel->setItem(i,5,new QStandardItem(query.value("goodssave").toString()));
            storgeList.append(query.value("goodssave").toString());

            tableModel->setItem(i,6,new QStandardItem(query.value("goodsstatus").toString()));
            storgeList.append(query.value("goodsstatus").toString());

            if(query.value("goodsstatus").toString()=="停用")
            {
                tableModel->item(i,6)->setBackground(QBrush(QColor(255,0, 0)));
            }
            else
            {
                tableModel->item(i,6)->setBackground(QBrush(QColor(255, 255, 255)));

            }

            i++;
        }
    }
}
Ejemplo n.º 22
0
void SlideWidget::setImage( const QImage &image )
{
    QPalette palette;
    palette.setBrush( backgroundRole(), QBrush( QPixmap::fromImage( image ) ) );
    setPalette( palette );
}
Ejemplo n.º 23
0
void FGWCondition::paintEvent(QPaintEvent *)
{
    QPainter painter(this);
    painter.setRenderHint(QPainter::Antialiasing);

    QFontMetrics fm = painter.fontMetrics();
    if (fm.ascent() + fm.descent() != m_fontHeight)
    {
        m_fontHeight = fm.ascent() + fm.descent();
        updateTransforms();
    }

    // Y-Axis label
    QTransform transform;
    transform.rotate(270);
    transform.translate(-(height() + fm.width(m_yAxisLabel)) / 2, fm.ascent());
    painter.setTransform(transform);
    painter.drawText(QPointF(0, 0), m_yAxisLabel);

    // X-Axis label
    transform.reset();
    painter.setTransform(transform);
    painter.drawText(QPointF((width() - fm.width(m_xAxisLabel)) / 2, height() - fm.descent()), m_xAxisLabel);

    // The actual graph
    if (m_forceCondition)
    {
        QPointF startPos(-1.0, 0.0);
        QPointF startViewPos = m_model2View.map(startPos);

        QPointF endPos(1.0, 0.0);
        QPointF endViewPos = m_model2View.map(endPos);

        double negativeSaturation = m_forceCondition->negativeSaturation();
        if (m_forceCondition->negativeCoefficient() < 0.0)
        {
            negativeSaturation = -negativeSaturation;
        }

        double positiveSaturation = m_forceCondition->positiveSaturation();
        if (m_forceCondition->positiveCoefficient() < 0.0)
        {
            positiveSaturation = -positiveSaturation;
        }

        double negativeDeadBandValue = CLIP11(m_forceCondition->offset() - m_forceCondition->deadBand());
        double positiveDeadBandValue = CLIP11(m_forceCondition->offset() + m_forceCondition->deadBand());

        double negCoeff = m_forceCondition->negativeCoefficient();
        double negCoeffValue = 1000.0;
        if (0.001 < fabs(negCoeff))
        {
            negCoeffValue = (1.0 / fabs(negCoeff)) - 1.0;
        }
        negCoeffValue *= m_forceCondition->negativeSaturation();
        double negativeSaturationValue = negativeDeadBandValue - negCoeffValue;
        if (negativeSaturationValue < -1.0)
        {
            double negCoeffVisible = negativeDeadBandValue + 1.0;
            double ratio = negCoeffVisible / negCoeffValue;
            negativeSaturation *= ratio;
            negativeSaturationValue = -1.0;
        }

        double posCoeff = m_forceCondition->positiveCoefficient();
        double posCoeffValue = 1000.0;
        if (0.001 < fabs(posCoeff))
        {
            posCoeffValue = (1.0 / fabs(posCoeff)) - 1.0;
        }
        posCoeffValue *= m_forceCondition->positiveSaturation();
        double positiveSaturationValue = positiveDeadBandValue + posCoeffValue;
        if (1.0 < positiveSaturationValue)
        {
            double posCoeffVisible = 1.0 - positiveDeadBandValue;
            double ratio = posCoeffVisible / posCoeffValue;
            positiveSaturation *= ratio;
            positiveSaturationValue = 1.0;
        }

        QPointF offsetPos(m_forceCondition->offset(), 0.0);
        QPointF offsetViewPos = m_model2View.map(offsetPos);

        QPointF negativeSaturationPos(-1.0, negativeSaturation);
        QPointF negativeSaturationViewPos = m_model2View.map(negativeSaturationPos);

        QPointF negativeCoefficientPos(negativeSaturationValue, negativeSaturation);
        QPointF negativeCoefficientViewPos = m_model2View.map(negativeCoefficientPos);

        QPointF negativeDeadBandPos(negativeDeadBandValue, 0.0);
        QPointF negativeDeadBandViewPos = m_model2View.map(negativeDeadBandPos);

        QPointF positiveDeadBandPos(positiveDeadBandValue, 0.0);
        QPointF positiveDeadBandViewPos = m_model2View.map(positiveDeadBandPos);

        QPointF positiveCoefficientPos(positiveSaturationValue, positiveSaturation);
        QPointF positiveCoefficientViewPos = m_model2View.map(positiveCoefficientPos);

        QPointF positiveSaturationPos(1.0, positiveSaturation);
        QPointF positiveSaturationViewPos = m_model2View.map(positiveSaturationPos);

        painter.setPen(Qt::black);
        painter.setBrush(Qt::green);
        QPolygon envelope;
        envelope << startViewPos.toPoint()
                 << negativeSaturationViewPos.toPoint()
                 << negativeCoefficientViewPos.toPoint()
                 << negativeDeadBandViewPos.toPoint()
                 << positiveDeadBandViewPos.toPoint()
                 << positiveCoefficientViewPos.toPoint()
                 << positiveSaturationViewPos.toPoint()
                 << endViewPos.toPoint();
        painter.drawPolygon(envelope);

        painter.setBrush(QBrush(Qt::red));
        painter.drawEllipse(negativeCoefficientViewPos, m_handleRadius, m_handleRadius);
        painter.drawEllipse(negativeDeadBandViewPos, m_handleRadius, m_handleRadius);
        painter.drawEllipse(positiveDeadBandViewPos, m_handleRadius, m_handleRadius);
        painter.drawEllipse(positiveCoefficientViewPos, m_handleRadius, m_handleRadius);

        if (!m_dragHandler->isDragging())
        {
            double negSatHalfWidth = (negativeCoefficientViewPos.x() - startViewPos.x()) / 2.0;
            m_dragHandler->setHitAreaView(NegativeSaturation,
                                          QPointF(startViewPos.x() + negSatHalfWidth, negativeSaturationViewPos.y()),
                                          negSatHalfWidth, m_handleRadius);
            m_dragHandler->setHitAreaView(NegativeCoefficient, negativeCoefficientViewPos);
            m_dragHandler->setHitAreaView(NegativeDeadBand, negativeDeadBandViewPos);
            double offsetHalfWidth = (positiveDeadBandViewPos.x() - negativeDeadBandViewPos.x()) / 2.0;
            m_dragHandler->setHitAreaView(Offset, offsetViewPos, offsetHalfWidth, m_handleRadius);
            m_dragHandler->setHitAreaView(PositiveDeadBand, positiveDeadBandViewPos);
            m_dragHandler->setHitAreaView(PositiveCoefficient, positiveCoefficientViewPos);
            double posSatHalfWidth = (endViewPos.x() - positiveCoefficientViewPos.x()) / 2.0;
            m_dragHandler->setHitAreaView(PositiveSaturation,
                                          QPointF(endViewPos.x() - posSatHalfWidth, positiveSaturationViewPos.y()),
                                          posSatHalfWidth, m_handleRadius);
        }
    }
}
Ejemplo n.º 24
0
Geometryval::Geometryval(const Mlt::Profile *profile, const Timecode &t, const QPoint &frame_size, int startPoint, QWidget* parent) :
        QWidget(parent),
        m_profile(profile),
        m_paramRect(NULL),
        m_geom(NULL),
        m_path(NULL),
        m_fixedMode(false),
        m_frameSize(frame_size),
        m_startPoint(startPoint),
        m_timePos(t)
{
    setupUi(this);
    toolbarlayout->addWidget(&m_timePos);
    toolbarlayout->insertStretch(-1);

    QVBoxLayout* vbox = new QVBoxLayout(widget);
    m_sceneview = new QGraphicsView(this);
    m_sceneview->setBackgroundBrush(QBrush(Qt::black));
    vbox->addWidget(m_sceneview);
    vbox->setContentsMargins(0, 0, 0, 0);

    QVBoxLayout* vbox2 = new QVBoxLayout(keyframeWidget);
    m_helper = new KeyframeHelper(this);
    vbox2->addWidget(m_helper);
    vbox2->setContentsMargins(0, 0, 0, 0);

    connect(m_helper, SIGNAL(positionChanged(int)), this, SLOT(slotPositionChanged(int)));
    connect(m_helper, SIGNAL(keyframeMoved(int)), this, SLOT(slotKeyframeMoved(int)));
    connect(m_helper, SIGNAL(addKeyframe(int)), this, SLOT(slotAddFrame(int)));
    connect(m_helper, SIGNAL(removeKeyframe(int)), this, SLOT(slotDeleteFrame(int)));

    m_scene = new GraphicsSceneRectMove(this);
    m_scene->setTool(TITLE_SELECT);
    m_sceneview->setScene(m_scene);
    m_dar = (m_profile->height() * m_profile->dar()) / (double) m_profile->width();

    m_realWidth = (int)(profile->height() * profile->dar() + 0.5);
    QGraphicsRectItem *frameBorder = new QGraphicsRectItem(QRectF(0, 0, m_realWidth, profile->height()));
    frameBorder->setZValue(-1100);
    frameBorder->setBrush(QColor(255, 255, 0, 30));
    frameBorder->setPen(QPen(QBrush(QColor(255, 255, 255, 255)), 1.0, Qt::DashLine));
    m_scene->addItem(frameBorder);

    buttonNext->setIcon(KoIconUtils::themedIcon(QStringLiteral("media-skip-forward")));
    buttonNext->setToolTip(i18n("Go to next keyframe"));
    buttonPrevious->setIcon(KoIconUtils::themedIcon(QStringLiteral("media-skip-backward")));
    buttonPrevious->setToolTip(i18n("Go to previous keyframe"));
    buttonAdd->setIcon(KoIconUtils::themedIcon(QStringLiteral("document-new")));
    buttonAdd->setToolTip(i18n("Add keyframe"));
    buttonDelete->setIcon(KoIconUtils::themedIcon(QStringLiteral("edit-delete")));
    buttonDelete->setToolTip(i18n("Delete keyframe"));

    m_configMenu = new QMenu(i18n("Misc..."), this);
    buttonMenu->setMenu(m_configMenu);
    buttonMenu->setPopupMode(QToolButton::MenuButtonPopup);

    m_editOptions = m_configMenu->addAction(KoIconUtils::themedIcon(QStringLiteral("system-run")), i18n("Show/Hide options"));
    m_editOptions->setCheckable(true);
    buttonMenu->setDefaultAction(m_editOptions);
    connect(m_editOptions, SIGNAL(triggered()), this, SLOT(slotSwitchOptions()));
    slotSwitchOptions();

    m_reset = m_configMenu->addAction(KoIconUtils::themedIcon(QStringLiteral("view-refresh")), i18n("Reset"), this, SLOT(slotResetPosition()));

    m_syncAction = m_configMenu->addAction(i18n("Sync timeline cursor"), this, SLOT(slotSyncCursor()));
    m_syncAction->setCheckable(true);
    m_syncAction->setChecked(KdenliveSettings::transitionfollowcursor());

    //scene->setSceneRect(0, 0, profile->width * 2, profile->height * 2);
    //view->fitInView(m_frameBorder, Qt::KeepAspectRatio);
    const double sc = 100.0 / profile->height() * 0.8;
    QRectF srect = m_sceneview->sceneRect();
    m_sceneview->setSceneRect(srect.x(), -srect.height() / 3 + 10, srect.width(), srect.height() + srect.height() / 3 * 2 - 10);
    m_scene->setZoom(sc);
    m_sceneview->centerOn(frameBorder);
    m_sceneview->setMouseTracking(true);
    connect(buttonNext , SIGNAL(clicked()) , this , SLOT(slotNextFrame()));
    connect(buttonPrevious , SIGNAL(clicked()) , this , SLOT(slotPreviousFrame()));
    connect(buttonDelete , SIGNAL(clicked()) , this , SLOT(slotDeleteFrame()));
    connect(buttonAdd , SIGNAL(clicked()) , this , SLOT(slotAddFrame()));
    connect(m_scene, SIGNAL(actionFinished()), this, SLOT(slotUpdateTransitionProperties()));

    buttonhcenter->setIcon(KoIconUtils::themedIcon(QStringLiteral("kdenlive-align-hor")));
    buttonhcenter->setToolTip(i18n("Align item horizontally"));
    buttonvcenter->setIcon(KoIconUtils::themedIcon(QStringLiteral("kdenlive-align-vert")));
    buttonvcenter->setToolTip(i18n("Align item vertically"));
    buttontop->setIcon(KoIconUtils::themedIcon(QStringLiteral("kdenlive-align-top")));
    buttontop->setToolTip(i18n("Align item to top"));
    buttonbottom->setIcon(KoIconUtils::themedIcon(QStringLiteral("kdenlive-align-bottom")));
    buttonbottom->setToolTip(i18n("Align item to bottom"));
    buttonright->setIcon(KoIconUtils::themedIcon(QStringLiteral("kdenlive-align-right")));
    buttonright->setToolTip(i18n("Align item to right"));
    buttonleft->setIcon(KoIconUtils::themedIcon(QStringLiteral("kdenlive-align-left")));
    buttonleft->setToolTip(i18n("Align item to left"));

    connect(buttonhcenter, SIGNAL(clicked()), this, SLOT(slotAlignHCenter()));
    connect(buttonvcenter, SIGNAL(clicked()), this, SLOT(slotAlignVCenter()));
    connect(buttontop, SIGNAL(clicked()), this, SLOT(slotAlignTop()));
    connect(buttonbottom, SIGNAL(clicked()), this, SLOT(slotAlignBottom()));
    connect(buttonright, SIGNAL(clicked()), this, SLOT(slotAlignRight()));
    connect(buttonleft, SIGNAL(clicked()), this, SLOT(slotAlignLeft()));
    connect(spinX, SIGNAL(valueChanged(int)), this, SLOT(slotGeometryX(int)));
    connect(spinY, SIGNAL(valueChanged(int)), this, SLOT(slotGeometryY(int)));
    connect(spinWidth, SIGNAL(valueChanged(int)), this, SLOT(slotGeometryWidth(int)));
    connect(spinHeight, SIGNAL(valueChanged(int)), this, SLOT(slotGeometryHeight(int)));
    connect(spinResize, SIGNAL(editingFinished()), this, SLOT(slotResizeCustom()));
    connect(buttonResize, SIGNAL(clicked()), this, SLOT(slotResizeOriginal()));

    connect(this, SIGNAL(parameterChanged()), this, SLOT(slotUpdateGeometry()));
}
Ejemplo n.º 25
0
void ChessBoard::renderBoard( QPainter &p, const QRectF &rc, bool flip,
    const std::vector<cheng4::Square> *excludeSquares )
{
    qreal maxh = std::max( rc.width(), rc.height() )/14;
    maxh = 18;
	qreal bordersz = maxh;
	if ( !border )
		bordersz = 0;
	qreal sw = (rc.width() - 2*bordersz) / 8;
	qreal sh = (rc.height() - 2*bordersz) / 8;
    sh = sw = std::min(sw, sh);

    QColor wb[2] = { QColor(255, 255, 255, 255), QColor(0, 0, 0, 255) };

	QColor bord = borderColor;

	QBrush lightb(lightColor);
	QBrush darkb(darkColor);
    p.setPen(Qt::transparent);
    // render border...
    p.setBrush( QBrush(bord) );
	p.drawRect(QRectF(rc.left(), rc.top(), 8*sw + 2*bordersz+1, 8*sh + 2*bordersz+1));

    QPen bpen( QColor(0, 0, 0, 128) );
    bpen.setWidth(1);
    p.setPen( bpen );
    p.setBrush( Qt::transparent );
    QRectF brect;
	brect.setTopLeft( QPoint(bordersz-1, bordersz-1) );
    brect.setSize( QSizeF(8*sw+2, 8*sh+2) );
    p.drawRect( brect );

    brect.setTopLeft( QPoint(0, 0) );
	brect.setSize( QSizeF(8*sw+2*bordersz, 8*sh+2*bordersz) );
    p.drawRect( brect );

    p.setPen( Qt::transparent );

    for (cheng4::Square s = 0; s < 64; s++)
    {
        cheng4::File f = cheng4::SquarePack::file(s);
        cheng4::Rank r = cheng4::SquarePack::rank(s);
		QRectF sub(rc.left() + sw*f + bordersz, rc.top() + sh*r + bordersz, sw, sh);
        cheng4::Square sq = flip ? cheng4::SquarePack::flipH(cheng4::SquarePack::flipV(s)) : s;


        p.setBrush( ((f+r) & 1) ? darkb : lightb );
        p.drawRect( sub );
        if ( excludeSquares && std::find(excludeSquares->begin(), excludeSquares->end(), sq)
             != excludeSquares->end() )
            continue;

        cheng4::Piece pc = board.piece(sq);
        cheng4::Piece pt = cheng4::PiecePack::type(pc);
        if ( pt == cheng4::ptNone )
            continue;
        cheng4::Color c = cheng4::PiecePack::color(pc);
		if ( !pieceSet || !pieceSet->pieces[c][pt-1] )
			continue;
        pieceSet->pieces[c][pt-1]->renderer()->render(&p, sub);
	}

	// FIXME: better!!!
	for (cheng4::Square s = 0; s < 64; s++)
	{
		cheng4::File f = cheng4::SquarePack::file(s);
		cheng4::Rank r = cheng4::SquarePack::rank(s);
		QRectF sub(rc.left() + sw*f + bordersz, rc.top() + sh*r + bordersz, sw, sh);
		cheng4::Square sq = flip ? cheng4::SquarePack::flipH(cheng4::SquarePack::flipV(s)) : s;
		// now highlight!!!
		if ( highlight == cheng4::mcNone || highlight == cheng4::mcNull )
			continue;
		cheng4::Square from, to;
		from = cheng4::MovePack::from(highlight);
		to = cheng4::MovePack::to(highlight);
		if ( sq != from && sq != to )
			continue;

		QPen hpen( highlightColor );
		hpen.setWidth(2);
		p.setPen( hpen );
		p.setBrush( Qt::transparent );
		p.drawRect( sub );
		p.setPen( Qt::transparent );
	}

	if ( !border )
		return;

    // draw board letters
	p.setPen( letterColor );
    QTextOption opt;
    opt.setAlignment(Qt::AlignCenter);
    QFont font;
    font.setBold(0);
    font.setPixelSize(12);
    p.setFont(font);
    for (uint i=0; i<8; i++)
    {
        // rows:
		QPointF pt( 0, bordersz + sh*i );
        QRectF rct;
        rct.setTopLeft( pt );
		rct.setSize( QSizeF( bordersz, sh ) );
        QString text;
        int irow = 7-(int)i;
        if ( flip )
            irow = 8-1-irow;
        text.sprintf("%d", irow+1);
        p.drawText(rct, text, opt);
		pt.setX( bordersz+sw*8 );
        rct.setTopLeft( pt );
		rct.setSize( QSizeF( bordersz, sh ) );
        p.drawText(rct, text, opt);
        // cols:
        int icol = (int)i;
        if ( flip )
            icol = 8-1-i;
        text.sprintf("%c", 'a' + icol);
		pt.setX( bordersz + sw*i );
        pt.setY( 0 );
        rct.setTopLeft(pt);
		rct.setSize( QSizeF( sw, bordersz ) );
        p.drawText(rct, text, opt);
		pt.setY( bordersz+sh*8 );
        rct.setTopLeft( pt );
		rct.setSize( QSizeF( sw, bordersz ) );
        p.drawText(rct, text, opt);
    }
    // draw stm
    QRectF upr;
	upr.setTopLeft( QPointF( bordersz + sw*8 + bordersz/8, bordersz/8 ) );
	upr.setSize( QSizeF( bordersz - 2*bordersz/8, bordersz - 2*bordersz/8 ) );

    bool upper = board.turn() == (flip ? cheng4::ctWhite : cheng4::ctBlack);

    p.setPen( wb[ cheng4::flip(board.turn()) ] );
    p.setBrush( wb[ board.turn() ] );

    if ( upper )
        p.drawRect( upr );

    QRectF lwr;
	lwr.setTopLeft( QPointF( bordersz + sw*8 + bordersz/8, bordersz + sh*8 + bordersz/8 ) );
	lwr.setSize( QSizeF( bordersz - 2*bordersz/8, bordersz - 2*bordersz/8 ) );

    if ( !upper )
        p.drawRect( lwr );
}
void CPlayerLoop::ShowFrame()
{
    // для простоты удаляем все нарисованные объекты
    m_Scene->clear();
    setBackgroundBrush(QBrush(QColor(255,255,255), QPixmap("../player/ground.jpg")));     // сделал траву фоном


    int picPosX = 0;
    int picPosY = 0;
    int infoPosY = 1;
    int textPosX = 0;
   // int textPosY = 2;
  //  qreal Size = picSize/30;
    textPosX = m_Map.GetMapSizeX();


    QGraphicsTextItem* Info = m_Scene->addText("Press 'Space' for start/stop \nPress '+'('-') for to increase (decrease) a speed\n(After this press space twice)");
    Info->setPos(picSize * textPosX, picSize*16);

#if 0
    //  рисуем заново
    QGraphicsPixmapItem* ant = m_Scene->addPixmap(QPixmap("../player/worker.png"));
    ant->scale(2, 2);
    ant->setPos(rand() % m_GameStep, rand() % m_GameStep);

#endif

    for(size_t i = 0; i < m_Map.GetNumberOfAnts(); i++)
        {
            CAnt &ant = m_Map.GetAnt(i);
            std::stringstream sstream;
            sstream  << "AntPosX = "<< ant.GetAntPosX() << ", AntPosY = "<< ant.GetAntPosY() << ",  AntStatus = "<<ant.GetAntStatus();
            QString QStr = QString::fromStdString(sstream.str());

            switch(ant.GetAntType())
            {
            case AtQueen:
            {
                infoPosY++;
                QGraphicsPixmapItem* Queen = m_Scene->addPixmap(QPixmap("../player/queen.png"));
                Queen->setPos(picSize * (ant.GetAntPosX()), picSize *(ant.GetAntPosY()));
                QGraphicsTextItem* Queen_info =  m_Scene->addText(QStr);
                Queen_info->setPos((textPosX+4)*picSize, picSize*infoPosY);
                Queen->scale(Size, Size);
                QGraphicsPixmapItem* Queen2 = m_Scene->addPixmap(QPixmap("../player/queen.png"));
                Queen2->setPos(picSize * textPosX, picSize*infoPosY);
                Queen2->scale(Size, Size);
                QGraphicsTextItem* Queen_name = m_Scene->addText("- Queen");
                Queen_name->setPos(textPosX*(picSize+1)+1, picSize*infoPosY);
                break;
            }
            case  AtWorker:    // 1 - рабочий
            {
                infoPosY++;
                QGraphicsPixmapItem* Worker = m_Scene->addPixmap(QPixmap("../player/worker.jpeg"));
                Worker->setPos(picSize * (ant.GetAntPosX()), picSize *(ant.GetAntPosY()));
                QGraphicsTextItem* Worker_info =  m_Scene->addText(QStr);
                Worker_info->setPos((textPosX+4)*picSize, picSize*infoPosY);
               Worker->scale(Size, Size);
                QGraphicsPixmapItem* Worker2 = m_Scene->addPixmap(QPixmap("../player/worker.jpeg"));
                Worker2->setPos(picSize * textPosX, picSize*(infoPosY));
                  Worker2->scale(Size, Size);
                QGraphicsTextItem* Worker_name = m_Scene->addText("- Worker");
                Worker_name->setPos(textPosX*(picSize+1)+1, picSize*(infoPosY));
                break;
            }
            case AtScout:      // 2 - разведчик
            {
                infoPosY++;
                QGraphicsPixmapItem* Scout = m_Scene->addPixmap(QPixmap("../player/scout.png"));
                Scout->setPos(picSize * (ant.GetAntPosX()), picSize *(ant.GetAntPosY()));
                QGraphicsTextItem* Scout_info =  m_Scene->addText(QStr);
                Scout_info->setPos((textPosX+4)*picSize, picSize*infoPosY);
                Scout->scale(Size, Size);
                QGraphicsPixmapItem* Scout2 = m_Scene->addPixmap(QPixmap("../player/scout.png"));
                Scout2->setPos(picSize * textPosX, infoPosY*picSize);
                 Scout2->scale(Size, Size);
                QGraphicsTextItem* Scout_name = m_Scene->addText("- Scout");
                Scout_name->setPos(textPosX*(picSize+1)+1, infoPosY*picSize);
                break;
            }
            case AtTracker:       // 3 - следопыт
            {
                infoPosY++;
                QGraphicsPixmapItem* Tracker = m_Scene->addPixmap(QPixmap("../player/tracker.png"));
                Tracker->setPos(picSize * (ant.GetAntPosX()), picSize *(ant.GetAntPosY()));
                QGraphicsTextItem* Tracker_info =  m_Scene->addText(QStr);
                Tracker_info->setPos((textPosX+4)*picSize, picSize*infoPosY);
                Tracker->scale(Size, Size);
                QGraphicsPixmapItem* Tracker2 = m_Scene->addPixmap(QPixmap("../player/tracker.png"));
                Tracker2->setPos(picSize * textPosX, infoPosY*picSize);
                   Tracker2->scale(Size, Size);
                QGraphicsTextItem* Tracker_info2 = m_Scene->addText("- Tracker");
                Tracker_info2->setPos(textPosX*(picSize+1)+1, infoPosY*picSize);
                break;
            }
            case   AtSapper:       // 4 - сапер
            {
                infoPosY++;
                QGraphicsPixmapItem* Sapper = m_Scene->addPixmap(QPixmap("../player/sapper.jpeg"));
                Sapper->setPos(picSize * (ant.GetAntPosX()), picSize *(ant.GetAntPosY()));
                 Sapper->scale(0.2*Size, Size*0.2);
                QGraphicsTextItem* Sapper_info =  m_Scene->addText(QStr);
                Sapper_info->setPos((textPosX+4)*picSize, picSize*infoPosY);
                QGraphicsPixmapItem* Sapper2 = m_Scene->addPixmap(QPixmap("../player/sapper.jpeg"));
                Sapper2->setPos(picSize * textPosX, infoPosY*picSize);
                QGraphicsTextItem* Sapper_info2 = m_Scene->addText("- Sapper");
                Sapper_info2->setPos(textPosX*(picSize+1)+1, infoPosY*picSize);
                Sapper2->scale(0.2*Size, 0.2*Size);
                break;
            }
            case   AtDoctor:       // 5 - врач
            {
                infoPosY++;
                QGraphicsPixmapItem* Doctor = m_Scene->addPixmap(QPixmap("../player/doctor.png"));
                Doctor->setPos(picSize * (ant.GetAntPosX()), picSize *(ant.GetAntPosY()));
                QGraphicsTextItem* Doctor_info =  m_Scene->addText(QStr);
                Doctor_info->setPos((textPosX+4)*picSize, picSize*infoPosY);
                Doctor->scale(Size, Size);
                QGraphicsPixmapItem* Doctor2 = m_Scene->addPixmap(QPixmap("../player/doctor.png"));
                Doctor2->setPos(picSize * textPosX, picSize *infoPosY);
                 Doctor2->scale(Size, Size);
                QGraphicsTextItem* Doctor_info2 = m_Scene->addText("- Doctor");
                Doctor_info2->setPos(textPosX*(picSize+1)+1, picSize*infoPosY);
                break;
            }
            case   AtTutor:       // 6 - воспитатель
            {
                infoPosY++;
                QGraphicsPixmapItem* Tutor = m_Scene->addPixmap(QPixmap("../player/tutor.jpeg"));
                Tutor->setPos(picSize * (ant.GetAntPosX()), picSize *(ant.GetAntPosY()));
                Tutor->scale(TrapScale*Size, TrapScale*Size);
                QGraphicsTextItem* Tutor_info =  m_Scene->addText(QStr);
                Tutor_info->setPos((textPosX+4)*picSize, picSize*infoPosY);
                QGraphicsPixmapItem* Tutor2 = m_Scene->addPixmap(QPixmap("../player/tutor.jpeg"));
                Tutor2->setPos(picSize * textPosX,infoPosY*picSize);
                QGraphicsTextItem* Tutor_info2 = m_Scene->addText("- Tutor");
                Tutor_info2->setPos(textPosX*(picSize+1)+1, infoPosY*picSize);
                Tutor2->scale(TrapScale*Size, Size*TrapScale);
                break;
            }
            case AtFarmer:       // 7 - фермер
            {
                infoPosY++;
                QGraphicsPixmapItem* Farmer = m_Scene->addPixmap(QPixmap("../player/farmer.png"));
                Farmer->setPos(picSize * (ant.GetAntPosX()), picSize *(ant.GetAntPosY()));
                QGraphicsTextItem* Farmer_info =  m_Scene->addText(QStr);
                Farmer_info->setPos((textPosX+4)*picSize, picSize*infoPosY);
                Farmer->scale(Size, Size);
                QGraphicsPixmapItem* Farmer2 = m_Scene->addPixmap(QPixmap("../player/farmer.jpg"));
                Farmer2->setPos(picSize * textPosX, infoPosY*picSize);
                Farmer2->scale(Size, Size);
                QGraphicsTextItem* Farmer_info2 = m_Scene->addText("- Farmer");
                Farmer_info2->setPos(textPosX*(picSize+1)+1, infoPosY*picSize);
                break;
            }
            case AtHunter:     // 8 - охотник
            {
                infoPosY++;
                QGraphicsPixmapItem* Hunter = m_Scene->addPixmap(QPixmap("../player/hunter.png"));
                Hunter->setPos(picSize * (ant.GetAntPosX()), picSize *(ant.GetAntPosY()));
                QGraphicsTextItem* Hunter_info =  m_Scene->addText(QStr);
                Hunter_info->setPos((textPosX+4)*picSize, picSize*infoPosY);
                Hunter->scale(0.188*Size, 0.188*Size);
                QGraphicsPixmapItem* Hunter2 = m_Scene->addPixmap(QPixmap("../player/hunter.jpeg"));
                Hunter2->setPos(picSize * textPosX, infoPosY*picSize);
                QGraphicsTextItem* Hunter_info2 = m_Scene->addText("- Hunter");
                Hunter_info2->setPos(textPosX*(picSize+1)+1, infoPosY*picSize);
                Hunter2->scale(0.188*Size, 0.188*Size);
                break;
            }
            case  AtManager:      // 9 - завхоз
            {
                infoPosY++;
                QGraphicsPixmapItem* Manager = m_Scene->addPixmap(QPixmap("../player/manager.gif"));
                Manager->setPos(picSize * (ant.GetAntPosX()), picSize *(ant.GetAntPosY()));
                Manager->scale(0.08*Size, 0.08*Size);
                QGraphicsTextItem* Manager_info =  m_Scene->addText(QStr);
                Manager_info->setPos((textPosX+4)*picSize, picSize*infoPosY);
                QGraphicsPixmapItem* Manager2 = m_Scene->addPixmap(QPixmap("../player/manager.gif"));
                Manager2->setPos(picSize * textPosX, picSize *infoPosY);
                QGraphicsTextItem* Manager_info2 = m_Scene->addText("- Manager");
                Manager_info2->setPos(textPosX*(picSize+1)+1, infoPosY*picSize);
                Manager2->scale(0.08*Size, 0.08*Size);

                break;
            }
            case   AtCowboy:     // 10 - пастух
            {
                infoPosY++;
                QGraphicsPixmapItem* Cowboy = m_Scene->addPixmap(QPixmap("../player/cowboy.png"));
                Cowboy->setPos(picSize * (ant.GetAntPosX()), picSize *(ant.GetAntPosY()));
                QGraphicsTextItem* Cowboy_info =  m_Scene->addText(QStr);
                Cowboy_info->setPos((textPosX+4)*picSize, picSize*infoPosY);
                Cowboy->scale(1*Size,Size*0.7);
                QGraphicsPixmapItem* Cowboy2 = m_Scene->addPixmap(QPixmap("../player/cowboy.png"));
                Cowboy2->setPos(picSize * textPosX, picSize *infoPosY);
                QGraphicsTextItem* Cowboy_info2 = m_Scene->addText("- Cowboy");
                Cowboy_info2->setPos(textPosX*(picSize+1)+1, infoPosY*picSize);
                Cowboy2->scale(1*Size,0.7*Size);
                break;
            }
            case  AtCow:     // 11 - коровка
            {
                infoPosY++;
                QGraphicsPixmapItem* Cow = m_Scene->addPixmap(QPixmap("../player/cow.jpeg"));
                Cow->setPos(picSize * (ant.GetAntPosX()), picSize *(ant.GetAntPosY()));
                QGraphicsTextItem* Cow_info =  m_Scene->addText(QStr);
                Cow_info->setPos((textPosX+4)*picSize, picSize*infoPosY);
                Cow->scale(0.1875*Size, 0.1875*Size);

                QGraphicsPixmapItem* Cow2 = m_Scene->addPixmap(QPixmap("../player/cow.jpeg"));
                Cow2->setPos(picSize * textPosX, picSize*infoPosY);
                QGraphicsTextItem* Cow_name = m_Scene->addText("- Cow");
                Cow_name->setPos(textPosX*(picSize+1)+1, picSize*infoPosY);
                Cow2->scale(0.1875*Size, 0.1875*Size);
                break;
            }
            case   AtLion:
            {
                infoPosY++;
                QGraphicsPixmapItem* Lion = m_Scene->addPixmap(QPixmap("../player/lion.png"));
                Lion->setPos(picSize * (ant.GetAntPosX()), picSize *(ant.GetAntPosY()));
                QGraphicsTextItem* Lion_info =  m_Scene->addText(QStr);
                Lion_info->setPos((textPosX+4)*picSize, picSize*infoPosY);
                Lion->scale(Size, Size);
                QGraphicsPixmapItem* Lion2 = m_Scene->addPixmap(QPixmap("../player/lion.png"));
                Lion2->setPos(picSize * textPosX, picSize *infoPosY);
                Lion2->scale(Size, Size);
                QGraphicsTextItem* Lion_info2 = m_Scene->addText("- Lion");
                Lion_info2->setPos(textPosX*(picSize+1)+1, infoPosY*picSize);
                break;
            }
            case   AtUnknown:
            {
                QGraphicsPixmapItem* Unknown = m_Scene->addPixmap(QPixmap("../player/unknown.png"));
                Unknown->setPos(picSize * (ant.GetAntPosX()), picSize *(ant.GetAntPosY()));
                break;
            }
            case   AtCount:
            {
                QGraphicsPixmapItem* Count = m_Scene->addPixmap(QPixmap("../player/ant.png"));
                Count->setPos(picSize * (ant.GetAntPosX()), picSize *(ant.GetAntPosY()));
                break;
            }
            }

        }
       infoPosY = 1;
    for(int i=0;i<m_Map.GetMapSizeX()*m_Map.GetMapSizeY();i++)
        {

            switch(m_Map.Cell(picPosX, picPosY))
            {

            case McTrap:
            {
                QGraphicsPixmapItem* Trap = m_Scene->addPixmap(QPixmap("../player/trap.jpeg"));
                Trap->setPos(picSize * picPosX, picSize * picPosY);
                picPosX = picPosX + 1;
                Trap->scale(0.133*Size,0.133*Size);

                if(picPosX == m_Map.GetMapSizeX())
                {
                    picPosX = 0;
                    picPosY = picPosY + 1;
                }
                break;
            }
            case McUnknown:
            {
                QGraphicsPixmapItem* Unknown = m_Scene->addPixmap(QPixmap("../player/unknown.png"));
                Unknown->setPos(picSize * picPosX, picSize * picPosY);
                picPosX = picPosX + 1;
                if(picPosX == m_Map.GetMapSizeX())
                {
                    picPosX = 0;
                    picPosY = picPosY + 1;
                }
                break;
            }
            case McWater:
            {
                QGraphicsPixmapItem* Water = m_Scene->addPixmap(QPixmap("../player/water.png"));
                Water->setPos(picSize*picPosX, picSize*picPosY);
                Water->scale(Size, Size);
                picPosX = picPosX + 1;
                if(picPosX == m_Map.GetMapSizeX())
                {
                    picPosX = 0;
                    picPosY = picPosY + 1;
                }
                break;
            }
            case McWall:
            {
                QGraphicsPixmapItem* Wall = m_Scene->addPixmap(QPixmap("../player/wall.png"));
                Wall->setPos(picSize*picPosX, picSize*picPosY);
                Wall->scale(Size, Size);
                picPosX = picPosX + 1;
                if(picPosX==m_Map.GetMapSizeX())
                {
                    picPosX = 0;
                    picPosY = picPosY + 1;
                }
                break;
            }
            case McHill:
            {
                QGraphicsPixmapItem* Hill = m_Scene->addPixmap(QPixmap("../player/hill.png"));
                Hill->setPos(picSize * picPosX, picSize * picPosY);
                picPosX = picPosX + 1;
                Hill->scale(Size, Size);
                if(picPosX == m_Map.GetMapSizeX())
                {
                    picPosX = 0;
                    picPosY = picPosY + 1;
                }
                break;
            }
            case McGround:
            {
                // сделал траву фоном (строка 43)
                // QGraphicsPixmapItem* Ground = m_Scene->addPixmap(QPixmap("../player/ground.jpg"));
                //  Ground->setPos(picSize * picPosX, picSize * picPosY);
                picPosX = picPosX + 1;
                if(picPosX == m_Map.GetMapSizeX())
                {
                    picPosX = 0;
                    picPosY = picPosY + 1;
                }
                break;
            }
            case McFood:
            {
                QGraphicsPixmapItem*  Food = m_Scene->addPixmap(QPixmap("../player/food.png"));
                Food->setPos(picSize * picPosX, picSize * picPosY);
                picPosX = picPosX + 1;
                Food->scale(Size, Size);
                if(picPosX == m_Map.GetMapSizeX())
                {
                    picPosX = 0;
                    picPosY = picPosY + 1;
                }

                break;
            }
            case McStick:
            {
                QGraphicsPixmapItem* Stick = m_Scene->addPixmap(QPixmap("../player/stick.png"));
                Stick->setPos(picSize * picPosX, picSize * picPosY);
                picPosX = picPosX + 1;
                Stick->scale(Size, Size);
                if(picPosX == m_Map.GetMapSizeX())
                {
                    picPosX = 0;
                    picPosY = picPosY + 1;
                }
                break;
            }
            case McStock:
            {
                QGraphicsPixmapItem* Stock = m_Scene->addPixmap(QPixmap("../player/stock.jpeg"));
                Stock->setPos(picSize * picPosX, picSize * picPosY);
                picPosX = picPosX + 1;
                Stock->scale(Size/4, Size/4);
                if(picPosX == m_Map.GetMapSizeX())
                {
                    picPosX = 0;
                    picPosY = picPosY + 1;
                }
                break;
            }

            case McWay:
            {
                QGraphicsPixmapItem* Way = m_Scene->addPixmap(QPixmap("../player/ground.jpg"));
                Way->setPos(picSize * picPosX, picSize * picPosY);
                picPosX = picPosX + 1;
                if(picPosX == m_Map.GetMapSizeX())
                {
                    picPosX = 0;
                    picPosY = picPosY + 1;
                }
                break;
            }

            case McError:
            {
                QGraphicsPixmapItem* Error = m_Scene->addPixmap(QPixmap("../player/unknown.png"));
                Error->setPos(picSize * picPosX, picSize * picPosY);
                picPosX = picPosX + 1;
                if(picPosX == m_Map.GetMapSizeX())
                {
                    picPosX = 0;
                    picPosY = picPosY + 1;
                }
                break;
            }

            }
        }


    std::stringstream sstream;
    sstream  << "MapSize = "<<m_Map.GetMapSizeX() << "\nGame step = " << m_GameStep;
    QString QStr = QString::fromStdString(sstream.str());
    QGraphicsTextItem* Size_of_Map = m_Scene->addText(QStr);
    Size_of_Map->setPos((m_Map.GetMapSizeX()+1)*picSize, 1);



    // перерисовываем окно вывода
    repaint();

}
QVariant CComputerConfModel::data(const QModelIndex &stIndex, int role) const
{
	if (!stIndex.isValid())
		return QVariant();
	int iRow = stIndex.row();
	int iColumn = stIndex.column();
	if (iRow>rowCount()-1 || iColumn>columnCount()-1)
		return QVariant();
	bool bCellActive(true);
	if (false){}
#ifdef VIEW_WITH_FROZEN_COLUMN
	else if (iColumn==0 && iRow!=0)
		bCellActive=m_ptrPriv->vComponentsList[iRow-FROZEN_ROW_FIX].bActive;
#endif
#ifdef VIEW_WITH_FROZEN_ROW
	else if (iColumn!=0 && iRow==0)
		bCellActive=m_ptrPriv->vShopsList[iColumn-FROZEN_COLUMN_FIX].bActive;
#endif
#if defined(VIEW_WITH_FROZEN_COLUMN) && defined(VIEW_WITH_FROZEN_ROW)
	else if (iColumn==0 && iRow==0)
		bCellActive=true;
#endif
	else 
		bCellActive=m_ptrPriv->vvPricesMatrix[iRow-FROZEN_ROW_FIX][iColumn-FROZEN_COLUMN_FIX].bActive;
	switch(role)
	{
	case Qt::TextAlignmentRole:
		return Qt::AlignCenter;
	case Qt::FontRole:
		#ifdef VIEW_WITH_FROZEN_COLUMN
			if (iColumn==0 && bCellActive)
			{
				return m_ptrPriv->m_BoldFont;
			}
		#endif
		#ifdef VIEW_WITH_FROZEN_ROW
			if (iRow==0 && bCellActive)
			{
				return m_ptrPriv->m_BoldFont;
			}
		#endif
		return m_ptrPriv->m_currentFont;
	case Qt::BackgroundRole:
		{
		#ifdef VIEW_WITH_FROZEN_COLUMN
			if (iColumn==0)
			{
				if (bCellActive)
					return QBrush(ccFrozenRowColumnColor);
				else
					return QBrush(ccFrozenDisRowColumnColor);
			}
		#endif
		#ifdef VIEW_WITH_FROZEN_ROW
			if (iRow==0)
			{
				if (bCellActive)
					return QBrush(ccFrozenRowColumnColor);
				else
					return QBrush(ccFrozenDisRowColumnColor);
			}
		#endif
			if (bCellActive)
			{
				const CompShopPriceEntry & eEntry = m_ptrPriv->vvPricesMatrix[iRow-FROZEN_ROW_FIX][iColumn-FROZEN_COLUMN_FIX];
				if (eEntry.bBestPrice)
					return QBrush(ccBestPriceColor);
				else if (eEntry.bWorsePrice)
					return QBrush(ccWorstColor);
				else if (eEntry.eSearchResult!=SR_NONE && eEntry.eSearchResult!=SR_COMPFOUND)
					return QBrush(ccRefreshError);
				else
					return QBrush(ccDefaultColor);
			}
			return QBrush(ccDisableColor);
		}
	case Qt::DecorationRole:
#if defined(VIEW_WITH_FROZEN_COLUMN)
		if (iColumn==0)	return QVariant();
#endif
#if defined(VIEW_WITH_FROZEN_ROW)
		if (iRow==0)	return QVariant();
#endif
		{
			const CompShopPriceEntry & eEntry = m_ptrPriv->vvPricesMatrix[iRow-FROZEN_ROW_FIX][iColumn-FROZEN_COLUMN_FIX];
			if (eEntry.bBestPrice)
				return m_ptrPriv->cBestIcon;
			if (eEntry.bWorsePrice)
				return m_ptrPriv->cWorstIcon;
			if (eEntry.eSearchResult==SR_LOADINGTIMEOUT)
				return m_ptrPriv->cTimeoutIcon;
			if (eEntry.eSearchResult!=SR_NONE && eEntry.eSearchResult!=SR_COMPFOUND)
				return m_ptrPriv->cErrorIcon;
			if (eEntry.bCellIsRefreshing)
				return m_ptrPriv->cSearchingIcon;
			break;
		}
	case Role_CompShopPrice:
	case Qt::DisplayRole:
	case Qt::EditRole:
		double dPrice;
#ifdef VIEW_WITH_FROZEN_COLUMN
		if (iColumn==0 && iRow!=0)
		{
			dPrice = m_ptrPriv->vComponentsList[iRow-FROZEN_ROW_FIX].dBestPrice;
			return m_ptrPriv->m_Locale.toString(dPrice,'f',0);
		}
#endif
#ifdef VIEW_WITH_FROZEN_ROW
		if (iRow==0 && iColumn!=0)
		{
			dPrice = m_ptrPriv->vShopsList[iColumn-FROZEN_COLUMN_FIX].dComponentPriceSum;
			return m_ptrPriv->m_Locale.toString(dPrice,'f',0);
		}
#endif
#ifdef VIEW_WITH_FROZEN_ROW
#ifdef VIEW_WITH_FROZEN_COLUMN
		if (iRow==0 && iColumn==0)
		{
			return m_ptrPriv->m_Locale.toString(m_ptrPriv->m_iBestPricesSum,'f',0);
		}
#endif
#endif
		dPrice = m_ptrPriv->vvPricesMatrix[iRow-FROZEN_ROW_FIX][iColumn-FROZEN_COLUMN_FIX].dPrice;
		return m_ptrPriv->m_Locale.toString(dPrice,'f',0);
	case Role_CompShopURL:
#if defined(VIEW_WITH_FROZEN_COLUMN)
		if (iColumn==0)	return QVariant();
#endif
#if defined(VIEW_WITH_FROZEN_ROW)
		if (iRow==0)	return QVariant();
#endif
		return m_ptrPriv->vvPricesMatrix[iRow-FROZEN_ROW_FIX][iColumn-FROZEN_COLUMN_FIX].strURL;
	case Role_CompShopSearchURL:
#if defined(VIEW_WITH_FROZEN_COLUMN)
		if (iColumn==0)	return QVariant();
#endif
#if defined(VIEW_WITH_FROZEN_ROW)
		if (iRow==0)	return QVariant();
#endif
		{
			QString strSearchURL = m_ptrPriv->vvPricesMatrix[iRow-FROZEN_ROW_FIX][iColumn-FROZEN_COLUMN_FIX].strSearchPageURL;
			if (strSearchURL.isEmpty())
			{
				QString strShopName = m_ptrPriv->vShopsList[iColumn-FROZEN_COLUMN_FIX].strName;
				strSearchURL= m_ptrPriv->mPlugins[strShopName]->getSearchProductPageURL(m_ptrPriv->vComponentsList[iRow-FROZEN_ROW_FIX].strName);
			}
			return strSearchURL;
		}
	case Role_CellIsRefreshing:
#if defined(VIEW_WITH_FROZEN_COLUMN)
		if (iColumn==0)	return QVariant();
#endif
#if defined(VIEW_WITH_FROZEN_ROW)
		if (iRow==0)	return QVariant();
#endif
		return m_ptrPriv->vvPricesMatrix[iRow-FROZEN_ROW_FIX][iColumn-FROZEN_COLUMN_FIX].bCellIsRefreshing;
	case Role_CellRefreshProgress:
#if defined(VIEW_WITH_FROZEN_COLUMN)
		if (iColumn==0)	return QVariant();
#endif
#if defined(VIEW_WITH_FROZEN_ROW)
		if (iRow==0)	return QVariant();
#endif
		return m_ptrPriv->vvPricesMatrix[iRow-FROZEN_ROW_FIX][iColumn-FROZEN_COLUMN_FIX].iRefreshProgress;
		break;
	}
	return QVariant();
}
Ejemplo n.º 28
0
QgsDiagramProperties::QgsDiagramProperties( QgsVectorLayer* layer, QWidget* parent )
    : QWidget( parent )
{
  mLayer = layer;

  if ( !layer )
  {
    return;
  }

  setupUi( this );

  // get rid of annoying outer focus rect on Mac
  mDiagramOptionsListWidget->setAttribute( Qt::WA_MacShowFocusRect, false );

  connect( mEnableDiagramsCheckBox, SIGNAL( toggled( bool ) ), mDiagramTypeFrame, SLOT( setEnabled( bool ) ) );
  connect( mEnableDiagramsCheckBox, SIGNAL( toggled( bool ) ), mDiagramFrame, SLOT( setEnabled( bool ) ) );

  mScaleRangeWidget->setMapCanvas( QgisApp::instance()->mapCanvas() );

  mBackgroundColorButton->setColorDialogTitle( tr( "Select background color" ) );
  mBackgroundColorButton->setAllowAlpha( true );
  mBackgroundColorButton->setContext( "symbology" );
  mBackgroundColorButton->setShowNoColor( true );
  mBackgroundColorButton->setNoColorString( tr( "Transparent background" ) );
  mDiagramPenColorButton->setColorDialogTitle( tr( "Select pen color" ) );
  mDiagramPenColorButton->setAllowAlpha( true );
  mDiagramPenColorButton->setContext( "symbology" );
  mDiagramPenColorButton->setShowNoColor( true );
  mDiagramPenColorButton->setNoColorString( tr( "Transparent outline" ) );

  mMaxValueSpinBox->setShowClearButton( false );

  mDiagramUnitComboBox->insertItem( 0, tr( "mm" ), QgsDiagramSettings::MM );
  mDiagramUnitComboBox->insertItem( 1, tr( "Map units" ), QgsDiagramSettings::MapUnits );

  QGis::GeometryType layerType = layer->geometryType();
  if ( layerType == QGis::UnknownGeometry || layerType == QGis::NoGeometry )
  {
    mEnableDiagramsCheckBox->setChecked( false );
    mEnableDiagramsCheckBox->setEnabled( false );
    mDiagramTypeFrame->setEnabled( false );
    mDiagramFrame->setEnabled( false );
  }

  //insert placement options
  mPlacementComboBox->blockSignals( true );
  switch ( layerType )
  {
    case QGis::Point:
      mPlacementComboBox->addItem( tr( "Around Point" ), QgsDiagramLayerSettings::AroundPoint );
      mPlacementComboBox->addItem( tr( "Over Point" ), QgsDiagramLayerSettings::OverPoint );
      mLinePlacementFrame->setVisible( false );
      break;
    case QGis::Line:
      mPlacementComboBox->addItem( tr( "Around Line" ), QgsDiagramLayerSettings::Line );
      mPlacementComboBox->addItem( tr( "Over Line" ), QgsDiagramLayerSettings::Horizontal );
      mLinePlacementFrame->setVisible( true );
      break;
    case QGis::Polygon:
      mPlacementComboBox->addItem( tr( "Around Centroid" ), QgsDiagramLayerSettings::AroundPoint );
      mPlacementComboBox->addItem( tr( "Over Centroid" ), QgsDiagramLayerSettings::OverPoint );
      mPlacementComboBox->addItem( tr( "Perimeter" ), QgsDiagramLayerSettings::Line );
      mPlacementComboBox->addItem( tr( "Inside Polygon" ), QgsDiagramLayerSettings::Horizontal );
      mLinePlacementFrame->setVisible( false );
      break;
    default:
      break;
  }
  mPlacementComboBox->blockSignals( false );

  mDiagramTypeComboBox->blockSignals( true );
  QPixmap pix = QgsApplication::getThemePixmap( "pie-chart" );
  mDiagramTypeComboBox->addItem( pix, tr( "Pie chart" ), DIAGRAM_NAME_PIE );
  pix = QgsApplication::getThemePixmap( "text" );
  mDiagramTypeComboBox->addItem( pix, tr( "Text diagram" ), DIAGRAM_NAME_TEXT );
  pix = QgsApplication::getThemePixmap( "histogram" );
  mDiagramTypeComboBox->addItem( pix, tr( "Histogram" ), DIAGRAM_NAME_HISTOGRAM );
  mDiagramTypeComboBox->blockSignals( false );

  mLabelPlacementComboBox->addItem( tr( "Height" ), QgsDiagramSettings::Height );
  mLabelPlacementComboBox->addItem( tr( "x-height" ), QgsDiagramSettings::XHeight );

  mScaleDependencyComboBox->addItem( tr( "Area" ), true );
  mScaleDependencyComboBox->addItem( tr( "Diameter" ), false );

  mDataDefinedXComboBox->addItem( tr( "None" ), -1 );
  mDataDefinedYComboBox->addItem( tr( "None" ), -1 );

  mAngleOffsetComboBox->addItem( tr( "Top" ), 90 * 16 );
  mAngleOffsetComboBox->addItem( tr( "Right" ), 0 );
  mAngleOffsetComboBox->addItem( tr( "Bottom" ), 270 * 16 );
  mAngleOffsetComboBox->addItem( tr( "Left" ), 180 * 16 );

  QSettings settings;

  // reset horiz strech of left side of options splitter (set to 1 for previewing in Qt Designer)
  QSizePolicy policy( mDiagramOptionsListFrame->sizePolicy() );
  policy.setHorizontalStretch( 0 );
  mDiagramOptionsListFrame->setSizePolicy( policy );
  if ( !settings.contains( QString( "/Windows/Diagrams/OptionsSplitState" ) ) )
  {
    // set left list widget width on intial showing
    QList<int> splitsizes;
    splitsizes << 115;
    mDiagramOptionsSplitter->setSizes( splitsizes );
  }

  // restore dialog, splitters and current tab
  mDiagramOptionsSplitter->restoreState( settings.value( QString( "/Windows/Diagrams/OptionsSplitState" ) ).toByteArray() );
  mDiagramOptionsListWidget->setCurrentRow( settings.value( QString( "/Windows/Diagrams/Tab" ), 0 ).toInt() );

  // field combo and expression button
  mSizeFieldExpressionWidget->setLayer( mLayer );
  QgsDistanceArea myDa;
  myDa.setSourceCrs( mLayer->crs().srsid() );
  myDa.setEllipsoidalMode( QgisApp::instance()->mapCanvas()->mapSettings().hasCrsTransformEnabled() );
  myDa.setEllipsoid( QgsProject::instance()->readEntry( "Measure", "/Ellipsoid", GEO_NONE ) );
  mSizeFieldExpressionWidget->setGeomCalculator( myDa );

  //insert all attributes into the combo boxes
  const QgsFields& layerFields = layer->pendingFields();
  for ( int idx = 0; idx < layerFields.count(); ++idx )
  {
    QTreeWidgetItem *newItem = new QTreeWidgetItem( mAttributesTreeWidget );
    QString name = QString( "\"%1\"" ).arg( layerFields[idx].name() );
    newItem->setText( 0, name );
    newItem->setData( 0, Qt::UserRole, name );
    newItem->setFlags( newItem->flags() & ~Qt::ItemIsDropEnabled );

    mDataDefinedXComboBox->addItem( layerFields[idx].name(), idx );
    mDataDefinedYComboBox->addItem( layerFields[idx].name(), idx );
  }

  const QgsDiagramRendererV2* dr = layer->diagramRenderer();
  if ( !dr ) //no diagram renderer yet, insert reasonable default
  {
    mEnableDiagramsCheckBox->setChecked( false );
    mDiagramTypeFrame->setEnabled( false );
    mDiagramFrame->setEnabled( false );
    mFixedSizeRadio->setChecked( true );
    mDiagramUnitComboBox->setCurrentIndex( mDiagramUnitComboBox->findText( tr( "mm" ) ) );
    mLabelPlacementComboBox->setCurrentIndex( mLabelPlacementComboBox->findText( tr( "x-height" ) ) );
    mDiagramSizeSpinBox->setEnabled( true );
    mDiagramSizeSpinBox->setValue( 15 );
    mLinearScaleFrame->setEnabled( false );
    mIncreaseMinimumSizeSpinBox->setEnabled( false );
    mIncreaseMinimumSizeLabel->setEnabled( false );
    mBarWidthSpinBox->setValue( 5 );
    mScaleVisibilityGroupBox->setChecked( layer->hasScaleBasedVisibility() );
    mScaleRangeWidget->setScaleRange( 1.0 / layer->maximumScale(), 1.0 / layer->minimumScale() ); // caution: layer uses scale denoms, widget uses true scales
    mShowAllCheckBox->setChecked( true );

    switch ( layerType )
    {
      case QGis::Point:
        mPlacementComboBox->setCurrentIndex( mPlacementComboBox->findData( QgsDiagramLayerSettings::AroundPoint ) );
        break;
      case QGis::Line:
        mPlacementComboBox->setCurrentIndex( mPlacementComboBox->findData( QgsDiagramLayerSettings::Line ) );
        chkLineAbove->setChecked( true );
        chkLineBelow->setChecked( false );
        chkLineOn->setChecked( false );
        chkLineOrientationDependent->setChecked( false );
        break;
      case QGis::Polygon:
        mPlacementComboBox->setCurrentIndex( mPlacementComboBox->findData( QgsDiagramLayerSettings::AroundPoint ) );
        break;
      case QGis::UnknownGeometry:
      case QGis::NoGeometry:
        break;
    }
    mBackgroundColorButton->setColor( QColor( 255, 255, 255, 255 ) );
    mDiagramTypeComboBox->blockSignals( true );
    mDiagramTypeComboBox->setCurrentIndex( 0 );
    mDiagramTypeComboBox->blockSignals( false );
    //force a refresh of widget status to match diagram type
    on_mDiagramTypeComboBox_currentIndexChanged( mDiagramTypeComboBox->currentIndex() );
  }
  else // already a diagram renderer present
  {
    //single category renderer or interpolated one?
    if ( dr->rendererName() == "SingleCategory" )
    {
      mFixedSizeRadio->setChecked( true );
    }
    else
    {
      mAttributeBasedScalingRadio->setChecked( true );
    }
    mDiagramSizeSpinBox->setEnabled( mFixedSizeRadio->isChecked() );
    mLinearScaleFrame->setEnabled( mAttributeBasedScalingRadio->isChecked() );

    //assume single category or linearly interpolated diagram renderer for now
    QList<QgsDiagramSettings> settingList = dr->diagramSettings();
    if ( settingList.size() > 0 )
    {
      mEnableDiagramsCheckBox->setChecked( settingList.at( 0 ).enabled );
      mDiagramTypeFrame->setEnabled( mEnableDiagramsCheckBox->isChecked() );
      mDiagramFrame->setEnabled( mEnableDiagramsCheckBox->isChecked() );
      mDiagramFont = settingList.at( 0 ).font;
      QSizeF size = settingList.at( 0 ).size;
      mBackgroundColorButton->setColor( settingList.at( 0 ).backgroundColor );
      mTransparencySpinBox->setValue( settingList.at( 0 ).transparency * 100.0 / 255.0 );
      mDiagramPenColorButton->setColor( settingList.at( 0 ).penColor );
      mPenWidthSpinBox->setValue( settingList.at( 0 ).penWidth );
      mDiagramSizeSpinBox->setValue(( size.width() + size.height() ) / 2.0 );
      // caution: layer uses scale denoms, widget uses true scales
      mScaleRangeWidget->setScaleRange( 1.0 / ( settingList.at( 0 ).maxScaleDenominator > 0 ? settingList.at( 0 ).maxScaleDenominator : layer->maximumScale() ),
                                        1.0 / ( settingList.at( 0 ).minScaleDenominator > 0 ? settingList.at( 0 ).minScaleDenominator : layer->minimumScale() ) );
      mScaleVisibilityGroupBox->setChecked( settingList.at( 0 ).scaleBasedVisibility );
      if ( settingList.at( 0 ).sizeType == QgsDiagramSettings::MM )
      {
        mDiagramUnitComboBox->setCurrentIndex( 0 );
      }
      else
      {
        mDiagramUnitComboBox->setCurrentIndex( 1 );
      }

      if ( settingList.at( 0 ).labelPlacementMethod == QgsDiagramSettings::Height )
      {
        mLabelPlacementComboBox->setCurrentIndex( 0 );
      }
      else
      {
        mLabelPlacementComboBox->setCurrentIndex( 1 );
      }

      mAngleOffsetComboBox->setCurrentIndex( mAngleOffsetComboBox->findData( settingList.at( 0 ).angleOffset ) );

      mOrientationLeftButton->setProperty( "direction", QgsDiagramSettings::Left );
      mOrientationRightButton->setProperty( "direction", QgsDiagramSettings::Right );
      mOrientationUpButton->setProperty( "direction", QgsDiagramSettings::Up );
      mOrientationDownButton->setProperty( "direction", QgsDiagramSettings::Down );
      switch ( settingList.at( 0 ).diagramOrientation )
      {
        case QgsDiagramSettings::Left:
          mOrientationLeftButton->setChecked( true );
          break;

        case QgsDiagramSettings::Right:
          mOrientationRightButton->setChecked( true );
          break;

        case QgsDiagramSettings::Up:
          mOrientationUpButton->setChecked( true );
          break;

        case QgsDiagramSettings::Down:
          mOrientationDownButton->setChecked( true );
          break;
      }

      mBarWidthSpinBox->setValue( settingList.at( 0 ).barWidth );

      mIncreaseSmallDiagramsCheck->setChecked( settingList.at( 0 ).minimumSize != 0 );
      mIncreaseMinimumSizeSpinBox->setEnabled( mIncreaseSmallDiagramsCheck->isChecked() );
      mIncreaseMinimumSizeLabel->setEnabled( mIncreaseSmallDiagramsCheck->isChecked() );

      mIncreaseMinimumSizeSpinBox->setValue( settingList.at( 0 ).minimumSize );

      if ( settingList.at( 0 ).scaleByArea )
      {
        mScaleDependencyComboBox->setCurrentIndex( 0 );
      }
      else
      {
        mScaleDependencyComboBox->setCurrentIndex( 1 );
      }

      QList< QColor > categoryColors = settingList.at( 0 ).categoryColors;
      QList< QString > categoryAttributes = settingList.at( 0 ).categoryAttributes;
      QList< QString >::const_iterator catIt = categoryAttributes.constBegin();
      QList< QColor >::const_iterator coIt = categoryColors.constBegin();
      for ( ; catIt != categoryAttributes.constEnd(); ++catIt, ++coIt )
      {
        QTreeWidgetItem *newItem = new QTreeWidgetItem( mDiagramAttributesTreeWidget );
        newItem->setText( 0, *catIt );
        newItem->setData( 0, Qt::UserRole, *catIt );
        newItem->setFlags( newItem->flags() & ~Qt::ItemIsDropEnabled );
        QColor col( *coIt );
        col.setAlpha( 255 );
        newItem->setBackground( 1, QBrush( col ) );
      }
    }

    if ( dr->rendererName() == "LinearlyInterpolated" )
    {
      const QgsLinearlyInterpolatedDiagramRenderer* lidr = dynamic_cast<const QgsLinearlyInterpolatedDiagramRenderer*>( dr );
      if ( lidr )
      {
        mDiagramSizeSpinBox->setEnabled( false );
        mLinearScaleFrame->setEnabled( true );
        mMaxValueSpinBox->setValue( lidr->upperValue() );
        mSizeSpinBox->setValue(( lidr->upperSize().width() + lidr->upperSize().height() ) / 2 );
        if ( lidr->classificationAttributeIsExpression() )
        {
          mSizeFieldExpressionWidget->setField( lidr->classificationAttributeExpression() );
        }
        else
        {
          mSizeFieldExpressionWidget->setField( mLayer->pendingFields().at( lidr->classificationAttribute() ).name() );
        }
      }
    }

    const QgsDiagramLayerSettings *dls = layer->diagramLayerSettings();
    if ( dls )
    {
      mDiagramDistanceSpinBox->setValue( dls->dist );
      mPrioritySlider->setValue( dls->priority );
      mDataDefinedXComboBox->setCurrentIndex( mDataDefinedXComboBox->findData( dls->xPosColumn ) );
      mDataDefinedYComboBox->setCurrentIndex( mDataDefinedYComboBox->findData( dls->yPosColumn ) );
      if ( dls->xPosColumn != -1 || dls->yPosColumn != -1 )
      {
        mDataDefinedPositionGroupBox->setChecked( true );
      }
      mPlacementComboBox->setCurrentIndex( mPlacementComboBox->findData( dls->placement ) );

      chkLineAbove->setChecked( dls->placementFlags & QgsDiagramLayerSettings::AboveLine );
      chkLineBelow->setChecked( dls->placementFlags & QgsDiagramLayerSettings::BelowLine );
      chkLineOn->setChecked( dls->placementFlags & QgsDiagramLayerSettings::OnLine );
      if ( !( dls->placementFlags & QgsDiagramLayerSettings::MapOrientation ) )
        chkLineOrientationDependent->setChecked( true );

      mShowAllCheckBox->setChecked( dls->showAll );
    }

    if ( dr->diagram() )
    {
      QString diagramName = dr->diagram()->diagramName();
      mDiagramTypeComboBox->blockSignals( true );
      mDiagramTypeComboBox->setCurrentIndex( mDiagramTypeComboBox->findData( diagramName ) );
      mDiagramTypeComboBox->blockSignals( false );
      //force a refresh of widget status to match diagram type
      on_mDiagramTypeComboBox_currentIndexChanged( mDiagramTypeComboBox->currentIndex() );
      if ( mDiagramTypeComboBox->currentIndex() == -1 )
      {
        QMessageBox::warning( this, tr( "Unknown diagram type." ),
                              tr( "The diagram type '%1' is unknown. A default type is selected for you." ).arg( diagramName ), QMessageBox::Ok );
        mDiagramTypeComboBox->setCurrentIndex( mDiagramTypeComboBox->findData( DIAGRAM_NAME_PIE ) );
      }
    }
  } // if ( !dr )

  connect( mAddAttributeExpression, SIGNAL( clicked() ), this, SLOT( showAddAttributeExpressionDialog() ) );
  connect( mTransparencySlider, SIGNAL( valueChanged( int ) ), mTransparencySpinBox, SLOT( setValue( int ) ) );
  connect( mTransparencySpinBox, SIGNAL( valueChanged( int ) ), mTransparencySlider, SLOT( setValue( int ) ) );
}
Ejemplo n.º 29
0
void QModernProgressWidget::paintEvent(QPaintEvent *event) {
    QWidget::paintEvent(event);
    QPixmap m_pix(width(), height());

    //if (m_doRepaint) {
        m_doRepaint=false;
        QPen pen;
        pen.setWidthF(1.0);

        double wid=qMin(height(), width());
        double displayFrac=(double)(m_value-m_rangeMin)/(double)(m_rangeMax-m_rangeMin);
        int currentItem=qMax(0, qMin(m_items, (int)round(displayFrac*(double)m_items)));
        int lastItem=round(m_nonBackgroundRange*(double)m_items);
        if (m_spin) currentItem=m_spinItem;
        if (!m_spin) lastItem=currentItem;
        //if (!m_spin) std::cout<<"m_value="<<m_value<<"   currentItem="<<currentItem<<std::endl;
        QPointF center=QPointF(width()/2.0, height()/2.0);

        double rIn=wid/2.0*m_innerRadius;
        double rOut=wid/2.0*m_outerRadius;
        if (rIn>rOut) qSwap(rIn, rOut);

        //                           2*M_PI
        double strokeWidth=qMax(1.0, 6.283 * rIn/(1.75*(double)m_items));
        double dAngle=360.0/(double)m_items;

        //m_pix.fill(this, 0, 0);
        m_pix.fill(Qt::transparent);

        QPainter painter(&m_pix);

        if (m_mode==QModernProgressWidget::Strokes) {
            QPen strokePen=pen;
            strokePen.setWidthF(strokeWidth);
            strokePen.setCapStyle(Qt::RoundCap);
            strokePen.setJoinStyle(Qt::RoundJoin);
            painter.save();
                painter.setRenderHint(QPainter::Antialiasing, true);
                painter.translate(center);
                if (m_spin) painter.rotate(-dAngle*(double)currentItem);
                else painter.rotate(-180);
                for (int i=0; i<m_items; i++) {
                    strokePen.setColor(m_backgroundColor);
                    //double frac=(double)i/(double)(m_items-1.0);

                    if (i<lastItem) {
                        const double r=m_startColor.redF();
                        const double g=m_startColor.greenF();
                        const double b=m_startColor.blueF();
                        const double re=m_stopColor.redF();
                        const double ge=m_stopColor.greenF();
                        const double be=m_stopColor.blueF();
                        double f=(double)i/(m_nonBackgroundRange*(double)m_items);
                        if (f>1) f=1.0;
                        if (f<0) f=0;
                        f=1.0-f;
                        QColor col;
                        col.setRgbF(r+f*(re-r), g+f*(ge-g), b+f*(be-b));
                        strokePen.setColor(col);
                    }
                    //if (fabs(frac-displayFrac)<=1.0/(double)m_items) strokePen.setColor(m_indicatorColor);
                    if (i==0) strokePen.setColor(m_indicatorColor);
                    painter.setPen(strokePen);
                    painter.drawLine(QLineF(0, rIn, 0, rOut));
                    painter.rotate(dAngle);
                }
            painter.restore();
        } else if (m_mode==QModernProgressWidget::Circles) {
            painter.save();
                painter.setRenderHint(QPainter::Antialiasing, true);
                painter.translate(center);
                if (m_spin) painter.rotate(-dAngle*(double)currentItem);
                else painter.rotate(-180);
                for (int i=0; i<m_items; i++) {
                    //double frac=(double)i/(double)(m_items-1.0);

                    QColor col=m_backgroundColor;

                    if (i<lastItem) {
                        const double r=m_startColor.redF();
                        const double g=m_startColor.greenF();
                        const double b=m_startColor.blueF();
                        const double re=m_stopColor.redF();
                        const double ge=m_stopColor.greenF();
                        const double be=m_stopColor.blueF();
                        double f=(double)i/(m_nonBackgroundRange*(double)m_items);
                        if (f>1) f=1.0;
                        if (f<0) f=0;
                        f=1.0-f;
                        col.setRgbF(r+f*(re-r), g+f*(ge-g), b+f*(be-b));
                    }
                    //if (fabs(frac-displayFrac)<=1.0/(double)m_items) strokePen.setColor(m_indicatorColor);
                    if (i==0) col=m_indicatorColor;
                    QBrush circleBrush(col);
                    QPen circlePen=QPen(col.darker(150));
                    painter.setBrush(circleBrush);
                    if (m_darkCircleBorder) {
                        painter.setPen(circlePen);
                    } else {
                        painter.setPen(QColor(Qt::transparent));
                    }
                    double d=(rOut-rIn)/2.0;
                    painter.drawEllipse(0, (rIn+rOut)/2.0, d, d);
                    painter.rotate(dAngle);
                }
            painter.restore();
        } else if (m_mode==QModernProgressWidget::GradientRing) {
            painter.save();
                QPainterPath path;
                path.setFillRule( Qt::OddEvenFill );
                path.addEllipse( QPointF(0,0), rOut, rOut );
                path.addEllipse( QPointF(0,0), rIn, rIn );

                painter.translate(center);
                if (m_spin) painter.rotate(-dAngle*(double)currentItem);
                else painter.rotate(-90);

                // Draw the ring background
                painter.setPen( Qt::NoPen );
                painter.setBrush( m_backgroundColor );
                painter.setRenderHint( QPainter::Antialiasing );
                painter.drawPath( path );

                // Draw the ring foreground
                QConicalGradient gradient( QPointF(0,0), 0.0 );
                if (m_spin) {
                    gradient.setColorAt( 0.0, m_backgroundColor );
                    gradient.setColorAt( qMax(0.0,(double)lastItem/(double)m_items-0.05), m_indicatorColor );
                    gradient.setColorAt( (double)lastItem/(double)m_items, m_backgroundColor );
                    painter.setBrush( gradient );
                } else {
                    double gfrac=qMax(0.0, qMin(1.0, 1.0-displayFrac));
                    //std::cout<<gfrac<<std::endl;
                    if ((fabs(gfrac)<=0.02)) {
                        painter.setBrush(QBrush(m_indicatorColor));
                    } else if (fabs(gfrac)>0.85) {
                        /*QColor cColor=m_indicatorColor;
                        cColor.setRedF(cColor.redF()+fabs(gfrac)/0.85*(m_backgroundColor.redF()-cColor.redF()));
                        cColor.setGreenF(cColor.greenF()+fabs(gfrac)/0.85*(m_backgroundColor.greenF()-cColor.greenF()));
                        cColor.setBlueF(cColor.blueF()+fabs(gfrac)/0.85*(m_backgroundColor.blueF()-cColor.blueF()));*/
                        QColor cColor=linColor(m_indicatorColor, m_backgroundColor, (gfrac-0.85)/0.15);
                        gradient.setColorAt( 0.05, m_backgroundColor );
                        gradient.setColorAt( 0.0, cColor );
                        gradient.setColorAt( 0.8, m_backgroundColor );
                        gradient.setColorAt( gfrac, cColor );
                        painter.setBrush( gradient );
                    } else if (fabs(gfrac)<0.15) {
                        /*QColor cColor=m_backgroundColor;
                        cColor.setRedF(m_indicatorColor.redF()-fabs(gfrac)/0.15*(m_indicatorColor.redF()-cColor.redF()));
                        cColor.setGreenF(m_indicatorColor.greenF()-fabs(gfrac)/0.15*(m_indicatorColor.greenF()-cColor.greenF()));
                        cColor.setBlueF(m_indicatorColor.blueF()-fabs(gfrac)/0.15*(m_indicatorColor.blueF()-cColor.blueF()));*/
                        QColor cColor=linColor(m_indicatorColor, m_backgroundColor, gfrac/0.15);
                        gradient.setColorAt( 0.0, m_indicatorColor );
                        gradient.setColorAt( gfrac/2.0, cColor );
                        gradient.setColorAt( gfrac, m_indicatorColor );
                        painter.setBrush( gradient );
                    } else {
                        gradient.setColorAt( 0.0, m_indicatorColor );
                        gradient.setColorAt( 0.05, m_backgroundColor );
                        gradient.setColorAt( qMax(0.0, gfrac-0.05), m_backgroundColor );
                        gradient.setColorAt( qMin(1.0, gfrac), m_indicatorColor );
                        painter.setBrush( gradient );
                    }
                }
                painter.drawPath( path );
            painter.restore();
        }

        if (m_displayPercent && ( (m_mode==QModernProgressWidget::Circles) || (m_mode==QModernProgressWidget::Strokes) || (m_mode==QModernProgressWidget::GradientRing) ) ) {
            painter.save();
            QFont f=font();
            QString s="";
            if (m_percentageMode==QModernProgressWidget::Percent) {
                s=QString::number(100.0*(double)(m_value-m_rangeMin)/(double)(m_rangeMax-m_rangeMin), 'f', m_precision)+"%";
            } else {
                s=QString::number(m_value, 'f', m_precision)+m_suffix;
            }
            QRect bound=QFontMetrics(f).boundingRect("100%");
            double r=sqrt( (bound.width()/2.0)*(bound.width()/2.0) + (bound.height()/2.0)*(bound.height()/2.0) );
            while ((f.pointSize()>5)&&(r>rIn)) {
                f.setPointSizeF(f.pointSizeF()-0.5);
                bound=QFontMetrics(f).boundingRect("100%");
                r=sqrt( (bound.width()/2.0)*(bound.width()/2.0) + (bound.height()/2.0)*(bound.height()/2.0) );
            }
            bound=QFontMetrics(f).boundingRect(s);
            painter.setFont(f);
            painter.setPen(m_textColor);
            painter.drawText(width()/2-bound.width()/2, height()/2+QFontMetrics(f).ascent()/2, s);
            painter.restore();
        }
    //}
    QPainter p(this);
    p.drawPixmap(QPoint(0,0), m_pix);
}
Ejemplo n.º 30
0
/**
 * Display the attrbiutes for the current feature and load the image
 */
void eVisGenericEventBrowserGui::loadRecord()
{
  treeEventData->clear();

  //Get a pointer to the current feature
  QgsFeature* myFeature;
  myFeature = featureAtId( mFeatureIds.at( mCurrentFeatureIndex ) );

  if ( !myFeature )
    return;

  QString myCompassBearingField = cboxCompassBearingField->currentText();
  QString myCompassOffsetField = cboxCompassOffsetField->currentText();
  QString myEventImagePathField = cboxEventImagePathField->currentText();
  QgsFields myFields = mDataProvider->fields();
  QgsAttributes myAttrs = myFeature->attributes();
  //loop through the attributes and display their contents
  for ( int i = 0; i < myAttrs.count(); ++i )
  {
    QStringList myValues;
    QString fieldName = myFields.at( i ).name();
    myValues << fieldName << myAttrs.at( i ).toString();
    QTreeWidgetItem* myItem = new QTreeWidgetItem( myValues );
    if ( fieldName == myEventImagePathField )
    {
      mEventImagePath = myAttrs.at( i ).toString();
    }

    if ( fieldName == myCompassBearingField )
    {
      mCompassBearing = myAttrs.at( i ).toDouble();
    }

    if ( mConfiguration.isAttributeCompassOffsetSet() )
    {
      if ( fieldName == myCompassOffsetField )
      {
        mCompassOffset = myAttrs.at( i ).toDouble();
      }
    }
    else
    {
      mCompassOffset = 0.0;
    }

    //Check to see if the attribute is a know file type
    int myIterator = 0;
    while ( myIterator < tableFileTypeAssociations->rowCount() )
    {
      if ( tableFileTypeAssociations->item( myIterator, 0 ) && ( myAttrs.at( i ).toString().startsWith( tableFileTypeAssociations->item( myIterator, 0 )->text() + ':', Qt::CaseInsensitive ) || myAttrs.at( i ).toString().endsWith( tableFileTypeAssociations->item( myIterator, 0 )->text(), Qt::CaseInsensitive ) ) )
      {
        myItem->setBackground( 1, QBrush( QColor( 183, 216, 125, 255 ) ) );
        break;
      }
      else
        myIterator++;
    }
    treeEventData->addTopLevelItem( myItem );
  }
  //Modify EventImagePath as needed
  buildEventImagePath();

  //Request the image to be displayed in the browser
  displayImage();
}