void MenuEquipmentScreen::initialize(BattleCharacterItem *character, Inventory *inventory) {
	QFont font("Times", 12, QFont::Bold);
	QBrush brush(Qt::white);
	_state = EQUIPPED_SELECTION;

	// Set character and inventory
	_character = character;
	_inventory = inventory;

	// Set the character's equipment
	QPointF position(_equippedEquipmentItem->pos().x(), _equippedEquipmentItem->pos().y() + 40);

	QStringList equipmentHeaders;
	equipmentHeaders << "Main Hand: " << "Off Hand: "
		<< "Helmet: " << "Torso: " << "Leggings: " << "Gloves: " << "Boots: "
		<< "Earring: " << "Necklace: " << "Ring: ";
	QVector<EquipmentPiece*> equipment = _character->getEquipment()->getEquipment();
	_currentEquippedEquipmentPiece = equipment.at(0);
	_equippedEquipmentItem->setText("Equipment of " + _character->getName());

	for (int i = 0; i < equipment.size(); i++) {
		QString itemText;
		itemText.append(equipmentHeaders.at(i));
		
		if (!!equipment.at(i))
			itemText.append(equipment.at(i)->getName());

		QGraphicsSimpleTextItem *item = new QGraphicsSimpleTextItem(this);
		item->setText(itemText);
		item->setBrush(brush);
		item->setFont(font);
		item->setPos(position);

		_equippedEquipmentItems.append(item);
		position.setY(position.y() + 20);
	}

	setCurrentEquippedItem(_equippedEquipmentItems.at(0), equipment.at(0));

	// Set Image
	if (_character->getCharacter()->getBattleImage().second != QString()) {
		QPixmap battlerImage = _character->getCharacter()->getBattleImage().first;

		if ((battlerImage.width() > _characterImage->boundingRect().width()) || (battlerImage.height() > _characterImage->boundingRect().height()))
			battlerImage = battlerImage.scaled(QSize(200, 200), Qt::KeepAspectRatio);
		
		QPixmap frame(200, 200);
		frame.fill(Qt::transparent);
		QPainter painter(&frame);
		painter.setCompositionMode(QPainter::CompositionMode_SourceOver);

		QPoint position(0, 0);
		position.setX(frame.width()/2 - battlerImage.width()/2);
		position.setY(frame.height()/2 - battlerImage.height()/2);
		painter.drawPixmap(position, battlerImage);
		painter.end();

		_characterImage->setPixmap(frame);
		
	} else {
		QPixmap image(200, 200);
		image.fill(Qt::transparent);
		_characterImage->setPixmap(image);
	}
}
示例#2
0
 void UpdText()
 {
     if (nLootAmount > 0)
         text->setText(name + "\n" + QString::fromStdString(FormatMoney(nLootAmount)));
     else
         text->setText(name);
 }
