Пример #1
0
int main(int argc, char *argv[])
{
// Depending on which is the recommended way for the platform, either use
// opengl graphics system or paint into QGLWidget.
#ifdef SHADEREFFECTS_USE_OPENGL_GRAPHICSSYSTEM
    QApplication::setGraphicsSystem("opengl");
#endif

    QApplication app(argc, argv);
    QmlApplicationViewer viewer;

#ifndef SHADEREFFECTS_USE_OPENGL_GRAPHICSSYSTEM
    QGLFormat format = QGLFormat::defaultFormat();
    format.setSampleBuffers(false);
    format.setSwapInterval(1);
    QGLWidget* glWidget = new QGLWidget(format);
    glWidget->setAutoFillBackground(false);
    viewer.setViewport(glWidget);
#endif

    viewer.setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
    viewer.setAttribute(Qt::WA_OpaquePaintEvent);
    viewer.setAttribute(Qt::WA_NoSystemBackground);
    viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
    viewer.setMainQmlFile(QLatin1String("qml/shadereffects/main.qml"));
    QObject::connect(viewer.engine(), SIGNAL(quit()), &viewer, SLOT(close()));
    viewer.showExpanded();

    return app.exec();
}
Пример #2
0
QT_BEGIN_NAMESPACE

QGLFormat QGLFormat::fromPlatformWindowFormat(const QPlatformWindowFormat &format)
{
    QGLFormat retFormat;
    retFormat.setAccum(format.accum());
    if (format.accumBufferSize() >= 0)
        retFormat.setAccumBufferSize(format.accumBufferSize());
    retFormat.setAlpha(format.alpha());
    if (format.alphaBufferSize() >= 0)
        retFormat.setAlphaBufferSize(format.alphaBufferSize());
    if (format.blueBufferSize() >= 0)
        retFormat.setBlueBufferSize(format.blueBufferSize());
    retFormat.setDepth(format.depth());
    if (format.depthBufferSize() >= 0)
        retFormat.setDepthBufferSize(format.depthBufferSize());
    retFormat.setDirectRendering(format.directRendering());
    retFormat.setDoubleBuffer(format.doubleBuffer());
    if (format.greenBufferSize() >= 0)
        retFormat.setGreenBufferSize(format.greenBufferSize());
    if (format.redBufferSize() >= 0)
        retFormat.setRedBufferSize(format.redBufferSize());
    retFormat.setRgba(format.rgba());
    retFormat.setSampleBuffers(format.sampleBuffers());
    retFormat.setSamples(format.sampleBuffers());
    retFormat.setStencil(format.stencil());
    if (format.stencilBufferSize() >= 0)
        retFormat.setStencilBufferSize(format.stencilBufferSize());
    retFormat.setStereo(format.stereo());
    retFormat.setSwapInterval(format.swapInterval());
    return retFormat;
}
Пример #3
0
MythRenderOpenGL* MythRenderOpenGL::Create(const QString &painter,
                                           QPaintDevice* device)
{
    QGLFormat format;
    format.setDepth(false);

#if defined(Q_WS_MAC)
    format.setSwapInterval(1);
#endif

#ifdef USING_OPENGLES
    if (device)
        return new MythRenderOpenGL2ES(format, device);
    return new MythRenderOpenGL2ES(format);
#else
    if (painter.contains("opengl2"))
    {
        if (device)
            return new MythRenderOpenGL2(format, device);
        return new MythRenderOpenGL2(format);
    }
    if (device)
        return new MythRenderOpenGL1(format, device);
    return new MythRenderOpenGL1(format);

#endif
}
Пример #4
0
void GRenderWindow::InitRenderTarget() {
    if (child) {
        delete child;
    }

    if (layout()) {
        delete layout();
    }

    // TODO: One of these flags might be interesting: WA_OpaquePaintEvent, WA_NoBackground,
    // WA_DontShowOnScreen, WA_DeleteOnClose
    QGLFormat fmt;
    fmt.setVersion(3, 3);
    fmt.setProfile(QGLFormat::CoreProfile);
    fmt.setSwapInterval(Settings::values.use_vsync);

    // Requests a forward-compatible context, which is required to get a 3.2+ context on OS X
    fmt.setOption(QGL::NoDeprecatedFunctions);

    child = new GGLWidgetInternal(fmt, this);
    QBoxLayout* layout = new QHBoxLayout(this);

    resize(Core::kScreenTopWidth, Core::kScreenTopHeight + Core::kScreenBottomHeight);
    layout->addWidget(child);
    layout->setMargin(0);
    setLayout(layout);

    OnMinimalClientAreaChangeRequest(GetActiveConfig().min_client_area_size);

    OnFramebufferSizeChanged();
    NotifyClientAreaSizeChanged(std::pair<unsigned, unsigned>(child->width(), child->height()));

    BackupGeometry();
}
Пример #5
0
const QGLFormat GLFormat::asQGLFormat() const
{
    QGLFormat format;

    format.setVersion(m_majorVersion, m_minorVersion);
    
    switch(m_profile)
    {
    default:
    case NoProfile:
        format.setProfile(QGLFormat::NoProfile); 
        break;
    case CoreProfile:
        format.setProfile(QGLFormat::CoreProfile); 
        break;
    case CompatibilityProfile:
        format.setProfile(QGLFormat::CompatibilityProfile); 
        break;
    };

    format.setRedBufferSize    (m_redBufferSize);
    format.setGreenBufferSize  (m_greenBufferSize);
    format.setBlueBufferSize   (m_blueBufferSize);
    format.setAlphaBufferSize  (m_alphaBufferSize);

    format.setDepthBufferSize  (m_depthBufferSize);
    format.setStencilBufferSize(m_stencilBufferSize);
    format.setDoubleBuffer     (m_doubleBuffer);
    format.setStereo           (m_stereo);
    format.setSampleBuffers    (m_sampleBuffers);
    format.setSamples          (m_samples);
    format.setSwapInterval     (m_swapInterval);

    return format;
}
Пример #6
0
Application::
Application(int& argc, char **argv, bool prevent_log_system_and_execute_args )
    :   QApplication(argc, argv),
        default_record_device(-1)
{
    QGLFormat glformat = QGLFormat::defaultFormat ();
#ifndef LEGACY_OPENGL
    EXCEPTION_ASSERTX(false, "Sonic AWE uses QPainters which doesn't support OpenGL 4. See legacy-opengl.prf");
    glformat.setProfile( QGLFormat::CoreProfile );
    glformat.setVersion( 3, 2 );
#endif
    bool vsync = false;
    glformat.setSwapInterval(vsync ? 1 : 0);
    QGLFormat::setDefaultFormat (glformat);
    shared_glwidget_ = new QGLWidget(glformat);
    shared_glwidget_->makeCurrent();

#ifndef LEGACY_OPENGL
    GlException_SAFE_CALL( glGenVertexArrays(1, &VertexArrayID) );
    GlException_SAFE_CALL( glBindVertexArray(VertexArrayID) );
#endif

    setOrganizationName("MuchDifferent");
    setOrganizationDomain("muchdifferent.com");

#if defined(TARGET_reader)
    setApplicationName("Sonic AWE Reader");
#elif defined(TARGET_hast)
    setApplicationName("Sonic AWE LOFAR");
#else
    setApplicationName("Sonic AWE");
#endif

    if (!prevent_log_system_and_execute_args)
        logSystemInfo(argc, argv);

    Sawe::Configuration::resetDefaultSettings();
    Sawe::Configuration::parseCommandLineOptions(argc, argv);

    if (!Sawe::Configuration::use_saved_state())
    {
        QSettings().remove("reset on next startup");

        QVariant value = QSettings().value("value");
        setApplicationName(applicationName() + " temp");
        QSettings().clear();
        QSettings().setValue("value", value);
    }
    if (QSettings().value("reset on next startup", false).toBool())
    {
        QVariant value = QSettings().value("value");
        QSettings().clear();
        QSettings().setValue("value", value);
    }

    if (!prevent_log_system_and_execute_args)
    {
        execute_command_line_options(); // will call 'exit(0)' on invalid arguments
    }
}
QGLFormat CompatibilityRenderer::getFormat()
{
  // Specify the necessary OpenGL context attributes for this renderer.
  QGLFormat glFormat;
  glFormat.setVersion(2, 1);
  glFormat.setSwapInterval(1);
  return glFormat;
}
Пример #8
0
static const QGLFormat getQGLFormat(const unsigned swapInterval) {
    QGLFormat f;

#ifndef PLATFORM_UNIX
    f.setSwapInterval(swapInterval);
#endif

    return f;
}
NativeEnginePrivate::NativeEnginePrivate(const NativeEngineSettings *settings)
      : glWidget(0), uiView(0), ogreRoot(0), ogreWindow(0), camera(0), viewport(0),
        keyPressCallback(0),keyReleaseCallback(0), mouseDoubleClickCallback(0),
        mousePressCallback(0), mouseReleaseCallback(0), mouseMoveCallback(0), sceneManager(0),
        wheelCallback(0), logCallback(0)
{
    initQApplication(settings);

    logCallback = settings->logCallback;

    /* Initialize OpenGL context format */
    QGLFormat format = QGLFormat::defaultFormat();
    format.setSwapInterval(0);

    /* Initialize OpenGL Widget */
    glWidget = new NativeEngineGLWidget(this, format);
    glWidget->setUpdatesEnabled(false);
    glWidget->installEventFilter(this);
    glWidget->setMouseTracking(true);
    glWidget->show();

    glWidgetPrivate = static_cast<QGLWidgetPrivate*>(QGLWidgetPrivate::get(glWidget));

    /* We will attempt to never change this GL context */
    glWidget->makeCurrent();

    // Paint once to init the OGL extension functions
    QPainter p(glWidget);
    p.end();

    /* Initialize UI View */
    uiView = new QDeclarativeView;
    connect(uiView, SIGNAL(statusChanged(QDeclarativeView::Status)), SLOT(viewStatusChanged()));

    uiView->scene()->setBackgroundBrush(Qt::NoBrush);
    uiView->setMouseTracking(true); // It would otherwise ignore mouse events we forward
    uiView->setViewportUpdateMode(QDeclarativeView::FullViewportUpdate);
    uiView->setOptimizationFlag(QDeclarativeView::DontAdjustForAntialiasing);
    uiView->setResizeMode(QDeclarativeView::SizeRootObjectToView);

    //saveGlState();
    initOgre();
    //restoreGlState();


    /* Set the Ogre Network manager on the view */
    uiView->engine()->setNetworkAccessManagerFactory(new OgreNetworkAccessManagerFactory);

    uiView->setSource(QUrl("qrc:/ui/InterfaceRoot.qml"));
}
Пример #10
0
GLRenderer::GLRenderer(VideoWidget* videoWidget) :
    AbstractRenderer(videoWidget)
    , m_glWindow(0)
{
    videoWidget->backend()->logMessage("Creating OpenGL renderer");
    QGLFormat format = QGLFormat::defaultFormat();
    format.setSwapInterval(1);    // Enable vertical sync on draw to avoid tearing
    m_glWindow = new GLRenderWidgetImplementation(videoWidget, format);

    if ((m_videoSink = m_glWindow->createVideoSink())) {    //if ((m_videoSink = m_glWindow->createVideoSink())) {
        gst_object_ref (GST_OBJECT (m_videoSink)); //Take ownership
        gst_object_sink (GST_OBJECT (m_videoSink));

        QWidgetVideoSinkBase*  sink = reinterpret_cast<QWidgetVideoSinkBase*>(m_videoSink);
        // Let the videosink know which widget to direct frame updates to
        sink->renderWidget = videoWidget;
    }
}
Пример #11
0
void ConfigManager::Initialize() {
    QGLFormat glf = QGLFormat::defaultFormat();
    glf.setRedBufferSize(8);
    glf.setGreenBufferSize(8);
    glf.setBlueBufferSize(8);
    glf.setAlphaBufferSize(8);
    glf.setSampleBuffers(true);
    glf.setSamples(8);
    glf.setDepth(true);
    glf.setDepthBufferSize(24);
    glf.setVersion(3, 3);
    glf.setProfile(QGLFormat::CompatibilityProfile);
    glf.setSwapInterval(1);
    QGLFormat::setDefaultFormat(glf);

    input_state_ = InputState::SELECT;
    snap_to_grid_ = true;
    grid_minor_color_ = QColor(175, 175, 175);
    grid_major_color_ = QColor(75, 75, 75);
}
Пример #12
0
int main(int argc, char* argv[])
{
    // Main window of application.
    MainWindow* nesicideWindow;

    QApplication nesicideApplication(argc, argv);

    AppEventFilter nesicideEventFilter;
    nesicideApplication.installEventFilter(&nesicideEventFilter); // Installing the event filter

    QCoreApplication::setOrganizationName("CSPSoftware");
    QCoreApplication::setOrganizationDomain("nesicide.com");
    QCoreApplication::setApplicationName("NESICIDE");

    // Run the startup splash
    StartupSplashDialog* splash = new StartupSplashDialog();
    //splash->exec();
    delete splash;

    // Set up default OpenGL format.
    QGLFormat fmt = QGLFormat::defaultFormat();

    // Disable VSYNC waiting.
    fmt.setSwapInterval(0);

    QGLFormat::setDefaultFormat(fmt);

    // Create the project model.
    CProjectModel projectModel;

    // Create, show, and execute the main window (UI) thread.
    nesicideWindow = new MainWindow(&projectModel);
    QObject::connect(&nesicideEventFilter,SIGNAL(applicationActivationChanged(bool)),nesicideWindow,SLOT(applicationActivationChanged(bool)));
    nesicideWindow->show();

    int result = nesicideApplication.exec();

    delete nesicideWindow;

    return result;
}
Пример #13
0
      QGLFormat core_format () {
        QGLFormat f (QGL::DoubleBuffer | QGL::DepthBuffer | QGL::Rgba);
        int swap_interval = MR::File::Config::get_int ("VSync", 0);
        f.setSwapInterval (swap_interval);
        bool need_core_profile = 
#ifdef MRTRIX_MACOSX
        true;
#else
        false;
#endif
        if (File::Config::get_bool ("NeedOpenGLCoreProfile", need_core_profile)) {
          f.setVersion (3,3);
          f.setProfile (QGLFormat::CoreProfile);
        }
        int nsamples = File::Config::get_int ("MSAA", 0);
        if (nsamples > 1) {
          f.setSampleBuffers (true);
          f.setSamples (nsamples);
        }
        return f;
      }
