void Gui::createGroupGui(const NodePtr & group, CreateNodeReason reason) { boost::shared_ptr<NodeGroup> isGrp = boost::dynamic_pointer_cast<NodeGroup>( group->getEffectInstance()->shared_from_this() ); assert(isGrp); boost::shared_ptr<NodeCollection> collection = boost::dynamic_pointer_cast<NodeCollection>(isGrp); assert(collection); TabWidget* where = 0; if (_imp->_lastFocusedGraph) { TabWidget* isTab = dynamic_cast<TabWidget*>( _imp->_lastFocusedGraph->parentWidget() ); if (isTab) { where = isTab; } else { QMutexLocker k(&_imp->_panesMutex); assert( !_imp->_panes.empty() ); where = _imp->_panes.front(); } } QGraphicsScene* scene = new QGraphicsScene(this); scene->setItemIndexMethod(QGraphicsScene::NoIndex); NodeGraph* nodeGraph = new NodeGraph(this, collection, scene, this); nodeGraph->setObjectName( QString::fromUtf8(group->getLabel().c_str()) ); _imp->_groups.push_back(nodeGraph); if ( where && reason == eCreateNodeReasonUserCreate && !getApp()->isCreatingPythonGroup() ) { where->appendTab(nodeGraph, nodeGraph); QTimer::singleShot( 25, nodeGraph, SLOT(centerOnAllNodes()) ); } else { nodeGraph->setVisible(false); } }
int main(int argc, char *argv[]) { QApplication app(argc, argv); QGraphicsScene scene; scene.setSceneRect(-500, -500, 1000, 1000); scene.setItemIndexMethod(QGraphicsScene::NoIndex); Car *car = new Car(); scene.addItem(car); QGraphicsView view(&scene); view.setRenderHint(QPainter::Antialiasing); view.setBackgroundBrush(Qt::darkGray); view.setWindowTitle(QT_TRANSLATE_NOOP(QGraphicsView, "Qt DBus Controlled Car")); view.resize(400, 300); view.show(); new CarInterfaceAdaptor(car); QDBusConnection connection = QDBusConnection::sessionBus(); connection.registerObject("/Car", car); connection.registerService("com.trolltech.CarExample"); return app.exec(); }
//! [0] int main(int argc, char **argv) { QApplication app(argc, argv); qsrand(QTime(0,0,0).secsTo(QTime::currentTime())); //! [0] //! [1] QGraphicsScene scene; scene.setSceneRect(-300, -300, 600, 600); //! [1] //! [2] scene.setItemIndexMethod(QGraphicsScene::NoIndex); //! [2] //! [3] for (int i = 0; i < MouseCount; ++i) { Mouse *mouse = new Mouse; mouse->setPos(::sin((i * 6.28) / MouseCount) * 200, ::cos((i * 6.28) / MouseCount) * 200); scene.addItem(mouse); } //! [3] //! [4] GraphicsView view(&scene); view.setRenderHint(QPainter::Antialiasing); view.setBackgroundBrush(QPixmap(":/images/cheese.jpg")); //! [4] //! [5] view.setCacheMode(QGraphicsView::CacheBackground); view.setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate); //! [5] //! [6] view.setWindowTitle(QT_TRANSLATE_NOOP(QGraphicsView, "Colliding Mice")); view.showMaximized(); return app.exec(); }
GraphWidget::GraphWidget(QWidget *parent) : timerId(0) { myMainwindow = dynamic_cast<QoccMainWindow*>(parent); QGraphicsScene *scene = new QGraphicsScene(this); scene->setItemIndexMethod(QGraphicsScene::NoIndex); scene->setSceneRect(0, 0, 8000, 8000); setScene(scene); //setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers))); //setViewport(new QGLWidget()); setRenderHint(QPainter::Antialiasing, false); //setDragMode(QGraphicsView::RubberBandDrag); setOptimizationFlags(QGraphicsView::DontSavePainterState); setViewportUpdateMode(QGraphicsView::SmartViewportUpdate); setCacheMode(CacheBackground); //setRenderHint(QPainter::Antialiasing); setTransformationAnchor(AnchorUnderMouse); setResizeAnchor(AnchorViewCenter); scale(qreal(0.8), qreal(0.8)); setMinimumSize(400, 400); setWindowTitle(tr("Elastic Nodes")); }
//! [0] GraphWidget::GraphWidget(QWidget *parent) : QGraphicsView(parent), timerId(0) { //初始化场景 QGraphicsScene *scene = new QGraphicsScene(this); scene->setItemIndexMethod(QGraphicsScene::NoIndex); //设置场景 setScene(scene); //缓存背景模式,提高绘制效率,防止闪屏 setCacheMode(CacheBackground); setViewportUpdateMode(BoundingRectViewportUpdate); //设置抗锯齿,平滑图像或字体边缘 setRenderHints(QPainter::Antialiasing|QPainter::TextAntialiasing|QPainter::SmoothPixmapTransform); //允许节点位置动态调整 setTransformationAnchor(AnchorUnderMouse); //允许上下文菜单 setContextMenuPolicy(Qt::ActionsContextMenu); //允许拖拽滚屏 setDragMode( QGraphicsView::ScrollHandDrag); setInteractive(true); setMinimumSize(Default_width, Default_height); }
int main(int argc, char *argv[]) { QApplication a(argc, argv); QImage texture("pics/nana.jpg"); if (texture.isNull()) { qDebug() << "Couldn't read the default texture. Shadow building, but forgot to set the run directory?"; return 0; } QPixmap *canvas = new QPixmap(texture.width(), texture.height()); QGraphicsScene scene; scene.setItemIndexMethod(QGraphicsScene::NoIndex); Boids boids(&scene, canvas, &texture); SettingsPanel settings; settings.move(1250, 200); BoidsView view(canvas); QGLWidget* viewport = new QGLWidget(); view.setViewport(viewport); view.setOptimizationFlag(QGraphicsView::DontSavePainterState); view.setAutoFillBackground(false); view.setGeometry(50, 100, texture.width(), texture.height()); view.setScene(&scene); view.setSceneRect(-view.width() / 2, -view.height() / 2, view.width(), view.height()); view.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); view.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); view.setWindowTitle("Boids"); QObject::connect(&view, SIGNAL(mousePositionChanged(float,float)), &boids, SLOT(setTargetLocation(float,float))); QObject::connect(&view, SIGNAL(enableSimulation(bool)), &boids, SLOT(enableSimulation(bool))); QObject::connect(&settings, SIGNAL(boidCountChanged(int)), &boids, SLOT(setBoidCount(int))); QObject::connect(&settings, SIGNAL(trailOpacityChanged(int)), &boids, SLOT(setTrailOpacity(int))); QObject::connect(&settings, SIGNAL(textureChanged(QString)), &boids, SLOT(loadTexture(QString))); QObject::connect(&settings, SIGNAL(clearCanvas()), &boids, SLOT(clearCanvas())); QObject::connect(&settings, SIGNAL(saveCanvas(QString)), &boids, SLOT(saveCanvas(QString))); QObject::connect(&settings, SIGNAL(colorEvolutionRateChanged(int)), &boids, SLOT(setColorEvolutionRate(int))); QObject::connect(&settings, SIGNAL(coloringModeChanged(Boids::ColoringMode)), &boids, SLOT(setColoringMode(Boids::ColoringMode))); QObject::connect(&boids, SIGNAL(canvasChanged(QPixmap*)), &view, SLOT(canvasChanged(QPixmap*))); QObject::connect(&settings, SIGNAL(maximumSpeedChanged(int)), &boids, SLOT(setMaxBoidSpeed(int))); QObject::connect(&settings, SIGNAL(minimumDistanceChanged(int)), &boids, SLOT(setMinimumDistance(int))); QObject::connect(&settings, SIGNAL(inertiaChanged(int)), &boids, SLOT(setInertia(int))); boids.setBoidCount(settings.boidCount()); boids.setColorEvolutionRate(settings.colorEvolutionRate()); boids.setColoringMode(settings.coloringMode()); boids.setTrailOpacity(settings.trailOpacity()); boids.setMaxBoidSpeed(settings.maximumSpeed()); boids.setMinimumDistance(settings.minimumDistance()); boids.setInertia(settings.inertia()); view.show(); settings.show(); return a.exec(); }
int main(int argc, char *argv[]) { QApplication app(argc, argv); cv::Mat inputImage = cv::imread("./icon.png"); if(!inputImage.empty()){ cv::imshow("Display Image", inputImage); waitKey(1); } QGraphicsScene scene; scene.setSceneRect(0, 0, 500, 500); scene.setItemIndexMethod(QGraphicsScene::NoIndex); Car *car = new Car(); scene.addItem(car); car->turnLeft(); car->accelerate(); QGraphicsView view(&scene); view.setRenderHint(QPainter::Antialiasing); view.setBackgroundBrush(Qt::darkGray); view.setWindowTitle(QT_TRANSLATE_NOOP(QGraphicsView, "CV Controlled Car")); view.resize(1000, 1000); view.show(); return app.exec(); }
void ScopeviewForm::setupUI() { _showFormAct = UIUtil::createWidgetWithName<QAction>("ScopeView Pannel"); connect(_showFormAct, SIGNAL(triggered()), this, SLOT(onShowForm())); _graphView = new QGraphicsView(); QGraphicsScene* scene = new QGraphicsScene(_graphView); scene->setItemIndexMethod(QGraphicsScene::NoIndex); scene->setSceneRect(this->rect()); _graphView->setScene(scene); _graphView->setCacheMode(QGraphicsView::CacheBackground); _graphView->setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate); _graphView->setBackgroundBrush(QBrush(QColor(195,195,195))); QVBoxLayout* vv = new QVBoxLayout(); vv->addWidget(_graphView); vv->setContentsMargins(0,0,0,0); this->setLayout(vv); /* for (int i = 0; i < 8; ++i) { QGroupBox* gbox = createGroupBox(i + 1); _groupboxs.append(gbox); this->scene()->addWidget(gbox); }*/ updateSceneRect(); updateSceneItemPos(); }
//! [0] GraphWidget::GraphWidget(QWidget *parent) : QGraphicsView(parent), timerId(0) { QGraphicsScene *scene = new QGraphicsScene(this); scene->setItemIndexMethod(QGraphicsScene::NoIndex); scene->setSceneRect(-200, -200, 400, 400); setScene(scene); setCacheMode(CacheBackground); setViewportUpdateMode(BoundingRectViewportUpdate); setRenderHint(QPainter::Antialiasing); setTransformationAnchor(AnchorUnderMouse); scale(qreal(0.8), qreal(0.8)); setMinimumSize(400, 400); setWindowTitle(tr("Elastic Nodes")); //! [0] //! [1] Node *node1 = new Node(this); Node *node2 = new Node(this); Node *node3 = new Node(this); Node *node4 = new Node(this); centerNode = new Node(this); Node *node6 = new Node(this); Node *node7 = new Node(this); Node *node8 = new Node(this); Node *node9 = new Node(this); scene->addItem(node1); scene->addItem(node2); scene->addItem(node3); scene->addItem(node4); scene->addItem(centerNode); scene->addItem(node6); scene->addItem(node7); scene->addItem(node8); scene->addItem(node9); scene->addItem(new Edge(node1, node2)); scene->addItem(new Edge(node2, node3)); scene->addItem(new Edge(node2, centerNode)); scene->addItem(new Edge(node3, node6)); scene->addItem(new Edge(node4, node1)); scene->addItem(new Edge(node4, centerNode)); scene->addItem(new Edge(centerNode, node6)); scene->addItem(new Edge(centerNode, node8)); scene->addItem(new Edge(node6, node9)); scene->addItem(new Edge(node7, node4)); scene->addItem(new Edge(node8, node7)); scene->addItem(new Edge(node9, node8)); node1->setPos(-50, -50); node2->setPos(0, -50); node3->setPos(50, -50); node4->setPos(-50, 0); centerNode->setPos(0, 0); node6->setPos(50, 0); node7->setPos(-50, 50); node8->setPos(0, 50); node9->setPos(50, 50); }
MainWindow::MainWindow(QGraphicsScene *parent) : QGraphicsView(parent) { QGraphicsScene *mainScene = new QGraphicsScene; setScene(mainScene); setFrameShape(QFrame::NoFrame); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate); setCacheMode( QGraphicsView::CacheBackground ); setAttribute(Qt::WA_TranslucentBackground, false); setBackgroundBrush(QBrush(Qt::black, Qt::SolidPattern)); QDir templateDir = QApplication::applicationDirPath(); templateDir.cdUp(); templateDir.cd("app"); qDebug() << "Loading file: " << templateDir.filePath("index.html"); QGraphicsScene *scene = new QGraphicsScene; QDeclarativeEngine *engine = new QDeclarativeEngine; QDeclarativeComponent component(engine, QUrl::fromLocalFile(QApplication::applicationDirPath() + QLatin1String("/../qml/browser.qml"))); qDebug() << component.errors(); notifier = new Notifier(); QObject *comp = component.create(); QMLDialog = comp->findChild<QDeclarativeItem*>("dialog"); QMLGallery = comp->findChild<QDeclarativeItem*>("gallery"); QMLWebView = comp->findChild<QDeclarativeItem*>("webView"); engine->rootContext()->setContextProperty("notifier", notifier); ((QDeclarativeWebView*) QMLWebView)->setPage(new WebPage()); QMLWebView->setProperty("pageUrl", "../app/index.html"); ((QDeclarativeWebView*) QMLWebView)->page()->settings()->setAttribute(QWebSettings::LocalStorageEnabled, true); ((QDeclarativeWebView*) QMLWebView)->page()->settings()->setAttribute(QWebSettings::LocalStorageDatabaseEnabled, true); ((QDeclarativeWebView*) QMLWebView)->page()->settings()->setAttribute(QWebSettings::AcceleratedCompositingEnabled, true); ((QDeclarativeWebView*) QMLWebView)->page()->settings()->setAttribute(QWebSettings::TiledBackingStoreEnabled, true); ((QDeclarativeWebView*) QMLWebView)->settings()->enablePersistentStorage(); QMLWebView->setCacheMode(QGraphicsItem::DeviceCoordinateCache); new Extensions(((QDeclarativeWebView*) QMLWebView)); scene->addItem(qobject_cast<QGraphicsItem*>(comp)); scene->setSceneRect(0,0,width(),height()); scene->setItemIndexMethod(QGraphicsScene::NoIndex); QMLView = new QGraphicsView( this ); QMLView->setScene( scene ); QMLView->setGeometry(0,0,width(),height()); QMLView->setStyleSheet( "background: transparent; border: none;" ); QMLView->setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate); QMLView->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); QMLView->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); QMLView->setCacheMode( QGraphicsView::CacheBackground ); QMLView->setFrameShape(QFrame::NoFrame); ((QDeclarativeWebView*) QMLWebView)->page()->mainFrame()->evaluateJavaScript("window._nativeReady = true"); // Tell PhoneGap that init is complete. }
ImageViewerWidget::ImageViewerWidget(int width, int height) : QGraphicsView(), viewScale(1.0) { QGraphicsScene *scene = new QGraphicsScene(this); scene->setItemIndexMethod(QGraphicsScene::NoIndex); scene->setSceneRect(0, 0, width, height); setScene(scene); setCacheMode(CacheBackground); setRenderHint(QPainter::Antialiasing); setTransformationAnchor(AnchorUnderMouse); scale(qreal(1), qreal(1)); }
void GuiPrivate::createNodeGraphGui() { QGraphicsScene* scene = new QGraphicsScene(_gui); scene->setItemIndexMethod(QGraphicsScene::NoIndex); _nodeGraphArea = new NodeGraph(_gui, _appInstance.lock()->getProject(), kNodeGraphObjectName, scene, _gui); _nodeGraphArea->setLabel( tr("Node Graph").toStdString() ); _nodeGraphArea->setVisible(false); }
QGobanView::QGobanView(QWidget *parent) : QGraphicsView(parent) { QGraphicsScene *scene = new QGraphicsScene(this); scene->setItemIndexMethod(QGraphicsScene::NoIndex); scene->setSceneRect(0,0,450,450); setScene(scene); setCacheMode(CacheBackground); setViewportUpdateMode(FullViewportUpdate); setRenderHint(QPainter::Antialiasing); setTransformationAnchor(AnchorUnderMouse); setResizeAnchor(AnchorViewCenter); }
void TraceGraphView::initialise() { QGraphicsScene* scene = new QGraphicsScene; // scene->setSceneRect(-100,-300,200,300); scene->setItemIndexMethod(QGraphicsScene::BspTreeIndex); setScene(scene); setRenderHint(QPainter::Antialiasing); setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate); setDragMode(QGraphicsView::RubberBandDrag); setCacheMode(QGraphicsView::CacheNone); // connect( }
CRouteGraph::CRouteGraph(QWidget *parent) : QGraphicsView(parent) { QGraphicsScene *scene = new QGraphicsScene(this); scene->setItemIndexMethod(QGraphicsScene::NoIndex); setScene(scene); setCacheMode(CacheBackground); setViewportUpdateMode(BoundingRectViewportUpdate); setRenderHint(QPainter::Antialiasing); setTransformationAnchor(AnchorUnderMouse); m_ScaleFactor = 1; }
int main (int argc, char** argv) { QApplication app(argc, argv); QGraphicsView view; QGraphicsScene *scene = new QGraphicsScene(&view); scene->setItemIndexMethod(QGraphicsScene::NoIndex); Line *left, *right, *right2; int of = pos_x; for(int i = 0; i < c; i++) { Line* ball = new Line(QPoint(of, -2)); scene->addItem(ball); of += size; if(i==0) left = ball; else if(i == c - 1) right = ball; else if(i == c - 2) right2 = ball; } QTimeLine *LeftTimerTo = newAnim(left,0,45,QEasingCurve::OutQuart); QTimeLine *LeftTimerReturn = newAnim(left,45,0,QEasingCurve::InQuart); QTimeLine *RightTimerTo = newAnim(right,0,-45,QEasingCurve::OutQuart); QTimeLine *RightTimerBack = newAnim(right,-45,0,QEasingCurve::InQuart); QTimeLine *RightTimerTo2 = newAnim(right2,0,-45,QEasingCurve::OutQuart); QTimeLine *RightTimerBack2 = newAnim(right2,-45,0,QEasingCurve::InQuart); scene->setSceneRect(0, 0, 940, 460); view.setCacheMode(QGraphicsView::CacheBackground); view.setViewportUpdateMode(QGraphicsView::FullViewportUpdate); view.setScene(scene); view.resize(960, 480); view.show(); QObject::connect(LeftTimerTo, SIGNAL(finished()), LeftTimerReturn, SLOT(start())); QObject::connect(LeftTimerReturn, SIGNAL(finished()), RightTimerTo, SLOT(start())); QObject::connect(LeftTimerReturn, SIGNAL(finished()), RightTimerTo2, SLOT(start())); QObject::connect(RightTimerTo, SIGNAL(finished()), RightTimerBack, SLOT(start())); QObject::connect(RightTimerTo2, SIGNAL(finished()), RightTimerBack2, SLOT(start())); QObject::connect(RightTimerBack,SIGNAL(finished()), LeftTimerTo, SLOT(start())); LeftTimerReturn->start(); return app.exec(); }
void Gui::createGroupGui(const NodePtr & group, const CreateNodeArgs& args) { NodeGroupPtr isGrp = toNodeGroup( group->getEffectInstance()->shared_from_this() ); assert(isGrp); NodeCollectionPtr collection = boost::dynamic_pointer_cast<NodeCollection>(isGrp); assert(collection); TabWidget* where = 0; if (_imp->_lastFocusedGraph) { TabWidget* isTab = dynamic_cast<TabWidget*>( _imp->_lastFocusedGraph->parentWidget() ); if (isTab) { where = isTab; } else { std::list<TabWidgetI*> panes = getApp()->getTabWidgetsSerialization(); assert( !panes.empty() ); where = dynamic_cast<TabWidget*>(panes.front()); } } QGraphicsScene* scene = new QGraphicsScene(this); scene->setItemIndexMethod(QGraphicsScene::NoIndex); std::string newName = isGrp->getNode()->getFullyQualifiedName(); for (std::size_t i = 0; i < newName.size(); ++i) { if (newName[i] == '.') { newName[i] = '_'; } } newName += "_NodeGraph"; std::string label = tr(" Node Graph").toStdString(); NodeGraph::makeFullyQualifiedLabel(group, &label); NodeGraph* nodeGraph = new NodeGraph(this, collection, newName, scene, this); nodeGraph->setLabel(label); nodeGraph->setObjectName( QString::fromUtf8( group->getLabel().c_str() ) ); _imp->_groups.push_back(nodeGraph); SERIALIZATION_NAMESPACE::NodeSerializationPtr serialization = args.getPropertyUnsafe<SERIALIZATION_NAMESPACE::NodeSerializationPtr>(kCreateNodeArgsPropNodeSerialization); bool showSubGraph = args.getPropertyUnsafe<bool>(kCreateNodeArgsPropSubGraphOpened); if ( showSubGraph && where && !serialization ) { where->appendTab(nodeGraph, nodeGraph); QTimer::singleShot( 25, nodeGraph, SLOT(centerOnAllNodes()) ); } else { nodeGraph->setVisible(false); } }
Window::Window() { horizontalSliders = new SlidersGroup(Qt::Horizontal, tr("Simulation")); verticalSliders = new SlidersGroup(Qt::Vertical, tr("Simulation")); QGraphicsScene scene; scene.setSceneRect(-300, -300, 300, 300); scene.setItemIndexMethod(QGraphicsScene::NoIndex); QGraphicsView view(&scene); view.setRenderHint(QPainter::Antialiasing); view.setBackgroundBrush(QPixmap(":/images/cheese.jpg")); view.setCacheMode(QGraphicsView::CacheBackground); view.setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate); view.setDragMode(QGraphicsView::ScrollHandDrag); view.setWindowTitle(QT_TRANSLATE_NOOP(QGraphicsView, "Simulation")); view.resize(600, 600); // view.show(); stackedWidget = new QStackedWidget; stackedWidget->addWidget(horizontalSliders); stackedWidget->addWidget(verticalSliders); createControls(tr("Controls")); connect(weightLineEdit, SIGNAL(textChanged(QString)), temp, SLOT(setValue(QString))); connect(temp, SIGNAL(valueChanged(QString)), xValueLabel, SLOT(setText(QString))); connect(horizontalSliders, SIGNAL(valueChanged(int)), verticalSliders, SLOT(setValue(int))); // connect(verticalSliders, SIGNAL(valueChanged(int)), // valueSpinBox, SLOT(setValue(int))); // connect(valueSpinBox, SIGNAL(valueChanged(int)), // horizontalSliders, SLOT(setValue(int))); QHBoxLayout *layout = new QHBoxLayout; layout->addWidget(stackedWidget); // layout->addWidget(view); layout->addWidget(controlsGroup); setLayout(layout); // minimumSpinBox->setValue(0); // maximumSpinBox->setValue(20); // valueSpinBox->setValue(5); setWindowTitle(tr("Simulated Physics")); }
StoryLineWidget::StoryLineWidget(){ QGraphicsScene *scene = new QGraphicsScene(this); scene->setItemIndexMethod(QGraphicsScene::NoIndex); scene->setSceneRect(QRectF(0, 0, 3200, 300)); setScene(scene); setCacheMode(CacheBackground); setViewportUpdateMode(BoundingRectViewportUpdate); setRenderHint(QPainter::Antialiasing); setTransformationAnchor(AnchorUnderMouse); this->setAlignment(Qt::AlignLeft); story_stamp_vec_.clear(); result_value_map_ = NULL; }
MainWindow::MainWindow() { QGraphicsScene *scene = new BackgroundScene(this); scene->setItemIndexMethod(QGraphicsScene::NoIndex); scene->setSceneRect(0, 0, 400, 400); setScene(scene); //setCacheMode(CacheBackground); setViewportUpdateMode(BoundingRectViewportUpdate); setRenderHint(QPainter::Antialiasing); setTransformationAnchor(AnchorUnderMouse); setResizeAnchor(AnchorViewCenter); scale(qreal(0.8), qreal(0.8)); setMinimumSize(400, 400); setWindowTitle(tr("Bezier Curves")); }
WristWidget::WristWidget(QWidget *parent) : QGraphicsView(parent), timerId(0) { QGraphicsScene *scene = new QGraphicsScene(this); scene->setItemIndexMethod(QGraphicsScene::NoIndex); scene->setSceneRect(0, 0, 50, 50); setScene(scene); setCacheMode(CacheBackground); setViewportUpdateMode(BoundingRectViewportUpdate); setRenderHint(QPainter::Antialiasing); setTransformationAnchor(AnchorUnderMouse); scale(qreal(1), qreal(1)); setMinimumSize(50, 50); setWindowTitle(tr("Elastic Nodes")); wristAngle = 0; int x = WRIST_WIDTH / 2 * cos(wristAngle); int y = WRIST_WIDTH / 2 * sin(wristAngle); Line *line = new Line( WRIST_CENTER_X - x, WRIST_CENTER_Y + y, WRIST_CENTER_X + x, WRIST_CENTER_Y - y); line->setTransformOriginPoint(WRIST_CENTER_X,WRIST_CENTER_Y); x = WRIST_HEIGHT * cos(wristAngle + M_PI / 2); y = WRIST_HEIGHT * sin(wristAngle + M_PI / 2); QGraphicsLineItem *line2 = new QGraphicsLineItem( WRIST_CENTER_X, WRIST_CENTER_Y, WRIST_CENTER_X + x, WRIST_CENTER_Y - y); line->setPen(QPen(Qt::red,WRIST_LINE_WIDTH)); line2->setPen(QPen(Qt::red,WRIST_LINE_WIDTH)); // make the line be able to rotate around the origin point given as parameters line->setFlag(line->ItemIsMovable); line->setTransformOriginPoint(WRIST_CENTER_X, WRIST_CENTER_Y); scene->addItem(line); scene->addItem(line2); timerId = startTimer(1000 / 25); }
ArmWidget::ArmWidget(QWidget *parent) : QGraphicsView(parent), timerId(0) { QGraphicsScene *scene = new QGraphicsScene(this); scene->setItemIndexMethod(QGraphicsScene::NoIndex); scene->setSceneRect(0, 00, 210, 110); shoulder = true; elbow = true; setScene(scene); setCacheMode(CacheBackground); setViewportUpdateMode(BoundingRectViewportUpdate); setRenderHint(QPainter::Antialiasing); setTransformationAnchor(AnchorUnderMouse); scale(qreal(1), qreal(1)); setMinimumSize(210, 110); setWindowTitle(tr("Elastic Nodes")); joint *joint1 = new joint(this); joint *joint2 = new joint(this); joint *joint3 = new joint(this); scene->addItem(joint1); scene->addItem(joint2); scene->addItem(joint3); joint3->setFlag(joint3->ItemIsMovable); double x = armShoulderSegmentMeters; double y = armElbowSegmentMeters; joint1->setPos(this->sceneRect().left()+ARM_SHOULDER_X+5, this->sceneRect().bottom()-ARM_Y+ARM_BODY_TOP+5); joint2->setPos(this->sceneRect().left()+ARM_SHOULDER_X+5, -MetersToPixels(y)-ARM_Y+ARM_BODY_TOP+5+this->sceneRect().bottom()); joint3->setPos(MetersToPixels(x)+this->sceneRect().left()+ARM_SHOULDER_X+5, -MetersToPixels(y)-ARM_Y+ARM_BODY_TOP+5+this->sceneRect().bottom()); end_effector = QPointF(0,0); QGraphicsLineItem *line = new QGraphicsLineItem(joint1->pos().x()-5,joint1->pos().y()-5,joint2->pos().x()-5,joint2->pos().y()-5); scene->addItem(line); QGraphicsLineItem *line2 = new QGraphicsLineItem(joint2->pos().x()-5,joint2->pos().y()-5,joint3->pos().x()-5,joint3->pos().y()-5); scene->addItem(line2); }
//! [0] int main(int argc, char **argv) { QApplication app(argc, argv); qsrand(QTime(0,0,0).secsTo(QTime::currentTime())); //! [0] //! [1] QGraphicsScene scene; scene.setSceneRect(-300, -300, 600, 600); //! [1] //! [2] scene.setItemIndexMethod(QGraphicsScene::NoIndex); //! [2] //! [3] for (int i = 0; i < MouseCount; ++i) { Mouse *mouse = new Mouse; mouse->setPos(::sin((i * 6.28) / MouseCount) * 200, ::cos((i * 6.28) / MouseCount) * 200); scene.addItem(mouse); } //! [3] //! [4] QGraphicsView view(&scene); view.setRenderHint(QPainter::Antialiasing); view.setBackgroundBrush(QPixmap(":/images/cheese.jpg")); //! [4] //! [5] view.setCacheMode(QGraphicsView::CacheBackground); view.setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate); view.setDragMode(QGraphicsView::ScrollHandDrag); //! [5] //! [6] view.setWindowTitle(QT_TRANSLATE_NOOP(QGraphicsView, "Colliding Mice")); #if defined(Q_WS_S60) || defined(Q_WS_MAEMO_5) || defined(Q_WS_SIMULATOR) view.showMaximized(); #else view.resize(400, 300); view.show(); #endif QTimer timer; QObject::connect(&timer, SIGNAL(timeout()), &scene, SLOT(advance())); timer.start(1000 / 33); return app.exec(); }
widget::widget(QWidget *parent) :QGraphicsView(parent) { QGraphicsScene *scene = new QGraphicsScene(this); scene->setItemIndexMethod(QGraphicsScene::NoIndex); sceneX = -250; sceneY = -250; sceneHeigth = 490; sceneWidth = 490; scene->setSceneRect(sceneX, sceneY, sceneHeigth, sceneWidth); setScene(scene); setCacheMode(CacheBackground); setViewportUpdateMode(BoundingRectViewportUpdate); setRenderHint(QPainter::Antialiasing); setTransformationAnchor(AnchorUnderMouse); setWindowTitle(tr("Bacterial Growth")); bacteria * bact0 = new bacteria(); QRectF bactSize = bact0->boundingRect(); bacHorizonSize = bactSize.width(); bacVertSize = bactSize.height(); nHorizon = floor((double)sceneWidth/(double)bacHorizonSize); nVert = floor((double)sceneHeigth/(double)bacVertSize); bacteriaGrid.resize(nVert); for(int i = 0; i < nVert; i++) { bacteriaGrid[i].resize(nHorizon); for(int j = 0; j < nHorizon; j++) { bacteriaGrid[i][j] = -1; } } // first bacteria bacteria * bact1 = new bacteria(); scene->addItem(bact1); allBacterias << bact1; bacteriaGrid[12][12] = 0; allBacterias[0]->setPos(12.5 * bacHorizonSize + sceneX, 12.5 * bacVertSize + sceneY); // as bacterias sao indistinguiveis. timerId = startTimer(1000 / 0.5); timerAnimation = startTimer(1000 / 5); }
TMGUI::TMGUI(QWidget *parent) : QGraphicsView(parent) { QGraphicsScene *scene = new QGraphicsScene(this); scene->setItemIndexMethod(QGraphicsScene::NoIndex); scene->setSceneRect(-200, -200, 400, 400); setScene(scene); setCacheMode(CacheBackground); setViewportUpdateMode(BoundingRectViewportUpdate); setRenderHint(QPainter::Antialiasing); setTransformationAnchor(AnchorUnderMouse); setMinimumSize(400, 400); TMGUIState *from,*to; scene->addItem(from = new TMGUIState(0,0,this)); scene->addItem(to = new TMGUIState(100,100,this)); scene->addItem(new TMGUIEdge(from,to)); }
GraphWidget::GraphWidget(QWidget *parent, int w, int h): QGraphicsView(parent), width(w), heigth(h), cells(), diagonals(true) { QGraphicsScene *scene = new QGraphicsScene(this); scene->setItemIndexMethod(QGraphicsScene::NoIndex); scene->setSceneRect(-2000, -2000, 4000, 4000); setScene(scene); setCacheMode(CacheBackground); setViewportUpdateMode(BoundingRectViewportUpdate); setRenderHint(QPainter::Antialiasing); setTransformationAnchor(AnchorUnderMouse); scale(qreal(0.8), qreal(0.8)); setMinimumSize(400, 400); setWindowTitle(tr("Grid")); setDragMode(QGraphicsView::ScrollHandDrag); launchDialogBoxes(); }
GraphWidget::GraphWidget(QWidget *parent) : QGraphicsView(parent), timerId(0) { //nodes = new QVector<NodeView*>; //nodes.clear(); //nodes = QVector<NodeView*>(); QGraphicsScene *scene = new QGraphicsScene(this); scene->setItemIndexMethod(QGraphicsScene::NoIndex); scene->setSceneRect( - 500, -500, 500, 500); setScene(scene); setCacheMode(CacheBackground); setViewportUpdateMode(BoundingRectViewportUpdate); setRenderHint(QPainter::Antialiasing); setTransformationAnchor(AnchorUnderMouse); scale(qreal(1), qreal(1)); setMinimumSize(400, 400); setWindowTitle(tr("Elastic Nodes")); }
GraphWidget::GraphWidget(QWidget *parent) : QGraphicsView(parent), timerId(0) { QGraphicsScene *scene = new QGraphicsScene(this); scene->setItemIndexMethod(QGraphicsScene::NoIndex); scene->setSceneRect(parent->normalGeometry()); setScene(scene); setCacheMode(CacheBackground); setViewportUpdateMode(BoundingRectViewportUpdate); setRenderHint(QPainter::Antialiasing); setTransformationAnchor(AnchorUnderMouse); QString textruta=""; myTextItem = new QGraphicsSimpleTextItem(); myTextItem->setText(textruta); myTextItem->setPos(100,100); scene->addItem(myTextItem); }
MapView::MapView(QWidget* parent) : QGraphicsView(parent) { QGraphicsScene* myScene = new QGraphicsScene(this); myScene->setItemIndexMethod(QGraphicsScene::NoIndex); myScene->setSceneRect(-(width()/2), -(height()/2), width(), height()); setScene(myScene); // now add the map item map = new MapItem(this); map->setSize(width(), height()); map->setNorthUp(false); scene()->addItem(map); stn = nullptr; players.clear(); // setup a timer to call background refresh QTimer* bgTimer = new QTimer(this); connect(bgTimer, SIGNAL(timeout()), this, SLOT(refreshView())); bgTimer->start(20); }
GraphWidget::GraphWidget(QWidget *parent, int sceneBoundX, int sceneBoundY, qreal scaleFactorX, qreal scaleFactorY) : QGraphicsView(parent), timerId(0) { this->setStyleSheet("background:transparent;"); startBackgroundGradient = Qt::white; endBackgroundGradient = Qt::lightGray; QGraphicsScene *scene = new QGraphicsScene(this); scene->setItemIndexMethod(QGraphicsScene::NoIndex); scene->setSceneRect(0, 0,sceneBoundX,sceneBoundY); setScene(scene); setCacheMode(CacheBackground); setViewportUpdateMode(BoundingRectViewportUpdate); setRenderHint(QPainter::Antialiasing); setTransformationAnchor(AnchorUnderMouse); scale(scaleFactorX, scaleFactorY); //setViewport(new QGLWidget()); }