void MapLoader::extractButtons() { TiXmlElement *textureElement = rootHandle.FirstChild("texture").ToElement(); string texturePath("none"); string surfaceType("none"); Vector2f position; Vector2f size; if (textureElement) { do { textureElement->QueryStringAttribute("source", &texturePath); textureElement->QueryStringAttribute("type", &surfaceType); TiXmlElement *buttonElement = textureElement->FirstChildElement("GUIbutton"); if (buttonElement) { do { scene->buttons.emplace_back(); GUIButton &button = scene->buttons.back(); buttonElement->QueryFloatAttribute("x", &position.x); buttonElement->QueryFloatAttribute("y", &position.y); buttonElement->QueryFloatAttribute("w", &size.x); buttonElement->QueryFloatAttribute("h", &size.y); button.texture = TextureLoader::getTexture(texturePath); button.texture.xTiling = 0.5f; button.texture.yTiling = 0.5f; } while ((buttonElement = buttonElement->NextSiblingElement("GUIbutton")) != nullptr); } texturePath = "none"; } while ((textureElement = textureElement->NextSiblingElement("texture")) != nullptr); } }
void MapLoader::extractWalls() { TiXmlElement *textureElement = rootHandle.FirstChild("texture").ToElement(); string texturePath("none"); string surfaceType("none"); if (textureElement) { do { textureElement->QueryStringAttribute("source", &texturePath); textureElement->QueryStringAttribute("type", &surfaceType); TiXmlElement *wallBoxElement = textureElement->FirstChildElement("wall"); if (wallBoxElement) { do { scene->walls.emplace_back(); PhysicsEntity &wall = scene->walls.back(); XmlHelper::extractPosition(wallBoxElement, wall.position); XmlHelper::extractRotation(wallBoxElement, wall.rotation); XmlHelper::extractScale(wallBoxElement, wall.scale); wall.texture = TextureLoader::getTexture(texturePath); wall.texture.xTiling = 0.5f; wall.texture.yTiling = 0.5f; wall.mesh = MeshLoader::getPortalBox(wall); wall.physBody = BoxCollider::generateCage(wall); } while ((wallBoxElement = wallBoxElement->NextSiblingElement("wall")) != nullptr); } texturePath = "none"; } while ((textureElement = textureElement->NextSiblingElement("texture")) != nullptr); } }
/*! Returns the rectangle of the surface device() that is occupied by the viewport for this surface. The origin is at the top-left. This function calls viewportGL() and then flips the rectangle upside down using the height of device() so that the origin is at the top-left instead of the bottom-left. \sa viewportGL(), device() */ QRect QGLAbstractSurface::viewportRect() const { Q_ASSERT(isValid()); QRect view = viewportGL(); int height = 0; if (surfaceType() == Window) { Q_ASSERT(window()); height = window()->height(); } else if (surfaceType() == FramebufferObject) { Q_ASSERT(framebufferObject()); height = framebufferObject()->size().height(); } return QRect(view.x(), height - (view.y() + view.height()), view.width(), view.height()); }
void SpacesSubtabGridView::surfaceTypeFilterChanged(const QString& text) { m_objectsFilteredBySurfaceType.clear(); if (text == ALL) { // nothing to filter } else { for (auto obj : this->m_gridController->getObjectSelector()->m_selectorObjects) { auto surface = obj.optionalCast<model::Surface>(); if (surface) { QString surfaceType(surface->surfaceType().c_str()); if (surfaceType != text) { m_objectsFilteredBySurfaceType.insert(obj); } } } } filterChanged(); }
void ConnectionWindow::setConnected(bool conn) { m_connected = conn; if ( connected() ) { m_pollServerThread = new PollServerThread(m_rfbClient, this); connect(pollServerThread(), SIGNAL(messageArrived()), this, SLOT(messageArrived()), Qt::BlockingQueuedConnection); connect(pollServerThread(), SIGNAL(connectionClosed()), this, SLOT(connectionClosed())); switch ( surfaceType() ) { case QVNCVIEWER_SURFACE_RASTER: default: surfaceWidget()->setSurfaceSize(QSize(m_rfbClient->width, m_rfbClient->height)); surfaceWidget()->setDefaultMessage(tr("Connected")); surfaceWidget()->update(); surfaceWidget()->setFocus(); break; } pollServerThread()->start(); m_rfbClient->updateRect.x = m_rfbClient->updateRect.y = 0; m_rfbClient->updateRect.w = m_rfbClient->width; m_rfbClient->updateRect.h = m_rfbClient->height; SendIncrementalFramebufferUpdateRequest(m_rfbClient); } else { if ( pollServerThread() ) { pollServerThread()->disconnect(); pollServerThread()->setExit(true); pollServerThread()->wait(); delete pollServerThread(); m_pollServerThread = 0; } switch ( surfaceType() ) { case QVNCVIEWER_SURFACE_RASTER: default: surfaceWidget()->clearSurface(); surfaceWidget()->setDefaultMessage(tr("Disconnected")); surfaceWidget()->update(); break; } } }
ConnectionWindow::ConnectionWindow(QWidget *parent) : QWidget(parent), ui(new Ui::ConnectionWindow), m_connected(false), m_rfbClient(0), m_pollServerThread(0), m_surfaceWidget(0), m_lookUpId(-1), m_surfaceType(globalConfig->preferencesSurfaceType()) { ui->setupUi(this); if ( m_nextConnectionNumber == 0 ) { if ( QVNCVIEWER_ARG_RASTER ) setSurfaceType(QVNCVIEWER_ARG_RASTER); if ( QVNCVIEWER_ARG_OPENGL ) setSurfaceType(QVNCVIEWER_ARG_OPENGL); } this->setLayout(&mLayout); layout()->setContentsMargins(0, 0, 0, 0); switch ( surfaceType() ) { case QVNCVIEWER_SURFACE_RASTER: default: m_surfaceWidget = new SurfaceWidget(this, this); layout()->addWidget(surfaceWidget()); break; } layout()->setSpacing(0); // configuration menu switch ( surfaceType() ) { case QVNCVIEWER_SURFACE_RASTER: default: surfaceWidget()->setShowFps(globalConfig->preferencesShowFps()); break; } m_currentEncoding = globalConfig->preferencesEncoding(); }
void CubeData::on_calculateButton_clicked(bool) { accept(); QColor positive(Preferences::PositiveSurfaceColor()); QColor negative(Preferences::NegativeSurfaceColor()); double isovalue(m_cubeDataConfigurator.isovalue->value()); unsigned quality(0); bool isSigned(m_cubeDataConfigurator.signedButton->checkState() == Qt::Checked); bool simplifyMesh(m_cubeDataConfigurator.simplifyMeshCheckBox->isChecked()); Data::SurfaceType surfaceType(Data::SurfaceType::CubeData); Data::SurfaceInfo surfaceInfo(surfaceType, quality, isovalue, positive, negative, isSigned, simplifyMesh); calculateSurface(surfaceInfo); }
void ConnectionWindow::doDisconnect() { setConnected(false); if ( m_rfbClient ) { ::close(m_rfbClient->sock); free(m_rfbClient->frameBuffer); m_rfbClient->frameBuffer = 0; rfbClientCleanup(m_rfbClient); m_updatePixmaps.remove(m_rfbClient); m_clientToWindowHash.remove(m_rfbClient); m_rfbClient = 0; } setWindowTitle(m_defaultWindowTitle); switch ( surfaceType() ) { case QVNCVIEWER_SURFACE_RASTER: default: surfaceWidget()->setDefaultMessage(tr("Disconnected")); break; } }
void MapLoader::extractButtons() { // FIXME #if 0 XMLElement *textureElement = rootHandle.FirstChild("texture").ToElement(); string texturePath("none"); string surfaceType("none"); Vector2f position; Vector2f size; if (textureElement) { do { textureElement->QueryStringAttribute("source", &texturePath); textureElement->QueryStringAttribute("type", &surfaceType); XMLElement *buttonElement = textureElement->FirstChildElement("GUIbutton"); if (buttonElement) { do { scene->buttons.emplace_back(); GUIButton &button = scene->buttons.back(); buttonElement->QueryFloatAttribute("x", &position.x); buttonElement->QueryFloatAttribute("y", &position.y); buttonElement->QueryFloatAttribute("w", &size.x); buttonElement->QueryFloatAttribute("h", &size.y); button.material = MaterialLoader::fromTexture(texturePath); button.material.scaleU = button.material.scaleV = 2.f; } while ((buttonElement = buttonElement->NextSiblingElement("GUIbutton")) != nullptr); } texturePath = "none"; } while ((textureElement = textureElement->NextSiblingElement("texture")) != nullptr); } #endif }
EGLConfig QEglConfigChooser::chooseConfig() { QVector<EGLint> configureAttributes = q_createConfigAttributesFromFormat(m_format); configureAttributes.append(EGL_SURFACE_TYPE); configureAttributes.append(surfaceType()); configureAttributes.append(EGL_RENDERABLE_TYPE); bool needsES2Plus = false; switch (m_format.renderableType()) { case QSurfaceFormat::OpenVG: configureAttributes.append(EGL_OPENVG_BIT); break; #ifdef EGL_VERSION_1_4 case QSurfaceFormat::DefaultRenderableType: #ifndef QT_NO_OPENGL if (QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGL) configureAttributes.append(EGL_OPENGL_BIT); else #endif // QT_NO_OPENGL needsES2Plus = true; break; case QSurfaceFormat::OpenGL: configureAttributes.append(EGL_OPENGL_BIT); break; #endif case QSurfaceFormat::OpenGLES: if (m_format.majorVersion() == 1) { configureAttributes.append(EGL_OPENGL_ES_BIT); break; } // fall through default: needsES2Plus = true; break; } if (needsES2Plus) { if (m_format.majorVersion() >= 3 && q_hasEglExtension(display(), "EGL_KHR_create_context")) configureAttributes.append(EGL_OPENGL_ES3_BIT_KHR); else configureAttributes.append(EGL_OPENGL_ES2_BIT); } configureAttributes.append(EGL_NONE); EGLConfig cfg = 0; do { // Get the number of matching configurations for this set of properties. EGLint matching = 0; if (!eglChooseConfig(display(), configureAttributes.constData(), 0, 0, &matching) || !matching) continue; // Fetch all of the matching configurations and find the // first that matches the pixel format we wanted. int i = configureAttributes.indexOf(EGL_RED_SIZE); m_confAttrRed = configureAttributes.at(i+1); i = configureAttributes.indexOf(EGL_GREEN_SIZE); m_confAttrGreen = configureAttributes.at(i+1); i = configureAttributes.indexOf(EGL_BLUE_SIZE); m_confAttrBlue = configureAttributes.at(i+1); i = configureAttributes.indexOf(EGL_ALPHA_SIZE); m_confAttrAlpha = i == -1 ? 0 : configureAttributes.at(i+1); QVector<EGLConfig> configs(matching); eglChooseConfig(display(), configureAttributes.constData(), configs.data(), configs.size(), &matching); if (!cfg && matching > 0) cfg = configs.first(); // Filter the list. Due to the EGL sorting rules configs with higher depth are // placed first when the minimum color channel sizes have been specified (i.e. the // QSurfaceFormat contains color sizes > 0). To prevent returning a 888 config // when the QSurfaceFormat explicitly asked for 565, go through the returned // configs and look for one that exactly matches the requested sizes. When no // sizes have been given, take the first, which will be a config with the smaller // (e.g. 16-bit) depth. for (int i = 0; i < configs.size(); ++i) { if (filterConfig(configs[i])) return configs.at(i); } } while (q_reduceConfigAttributes(&configureAttributes)); if (!cfg) qWarning("Cannot find EGLConfig, returning null config"); return cfg; }
void ConnectionWindow::doConnect() { if (connected()) return; switch ( surfaceType() ) { case QVNCVIEWER_SURFACE_RASTER: default: surfaceWidget()->setDefaultMessage(tr("Connecting...")); surfaceWidget()->update(); break; } qApp->processEvents(QEventLoop::AllEvents, 100); // prepare RFB client structure m_rfbClient = rfbGetClient(QVNCVIEWER_BITS_PER_SAMPLE, QVNCVIEWER_SAMPLES_PER_PIXEL, QVNCVIEWER_BYTES_PER_PIXEL); m_rfbClient->MallocFrameBuffer = rfbResize; m_rfbClient->GotFrameBufferUpdate = rfbUpdate; /* FIXME: we currently don't need these functions m_rfbClient->FinishedFrameBufferUpdate = rfbUpdateFinished; m_rfbClient->GotCopyRect = rfbUpdateCopyRect; m_rfbClient->HandleCursorPos = rfbHandleCursorPos; */ m_rfbClient->programName = QVNCVIEWER_APP_TITLE_CSTR; m_rfbClient->frameBuffer = 0; m_rfbClient->canHandleNewFBSize = true; m_rfbClient->canUseCoRRE = true; m_rfbClient->canUseHextile = true; m_rfbClient->appData.forceTrueColour = true; m_rfbClient->appData.useRemoteCursor = true; m_rfbClient->appData.enableJPEG = true; m_clientToWindowHash[m_rfbClient] = this; PollServerThread::setConnecting(true); if ( ConnectToRFBServer(m_rfbClient, mHostName.toLocal8Bit().constData(), mDisplayNumber + QVNCVIEWER_VNC_BASE_PORT) ) { PollServerThread::setConnecting(false); if ( InitialiseRFBConnection(m_rfbClient) ) { QString rfbDesktopName(m_rfbClient->desktopName); if ( !rfbDesktopName.isEmpty() ) setWindowTitle(rfbDesktopName); VncMainWindow::log(tr("Setting encoding to '%1'").arg(m_currentEncoding)); m_rfbClient->appData.encodingsString = (const char*)m_currentEncoding.constData(); m_rfbClient->appData.qualityLevel = 95; m_rfbClient->appData.compressLevel = 9; if ( !SetFormatAndEncodings(m_rfbClient) ) VncMainWindow::log(tr("WARNING: Failed sending formats and encondings to %1:%2").arg(mHostName).arg(mDisplayNumber)); m_rfbClient->width = m_rfbClient->si.framebufferWidth; m_rfbClient->height = m_rfbClient->si.framebufferHeight; m_rfbClient->frameBuffer = (uint8_t *)malloc(m_rfbClient->width * m_rfbClient->height * QVNCVIEWER_BYTES_PER_PIXEL); setConnected(true); } else { PollServerThread::setConnecting(false); setConnected(false); ::close(m_rfbClient->sock); free(m_rfbClient->frameBuffer); m_rfbClient->frameBuffer = 0; rfbClientCleanup(m_rfbClient); m_clientToWindowHash.remove(m_rfbClient); m_rfbClient = 0; setWindowTitle(m_defaultWindowTitle); } } else { PollServerThread::setConnecting(false); setConnected(false); rfbClientCleanup(m_rfbClient); m_clientToWindowHash.remove(m_rfbClient); m_rfbClient = 0; setWindowTitle(m_defaultWindowTitle); VncMainWindow::log(tr("WARNING: Failed connection to %1:%2").arg(mHostName).arg(mDisplayNumber)); } }