Пример #14
0
MainWindow::MainWindow(int swapInterval, int width, int height) {
    arrowAutoRepeat = true;
    keyCallback = NULL;
    repaintTimer = new QTimer(this);

    QVBoxLayout* layout = new QVBoxLayout();
    layout->setContentsMargins(QMargins());
    this->setLayout(layout);
    resize(width, height);

    QObject::connect(this, SIGNAL(postGUISignal(guiAction*)),
                     this, SLOT(postGUISlot(guiAction*)));

    // child widget
    QGLFormat format = QGLFormat::defaultFormat();
    format.setSwapInterval(swapInterval);
    glContext = new GLContext(format);
    if (glContext->isValid()) {
        fallbackContext = 0;
        generalContext = glContext;

        glContext->drawingCallback = emptyDrawingCallback;
    } else {
        glContext = 0;
        fallbackContext = new FallbackContext();
        generalContext = fallbackContext;

        fallbackContext->drawingCallback = emptyDrawingCallback;
    };

    generalContext->setAutoFillBackground(false);
    generalContext->setCursor(Qt::BlankCursor);
    generalContext->setFocusPolicy(Qt::StrongFocus);

    QObject::connect(this->repaintTimer, SIGNAL(timeout()),
                     generalContext, SLOT(update()));
    layout->addWidget(generalContext);
};
Пример #15
0
GLView * GLView::create( NifSkope * window )
{
	QGLFormat fmt;
	static QList<QPointer<GLView> > views;

	QGLWidget * share = nullptr;
	for ( const QPointer<GLView>& v : views ) {
		if ( v )
			share = v;
	}

	// All new windows after the first window will share a format
	if ( share ) {
		fmt = share->format();
	} else {
		fmt.setSampleBuffers( Options::antialias() );
	}
	
	// OpenGL version
	fmt.setVersion( 2, 1 );
	// Ignored if version < 3.2
	//fmt.setProfile(QGLFormat::CoreProfile);

	// V-Sync
	fmt.setSwapInterval( 1 );
	fmt.setDoubleBuffer( true );

	fmt.setSamples( Options::antialias() ? 16 : 0 );

	fmt.setDirectRendering( true );
	fmt.setRgba( true );

	views.append( QPointer<GLView>( new GLView( fmt, window, share ) ) );

	return views.last();
}
Пример #16
0
void QtEngineDriver::_initGUI()
{
	QGLFormat fmt;
	fmt.setSampleBuffers(true);
	fmt.setSwapInterval(0); // vsync off; for now... eventually make this an option.

	_glWidget = new GLWidget(_engine,fmt,_dumpFrames);
	_moduleLoaderWidget = new ModuleLoaderWidget(_engine);
	_clockWidget = new ClockWidget(_engine);
	_eventFilter = new GlobalEventFilter(_controller, _mainWindow, _glWidget);

	_moduleLoaderWidget->init();
	_clockWidget->init();
	//_glWidget->init();
	//_consoleWidget->init();

	_app->installEventFilter(_eventFilter);

	QDockWidget * consoleDockWidget = new QDockWidget("Console");
	consoleDockWidget->setWidget(_consoleWidget);

	QDockWidget * moduleLoaderDockWidget = new QDockWidget("Module Loader");
	moduleLoaderDockWidget->setWidget(_moduleLoaderWidget);

	QDockWidget * clockDockWidget = new QDockWidget("Clock");
	clockDockWidget->setWidget(_clockWidget);

	_mainWindow->setCentralWidget(_glWidget);
	_mainWindow->addDockWidget(Qt::BottomDockWidgetArea, consoleDockWidget);
	_mainWindow->addDockWidget(Qt::RightDockWidgetArea, moduleLoaderDockWidget);
	_mainWindow->addDockWidget(Qt::RightDockWidgetArea, clockDockWidget);

	_mainWindow->setWindowTitle(QMainWindow::tr("SteerSim"));
	_mainWindow->resize(1000, 750);
	_mainWindow->setUnifiedTitleAndToolBarOnMac(true);
}
Пример #17
0
hosted_button_id=RZ2A2ZB93827Y";

