int main(int argc, char *argv[]) { QApplication app(argc, argv); if (!createConnection()) return 1; QSqlTableModel model; initializeModel(&model); #if defined(Q_OS_SYMBIAN) || defined(Q_WS_MAEMO_5) || defined(Q_WS_SIMULATOR) QTabWidget *tabWidget = new QTabWidget; tabWidget->addTab(createView(&model), "View 1"); tabWidget->addTab(createView(&model), "View 2"); tabWidget->showMaximized(); #else QTableView *view1 = createView(&model, QObject::tr("Table Model (View 1)")); QTableView *view2 = createView(&model, QObject::tr("Table Model (View 2)")); view1->show(); view2->move(view1->x() + view1->width() + 20, view1->y()); view2->show(); #endif return app.exec(); }
View::View(QWidget *parent, const QStringList &views) : QWidget(parent) , needToUpdate(false) , spinner(0) , selector(0) , stack(0) { QVBoxLayout *layout=new QVBoxLayout(this); header=new QLabel(this); if (views.isEmpty()) { TextBrowser *t=createView(this); texts.append(t); } else { stack=new QStackedWidget(this); selector=new SelectorLabel(this); selector->setUseArrow(true); foreach (const QString &v, views) { TextBrowser *t=createView(stack); selector->addItem(v, v); stack->addWidget(t); texts.append(t); } connect(selector, SIGNAL(activated(int)), stack, SLOT(setCurrentIndex(int))); connect(selector, SIGNAL(activated(int)), this, SIGNAL(viewChanged())); }
void MapView::createObjects() { Render::getSingleton().select(this); Ogre::Root::getSingleton().renderOneFrame(); ObjectList::const_iterator i = mMap->getObjects().begin(); for (; i != mMap->getObjects().end(); ++i) { const ObjectType types[5] = { OT_STREET, OT_BUILDING, OT_PLANT, OT_WATER_OBJECT, OT_ROUTE }; for (int j = 0; j < 5; ++j) { if (i->second->is(types[j]) && ((mObjectsLoaded & types[j]) == types[j])) { createView(i->second); break; } } } // Create junctions. Have to be loaded after routes. { Ogre::Root::getSingleton().renderOneFrame(); ObjectList::const_iterator i = mMap->getObjects().begin(); for (; i != mMap->getObjects().end(); ++i) { const ObjectType types[1] = { OT_JUNCTION }; for (int j = 0; j < 1; ++j) { if (i->second->is(types[j]) && ((mObjectsLoaded & types[j]) == types[j])) { createView(i->second); break; } } } } }
void MyApp::createViews() { cg::View* v0 = createView("view1"); v0->setViewport(0.1f,0.25f,0.35f,0.5f); v0->linkEntityAtEnd("camera"); v0->linkEntityAtEnd("world"); v0->linkEntityAtEnd("rectangle"); cg::View* v1 = createView("view2"); v1->setViewport(0.55f,0.25f,0.35f,0.5f); v1->linkEntityAtEnd("camera"); v1->linkEntityAtEnd("world"); v1->linkEntityAtEnd("rectangle"); }
ContainerWidget * MultiViewWidget::createContainer(QWidget *widget) { ContainerWidget *container = new ContainerWidget; connect(container, SIGNAL(splitHorizontal()), SLOT(splitHorizontal())); connect(container, SIGNAL(splitVertical()), SLOT(splitVertical())); connect(container, SIGNAL(closeView()), SLOT(removeView())); if (widget) { container->setViewWidget(widget); } // If we have a factory, then create the options widget too! else if (m_factory) { QWidget *optionsWidget = new QWidget; QVBoxLayout *v = new QVBoxLayout; optionsWidget->setLayout(v); v->addStretch(); foreach (const QString &name, m_factory->views()) { QPushButton *button = new QPushButton(name); button->setToolTip(tr("Create a new view")); connect(button, SIGNAL(clicked()), SLOT(createView())); QHBoxLayout *h = new QHBoxLayout; h->addStretch(); h->addWidget(button); h->addStretch(); v->addLayout(h); } v->addStretch(); container->layout()->addWidget(optionsWidget); } return container; }
int main(int argc, char *argv[]) { FILE *input; char *fileName = argv[1]; Sphere **sphereList = (Sphere **) malloc(sizeof(Sphere *)); int sphereListLength = 0; View view; Point eyePoint; Light lightSource; Color ambientLight; FILE *output; tryOpen(&input, fileName); readSphereList(&input, sphereList, &sphereListLength); createView(&view); createEyePoint(&eyePoint); createLightSource(&lightSource); createAmbience(&ambientLight); output = fopen("image.ppm", "w"); fprintf(output, "P3\n"); fprintf(output, "%d %d\n", view.width, view.height); fprintf(output, "%d\n\n", 255); castAllRays(&view, &eyePoint, &ambientLight, &lightSource, sphereList, &sphereListLength, &output); free(sphereList); fclose(output); }
void DesignerMainWnd::updateTabInfo() { if(!currentModel) { if(ui->tabWidget->count()==0) createView("WelcomeView", true); } }
Node* Toast::getView() { Node *view = createView(); const float half_h = view->getContentSize().height / 2; // -10 is just to play safe view->setPosition(Res::kDesignW / 2, Res::kDesignH + half_h + 10); view->runAction(MoveBy::create(0.25f, Vec2(0, -view->getContentSize().height - 10 - 16))); view->setCascadeOpacityEnabled(true); view->setOpacity(0); view->runAction(FadeIn::create(0.25f)); auto dismiss = [this, view](const float) { view->removeFromParent(); invokeListeners(); // FIXME getContext().getNotificationManager()->next(); }; auto exit = [this, view, dismiss](const float) { view->runAction(ScaleTo::create(0.25f, 0.0f)); view->runAction(FadeOut::create(0.25f)); view->getScheduler()->schedule(dismiss, view, 0.25f, 0, 0.0f, false, "toast_dismiss"); }; const float duration = (m_duration == 0.0f) ? 2.0f + m_text.size() * 0.1f : m_duration; view->getScheduler()->schedule(exit, view, duration, 0, 0.0f, false, "toast_exit"); return view; }
void AView::read(QDomNode &element) { QDomNodeList nodeList = element.childNodes(); for(int i = 0; i < nodeList.count(); ++i) { QDomNode node = nodeList.item(i); if(!node.isElement()) continue; QDomElement element = node.toElement(); QString name = node.nodeName(); AView* newView = createView(name, this); if(!newView) continue; childs.append(newView); newView->read(element); } QDomElement e = element.toElement(); id = e.attribute("android:id"); id = explodeName(id); id = captializeName(id); width = QString::number(atof(qPrintable(e.attribute("android:layout_width")))); height = QString::number(atof(qPrintable(e.attribute("android:layout_height")))); }
void DolphinView::setMode(Mode mode) { if (mode == m_mode) { return; // the wished mode is already set } QWidget* view = (m_iconsView != 0) ? static_cast<QWidget*>(m_iconsView) : static_cast<QWidget*>(m_detailsView); if (view != 0) { m_topLayout->remove(view); view->close(); view->deleteLater(); m_iconsView = 0; m_detailsView = 0; } m_mode = mode; createView(); ViewProperties props(m_urlNavigator->url()); props.setViewMode(m_mode); emit signalModeChanged(); }
void MultiViewWindow::setNrOfViews(int viewCount) { mWidget->clearViews(); for(int i = 0; i < viewCount; i++) { createView(); } createLayout(); }
void tst_qquickcustomaffector::test_basic() { QQuickView* view = createView(testFileUrl("basic.qml"), 600); QQuickParticleSystem* system = view->rootObject()->findChild<QQuickParticleSystem*>("system"); ensureAnimTime(600, system->m_animation); QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10)); for (QQuickParticleData *d : qAsConst(system->groupData[0]->data)) { if (d->t == -1) continue; //Particle data unused //in CI the whole simulation often happens at once, so dead particles end up missing out if (!d->stillAlive(system)) continue; //parameters no longer get set once you die QCOMPARE(d->x, 100.f); QCOMPARE(d->y, 100.f); QCOMPARE(d->vx, 100.f); QCOMPARE(d->vy, 100.f); QCOMPARE(d->ax, 100.f); QCOMPARE(d->ay, 100.f); QCOMPARE(d->lifeSpan, 0.5f); QCOMPARE(d->size, 100.f); QCOMPARE(d->endSize, 100.f); QCOMPARE(d->autoRotate, 1.f); QCOMPARE(d->color.r, (uchar)0); QCOMPARE(d->color.g, (uchar)255); QCOMPARE(d->color.b, (uchar)0); QCOMPARE(d->color.a, (uchar)0); QVERIFY(myFuzzyLEQ(d->t, ((qreal)system->timeInt/1000.0))); } delete view; }
void tst_qquickcustomaffector::test_move() { QQuickView* view = createView(testFileUrl("move.qml"), 600); QQuickParticleSystem* system = view->rootObject()->findChild<QQuickParticleSystem*>("system"); ensureAnimTime(600, system->m_animation); QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10)); for (QQuickParticleData *d : qAsConst(system->groupData[0]->data)) { if (d->t == -1) continue; //Particle data unused if (!d->stillAlive(system)) continue; //parameters no longer get set once you die QVERIFY2(myFuzzyCompare(d->curX(system), 50.0), QByteArray::number(d->curX(system))); QVERIFY2(myFuzzyCompare(d->curY(system), 50.0), QByteArray::number(d->curY(system))); QVERIFY2(myFuzzyCompare(d->curVX(system), 50.0), QByteArray::number(d->curVX(system))); QVERIFY2(myFuzzyCompare(d->curVY(system), 50.0), QByteArray::number(d->curVY(system))); QVERIFY2(myFuzzyCompare(d->curAX(), 50.0), QByteArray::number(d->curAX())); QVERIFY2(myFuzzyCompare(d->curAY(), 50.0), QByteArray::number(d->curAY())); QCOMPARE(d->lifeSpan, 0.5f); QCOMPARE(d->size, 32.f); QCOMPARE(d->endSize, 32.f); QVERIFY2(myFuzzyLEQ(d->t, ((qreal)system->timeInt/1000.0)), QString::fromLatin1("%1 <= %2 / 1000").arg(d->t).arg(system->timeInt).toUtf8()); } delete view; }
void KateViewManager::activateView ( KTextEditor::View *view ) { if (!view) return; if (!m_activeStates[view]) { if ( !activeViewSpace()->showView(view) ) { // since it wasn't found, give'em a new one createView( view->document() ); return; } setActiveView (view); mainWindow()->setUpdatesEnabled( false ); bool toolbarVisible = mainWindow()->toolBar()->isVisible(); if (toolbarVisible) mainWindow()->toolBar()->hide(); // hide to avoid toolbar flickering if (guiMergedView) mainWindow()->guiFactory()->removeClient( guiMergedView ); guiMergedView = view; if (!m_blockViewCreationAndActivation) mainWindow()->guiFactory()->addClient( view ); if (toolbarVisible) mainWindow()->toolBar()->show(); mainWindow()->setUpdatesEnabled( true ); emit viewChanged(); } }
void tst_qquickpointdirection::test_basic() { QQuickView* view = createView(testFileUrl("basic.qml"), 600); QQuickParticleSystem* system = view->rootObject()->findChild<QQuickParticleSystem*>("system"); ensureAnimTime(600, system->m_animation); QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10)); for (QQuickParticleData *d : qAsConst(system->groupData[0]->data)) { if (d->t == -1) continue; //Particle data unused QCOMPARE(d->x, 0.f); QCOMPARE(d->y, 0.f); QCOMPARE(d->vx, 100.f); QCOMPARE(d->vy, 100.f); QVERIFY(d->ax >= 0.f); QVERIFY(d->ax <= 200.f); QVERIFY(d->ay >= 0.f); QVERIFY(d->ay <= 200.f); QCOMPARE(d->lifeSpan, 0.5f); QCOMPARE(d->size, 32.f); QCOMPARE(d->endSize, 32.f); QVERIFY(myFuzzyLEQ(d->t, ((qreal)system->timeInt/1000.0))); } delete view; }
NewJoinWidget::NewJoinWidget() { sqlModel = new SqlTableModel(); //TODO 修改默认表功能 sqlModel->setTable("stu_2012"); createSqlTableModel(); sqlModel->select(); // 创建显示模式 createView(); // 建立数据操作按钮 createUserItem(); // 组装主显示右侧的 Layout rightLayout = new QVBoxLayout(); rightLayout->addWidget(stuGroupBox); rightLayout->addStretch(); rightLayout->addWidget(seniorGroupBox); rightLayout->addStretch(); rightLayout->addWidget(buttonGroupBox); // 组装主显示的 Layout mainLayout = new QHBoxLayout(); mainLayout->addWidget(view); mainLayout->addLayout(rightLayout); this->setLayout(mainLayout); }
osg::ref_ptr<osgViewer::View> AugmentationEnvironment::createCameraView(cv::VideoCapture &vCapture, float camWidth, float camHeight) { /**Create the background camera */ osg::ref_ptr<osg::Camera> camera = new osg::Camera; //Set camera parameters camera->setRenderOrder( osg::Camera::PRE_RENDER ); camera->setReferenceFrame( osg::Camera::ABSOLUTE_RF ); camera->setProjectionMatrixAsOrtho(0,camWidth,0, camHeight, -1 , 1); camera->setViewMatrixAsLookAt( osg::Vec3(0.0f, 0.0f, 0.0f), osg::Vec3(0, 0, -1), osg::Vec3(0, 1, 0) ); osg::ref_ptr<UpdateCameraView> backgroundCallback = new UpdateCameraView(vCapture, this); camera->setUpdateCallback( backgroundCallback ); //Create the geometry for texture 2D { osg::ref_ptr<osg::Node> textureNode = createGeodes(camWidth, camHeight); osg::StateSet* state = textureNode->getOrCreateStateSet(); state->setMode( GL_LIGHTING, osg::StateAttribute::OFF | osg::StateAttribute::PROTECTED ); // Set the texture object but not connect with any image osg::ref_ptr<osg::Texture2D> tex = new osg::Texture2D; tex->setResizeNonPowerOfTwoHint(false); tex->setUnRefImageDataAfterApply( true ); state->setTextureAttributeAndModes( 0, tex.get() ); // Turn on blending osg::BlendFunc* bf = new osg::BlendFunc( osg::BlendFunc::SRC_ALPHA, osg::BlendFunc::ONE_MINUS_SRC_ALPHA ); state->setAttributeAndModes( bf ); // Turn on alpha testing osg::AlphaFunc* af = new osg::AlphaFunc(osg::AlphaFunc::GREATER, 0.05f ); state->setAttributeAndModes( af ); textureNode->setDataVariance( osg::Object::DYNAMIC ); textureNode->setName("Background texture"); camera->addChild( textureNode.get() ); } //Create geometry for detected points { osg::ref_ptr<osg::Geode> detectedPointsNode (new osg::Geode()); //Why the color is black? detectedPointsNode->addDrawable (createPrimitiveGeometry(osg::PrimitiveSet::POINTS, vector<cv::Point2f>(), osg::Vec4(0.0,0.0,1.0,1.0))); detectedPointsNode->setDataVariance( osg::Object::DYNAMIC ); detectedPointsNode->setName("Detected points"); camera->addChild( detectedPointsNode.get() ); } osg::ref_ptr<osgViewer::View> cameraView = createView(0, 0, camWidth, camHeight, camera); cameraView->getCamera()->setClearMask( GL_DEPTH_BUFFER_BIT ); // cameraView->addEventHandler(new KeyboardEventHandler(this)); return cameraView; }
void KateViewManager::splitViewSpace( KateViewSpace* vs, // = 0 Qt::Orientation o )// = Qt::Horizontal { // emergency: fallback to activeViewSpace, and if still invalid, abort if (!vs) vs = activeViewSpace(); if (!vs) return; // get current splitter, and abort if null QSplitter *currentSplitter = qobject_cast<QSplitter*>(vs->parentWidget()); if (!currentSplitter) return; // index where to insert new splitter/viewspace const int index = currentSplitter->indexOf( vs ); // create new viewspace KateViewSpace* vsNew = new KateViewSpace( this ); // only 1 children -> we are the root container. So simply set the orientation // and add the new view space, then correct the sizes to 50%:50% if (currentSplitter->count() == 1) { if( currentSplitter->orientation() != o ) currentSplitter->setOrientation( o ); QList<int> sizes = currentSplitter->sizes(); sizes << (sizes.first() - currentSplitter->handleWidth() ) / 2; sizes[0] = sizes[1]; currentSplitter->insertWidget( index, vsNew ); currentSplitter->setSizes( sizes ); } else { // create a new QSplitter and replace vs with the splitter. vs and newVS are // the new children of the new QSplitter QSplitter* newContainer = new QSplitter( o ); newContainer->setOpaqueResize( KGlobalSettings::opaqueResize() ); QList<int> currentSizes = currentSplitter->sizes(); newContainer->addWidget( vs ); newContainer->addWidget( vsNew ); currentSplitter->insertWidget( index, newContainer ); newContainer->show(); // fix sizes of children of old and new splitter currentSplitter->setSizes( currentSizes ); QList<int> newSizes = newContainer->sizes(); newSizes[0] = (newSizes[0] + newSizes[1] - newContainer->handleWidth()) / 2; newSizes[1] = newSizes[0]; newContainer->setSizes( newSizes ); } m_viewSpaceList.append( vsNew ); activeViewSpace()->setActive( false ); vsNew->setActive( true, true ); vsNew->show(); createView ((KTextEditor::Document*)activeView()->document()); updateViewSpaceActions (); }
QVariant Expression::view(int column) const { if (column == 1) { QString key = expression[column].toString(); QJsonObject prop = Config::expressionsDefinitions[key]; if (!prop.isEmpty()) return createView(prop); } return expression[column].toString(); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { createView(); createToolBar(); qsrand(0); _timer.setInterval(1000); }
GUI::GUI() { IGTLinkStreamer::pointer streamer = IGTLinkStreamer::New(); setWidth(getScreenWidth()); setHeight(getScreenHeight()); enableMaximized(); setTitle("FAST Neural Network Despeckling"); auto resizer = ImageResizer::New(); resizer->setInputConnection(streamer->getOutputPort()); resizer->setWidth(512); resizer->setHeight(512); UltrasoundImageEnhancement::pointer enhancer1 = UltrasoundImageEnhancement::New(); enhancer1->setInputConnection(resizer->getOutputPort()); ImageRenderer::pointer renderer1 = ImageRenderer::New(); renderer1->addInputConnection(enhancer1->getOutputPort()); View* viewOrig = createView(); viewOrig->setBackgroundColor(Color::Black()); viewOrig->set2DMode(); viewOrig->addRenderer(renderer1); ImageToImageNetwork::pointer network = ImageToImageNetwork::New(); network->load("/home/smistad/Downloads/filname_test.pb"); network->addOutputNode(0, "activation_8/Tanh:0", NodeType::TENSOR); network->setSignedInputNormalization(true); network->setScaleFactor(1.0f/255.0f); network->setInputConnection(streamer->getOutputPort()); UltrasoundImageEnhancement::pointer enhancer2 = UltrasoundImageEnhancement::New(); enhancer2->setInputConnection(network->getOutputPort()); ImageRenderer::pointer renderer2 = ImageRenderer::New(); renderer2->addInputConnection(enhancer2->getOutputPort()); View* view = createView(); view->setBackgroundColor(Color::Black()); view->set2DMode(); view->addRenderer(renderer2); QHBoxLayout* layout = new QHBoxLayout; layout->addWidget(viewOrig); layout->addWidget(view); mWidget->setLayout(layout); }
void KateViewManager::documentDeleted (KTextEditor::Document *) { if (m_blockViewCreationAndActivation) return; // just for the case we close a document out of many and this was the active one // if all docs are closed, this will be handled by the documentCreated if (!activeView() && (KateDocManager::self()->documents() > 0)) createView (KateDocManager::self()->document(KateDocManager::self()->documents() - 1)); }
Sheet* prepareTestSheet(Sheet *sheet) { if (sheet!=null) { (*sheet).x = 10; (*sheet).y = 100; (*sheet).width = 180; (*sheet).height = 200; (*sheet).buffer = (char *)allocMemoryInPage(300*200*SCREEN_DENSITY); View *mainView = createView(0, 0, 180, 200); Color startColor; startColor.red = 250; startColor.green = 250; startColor.blue = 250; Color endColor; endColor.red = 220; endColor.green = 220; endColor.blue = 220; Corner corner; corner.leftTop=2; corner.rightTop=2; corner.leftBtm=0; corner.rightBtm=0; Color mainBgColor; mainBgColor.red = 120; mainBgColor.green = 120; mainBgColor.blue = 120; Color mainColor; mainColor.red = 20; mainColor.green = 40; mainColor.blue = 60; Color txtBorderColor; txtBorderColor.red = 160; txtBorderColor.green = 160; txtBorderColor.blue = 160; drawCornerRect(mainView, 0, 0, (*mainView).width, 21, mainBgColor, corner); drawGradualVerticalCornerRect(mainView, 1, 1, (*mainView).width-2, 20, startColor, endColor, corner, DIRECTION_UP); drawRect(mainView, 0, 21, (*mainView).width, 179, mainBgColor); drawRect(mainView, 1, 21, (*mainView).width-2, 177, mainColor); loadContentView(sheet, mainView); //drawCornerRect((*sheet).buffer, sheet, 0, 0, (*sheet).width, 21, mainBgColor, corner); //drawGradualVerticalCornerRect((*sheet).buffer, sheet, 1, 1, (*sheet).width-2, 20, startColor, endColor, corner); //drawRect((*sheet).buffer, sheet, 0, 21, (*sheet).width, 179, mainBgColor); //drawRect((*sheet).buffer, sheet, 1, 22, (*sheet).width-2, 178, mainColor); return sheet; } }
bool ColorPicker::addPanel() { auto viewCreator = get< IViewCreator >(); if (viewCreator) { viewCreator->createView( "WGColorPicker/WGColorPickerPanel.qml", colorPickerContext_, colorView_ ); } return true; }
int main(int argc, char *argv[]) { QApplication app(argc, argv); if (!createConnection()) return 1; QSqlTableModel model; initializeModel(&model); QTableView *view1 = createView(&model, QObject::tr("Table Model (View 1)")); QTableView *view2 = createView(&model, QObject::tr("Table Model (View 2)")); view1->show(); view2->move(view1->x() + view1->width() + 20, view1->y()); view2->show(); return app.exec(); }
KTextEditor::View* createView(QWidget* tabWidget) { auto document = KTextEditor::Editor::instance()->createDocument(tabWidget); auto view = document->createView(tabWidget); view->action("file_save")->setEnabled(false); tabWidget->layout()->addWidget(view); view->setStatusBarEnabled(false); return view; }
int main(int argc, char *argv[]) { QApplication app(argc, argv); EditableSqlModel *editableModel = new EditableSqlModel; initializeModel(editableModel); createView(editableModel); return app.exec(); }
GraphPanel *createGraphPanel(int x, int y, int w, int h) { GraphPanel *graphPanel = (GraphPanel *)allocMemory(sizeof(GraphPanel)); graphPanel = (GraphPanel*)initWithViewFunction((View*)graphPanel, x, y, w, h); (*graphPanel).canvas = createView(x, y, w, h); (*graphPanel).initPanel = initGraphPanel; (*graphPanel).initPanel(graphPanel); (*graphPanel).view.onMouseDown = onMouseDown; return graphPanel; }
int main(int argc, char *argv[]) { QApplication app(argc, argv); if (!createConnection()) return 1; QSqlQueryModel plainModel; EditableSqlModel editableModel; CustomSqlModel customModel; initializeModel(&plainModel); initializeModel(&editableModel); initializeModel(&customModel); createView(QObject::tr("Plain Query Model"), &plainModel); createView(QObject::tr("Editable Query Model"), &editableModel); createView(QObject::tr("Custom Query Model"), &customModel); return app.exec(); }
MyWidget::MyWidget(QWidget* parent) : QWidget(parent) { modelIsChanged=false; typeData=-1; createActions(); createMenus(); createModel(); createDataWidget(); createView(); createDxBar(); connectSignalSlot(); }