static void init() { Desktop::add(new ControlView("0ControlView")); Desktop::add(new ControlView("1ControlView")); Desktop::add(new ControlView("2ControlView")); setVertical(); }
bool MiniProgrammerUI::eventFilter(QObject *obj, QEvent *event) { if (event->type() != QEvent::Resize) return QObject::eventFilter(obj, event); QResizeEvent *e = (QResizeEvent*)event; setVertical(e->size().width() < e->size().height()); return QObject::eventFilter(obj, event); }
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; }
bool OCRuler::setAttr(const QString& name, const QVariant& value) { if (name == "min") { bool ok; double v = value.toDouble(&ok); if (ok) setMin(v); return ok; } if (name == "max") { bool ok; double v = value.toDouble(&ok); if (ok) setMax(v); return ok; } if (name == "vertical") { setVertical(value.toBool()); return true; } return OCDataWidget::setAttr(name, value); }
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(); }
//------------------------------------------------------------------------------ // setSlotVertical() - vertical or horizontal tape //------------------------------------------------------------------------------ bool Tape::setSlotVertical(const Basic::Number* const x) { bool ok = false; if (x != 0) ok = setVertical(x->getBoolean()); return ok; }