void MenuEquipmentScreen::nextEquipmentItem() {
	if (_currentEquipmentListItem == _activeEquipmentListItems.last()) {
		// If the last equipment item was selected
		if (_currentSelectedEquipmentString == (_equipmentStringList.size()-1)) {

			for (int i = 0; i < _activeEquipmentListItems.size(); i++) {
				QGraphicsSimpleTextItem *item = _activeEquipmentListItems.at(i);
				item->setText(_equipmentStringList.at(i));
			}

			_currentSelectedEquipmentString = 0;
			setCurrentEquipmentItem(_activeEquipmentListItems.at(0), 0);

		} else { // Else scroll to the next equipment item

			for (int i = 0; i < _activeEquipmentListItems.size()-1; i++) {
				QGraphicsSimpleTextItem *item = _activeEquipmentListItems.at(i);
				item->setText(_activeEquipmentListItems.at(i+1)->text());
			}

			_currentSelectedEquipmentString++;
			QGraphicsSimpleTextItem *item = _activeEquipmentListItems.at(_activeEquipmentListItems.size() - 1);
			item->setText(_equipmentStringList.at(_currentSelectedEquipmentString));
			setCurrentEquipmentItem(item, _equipmentList.at(_currentSelectedEquipmentString - 1));
		}

	} else {
		_currentSelectedEquipmentString++;
		setCurrentEquipmentItem(_activeEquipmentListItems.at(_activeEquipmentListItems.indexOf(_currentEquipmentListItem) + 1), _equipmentList.at(_currentSelectedEquipmentString -1));
	}
}
示例#4
0
void GameArena::slotMapWinner(qint8 playerId, bool end) {
    QFont bigText;
    bigText.setPointSize(32);
    bigText.setWeight(QFont::Bold);

    QGraphicsSimpleTextItem* textOver = new QGraphicsSimpleTextItem();
    if(playerId == -1)
        textOver->setText("DRAW GAME!");
    else
        textOver->setText(QString("PLAYER ") + QString::number(playerId + 1) + QString(" WINS!"));
    textOver->setFont(bigText);
    textOver->setZValue(1.0);

    scene->addItem(textOver);

    QGraphicsSimpleTextItem* text2 = new QGraphicsSimpleTextItem();
    text2->setText(textOver->text());
    text2->setFont(bigText);
    text2->setZValue(0.9);
    text2->setX(text2->x() + 1);
    text2->setY(text2->y() + 1);
    text2->setBrush(QBrush(Qt::white));

    scene->addItem(text2);
}
示例#5
0
void cbGraphView::contentsMouseMoveEvent(QMouseEvent *e)
{
	double x,y,dist;
	int xi,yi;

    xi=(int)(e->x()/(simulator->labCanvasWidth/(double)GRIDSIZE));
    yi=(int)(e->y()/(simulator->labCanvasHeight/(double)GRIDSIZE));

    if(xi>=0 && xi < GRIDSIZE && yi >=0 && yi < GRIDSIZE) {
        x=(xi+0.5)*simulator->Lab()->Width()/GRIDSIZE;
        y=(GRIDSIZE-yi-0.5)*simulator->Lab()->Height()/GRIDSIZE;
	    dist = simulator->distGrid[xi][yi];
        if(xi<GRIDSIZE/2) {
            distLabel->setPos(e->x()+10,e->y());
	    }
        else {
            distLabel->setPos(e->x()-200,e->y());
        }
        distLabel->setText(QString("(%1,%2) -> dist=%3").arg(x).arg(y).arg(dist));
	}
    else {
        distLabel->setText("Out of bounds");
	}

    scene()->update();
}
示例#6
0
QGraphicsItem* TextContent::createGraphicsItem(const QRectF& rect)
{

    QFile   file(_url);
    if(!file.open(QIODevice::ReadOnly))
        throw 0;

    int rectHeight = rect.height();

    QTextStream in(&file);
    QString text (in.readAll());

    QGraphicsSimpleTextItem* item = new QGraphicsSimpleTextItem();
    // measuring text
    QFont newFont( item->font() );
    newFont.setStyleStrategy( QFont::OpenGLCompatible );
    int textSize = 0;
    int textHeightInPixels = 1;
    while(textHeightInPixels < rectHeight)
    {
        ++textSize;
        newFont.setPointSize(textSize);
        QFontMetrics fm(newFont);
        fm.width(text);
        textHeightInPixels = fm.height();
    }

    newFont.setPointSize( textSize-1 );
    item->setFont( newFont );
    item->setText( text );

    return item;
}
示例#7
0
QGraphicsItem* CGraphicsTextItem::createItem()
{
	QGraphicsSimpleTextItem* pItem = new QGraphicsSimpleTextItem(m_Parent);
	QFont font;
	//字体宽度
	font.setWeight(GET_VALUE(p_FontWidth).toInt());
	//字体大小
	font.setPixelSize(GET_VALUE(fs).toInt());
	//字间距
	font.setWordSpacing(GET_VALUE(p_FontInterval).toInt());
	//字体高度
	//字体类型
	QString strFamily(GET_VALUE(ff));

	if (!strFamily.isEmpty())
	{
		font.setFamily(strFamily);
	}

	pItem->setFont(font);

	//字体颜色
	QPen pen;
	QStringList lstLc = GET_VALUE(lc).split(',');
	pen.setColor(QColor::fromRgb(lstLc[0].toInt(),lstLc[1].toInt(),lstLc[2].toInt()));
	pItem->setPen(pen);

	pItem->setText(GET_VALUE(ts));
	return pItem;

}
示例#8
0
asd::Waypoint* asd::Waypoint::Builder::build() {
    asd::Waypoint *waypoint = new asd::Waypoint;

    //
    // Properties
    //

    waypoint->setPen(properties_.pen());
    waypoint->setBrush(properties_.brush());
    waypoint->setZValue(properties_.zlayer());

    qreal size = properties_.size();
    waypoint->setRect(-size/2, -size/2, size, size);

    if (!name_.isEmpty()) {
        QGraphicsSimpleTextItem *text = new QGraphicsSimpleTextItem(waypoint);
        text->setPen(Qt::NoPen);
        text->setBrush(properties_.pen().brush());

        text->setText(name_);
    }

    waypoint->setPos(location_);

    return waypoint;
}
示例#9
0
void controlGraph::drawFixedPoints() {
    QHash<QString, fixedPoint>::iterator i;
    QHash<QString, bGraphicsEllipseItem*>::iterator ii;

    for (ii = elliseFixedPointHash.begin(); ii != elliseFixedPointHash.end(); ++ii)delete ii.value();
    elliseFixedPointHash.clear();

    for (i = fixedPoints->begin(); i != fixedPoints->end(); ++i) {
        bGraphicsEllipseItem *e = new bGraphicsEllipseItem(0);
        scene.addItem(e);
        e->setRect(1.0 * (i->panValue -  rangeMinPan) * scene.width() / visibleRangePan - 15, scene.height() - 1.0 * (i->tiltValue -  rangeMinPan) * scene.height() / visibleRangeTilt - 15 , 30, 30 );
        e->setBrush(QBrush(QColor("#d3f9fe")));
        if(i->timelapseMember == 1)e->setBrush(QBrush(QColor("#19c6ee")));
        e->setZValue(1);

        QGraphicsSimpleTextItem *et = new QGraphicsSimpleTextItem(e);
        et->setPos(1.0 * (i->panValue - rangeMinTilt) * scene.width() / visibleRangePan - 20, scene.height() - 1.0 * (i->tiltValue - rangeMinTilt) * scene.height() / visibleRangeTilt - 30);
        et->setFont(QFont("Calibri", 14, QFont::Normal));

        et->setText(i->name);
        et->setZValue(1);

        elliseFixedPointHash.insert(i.key(), e);
    }
}
示例#10
0
NodeGui::NodeGui(unsigned int id, std::string name)
    : QGraphicsEllipseItem(-35 - ADJUST, -10 - ADJUST, 70 + ADJUST, 20 + ADJUST),
      id_(id),
      name_(name),
      abbrev_(QString::fromStdString(name)),
      nodeColor(Qt::gray),
      secondNodeColor(Qt::gray),
      colorFixed(false)
{
    setFlag(ItemIsMovable);
    setFlag(ItemSendsGeometryChanges);
    setCursor(Qt::ArrowCursor);
    setAcceptHoverEvents(true);
    setZValue(-1);

    if (name.size() > 12){
        setToolTip(abbrev_);
    }

    if (abbrev_.size() > 12){
        abbrev_.resize(12);
        for (int i = 10; i<12; i++){
            abbrev_[i]='.';
        }
    }

	QGraphicsSimpleTextItem* child = new QGraphicsSimpleTextItem(this);
	QFont f("Monospace", 6);
	child->setFont(f);
	child->setText(abbrev_);
	child->setPos(getStart(abbrev_), - QFontMetrics(f).height() / 2.f);

	setColors(nodeColor, secondNodeColor);
}
void MenuEquipmentScreen::equippedItemSelected() {
	// Reset updated stats and equipment list
	_updatedStatsItem->setText(QString());
	for (int i = 0; i < _updatedStatsItems.size(); i++)
		delete _updatedStatsItems.at(i);
	_updatedStatsItems.clear();

	_equipmentList.clear();
	_equipmentStringList.clear();
	_currentSelectedEquipmentString = 0;
	_currentEquipmentListItem = 0;
	_equipmentListItem->setText(QString());
	for (int i = 0; i < _activeEquipmentListItems.size(); i++)
		delete _activeEquipmentListItems.at(i);
	_activeEquipmentListItems.clear();

	// Build the equipmentlist
	QVector<QPair<EquipmentPiece*, int>> equipment = _inventory->getEquipment();
	for (int i = 0; i < equipment.size();) {
		if (!equipmentFilter(equipment.at(i).first))
			equipment.remove(i);
		else {
			_equipmentList.append(equipment.at(i).first);
			i++;
		}
	}

	// Set the equipment list
	QFont font ("Times", 12, QFont::Bold);
	QBrush brush(Qt::white);
	QPointF position(_equipmentListItem->pos().x(), _equipmentListItem->pos().y() + 20);

	_currentSelectedEquipmentString = 0;
	_equipmentStringList.append(QString("Clear equipment slot"));
	for (int i = 0; i < _equipmentList.size(); i++)
		_equipmentStringList.append(_equipmentList.at(i)->getName());

	_equipmentListItem->setText("Select equipment:");
	for (int i = 0; i < qMin<int>(_equipmentStringList.size(), 8); i++) {
		QGraphicsSimpleTextItem *item = new QGraphicsSimpleTextItem(_equipmentListPanel);

		item->setBrush(brush);
		item->setFont(font);
		item->setText(_equipmentStringList.at(i));
		item->setPos(position);

		position.setY(position.y() + 20);
		_activeEquipmentListItems.append(item);
	}

	setCurrentEquipmentItem(_activeEquipmentListItems.first(), 0);
	_state = MenuEquipmentScreen::EQUIPMENT_SELECTION;
}
void MenuEquipmentScreen::previousEquipmentItem() {
	if (_currentEquipmentListItem == _activeEquipmentListItems.first()) {
		
		// If the first equipment item was selected
		if (_currentSelectedEquipmentString == 0) {
			for (int i = (_activeEquipmentListItems.size()-1); i >= 0; i--) {
				QGraphicsSimpleTextItem *item = _activeEquipmentListItems.at(i);
				item->setText(_equipmentStringList.at(_equipmentStringList.size() - _activeEquipmentListItems.size() + i));
			}

			_currentSelectedEquipmentString = _equipmentStringList.size() - 1;
			if (!_equipmentList.empty())
				setCurrentEquipmentItem(_activeEquipmentListItems.last(), _equipmentList.last());
			else
				setCurrentEquipmentItem(_activeEquipmentListItems.last(), 0);

		} else { // Else scroll to the previous equipment item
			for (int i = (_activeEquipmentListItems.size() - 1); i > 0; i--) {
				QGraphicsSimpleTextItem *item = _activeEquipmentListItems.at(i);
				item->setText(_activeEquipmentListItems.at(i-1)->text());
			}

			_currentSelectedEquipmentString--;
			QGraphicsSimpleTextItem *item = _activeEquipmentListItems.first();
			item->setText(_equipmentStringList.at(_currentSelectedEquipmentString));
			setCurrentEquipmentItem(item, _equipmentList.at(_currentSelectedEquipmentString - 1));
		}

	} else {
		_currentSelectedEquipmentString--;
		if (_currentSelectedEquipmentString == 0)
			setCurrentEquipmentItem(_activeEquipmentListItems.at(_activeEquipmentListItems.indexOf(_currentEquipmentListItem) - 1), 0);
		else
			setCurrentEquipmentItem(_activeEquipmentListItems.at(_activeEquipmentListItems.indexOf(_currentEquipmentListItem) - 1), _equipmentList.at(_currentSelectedEquipmentString -1));
	}
}
示例#13
0
ItemBook::ItemBook(QString Title)
{
    dragging = false;
    this->Title = Title;

    QGraphicsScene scene;
    scene.setParent(this);
    scene.addText(this->Title);
    QPen pen(QColor(0,0,0));
    scene.addLine(QLineF(0,0,1,2));
    this->resize(64,64*1.5);
    this->setScene(&scene);

    QGraphicsSimpleTextItem text;
    text.setText("Hello world");
    scene.addItem(&text);
}
void MenuEquipmentScreen::setCurrentEquippedItem(QGraphicsSimpleTextItem *item, EquipmentPiece *equipment) {
	QBrush whiteBrush(Qt::white);
	QBrush yellowBrush(Qt::yellow);
	QFont font("Times", 12, QFont::Bold);

	if (!!_currentEquippedEquipmentItem)
		_currentEquippedEquipmentItem->setBrush(whiteBrush);

	_currentEquippedEquipmentItem = item;
	_currentEquippedEquipmentItem->setBrush(yellowBrush);
	_currentEquippedEquipmentPiece = equipment;

	// Reset the current selected equipped item
	_equippedStatsItem->setText(QString());
	for (int i = 0; i < _equippedStatsItems.size(); i++)
		delete _equippedStatsItems.at(i);
	_equippedStatsItems.clear();

	// If the current slot contains an equipment piece
	if (!!_currentEquippedEquipmentPiece) {
		QPointF position(_equippedStatsItem->pos().x(), _equippedStatsItem->pos().y() + 20);
		_equippedStatsItem->setText("Attributes of " + equipment->getName());
		QVector<QPair<Attribute*, int>> attributes = equipment->getAttributes();

		for (int i = 0; i < attributes.size(); i++) {
			QPair<Attribute*, int> it = attributes.at(i);
			QString itemText(it.first->getName() + " + " + QString::number(it.second));

			QGraphicsSimpleTextItem *item = new QGraphicsSimpleTextItem(_equipmentStatsPanel);

			item->setText(itemText);
			item->setBrush(whiteBrush);
			item->setFont(font);
			item->setPos(position);

			_equippedStatsItems.append(item);
			position.setY(position.y() + 20);
		}

	} else
		_equippedStatsItem->setText("No equipment selected");
}
示例#15
0
void GraphViewer::onValueEdited()
{
    bool ok=false;
    int newvalue = _valueEditor.text().toInt(&ok);
    if (ok)
    {

        if (qgraphicsitem_cast<QGraphicsSimpleTextItem*>(_editedItem))
        {
            QGraphicsSimpleTextItem* text = qgraphicsitem_cast<QGraphicsSimpleTextItem*>(_editedItem);
            text->setText(QString("%1").arg(newvalue));
            QGraphicsItem* parent = text->parentItem();
            if (parent)
            {
                parent->setData(KEY_EDGE_WEIGHT, newvalue);
            }
            _valueEditor.hide();
        }

    }
}
示例#16
0
bool ZipplXmlReader::read( QIODevice *dev )
{
  setDevice( dev );
  bool res = true;
  bool metaMode = false;
  mCurrParent = 0;
  mCurrSpot = 0;

  QGraphicsScene *scene = mGraphWidget->scene();
  int spotID = 0;

  while (!atEnd()) {
    readNext();

    if( isStartElement() ) {
      qDebug() << "XML name: " << name();

      if( name() == "presentation") {
        // presentation mode: debug & presentation
        QString mode = attributes().value("mode").toString();
        if( !mode.isEmpty() ) mMode = mode;

        mPath = attributes().value("path").toString();
        if( !mPath.endsWith('/') ) mPath += "/";


        qreal dx = qrealAttrib("width") / -2.0;
        qreal dy = qrealAttrib("height") / -2.0;
        QRectF rect( dx, dy, -2.0*dx, -2.0*dy );
        scene->setSceneRect( rect );
      } else if( name() == "meta" ) {
        metaMode = true;
      } else if( name() == "title" && metaMode ) {
        mPresentationTitle = readElementText();
      } else if( name() == "description" && metaMode ) {
        mPresentationDescr = readElementText();
      } else if( name() == "date" && metaMode ) {
        mPresentationDate = readElementText();
      } else if( name() == "name" && metaMode ) {
        mAuthorName = readElementText();
      } else if( name() == "email" && metaMode ) {
        mAuthorEmail = readElementText();
      } else if( name() == "tocentry" ) {
        if( mCurrSpot ) {
          mCurrSpot->setData( TOCENTRY, readElementText() );
        }
      } else if( name() == "spot" ) {
        if( mCurrParent != 0 ) {
          qDebug() << "Strange: Current Parent should be zero here!";
        }
        QGraphicsRectItem *rectItem = new QGraphicsRectItem( );

        rectItem->setPen( pen( rectItem->pen(), QColor("#aeaeae") ));

        mCurrParent = rectItem;
        mCurrSpot = rectItem;
        mCurrParent->setData( ID, QVariant( spotID++ ));

        mCurrParent->setPos( position() );

        rectItem->setBrush( brush( rectItem->brush() ) );

        scene->addItem( mCurrParent );
        mSpots.append( mCurrParent );

        // Prepare the hidden items list
        GraphicsItemList list;
        mHiddenItems.insert( mCurrParent, list );

      } else if( name() == "hidden" ) {
        QGraphicsRectItem *rectItem = new QGraphicsRectItem( mCurrParent, scene );
        rectItem->setPen( QPen( QColor( 240, 240, 240 )));

        // append this hidden item to the list of hiddens of the parent spot.
        GraphicsItemList list = mHiddenItems[mCurrSpot];
        list.append( rectItem );
        mHiddenItems[mCurrSpot] = list;

        mCurrParent = rectItem;
        mCurrParent->setData( ID, QVariant( spotID++ ));

      } else if( name() == "rect" ) {
        if( mCurrParent ) { // within a spot
          qDebug() << "Creating a rectangle!";
          QGraphicsRectItem *rectItem = new QGraphicsRectItem( mCurrParent, scene );

          qreal width = qrealAttrib( "width" );
          qreal height = qrealAttrib( "height" );

          QPointF pos = position();
          if( width > 0 && height > 0 ) {
            rectItem->setRect( pos.x(), pos.y(), width, height );
          } else {
            rectItem->setPos( pos );
          }
          rectItem->setPen( pen( rectItem->pen() ) );

          mCurrParent = rectItem;
        }
      } else if( name() == "circle" ) {
        QPointF pos = position();
        QGraphicsEllipseItem *ellipse = new QGraphicsEllipseItem( mCurrParent, scene );
        // ellipse->setBrush( getBrush() );
        qreal r = 2.0 * qrealAttrib( "r" );

        QRectF rect( pos, QSizeF( r, r ) );

        ellipse->setPen( pen( ellipse->pen() ) );

        ellipse->setRect( rect );


      } else if( name() == "text" ) {
        QGraphicsSimpleTextItem *textItem = new QGraphicsSimpleTextItem( mCurrParent, scene );

        QString font = attributes().value("font").toString();
        QString size = attributes().value("size").toString();


        QFont currFont = textItem->font();
        if( !font.isEmpty() ) {
          currFont.setFamily( font );
          textItem->setFont( currFont );
        }
        if( !size.isEmpty() ) {
          currFont.setPointSize( size.toInt() );
          textItem->setFont( currFont );
        }

        textItem->setPos( position() );

        // set the brush
        QBrush b( textItem->brush() );
        b.setColor( color() );

        textItem->setBrush( b );

        QString text = readElementText();
        textItem->setText( text );

      } else if( name() == "image" ) {
        if( handleImg( scene ) ) {

        }
      }
    } else if( isEndElement() ) {
      qDebug( ) << "XML CLOSE: " << name().toString();
      if( name() == "spot" || name() == "toc" ) {
        QRectF rect = mCurrParent->childrenBoundingRect();
        rect.setX(0);
        rect.setY(0);
        qgraphicsitem_cast<QGraphicsRectItem*>(mCurrParent)->setRect( rect);
        mCurrParent = 0;
      } else if( name() == "rect" ) {
        QGraphicsRectItem *item = qgraphicsitem_cast<QGraphicsRectItem*>(mCurrParent);

        if( item->rect().isEmpty() )
          item->setRect( mCurrParent->childrenBoundingRect() );
        mCurrParent = mCurrParent->parentItem();
      } else if( name() == "hidden") {
        mCurrParent->setOpacity( 0.0 );
        mCurrParent = mCurrParent->parentItem();
      } else if( name() == "meta" ) {
        metaMode = false;
      }
    }
  }

  createToc( scene );

  return res;
}
示例#17
0
MainWindow::MainWindow(AmViewerState *state) : _state(state) {
    _state->recon_tree = NULL;
    _state->amEvent = NULL;
    _state->show_dBm = false;
    _state->filtered = true;
    _state->sumpols = false;
    _state->resetSearch(); // couldn't hurt?

    setWindowTitle("AmViewer");

    // creat dialogs
    _searchWindow = new SearchWindow(this,_state);
    _visWindow = new VisWindow(this,_state);
    _fovWindow = new FovWindow(this,_state);
    _filterWindow = NULL;
    _infoWindow = NULL;

    QWidget *centralWidget = new QWidget();
    setCentralWidget(centralWidget);
    QVBoxLayout *bigLayout = new QVBoxLayout(centralWidget);

    // File menu
    QAction *quitMenu = new QAction("&Exit",this);
    quitMenu->setShortcut(tr("Ctrl+Q"));
    connect(quitMenu,SIGNAL(triggered()),qApp,SLOT(quit()));

    QAction *openMenu = new QAction("&Open ROOT file...",this);
    openMenu->setShortcut(tr("Ctrl+O"));
    connect(openMenu,SIGNAL(triggered()),this,SLOT(openFile()));

    _saveMenu = new QAction("&Save event candidates...",this);
    connect(_saveMenu,SIGNAL(triggered()),this,SLOT(saveFile()));

    QMenu *fileDrop;
    fileDrop = menuBar()->addMenu("&File");
    fileDrop->addAction(openMenu);
    fileDrop->addAction(_saveMenu);
    fileDrop->addAction(quitMenu);

    _saveMenu->setEnabled(false);

    // View menu
    _unitsMenu = new QAction("&Display dBm",this);
    _unitsMenu->setCheckable(true);
    _unitsMenu->setChecked(false);
    connect(_unitsMenu,SIGNAL(triggered()),this,SLOT(applyUnits()));

    // Filter dialog
    _filterMenu = new QAction("&Filter Settings",this);
    connect(_filterMenu,SIGNAL(triggered()),this,SLOT(openFilter()));

    // Polarization checkbox
    _polMenu = new QAction("&Sum Polarizations",this);
    _polMenu->setCheckable(true);
    _polMenu->setChecked(false);
    _polMenu->setEnabled(false);
    connect(_polMenu,SIGNAL(triggered()),this,SLOT(applySumPol()));

    QMenu *viewDrop;
    viewDrop = menuBar()->addMenu("&View");
    viewDrop->addAction(_unitsMenu);
    viewDrop->addAction(_polMenu);
    viewDrop->addAction(_filterMenu);
    _filterMenu->setEnabled(false);

    // Analysis menu
    QAction *infoMenu = new QAction("&Event Info",this);
    connect(infoMenu,SIGNAL(triggered()),this,SLOT(openInfo()));

    _analysisDrop = menuBar()->addMenu("&Analysis");
    _analysisDrop->addAction(infoMenu);

    QAction *searchMenu = new QAction("&Search Parameters",this);
    connect(searchMenu,SIGNAL(triggered()),this,SLOT(openSearch()));

    _analysisDrop->addAction(searchMenu);
    _analysisDrop->setEnabled(false);

    QAction *visMenu = new QAction("&Event Visualization",this);
    connect(visMenu,SIGNAL(triggered()),this,SLOT(openVis()));
    _analysisDrop->addAction(visMenu);

    QAction*fovMenu = new QAction("&AMBER Field of View",this);
    connect(fovMenu,SIGNAL(triggered()),this,SLOT(openFov()));
    _analysisDrop->addAction(fovMenu);

    // Set up layout for event browser, pixel windows, graphs
    QHBoxLayout *hbox = new QHBoxLayout();
    bigLayout->addLayout(hbox);

    // Event list stuff
    _eventList = new QTreeWidget(this);
    _eventList->setColumnCount(2);
    _eventList->setColumnHidden(1,true); //'true' valid in C++?

    QTreeWidgetItem *_source0 = new QTreeWidgetItem(_eventList);
    _source0->setText(0,"Source:0 (LTRIG)");

    QTreeWidgetItem *_source1 = new QTreeWidgetItem(_eventList);
    _source1->setText(0,"Source:1 (PPS)");

    QTreeWidgetItem *_source2 = new QTreeWidgetItem(_eventList);
    _source2->setText(0,"Source:2 (Auger)");

    _eventList->setHeaderLabel("Events");

    hbox->addWidget(_eventList);

    // Some gross stuff concerning the clickable horns
    _hornDisplay = new HornDisplay(this,1);

    CenterHorns *centerLegend = new CenterHorns("center",true);
    QGraphicsProxyWidget *centerLegendProxy = new QGraphicsProxyWidget();
    centerLegendProxy->setWidget(centerLegend->widget);

    _hornDisplay->hornScene->addItem(centerLegendProxy);

    centerLegendProxy->rotate(45);
    centerLegendProxy->setPos(0,-50);
    centerLegendProxy->setZValue(0.0);

    AmHorn *ppsHorn[4];

    int i;
    stringstream out;

    QToolButton *b;

    for(i=0; i<4; i++) {
        b = new QToolButton();
        b->setFixedSize(25,25);
        out.str("");
        out << (i+1);
        ppsHorn[i] = new AmHorn(b,"PPS" + out.str());
        ppsHorn[i]->proxyWidget = new QGraphicsProxyWidget();
        ppsHorn[i]->proxyWidget->setWidget(ppsHorn[i]->_button);
        _hornDisplay->hornScene->addItem(ppsHorn[i]->proxyWidget);
        ppsHorn[i]->proxyWidget->setPos(25*i-145,375);

        // probably stupid, delete
        //ppsHorn[i]->trigger_color = "blue";
        //ppsHorn[i]->updateStyle();

        //delete b;
    }

    QGraphicsSimpleTextItem *item;

    for(i=0; i<4; i++) {
        item = new QGraphicsSimpleTextItem();
        _hornDisplay->hornScene->addItem(item);
        if(i==0) {
            item->setText("CH");
            item->setPos(-7,-31);
            item->setZValue(1.0);
        }
        if(i==1) {
            item->setText("CV");
            item->setPos(-7,5);
            item->setZValue(1.0);
        }
        if(i==2) {
            item->setText("KH");
            item->setPos(-24,-15);
            item->setZValue(1.0);
        }
        if(i==3) {
            item->setText("KV");
            item->setPos(12,-15);
            item->setZValue(1.0);
        }
        //delete item;
    }

    // CRUFT ALERT
    // THIS WHOLE NEXT LOOP IS HIGHLY SUSPECT, I DOUBT IT DOES ANYTHING
    QString qstr;
    for(i=0; i<16; i++) {
        out.str("");
        out << (i+1);
        qstr = QString::fromStdString(out.str());
        item = new QGraphicsSimpleTextItem(qstr);
        _hornDisplay->hornScene->addItem(item);
        if(i==0)
            item->setPos(-2.5,75.0);
        else if(i==1)
            item->setPos(-105.0,177.5);
        else if(i==2)
            item->setPos(-2.5,280.0);
        else if(i==3)
            item->setPos(102.5,177.5);
        else if(i==4)
            item->setPos(-70.0,55.0);
        else if(i==5)
            item->setPos(-95.0,80.0);
        else if(i==6)
            item->setPos(-120.0,105.0);
        else if(i==7)
            item->setPos(-125.0,250.0);
        else if(i==8)
            item->setPos(-100.0,275.5);
        else if(i==9)
            item->setPos(-75.0,300.0);
        else if(i==10)
            item->setPos(60.0,300.0);
        else if(i==11)
            item->setPos(85.0,275.0);
        else if(i==12)
            item->setPos(110.0,250.0);
        else if(i==13)
            item->setPos(120.0,110.0);
        else if(i==14)
            item->setPos(95.0,85.0);
        else if(i==15)
            item->setPos(70.0,60.0);
    }

    QVBoxLayout *evVbox = new QVBoxLayout();
    hbox->addLayout(evVbox);

    QGridLayout *evInfoGrid = new QGridLayout();
    evVbox->addLayout(evInfoGrid);

    _evIdLabel = new QLabel("");
    _evSourceLabel = new QLabel("");
    _evSecLabel = new QLabel("");
    _evNsLabel = new QLabel("");
    _evInfoLabel = new QLabel("");

    evInfoGrid->addWidget(_evIdLabel,0,0);
    evInfoGrid->addWidget(_evSourceLabel,0,1);
    evInfoGrid->addWidget(_evSecLabel,1,0);
    evInfoGrid->addWidget(_evNsLabel,1,1);
    evInfoGrid->addWidget(_evInfoLabel,2,0);

    evVbox->addWidget(_hornDisplay);

    QVBoxLayout *pixelVbox = new QVBoxLayout();
    hbox->addLayout(pixelVbox);

    for(i=0; i<4; i++) {
        pixelWindow[i] = new PixelWindow(this,i);
        pixelWindow[i]->setMinimumHeight(100);
        pixelWindow[i]->setMinimumWidth(300);
        pixelVbox->addWidget(pixelWindow[i]);
    }

    for(i=0; i<28; i++) {
        _hornDisplay->channel[i]->setHornClickFunction(this);
        connect(_hornDisplay->channel[i]->_button,SIGNAL(clicked()),_hornDisplay->channel[i],SLOT(hornClick()));
    }

    for(i=0; i<4; i++) {
        //ppsHorn[i]->setHornClickFunction(clickHornSetPixel);
        ppsHorn[i]->setHornClickFunction(this);
        connect(ppsHorn[i]->_button,SIGNAL(clicked()),ppsHorn[i],SLOT(hornClick()));
    }
}
示例#18
0
void CalendarGraphicsItem::setSelectedDay(const QDate & sDate)
{
  //if(sDate == _selectedDay)
  //  return;

  _selectedDay = sDate;

  QDate today = QDate::currentDate();
  QDate firstMonthDay = QDate(_selectedDay.year(), _selectedDay.month(), 1);
  QDate firstCalendarDay = firstMonthDay.addDays(firstMonthDay.dayOfWeek() * -1);
  if(firstMonthDay.dayOfWeek() < 2)
    firstCalendarDay = firstCalendarDay.addDays(-7);

  QGraphicsRectItem * titleBackground = static_cast<QGraphicsRectItem*>(_items["titleBackground"]);
  QGraphicsSimpleTextItem * title = static_cast<QGraphicsSimpleTextItem*>(_items["title"]);
  if(title && titleBackground)
  { 
    title->setText(_selectedDay.toString("MMMM yyyy"));
    QPointF ct = titleBackground->boundingRect().center();
    QRectF rt = title->boundingRect();
    title->setPos(ct.x() - (rt.width() / 2),
                     ct.y() - (rt.height() / 2));
  }

  QDate date;
  QApplication::setOverrideCursor(Qt::WaitCursor);
  for(int wday = 0; wday < 42; wday++)
  {
    date = firstCalendarDay.addDays(wday);

    QBrush fill;
    QBrush dayFill = blackFill;
    if(date == _selectedDay)
      fill = selectedFill;
    else if(date.month() != _selectedDay.month())
    {
      fill = nonMonthFill;
      dayFill = nonMonthDayFill;
    }
    else if(date == today)
      fill = todayFill;
    else if(date.dayOfWeek() > 5)
      fill = weekendFill;

    QString additionalText;
    if(_controller)
      additionalText = _controller->contents(date);

    QGraphicsRectItem * ri = static_cast<QGraphicsRectItem*>(_items[QString("day%1").arg(wday)]);
    if(ri)
      ri->setBrush(fill);
  
    QGraphicsSimpleTextItem * si = static_cast<QGraphicsSimpleTextItem*>(_items[QString("day%1Number").arg(wday)]);
    if(si)
    {
      si->setText(QString::number(date.day()));
      si->setBrush(dayFill);
    }

    QGraphicsSimpleTextItem * si2 = static_cast<QGraphicsSimpleTextItem*>(_items[QString("day%1Text").arg(wday)]);
    if(si2)
    {
      si2->setText(additionalText);
      si2->setBrush(dayFill);
    }
  }
  QApplication::restoreOverrideCursor();

  if(_controller)
   _controller->setSelectedDay(_selectedDay);
}
void MenuEquipmentScreen::setCurrentEquipmentItem(QGraphicsSimpleTextItem *item, EquipmentPiece *equipment) {
	// Set brushes
	QBrush whiteBrush(Qt::white);
	QBrush yellowBrush(Qt::yellow);
	QBrush greenBrush(Qt::green);
	QBrush redBrush(Qt::red);
	QFont font("Times", 12, QFont::Bold);

	// Set current item
	if (!!_currentEquipmentListItem)
		_currentEquipmentListItem->setBrush(whiteBrush);

	_currentEquipmentListItem = item;
	_currentEquipmentListItem->setBrush(yellowBrush);

	// Reset the updated equipment stats
	_updatedStatsItem->setText(QString());
	for (int i = 0; i < _updatedStatsItems.size(); i++)
		delete _updatedStatsItems.at(i);
	_updatedStatsItems.clear();

	// Set the updated equipment stats
	QPointF position(_updatedStatsItem->pos().x(), _updatedStatsItem->pos().y() + 20);
	_updatedStatsItem->setText("Preview:");

	QVector<QPair<Attribute*, int>> currentEquipped(0);
	if (!!_currentEquippedEquipmentPiece)
		currentEquipped = _currentEquippedEquipmentPiece->getAttributes();

	QVector<QPair<Attribute*, int>> previewEquipped(0);
	if (!!equipment)
		previewEquipped = equipment->getAttributes();

	// First go over all of the currently equipped 
	// attributes for comparison.
	for (int i = 0; i < currentEquipped.size(); i++) {
		QPair<Attribute*, int> it1 = currentEquipped.at(i);
		QPair<Attribute*, int> it2(0, 0);

		for (int j = 0; j < previewEquipped.size();) {
			if (previewEquipped.at(j).first == it1.first) {
				it2 = previewEquipped.at(j);
				previewEquipped.remove(j);
				break;
			} else {
				j++;
			}
		}

		QGraphicsSimpleTextItem *item = new QGraphicsSimpleTextItem(_updatedStatsPanel);
		item->setText(it1.first->getName() + " + " + QString::number(it2.second));
		item->setFont(font);
		item->setPos(position);

		// Set brush
		if (it1.second > it2.second)
			item->setBrush(redBrush);
		else if (it1.second < it2.second)
			item->setBrush(greenBrush);
		else
			item->setBrush(whiteBrush);

		position.setY(position.y() + 20);
		_updatedStatsItems.append(item);
	}

	// Go over all the attributes of the considered
	// Equipment Piece for comparison.
	for (int i = 0; i < previewEquipped.size(); i++) {
		QPair<Attribute*, int> it = previewEquipped.at(i);

		QGraphicsSimpleTextItem *item = new QGraphicsSimpleTextItem(_updatedStatsPanel);
		item->setText(it.first->getName() + " + " + QString::number(it.second));
		item->setFont(font);
		item->setBrush(greenBrush);
		item->setPos(position);

		position.setY(position.y() + 20);
		_updatedStatsItems.append(item);
	}
}