int main(int argc, char **argv)
{
    QApplication app (argc, argv);
    app.setOrganizationName("SfietKonstantin");
    app.setApplicationName("qfb-mobile");

//    QFB::QueryManager queryManager;
    QFB::LoginManager loginManager;
    TokenManager tokenManager;
    Me me;
//    PostUpdateRelay postUpdateRelay;

    qmlRegisterType<UserInfoHelper>("org.SfietKonstantin.qfb.mobile", 4, 0, "QFBUserInfoHelper");
//    qmlRegisterType<BackPixmapItem>("org.SfietKonstantin.qfb.mobile", 4, 0,
//                                    "QFBBackPixmapItem");
    qmlRegisterType<PostHelper>("org.SfietKonstantin.qfb.mobile", 4, 0, "QFBPostHelper");
//    qmlRegisterType<MobilePostValidator>("org.SfietKonstantin.qfb.mobile", 4, 0,
//                                         "QFBMobilePostValidator");

    QDeclarativeView view;
#ifdef MEEGO_EDITION_HARMATTAN
    QGLFormat format = QGLFormat::defaultFormat();
    format.setSampleBuffers(false);
    format.setSwapInterval(1);
    QGLWidget* glWidget = new QGLWidget(format);
    glWidget->setAutoFillBackground(false);
    view.setViewport(glWidget);
    PagePixmapProvider *pagePixmapProvider = new PagePixmapProvider(glWidget);
#else
    PagePixmapProvider *pagePixmapProvider = new PagePixmapProvider(&view);
#endif

#ifndef MEEGO_EDITION_HARMATTAN
    view.engine()->addImportPath(IMPORT_PATH);
#endif
    view.engine()->addImageProvider("pagepixmapprovider", pagePixmapProvider);
    view.engine()->setNetworkAccessManagerFactory(new NetworkAccessManagerFactory());
//    view.rootContext()->setContextProperty("QUERY_MANAGER", &queryManager);
    view.rootContext()->setContextProperty("LOGIN_MANAGER", &loginManager);
    view.rootContext()->setContextProperty("TOKEN_MANAGER", &tokenManager);
//    view.rootContext()->setContextProperty("POST_UPDATE_RELAY", &postUpdateRelay);
    view.rootContext()->setContextProperty("ME", &me);
    view.rootContext()->setContextProperty("DATA_PATH", DATA_PATH);
    view.rootContext()->setContextProperty("FACEBOOK_PAGE", FACEBOOK_PAGE);
    view.rootContext()->setContextProperty("PAYPAL_DONATE", PAYPAL_DONATE);
    view.rootContext()->setContextProperty("VERSION_MAJOR", QString::number(VERSION_MAJOR));
    view.rootContext()->setContextProperty("VERSION_MINOR", QString::number(VERSION_MINOR));
    view.rootContext()->setContextProperty("VERSION_PATCH", QString::number(VERSION_PATCH));

    // Friends specific
    QString clientId;
    QPluginLoader pluginLoader (CLIENT_ID_PLUGIN);
    if (pluginLoader.load()) {
        QObject *plugin = pluginLoader.instance();
        Interface *castedPlugin = qobject_cast<Interface *>(plugin);
        if (castedPlugin) {
            clientId = castedPlugin->clientId();
            qDebug() << "Client id loaded";
        }
    }

    if (clientId.isEmpty()) {
        if (app.arguments().count() == 2) {
            clientId = app.arguments().at(1);
        } else {
            qDebug() << "Failed to find the client id";
            return -1;
        }
    }
    view.rootContext()->setContextProperty("CLIENT_ID", clientId);
    // End Friends specific

    view.setSource(QUrl(MAIN_QML_FILE));
    view.showFullScreen();
    QObject::connect(view.engine(), SIGNAL(quit()), &app, SLOT(quit()));

    return app.exec();
}
Пример #18
0
ccViewer::ccViewer(QWidget *parent, Qt::WindowFlags flags)
	: QMainWindow(parent, flags)
	, m_glWindow(0)
	, m_selectedObject(0)
	, m_3dMouseInput(0)
{
	ui.setupUi(this);

	//insert GL window in a vertical layout
	QVBoxLayout* verticalLayout_2 = new QVBoxLayout(ui.GLframe);
	verticalLayout_2->setSpacing(0);
	const int margin = 10;
    verticalLayout_2->setContentsMargins(margin,margin,margin,margin);
    QGLFormat format;
    format.setSwapInterval(0);
	m_glWindow = new ccGLWindow(ui.GLframe,format);
	verticalLayout_2->addWidget(m_glWindow);

	updateGLFrameGradient();

	m_glWindow->setRectangularPickingAllowed(false); //multiple entities picking not supported

	//UI/display synchronization
	ui.actionFullScreen->setChecked(false);
	ui.menuSelected->setEnabled(false);
	reflectLightsState();
	reflectPerspectiveState();
	reflectPivotVisibilityState();

#ifdef CC_3DXWARE_SUPPORT
	enable3DMouse(true,true);
#else
	ui.actionEnable3DMouse->setEnabled(false);
#endif

	//Signals & slots connection
	connect(m_glWindow,								SIGNAL(filesDropped(const QStringList&)),			this,		SLOT(addToDB(const QStringList&)));
	connect(m_glWindow,								SIGNAL(entitySelectionChanged(int)),				this,		SLOT(selectEntity(int)));
    //connect(m_glWindow,								SIGNAL(entitiesSelectionChanged(std::set<int>)),	this,		SLOT(selectEntities(std::set<int>))); //not supported!
	//connect(m_glWindow,								SIGNAL(newLabel(ccHObject*),					this,		SLOT(handleNewEntity(ccHObject*))); //nothing to do in ccViewer!

	//"Options" menu
	connect(ui.actionDisplayParameters,				SIGNAL(triggered()),						this,	SLOT(showDisplayParameters()));
    connect(ui.actionEditCamera,					SIGNAL(triggered()),    					this,	SLOT(doActionEditCamera()));
    //"Display > Standard views" menu
    connect(ui.actionSetViewTop,					SIGNAL(triggered()),						this,	SLOT(setTopView()));
    connect(ui.actionSetViewBottom,					SIGNAL(triggered()),						this,	SLOT(setBottomView()));
    connect(ui.actionSetViewFront,					SIGNAL(triggered()),						this,	SLOT(setFrontView()));
    connect(ui.actionSetViewBack,					SIGNAL(triggered()),						this,	SLOT(setBackView()));
    connect(ui.actionSetViewLeft,					SIGNAL(triggered()),						this,	SLOT(setLeftView()));
    connect(ui.actionSetViewRight,					SIGNAL(triggered()),						this,	SLOT(setRightView()));
    connect(ui.actionSetViewIso1,					SIGNAL(triggered()),						this,	SLOT(setIsoView1()));
    connect(ui.actionSetViewIso2,					SIGNAL(triggered()),						this,	SLOT(setIsoView2()));

	//"Options > Perspective" menu
	connect(ui.actionSetOrthoView,					SIGNAL(triggered()),						this,	SLOT(setOrthoView()));
	connect(ui.actionSetCenteredPerspectiveView,	SIGNAL(triggered()),						this,	SLOT(setCenteredPerspectiveView()));
	connect(ui.actionSetViewerPerspectiveView,		SIGNAL(triggered()),						this,	SLOT(setViewerPerspectiveView()));
	//"Options > Rotation symbol" menu
	connect(ui.actionSetPivotAlwaysOn,				SIGNAL(triggered()),						this,	SLOT(setPivotAlwaysOn()));
	connect(ui.actionSetPivotRotationOnly,			SIGNAL(triggered()),						this,	SLOT(setPivotRotationOnly()));
	connect(ui.actionSetPivotOff,					SIGNAL(triggered()),						this,	SLOT(setPivotOff()));
	//"Options > 3D mouse" menu
	connect(ui.actionEnable3DMouse,					SIGNAL(toggled(bool)),						this,	SLOT(setup3DMouse(bool)));
    //"Display > Lights & Materials" menu
    connect(ui.actionToggleSunLight,				SIGNAL(toggled(bool)),    					this,	SLOT(toggleSunLight(bool)));
    connect(ui.actionToggleCustomLight,				SIGNAL(toggled(bool)),    					this,	SLOT(toggleCustomLight(bool)));
	//"Options" menu
	connect(ui.actionGlobalZoom,					SIGNAL(triggered()),						this,	SLOT(setGlobalZoom()));
	connect(ui.actionFullScreen,					SIGNAL(toggled(bool)),						this,	SLOT(toggleFullScreen(bool)));

	//"Options > Selected" menu
	connect(ui.actionShowColors,					SIGNAL(toggled(bool)),    					this,	SLOT(toggleColorsShown(bool)));
	connect(ui.actionShowNormals,					SIGNAL(toggled(bool)),    					this,	SLOT(toggleNormalsShown(bool)));
	connect(ui.actionShowScalarField,				SIGNAL(toggled(bool)),    					this,	SLOT(toggleScalarShown(bool)));
	connect(ui.actionShowColorRamp,					SIGNAL(toggled(bool)),    					this,	SLOT(toggleColorbarShown(bool)));
	connect(ui.actionZoomOnSelectedEntity,			SIGNAL(triggered()),						this,	SLOT(zoomOnSelectedEntity()));
    connect(ui.actionDelete,						SIGNAL(triggered()),						this,	SLOT(doActionDeleteSelectedEntity()));

	//"Help" menu
    connect(ui.actionAbout,							SIGNAL(triggered()),						this,	SLOT(doActionAbout()));
    connect(ui.actionHelpShortctus,					SIGNAL(triggered()),						this,	SLOT(doActionDisplayShortcuts()));
}
Пример #19
0
WaveformWidgetFactory::WaveformWidgetFactory() :
        m_type(WaveformWidgetType::Count_WaveformwidgetType),
        m_config(0),
        m_skipRender(false),
        m_frameRate(30),
        m_defaultZoom(3),
        m_zoomSync(false),
        m_overviewNormalized(false),
        m_openGLAvailable(false),
        m_openGLShaderAvailable(false),
        m_vsyncThread(NULL),
        m_frameCnt(0),
        m_actualFrameRate(0) {

    m_visualGain[All] = 1.5;
    m_visualGain[Low] = 1.0;
    m_visualGain[Mid] = 1.0;
    m_visualGain[High] = 1.0;

    if (QGLFormat::hasOpenGL()) {
        QGLFormat glFormat;
        glFormat.setDirectRendering(true);
        glFormat.setDoubleBuffer(true);
        glFormat.setDepth(false);
        // Disable waiting for vertical Sync
        // This can be enabled when using a single Threads for each QGLContext
        // Setting 1 causes QGLContext::swapBuffer to sleep until the next VSync
#if defined(__APPLE__)
        // On OS X, syncing to vsync has good performance FPS-wise and
        // eliminates tearing.
        glFormat.setSwapInterval(1);
#else
        // Otherwise, turn VSync off because it could cause horrible FPS on
        // Linux.
        // TODO(XXX): Make this configurable.
        // TOOD(XXX): What should we do on Windows?
        glFormat.setSwapInterval(0);
#endif


        glFormat.setRgba(true);
        QGLFormat::setDefaultFormat(glFormat);

        QGLFormat::OpenGLVersionFlags version = QGLFormat::openGLVersionFlags();

        int majorVersion = 0;
        int minorVersion = 0;
        if (version == QGLFormat::OpenGL_Version_None) {
            m_openGLVersion = "None";
        } else if (version & QGLFormat::OpenGL_Version_3_0) {
            majorVersion = 3;
        } else if (version & QGLFormat::OpenGL_Version_2_1) {
            majorVersion = 2;
            minorVersion = 1;
        } else if (version & QGLFormat::OpenGL_Version_2_0) {
            majorVersion = 2;
            minorVersion = 0;
        } else if (version & QGLFormat::OpenGL_Version_1_5) {
            majorVersion = 1;
            minorVersion = 5;
        } else if (version & QGLFormat::OpenGL_Version_1_4) {
            majorVersion = 1;
            minorVersion = 4;
        } else if (version & QGLFormat::OpenGL_Version_1_3) {
            majorVersion = 1;
            minorVersion = 3;
        } else if (version & QGLFormat::OpenGL_Version_1_2) {
            majorVersion = 1;
            minorVersion = 2;
        } else if (version & QGLFormat::OpenGL_Version_1_1) {
            majorVersion = 1;
            minorVersion = 1;
        }

        if (majorVersion != 0) {
            m_openGLVersion = QString::number(majorVersion) + "." +
                    QString::number(minorVersion);
        }

        m_openGLAvailable = true;

        QGLWidget* glWidget = new QGLWidget(); // create paint device
        // QGLShaderProgram::hasOpenGLShaderPrograms(); valgind error
        m_openGLShaderAvailable = QGLShaderProgram::hasOpenGLShaderPrograms(glWidget->context());
        delete glWidget;
    }

    evaluateWidgets();
    m_time.start();
}
Пример #20
0
ccViewer::ccViewer(QWidget *parent, Qt::WindowFlags flags)
	: QMainWindow(parent, flags)
	, m_glWindow(0)
	, m_selectedObject(0)
{
	ui.setupUi(this);

	//insert GL window in a vertical layout
	QVBoxLayout* verticalLayout_2 = new QVBoxLayout(ui.GLframe);
	verticalLayout_2->setSpacing(0);
	const int margin = 10;
    verticalLayout_2->setContentsMargins(margin,margin,margin,margin);
    QGLFormat format;
    format.setSwapInterval(0);
	m_glWindow = new ccGLWindow(ui.GLframe,format);
	verticalLayout_2->addWidget(m_glWindow);

	updateGLFrameGradient();

	//UI/display synchronization
	ui.actionToggleSunLight->setChecked(m_glWindow->sunLightEnabled());
	ui.actionToggleCustomLight->setChecked(m_glWindow->customLightEnabled());
	bool perspective,centered;
	perspective = m_glWindow->getPerspectiveState(centered);
	ui.actionDisablePerspective->setChecked(!perspective);
	ui.actionToggleCenteredPerspective->setChecked(perspective && centered);
	ui.actionToggleViewerBasedPerspective->setChecked(perspective && !centered);
	ui.actionFullScreen->setChecked(false);

	ui.menuSelected->setEnabled(false);

	//Signals & slots connection
	connect(m_glWindow,								SIGNAL(filesDropped(const QStringList&)),	this,	SLOT(addToDB(const QStringList&)));
	connect(m_glWindow,								SIGNAL(entitySelectionChanged(int)),		this,	SLOT(selectEntity(int)));
	//connect(m_glWindow,								SIGNAL(newLabel(ccHObject*),				this,	SLOT(handleNewEntity(ccHObject*))); //nothing to do in ccViewer!

	//"Options" menu
	connect(ui.actionDisplayParameters,				SIGNAL(triggered()),						this,	SLOT(showDisplayParameters()));
    connect(ui.actionEditCamera,					SIGNAL(triggered()),    					this,	SLOT(doActionEditCamera()));
    //"Display > Standard views" menu
    connect(ui.actionSetViewTop,					SIGNAL(triggered()),						this,	SLOT(setTopView()));
    connect(ui.actionSetViewBottom,					SIGNAL(triggered()),						this,	SLOT(setBottomView()));
    connect(ui.actionSetViewFront,					SIGNAL(triggered()),						this,	SLOT(setFrontView()));
    connect(ui.actionSetViewBack,					SIGNAL(triggered()),						this,	SLOT(setBackView()));
    connect(ui.actionSetViewLeft,					SIGNAL(triggered()),						this,	SLOT(setLeftView()));
    connect(ui.actionSetViewRight,					SIGNAL(triggered()),						this,	SLOT(setRightView()));
    //"Display > Lights & Materials" menu
    connect(ui.actionToggleSunLight,				SIGNAL(toggled(bool)),    					this,	SLOT(toggleSunLight(bool)));
    connect(ui.actionToggleCustomLight,				SIGNAL(toggled(bool)),    					this,	SLOT(toggleCustomLight(bool)));
	//"Options > Selected" menu
	connect(ui.actionShowColors,					SIGNAL(toggled(bool)),    					this,	SLOT(toggleColorsShown(bool)));
	connect(ui.actionShowNormals,					SIGNAL(toggled(bool)),    					this,	SLOT(toggleNormalsShown(bool)));
	connect(ui.actionShowScalarField,				SIGNAL(toggled(bool)),    					this,	SLOT(toggleScalarShown(bool)));
	connect(ui.actionShowColorRamp,					SIGNAL(toggled(bool)),    					this,	SLOT(toggleColorbarShown(bool)));
    connect(ui.actionDelete,						SIGNAL(triggered()),						this,	SLOT(doActionDeleteSelectedEntity()));
	//"Options > Perspective" menu
    connect(ui.actionDisablePerspective,			SIGNAL(toggled(bool)),						this,	SLOT(togglePerspectiveOff(bool)));
    connect(ui.actionToggleCenteredPerspective,		SIGNAL(toggled(bool)),						this,	SLOT(toggleCenteredPerspective(bool)));
    connect(ui.actionToggleViewerBasedPerspective,	SIGNAL(toggled(bool)),						this,	SLOT(toggleViewerBasedPerspective(bool)));
	//"Options" menu
	connect(ui.actionFullScreen,					SIGNAL(toggled(bool)),						this,	SLOT(toggleFullScreen(bool)));

    //"Help" menu
    connect(ui.actionAbout,							SIGNAL(triggered()),						this,	SLOT(doActionAbout()));
    connect(ui.actionHelpShortctus,					SIGNAL(triggered()),						this,	SLOT(doActionDisplayShortcuts()));
}
Пример #21
0
MainWindow::MainWindow()
{
    fullScreen_ = false;

    // Set Title and window properties
    setWindowTitle(tr("Examinationroom"));
    QMainWindow::setDockOptions(AnimatedDocks | AllowNestedDocks | AllowTabbedDocks);

    // Add Dock Widgets
    dockDesign_ = new DesignWidget("Design", this);
    dockCode_ = new CodeWidget("Code", this);
    dockConsole_ = new ConsoleWidget("Console", this);
    dockDesign_->setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable);
    dockCode_->setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable);
    dockConsole_->setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable);
    addDockWidget(Qt::RightDockWidgetArea, dockDesign_);
    addDockWidget(Qt::RightDockWidgetArea, dockCode_);
    addDockWidget(Qt::RightDockWidgetArea, dockConsole_);
    tabifyDockWidget(dockDesign_, dockCode_);
    tabifyDockWidget(dockDesign_, dockConsole_);

    // Set up logging early
    LogTool::initLogFile();
    LogTool::setConsoleWidget(dockConsole_);

    // File dialogs
