int gameTable::checkColision(int x, int y) { int horizontal, vertical; horizontal = checkHorizontalColision(x, y); vertical = checkVerticalColision(x, y); setHorizontal(x, y, horizontal); setVertical(x, y, vertical); if (horizontal >= 3 && vertical >= 3) { return horizontal + vertical; } else if (horizontal >= 3) return horizontal; else if (vertical >= 3) return vertical; else return 0; }
void BulletMLParserTinyXML::translateNode(TiXmlNode* node) { TiXmlElement* elem = node->ToElement(); assert(elem != 0); BulletMLNode* xmlNode = addContent(elem->Value()); if (xmlNode->getName() == BulletMLNode::bulletml) { TiXmlAttribute* attr; for (attr = elem->FirstAttribute(); attr; attr = attr->Next()) { if (attr->Value() == "horizontal") setHorizontal(); } } else { MyAttributes mattr; TiXmlAttribute* attr; for (attr = elem->FirstAttribute(); attr; attr = attr->Next()) { mattr.push_back(attr->Name()); mattr.push_back(attr->Value()); } addAttribute(mattr, xmlNode); if (curNode_ != 0) curNode_->addChild(xmlNode); } curNode_ = xmlNode; }
FieldWidget::FieldWidget(QWidget *parent) : QGraphicsView(parent), m_geometryUpdated(true), m_rotation(0.0f), m_worldStateUpdated(false), m_visualizationsUpdated(false), m_hasTouchInput(false), m_dragType(DragNone), m_dragItem(NULL) { m_touchStatusType = QGestureRecognizer::registerRecognizer(new TouchStatusRecognizer); grabGesture(m_touchStatusType); grabGesture(Qt::PanGesture); grabGesture(Qt::PinchGesture); geometrySetDefault(&m_geometry); // setup context menu m_contextMenu = new QMenu(this); QAction *actionHorizontal = m_contextMenu->addAction("Horizontal"); connect(actionHorizontal, SIGNAL(triggered()), SLOT(setHorizontal())); QAction *actionVertical = m_contextMenu->addAction("Vertical"); connect(actionVertical, SIGNAL(triggered()), SLOT(setVertical())); QAction *actionFlip = m_contextMenu->addAction("Flip"); connect(actionFlip, SIGNAL(triggered()), SLOT(flip())); m_contextMenu->addSeparator(); // add actions to allow hiding visualizations of a team m_actionShowBlueVis = m_contextMenu->addAction("Show blue visualizations"); m_actionShowBlueVis->setCheckable(true); m_actionShowBlueVis->setChecked(true); connect(m_actionShowBlueVis, SIGNAL(triggered()), SLOT(updateVisualizationVisibility())); m_actionShowYellowVis = m_contextMenu->addAction("Show yellow visualizations"); m_actionShowYellowVis->setCheckable(true); m_actionShowYellowVis->setChecked(true); connect(m_actionShowYellowVis, SIGNAL(triggered()), SLOT(updateVisualizationVisibility())); m_actionShowControllerVis = m_contextMenu->addAction("Show controller visualizations"); m_actionShowControllerVis->setCheckable(true); m_actionShowControllerVis->setChecked(true); connect(m_actionShowControllerVis, SIGNAL(triggered()), SLOT(updateVisualizationVisibility())); updateVisualizationVisibility(); // update the visibility map m_contextMenu->addSeparator(); // other actions QAction *actionShowAOI = m_contextMenu->addAction("Enable custom vision area"); actionShowAOI->setCheckable(true); connect(actionShowAOI, SIGNAL(toggled(bool)), SLOT(setAOIVisible(bool))); m_actionAntialiasing = m_contextMenu->addAction("Anti-aliasing"); m_actionAntialiasing->setCheckable(true); connect(m_actionAntialiasing, SIGNAL(toggled(bool)), SLOT(setAntialiasing(bool))); m_actionGL = m_contextMenu->addAction("OpenGL"); m_actionGL->setCheckable(true); connect(m_actionGL, SIGNAL(toggled(bool)), SLOT(setOpenGL(bool))); m_contextMenu->addSeparator(); QAction *actionScreenshot = m_contextMenu->addAction("Take screenshot"); connect(actionScreenshot, SIGNAL(triggered()), SLOT(takeScreenshot())); QAction *actionSaveSituation = m_contextMenu->addAction("Save Situation"); connect(actionSaveSituation, SIGNAL(triggered()), SLOT(saveSituation())); // create graphics scene m_scene = new QGraphicsScene(this); setScene(m_scene); // ball object const float ballRadius = 0.02133f; m_ball = new QGraphicsEllipseItem; m_ball->setPen(Qt::NoPen); m_ball->setBrush(QColor(255, 66, 0)); m_ball->setZValue(100.0f); m_ball->setRect(QRectF(-ballRadius, -ballRadius, ballRadius * 2.0f, ballRadius * 2.0f)); m_ball->hide(); m_scene->addItem(m_ball); // rectangle for area of interest m_aoiItem = new QGraphicsPathItem; m_aoiItem->setPen(Qt::NoPen); m_aoiItem->setBrush(QColor(0, 0, 0, 128)); m_aoiItem->setZValue(10000.0f); m_aoiItem->hide(); m_scene->addItem(m_aoiItem); m_aoi = QRectF(-1, -1, 2, 2); updateAOI(); m_scene->setBackgroundBrush(Qt::black); m_scene->setItemIndexMethod(QGraphicsScene::NoIndex); // should improve the performance setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); // transforms are centered on the mouse cursor setTransformationAnchor(QGraphicsView::NoAnchor); setOptimizationFlag(QGraphicsView::DontSavePainterState); setCacheMode(QGraphicsView::CacheBackground); setHorizontal(); // view update timer QTimer *timer = new QTimer(this); connect(timer, SIGNAL(timeout()), SLOT(updateAll())); timer->start(30); setMouseTracking(true); // create label to show field coordinates m_lblMousePos = new QLabel(this); m_lblMousePos->setAutoFillBackground(true); // solid background // draw frame m_lblMousePos->setFrameStyle(QFrame::StyledPanel | QFrame::Raised); m_lblMousePos->setMargin(2); // some space m_lblMousePos->hide(); // ensure that the label is hidden on startup // load settings QSettings s; s.beginGroup("Field"); m_actionGL->setChecked(s.value("OpenGL").toBool()); m_actionAntialiasing->setChecked(s.value("AntiAliasing").toBool()); s.endGroup(); }
void AbstractDisplay::setData(rvec getData) { data_ = getData; setHorizontal(0, data_.size()-1); }