#ifdef Q_WS_MACX
    Qt::WindowFlags dialogFlags = Qt::Sheet;
    QString defaultPath = QString("res/");
#else
    Qt::WindowFlags dialogFlags = Qt::Dialog;
    QString defaultPath = QString("res/");
#endif
    loadDialog_ = new QFileDialog(this, dialogFlags);
    loadDialog_->setFilter("Lua Scene File (*.lua)");
    loadDialog_->setWindowTitle("Open Lua Scene...");
    loadDialog_->setDirectory(defaultPath);
    storeDialog_ = new QFileDialog(this, dialogFlags);
    storeDialog_->setAcceptMode(QFileDialog::AcceptSave);
    storeDialog_->setFilter("Lua Scene File (*.lua)");
    storeDialog_->setWindowTitle("Save Lua Scene...");
    storeDialog_->setDirectory(defaultPath);
    storeDialog_->setDefaultSuffix("lua");
    connect(loadDialog_, SIGNAL(fileSelected(const QString &)), this, SLOT(loadLuaFile(const QString &)));
    connect(storeDialog_, SIGNAL(fileSelected(const QString &)), this, SLOT(storeLuaFile(const QString &)));

    // Create GL Widgets
    QGLFormat glFormat = QGLFormat::defaultFormat();
    // Stereo Buffering seems to work in SnowLeopard...
    // but is incompatible with other renderers and might cause problems.
    // enable at your own risk
    glFormat.setStereo(false);
    glFormat.setSwapInterval(1); // Enable VSync on platforms that support it
    QGLFormat::setDefaultFormat(glFormat);

    // Checking for errors here leads to a crash on OS X
    // Probably because OpenGL was not initialized yet?
    //ErrorTool::getErrors("MainWindow::MainWindow:1");
    mainGlWidget_ = new GLWidget(this);
    fsGlWidget_ = new GLWidget(0, mainGlWidget_);
    fsGlWidget_->setCursor(Qt::BlankCursor);
    mainGlWidget_->setStyle(GLWidget::single);
    fsGlWidget_->setStyle(GLWidget::single);
    mainGlWidget_->makeCurrent();
    GlErrorTool::getErrors("MainWindow::MainWindow:2");
    GlErrorTool::logVersionStrings();

    aboutWindow_ = 0;

    // Add menu
    QMenu *menu = menuBar()->addMenu(tr("&File"));
    menu->addAction(tr("&About Examinationroom..."),
                    this, SLOT(showAbout()));
    menu->addAction(tr("&Open Scene..."),
                    loadDialog_, SLOT(open()),
                    QKeySequence(QKeySequence::Open));
    menu->addAction(tr("Close Scene"),
                    this, SLOT(newScene()),
                    QKeySequence(QKeySequence::Close));
    menu->addAction(tr("&Save Copy As..."),
                    storeDialog_, SLOT(open()),
                    QKeySequence(QKeySequence::Save));
    menu->addAction(tr("&Revert Scene"),
                    this, SLOT(revert()));
    menu->addSeparator();
    menu->addAction(tr("&Quit"), this, SLOT(close()),
                    QKeySequence(tr("ctrl-Q")));

    // Signal mapper for display types
    signalMapper_ = new QSignalMapper(this);

    // Add display menu
    QAction * action;
    menu = menuBar()->addMenu(tr("&Output Mode"));

    action = menu->addAction(tr("&Fullscreen"),
                             this, SLOT(toggleFullscreen()),
                             QKeySequence(Qt::Key_F | Qt::CTRL));
    fsGlWidget_->addAction(action);

    menu->addSeparator();

    action = menu->addAction(tr("&Anaglyph"));
    action->setShortcut(QKeySequence(Qt::Key_1 | Qt::CTRL));
    connect(action, SIGNAL(triggered()), signalMapper_, SLOT(map()));
    signalMapper_->setMapping(action, GLWidget::anaglyph);
    fsGlWidget_->addAction(action);

    action = menu->addAction(tr("&Side by Side"));
    action->setShortcut(QKeySequence(Qt::Key_2 | Qt::CTRL));
    connect(action, SIGNAL(triggered()), signalMapper_, SLOT(map()));
    signalMapper_->setMapping(action, GLWidget::sidebyside);
    fsGlWidget_->addAction(action);

    action = menu->addAction(tr("&Line interlacing (Experimental)"));
    action->setShortcut(QKeySequence(Qt::Key_3 | Qt::CTRL));
    connect(action, SIGNAL(triggered()), signalMapper_, SLOT(map()));
    signalMapper_->setMapping(action, GLWidget::line);
    fsGlWidget_->addAction(action);

    action = menu->addAction(tr("Quad Buffering (Experimental)"));
    action->setShortcut(QKeySequence(Qt::Key_4 | Qt::CTRL));
    connect(action, SIGNAL(triggered()), signalMapper_, SLOT(map()));
    signalMapper_->setMapping(action, GLWidget::quad);
    fsGlWidget_->addAction(action);

    action = menu->addAction(tr("Matrix Anaglyph (Experimental)"));
    action->setShortcut(QKeySequence(Qt::Key_5 | Qt::CTRL));
    connect(action, SIGNAL(triggered()), signalMapper_, SLOT(map()));
    signalMapper_->setMapping(action, GLWidget::matrix);
    fsGlWidget_->addAction(action);

    menu->addSeparator();

    action = menu->addAction(tr("&Shader (Line interlacing)"));
    action->setShortcut(QKeySequence(Qt::Key_6 | Qt::CTRL));
    connect(action, SIGNAL(triggered()), signalMapper_, SLOT(map()));
    signalMapper_->setMapping(action, GLWidget::shaderLine);
    fsGlWidget_->addAction(action);

    action = menu->addAction(tr("&Shader (Mayan)"));
    action->setShortcut(QKeySequence(Qt::Key_7 | Qt::CTRL));
    connect(action, SIGNAL(triggered()), signalMapper_, SLOT(map()));
    signalMapper_->setMapping(action, GLWidget::shaderMayan);
    fsGlWidget_->addAction(action);

    menu->addSeparator();

    action = menu->addAction(tr("Si&ngle"));
    action->setShortcut(QKeySequence(Qt::Key_0 | Qt::CTRL));
    connect(action, SIGNAL(triggered()), signalMapper_, SLOT(map()));
    signalMapper_->setMapping(action, GLWidget::single);
    fsGlWidget_->addAction(action);

    connect(signalMapper_, SIGNAL(mapped(int)), this, SLOT(setDrawStyle(int)));

    // Object Creation Menu and signal mapper
    objectMenu_ = menuBar()->addMenu(tr("&Create Object"));
    objectMapper_ = new QSignalMapper(this);
    connect(objectMapper_, SIGNAL(mapped(int)), this, SLOT(onObjectCreate(int)));

#ifdef Q_WS_MACX
    // Make menu bar the default menu bar
    menuBar()->setParent(0);
#endif

    // Set up layout
    setFocusPolicy(Qt::StrongFocus);
    setCentralWidget(mainGlWidget_);

    // Create Scene
    setProgram(Program::create());

    // Set up redraw timer
    timer_ = new QTimer(this);
    connect(timer_, SIGNAL(timeout()), this, SLOT(onTimeout()));
    timer_->start(15); // ~60 fps
}
Пример #22
0
void OffscreenRenderer::prepareRendering(int w, int h)
{
    if((!pbuffer && !glWidget) || width < w || height < h)
    {
        bool usePBuffer = true;
        if(pbuffer)
        {
            delete pbuffer;
            pbuffer = 0;
        }
        if(glWidget)
        {
            delete glWidget;
            glWidget = 0;
            usePBuffer = false;
        }
        if(framebuffer)
        {
            glDeleteFramebuffersEXT(1, &framebuffer);
            framebuffer = 0;
        }
        if(renderbuffer)
        {
            glDeleteRenderbuffersEXT(1, &renderbuffer);
            renderbuffer = 0;
        }
        if(flippingBuffer)
        {
            delete[] flippingBuffer;
            flippingBuffer = 0;
        }

        QGLFormat format;
        format.setStencil(false);
        //format.setDoubleBuffer(false);
        format.setSwapInterval(0);
        if(usePBuffer)
        {
#ifdef _WIN32
            pbuffer = new QGLPixelBuffer(QSize(w, h), format);
#else
            pbuffer = 0;
#endif
        }
        if(!pbuffer || !pbuffer->isValid())
        {
            if(pbuffer)
            {
                delete pbuffer;
                pbuffer = 0;
            }

            // maybe fall back to "onscreen rendering"
            if(!glWidget)
            {
                glWidget = new QGLWidget(format, 0, 0, Qt::WindowStaysOnTopHint);
                glWidget->setFixedSize(w, h);
                glWidget->makeCurrent();

                width = w;
                height = h;

                graphicsManager->initContext(false);
            }

            // QGLFramebufferObject didn't work properly... but well, the framebuffer object extension is platform independend anyway
            if(GLEW_EXT_framebuffer_object)
            {
                GLenum status;
                glGenFramebuffersEXT(1, &framebuffer);
                glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framebuffer);
                glGenRenderbuffersEXT(1, &renderbuffer);
                glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, renderbuffer);
                glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGBA8, w, h);
                glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER_EXT, renderbuffer);
                status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
                if(status != GL_FRAMEBUFFER_COMPLETE_EXT)
                {
                    if(framebuffer)
                    {
                        glDeleteFramebuffersEXT(1, &framebuffer);
                        framebuffer = 0;
                    }
                    if(renderbuffer)
                    {
                        glDeleteRenderbuffersEXT(1, &renderbuffer);
                        renderbuffer = 0;
                    }
                }
            }

            if(framebuffer)
            {
                TRACE("OffscreenRenderer: using framebuffer object renderer");
            }
            else
            {
                TRACE("OffscreenRenderer: using window renderer");
            }

            determineImagePositionInBuffer(w, h);
        }
        else
        {
            TRACE("OffscreenRenderer: yeah, using pixel buffer renderer");
            pbuffer->makeCurrent();
            const QSize& size(pbuffer->size());
            width = size.width();
            height = size.height();
            ASSERT(width >= w && height >= h);
            graphicsManager->initContext(false);
            determineImagePositionInBuffer(w, h);
        }
    }
    VERIFY(makeCurrent());
}
Пример #23
0
int main(int argc, char *argv[])
{
#ifdef USE_OPENGL_GRAPHICS_SYSTEM
    QApplication::setGraphicsSystem("opengl");
#endif

    QApplication app(argc, argv);

#ifdef PERFORMANCEMONITOR_SUPPORT
    PerformanceMonitor::qmlRegisterTypes();
#endif

    QUrl fileName;
    qreal volume = 0.5;
    QStringList args = app.arguments();
#ifdef PERFORMANCEMONITOR_SUPPORT
    PerformanceMonitor::State performanceMonitorState;
#endif
    for (int i=1; i<args.count(); ++i) {
        const QString &arg = args.at(i);
        if (arg.startsWith('-')) {
            if ("-volume" == arg) {
                if (i+1 < args.count())
                    volume = 0.01 * args.at(++i).toInt();
                else
                    qtTrace() << "Option \"-volume\" takes a value";
            }
#ifdef PERFORMANCEMONITOR_SUPPORT
            else if (PerformanceMonitor::parseArgument(arg, performanceMonitorState)) {
                // Do nothing
            }
#endif
            else {
                qtTrace() << "Option" << arg << "ignored";
            }
        } else {
            if (fileName.isEmpty())
                fileName = QUrl::fromLocalFile(arg);
            else
                qtTrace() << "Argument" << arg << "ignored";
        }
    }

    QmlApplicationViewer viewer;

#ifndef USE_OPENGL_GRAPHICS_SYSTEM
    QGLFormat format = QGLFormat::defaultFormat();
    format.setSampleBuffers(false);
    format.setSwapInterval(1);
    QGLWidget* glWidget = new QGLWidget(format);
    glWidget->setAutoFillBackground(false);
    viewer.setViewport(glWidget);
#endif

    viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
    viewer.setMainQmlFile(QLatin1String("qml/qmlvideofx/") + MainQmlFile);
    viewer.setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
    QGraphicsObject *rootObject = viewer.rootObject();
    rootObject->setProperty("fileName", fileName);
    viewer.rootObject()->setProperty("volume", volume);

#ifdef PERFORMANCEMONITOR_SUPPORT
    if (performanceMonitorState.valid) {
        rootObject->setProperty("perfMonitorsLogging", performanceMonitorState.logging);
        rootObject->setProperty("perfMonitorsVisible", performanceMonitorState.visible);
    }
    PaintEventMonitor paintEventMonitor;
    paintEventMonitor.setTarget(viewer.viewport());
    QObject::connect(&paintEventMonitor, SIGNAL(targetPainted()),
                     rootObject, SLOT(qmlFramePainted()));
#endif

    FileReader fileReader;
    viewer.rootContext()->setContextProperty("fileReader", &fileReader);

    QString imagePath = "../../images";
    const QString picturesLocation = QDesktopServices::storageLocation(QDesktopServices::PicturesLocation);
    if (!picturesLocation.isEmpty())
        imagePath = picturesLocation;
    viewer.rootContext()->setContextProperty("imagePath", imagePath);

    QString videoPath;
    const QString moviesLocation = QDesktopServices::storageLocation(QDesktopServices::MoviesLocation);
    if (!moviesLocation.isEmpty())
        videoPath = moviesLocation;
    viewer.rootContext()->setContextProperty("videoPath", videoPath);

#ifdef SMALL_SCREEN_PHYSICAL
    viewer.setOrientation(QmlApplicationViewer::ScreenOrientationLockLandscape);
    viewer.showFullScreen();
#else
    viewer.showExpanded();
#endif

    // Delay invocation of init until the event loop has started, to work around
    // a GL context issue on Harmattan: without this, we get the following error
    // when the first ShaderEffectItem is created:
    // "QGLShaderProgram::addShader: Program and shader are not associated with same context"
    QMetaObject::invokeMethod(viewer.rootObject(), "init", Qt::QueuedConnection);

    return app.exec();
}
Пример #24
0
MainWindow::MainWindow( QWidget *_parent ): QMainWindow(_parent)
{
	this->resize(QSize(1024,800));
	m_kinect=QKinect::instance();
	QToolBar *toolbar = new QToolBar(this);
	toolbar->setObjectName("KinectToolbar");
	QLabel *label= new QLabel(toolbar);
	label->setText("angle");
	toolbar->addWidget(label);
	QDoubleSpinBox *angle = new QDoubleSpinBox(this);
	angle->setMaximum(30.0);
	angle->setMinimum(-30.0);
	angle->setSingleStep(1.0);
	QObject::connect(angle,SIGNAL(valueChanged(double)),m_kinect,SLOT(setAngle(double)));

	toolbar->addWidget(angle);
	QPushButton *reset = new QPushButton("reset");
	QObject::connect(reset,SIGNAL(clicked()),m_kinect,SLOT(resetAngle()));

	toolbar->addWidget(reset);
	QLabel *label2= new QLabel(toolbar);
	label2->setText("Camera Mode");
	toolbar->addWidget(label2);
	QComboBox *videoMode= new QComboBox(toolbar);

	videoMode->addItem("RGB");
	videoMode->addItem("Bayer");
	videoMode->addItem("IR 8");
	videoMode->addItem("IR 10");
	videoMode->addItem("IR 10 P");
	videoMode->addItem("YUV_RGB");
	videoMode->addItem("YUV_RAW");
	QObject::connect(videoMode,SIGNAL(currentIndexChanged(int)),m_kinect,SLOT(setVideoMode(int)));

	toolbar->addWidget(videoMode);

	QRadioButton *off = new QRadioButton("LED off",toolbar);
	off->setDown(true);
	QObject::connect(off,SIGNAL(clicked()),m_kinect,SLOT(setLedOff()));
	toolbar->addWidget(off);
	QRadioButton *red = new QRadioButton("LED red",toolbar);
	QObject::connect(red,SIGNAL(clicked()),m_kinect,SLOT(setRedLed()));

	toolbar->addWidget(red);
	QRadioButton *green = new QRadioButton("LED green",toolbar);
	QObject::connect(green,SIGNAL(clicked()),m_kinect,SLOT(setGreenLed()));

	toolbar->addWidget(green);
	QRadioButton *yellow = new QRadioButton("LED yellow",toolbar);
	QObject::connect(yellow,SIGNAL(clicked()),m_kinect,SLOT(setYellowLed()));

	toolbar->addWidget(yellow);

  QRadioButton *redF = new QRadioButton("flash red ",toolbar);
  QObject::connect(redF,SIGNAL(clicked()),m_kinect,SLOT(setRedLedFlash()));

	toolbar->addWidget(redF);
	QRadioButton *greenF = new QRadioButton("flash green",toolbar);

	QObject::connect(greenF,SIGNAL(clicked()),m_kinect,SLOT(setGreenLedFlash()));
	toolbar->addWidget(greenF);
	QRadioButton *yellowF = new QRadioButton("flash yellow",toolbar);
	QObject::connect(yellowF,SIGNAL(clicked()),m_kinect,SLOT(setYellowLedFlash()));

	toolbar->addWidget(yellowF);

	this->addToolBar(toolbar);

	m_mdiArea = new QMdiArea;
	m_mdiArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
	m_mdiArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
	setCentralWidget(m_mdiArea);
	this->setWindowTitle(QString("Kinect Demo"));

	QGLFormat format;
	format.setVersion(4,1);
	format.setProfile( QGLFormat::CoreProfile);
	format.setSwapInterval(1);


	QMdiSubWindow *subWindow1 = new QMdiSubWindow;
	VideoWindow *rgb = new VideoWindow(VideoWindow::RGB);
	QWidget *container = QWidget::createWindowContainer(rgb);
	subWindow1->setWidget(container);
	subWindow1->setAttribute(Qt::WA_DeleteOnClose);
	subWindow1->setWindowTitle("RGB Output");
	subWindow1->resize(500,350);
	m_mdiArea->addSubWindow(subWindow1);
	VideoWindow *depth = new VideoWindow(VideoWindow::DEPTH);
	container = QWidget::createWindowContainer(depth);
	QMdiSubWindow *subWindow2 = new QMdiSubWindow;
	subWindow2->setWidget(container);
	subWindow2->setAttribute(Qt::WA_DeleteOnClose);
	subWindow2->setWindowTitle("Depth Output");
	subWindow2->resize(500,350);
	m_mdiArea->addSubWindow(subWindow2);


	PointCloud *cloud = new PointCloud();
	container = QWidget::createWindowContainer(cloud);
	QMdiSubWindow *subWindow3 = new QMdiSubWindow;
	subWindow3->setWidget(container);
	subWindow3->setAttribute(Qt::WA_DeleteOnClose);
	subWindow3->setWindowTitle("PointCloud");
	subWindow3->resize(500,350);
	m_mdiArea->addSubWindow(subWindow3);

	this->setWindowTitle(QString("kinect demo"));


}
Пример #25
0
QtWindow::QtWindow()
{
    QCoreApplication::setOrganizationName("Instrument-Trainer");
    QCoreApplication::setOrganizationDomain("github.com/joshelser/Instrument-Trainer");
    QCoreApplication::setApplicationName("Instrument Trainer");
    m_settings = new CSettings(this);
    setWindowIcon(QIcon(":/images/Logo32x32.png"));
    setWindowTitle(tr("Instrument Trainer"));

    decodeCommandLine();

    if (Cfg::experimentalSwapInterval != -1)
    {
        QGLFormat fmt;
        fmt.setSwapInterval(Cfg::experimentalSwapInterval);
        int value = fmt.swapInterval();
        ppLogInfo("Open GL Swap Interval %d", value);
        QGLFormat::setDefaultFormat(fmt);
    }


#if USE_REALTIME_PRIORITY
    int rt_prio = sched_get_priority_max(SCHED_FIFO);
    set_realtime_priority(SCHED_FIFO, rt_prio);
#endif

    m_glWidget = new CGLView(this, m_settings);

    m_song = m_glWidget->getSongObject();
    m_score = m_glWidget->getScoreObject();


    QHBoxLayout *mainLayout = new QHBoxLayout;
    QVBoxLayout *columnLayout = new QVBoxLayout;

    m_sidePanel = new GuiSidePanel(this, m_settings);
    m_topBar = new GuiTopBar(this, m_settings);

    m_settings->init(m_song, m_sidePanel, m_topBar);

    mainLayout->addWidget(m_sidePanel);
    columnLayout->addWidget(m_topBar);
    columnLayout->addWidget(m_glWidget);
    mainLayout->addLayout(columnLayout);

    m_song->init(m_score, m_settings);
    m_glWidget->init();

    m_sidePanel->init(m_song, m_song->getTrackList(), m_topBar);
    m_topBar->init(m_song, m_song->getTrackList());
    createActions();
    createMenus();
    readSettings();

    QWidget *centralWin = new QWidget();
    centralWin->setLayout(mainLayout);

    setCentralWidget(centralWin);

    m_glWidget->setFocus(Qt::ActiveWindowFocusReason);

    m_song->setPianoSoundPatches(m_settings->value("Keyboard/RightSound", Cfg::defaultRightPatch()).toInt() - 1,
                                 m_settings->value("Keyboard/WrongSound", Cfg::defaultWrongPatch()).toInt() - 1, true);

    QString midiInputName = m_settings->value("Midi/Input").toString();
    if (midiInputName.startsWith("None"))
        CChord::setPianoRange(PC_KEY_LOWEST_NOTE, PC_KEY_HIGHEST_NOTE);
    else
        CChord::setPianoRange(m_settings->value("Keyboard/LowestNote", 0).toInt(),
                          m_settings->value("Keyboard/HighestNote", 127).toInt());

    m_song->setLatencyFix(m_settings->value("Midi/Latency", 0).toInt());


#ifdef _WIN32
    m_glWidget->m_cfg_openGlOptimise = true; // don't default to true on windows
#else
    m_glWidget->m_cfg_openGlOptimise = true; // changed to default to false on platforms
#endif

    m_glWidget->m_cfg_openGlOptimise = m_settings->value("Display/OpenGlOptimise", m_glWidget->m_cfg_openGlOptimise ).toBool();
    m_song->cfg_timingMarkersFlag = m_settings->value("Score/TimingMarkers", m_song->cfg_timingMarkersFlag ).toBool();
    m_song->cfg_stopPointMode = static_cast<stopPointMode_t> (m_settings->value("Score/StopPointMode", m_song->cfg_stopPointMode ).toInt());

    m_song->openMidiPort(CMidiDevice::MIDI_INPUT, midiInputName);
    m_song->openMidiPort(CMidiDevice::MIDI_OUTPUT,m_settings->value("midi/output").toString());

    m_settings->loadSettings();

    show();
}