Пример #1
0
GLWidget::GLWidget(QWidget *parent)
: QGLWidget(QGLFormat(QGL::SampleBuffers), parent) {
	
	_mouseState = UP;
	
	
}
Пример #2
0
//! [0]
GLWidgetShader::GLWidgetShader(QWidget *parent)
    : QGLWidget(QGLFormat(QGL::SampleBuffers), parent)
{
    glEnable(GL_MULTISAMPLE);

    // Important to enable the shaders
    QGLFormat rgbaformat;
    rgbaformat.setRgba(true);
    rgbaformat.setSampleBuffers(true);
    rgbaformat.setDoubleBuffer(true);
    rgbaformat.setSamples(4);
    rgbaformat.setOverlay(0);
    this->setFormat(rgbaformat);
    this->makeCurrent();
    // Very important
    this->setAutoFillBackground(false);

    QTimer *timer = new QTimer(this);
    timer->start(15);
    timer->setInterval(15);
    QObject::connect(timer,SIGNAL(timeout()),this,SLOT(repaint()));

    this->isDrawing=false;
    qglClearColor(Qt::white);
    this->nVertices = 0;
}
Пример #3
0
GLWidget::GLWidget(QWidget *parent) :
    QGLWidget(QGLFormat(QGL::DoubleBuffer), parent) {
    this->setFocusPolicy(Qt::StrongFocus);
    this->setMouseTracking(true);
    this->setAutoBufferSwap(false);
    prev_fps_ = 0.f;
}
Пример #4
0
ModelViewGadgetWidget::ModelViewGadgetWidget(QWidget *parent)
    : QGLWidget(new GLC_Context(QGLFormat(QGL::SampleBuffers)), parent)
    , m_Light()
    , m_World()
    , m_GlView(this)
    , m_MoverController()
    , m_ModelBoundingBox()
    , m_MotionTimer()
    , acFilename()
    , bgFilename()
    , vboEnable(false)
{
    setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
    CreateScene();

    QColor repColor;
    repColor.setRgbF(1.0, 0.11372, 0.11372, 0.0);
    m_MoverController = GLC_Factory::instance()->createDefaultMoverController(repColor, &m_GlView);

    // Get required UAVObjects
    ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
    UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
    attActual = AttitudeActual::GetInstance(objManager);

    connect(&m_MotionTimer, SIGNAL(timeout()), this, SLOT(updateAttitude()));
}
Пример #5
0
UiRenderPreview::UiRenderPreview(QWidget *parent, void *shared) :
    QGLWidget(QGLFormat(QGL::DoubleBuffer | QGL::DirectRendering), parent, (QGLWidget*)shared) {
#else
UiRenderPreview::UiRenderPreview(QWidget *parent, void *shared) :
    QOpenGLWidget(parent) {
    Q_UNUSED(shared);
    QSurfaceFormat sf;
    //sf.setProfile(QSurfaceFormat::CompatibilityProfile);
    //sf.setRenderableType(QSurfaceFormat::OpenGL);
    //sf.setSwapBehavior(QSurfaceFormat::DoubleBuffer);
    //sf.setOption(QSurfaceFormat::DeprecatedFunctions);
    sf.setSamples(4./devicePixelRatioFScale());
    setFormat(sf);
#endif
    setFocusPolicy(Qt::StrongFocus);
    render = 0;
}

void UiRenderPreview::initializeGL() {
    //OpenGL options
}

void UiRenderPreview::resizeGL(int width, int height) {
    glViewport(0, 0, (GLint)width, (GLint)height);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(0, 1, 0, 1, 1, -1);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
}
Пример #6
0
GlWidget::GlWidget(QWidget *parent)
    :   QGLWidget(QGLFormat(/* Additional format options */), parent)
{
    alpha = 25;
    beta = -25;
    distance = 2.5;
}
Пример #7
0
OpenGLWidget::OpenGLWidget(QWidget *parent) : QGLWidget(QGLFormat(QGL::SampleBuffers), parent)
{
    m_clearColor = QColor::fromRgb(0, 0, 0, 0);
    m_glContext = nullptr;
    m_width = 0;
    m_height = 0;
}
Пример #8
0
MyGLWidget::MyGLWidget(QWidget *parent)
    : QGLWidget(QGLFormat(QGL::SampleBuffers), parent)
{
    xRot = 0;
    yRot = 0;
    zRot = 0;
}
Пример #9
0
// ...
GLWidget::GLWidget(QWidget* parent) : QGLWidget(QGLFormat(QGL::DoubleBuffer | QGL::Rgba | QGL::DepthBuffer), parent)
{
	makeCurrent();
	initFont();
	resetSelection();

}
Пример #10
0
GLQuad::GLQuad(QWidget *parent)
   : QGLWidget(QGLFormat(QGL::SampleBuffers), parent)
{
   QTimer *timer = new QTimer(this);
   connect( timer, SIGNAL(timeout()), this, SLOT(updateGL()) );
   timer->start( 50 );
}
Пример #11
0
GLWidget::GLWidget(QWidget *p_parent)
    : QGLWidget(new QGLContext(QGLFormat(QGL::SampleBuffers)), p_parent)
    , m_Light()
    , m_World()
    , m_GlView()
    , m_MoverController()
    , m_ShuttleBoundingBox()
    , m_MotionTimer()
{
    connect(&m_GlView, SIGNAL(updateOpenGL()), this, SLOT(updateGL()));

    m_Light.setPosition(4000.0, 40000.0, 80000.0);
    //m_GlView.setBackgroundColor(Qt::white);
    m_Light.setAmbientColor(Qt::lightGray);

    m_GlView.cameraHandle()->setDefaultUpVector(glc::Z_AXIS);
    m_GlView.cameraHandle()->setIsoView();

    QColor repColor;
    repColor.setRgbF(1.0, 0.11372, 0.11372, 1.0);
    m_MoverController= GLC_Factory::instance()->createDefaultMoverController(repColor, &m_GlView);

    createScene();
    // Signal and slot connection
    connect(&m_MotionTimer, SIGNAL(timeout()), this, SLOT(rotateView()));

    qDebug() << glc::X_AXIS.signedAngleWithVect(-glc::Y_AXIS, glc::Z_AXIS);
    qDebug() << fmod(glc::X_AXIS.signedAngleWithVect(-glc::Y_AXIS, glc::Z_AXIS), 2.0 * glc::PI);
}
Пример #12
0
void CSceneWidget::setEnabledOpenGl(bool enable)
{
#ifndef QT_NO_OPENGL
    if(QGLFormat::hasOpenGL())
        setViewport(enable?new QGLWidget(QGLFormat(QGL::SampleBuffers | QGL::DirectRendering)):new QWidget);
#endif
}
Пример #13
0
GLWidget::GLWidget(QWidget *parent)
    : QGLWidget(QGLFormat(QGL::SampleBuffers), parent)
{
    resize(800,800);

    QString filename = qApp->arguments().value(1,"");
    qDebug() << "arglength: " << qApp->arguments().length();
    if (filename == "artificial" || qApp->arguments().length() == 1) {
        qDebug() << "creating new artificial data";
        cons = new ArtificialConnections();

    } else if (arg("nodes")!=""){
        qDebug() << arg("nodes");
        cons = new Connections(arg("nodes"), arg("cons"));
    } else {
        qDebug() << filename;
        cons = new Connections(filename);
    }

    view = new GLfloat[16];
    stuffAlpha = 0.99;
    QVector3D size = cons->max-cons->min;
    float largest = qMax(size.x(),size.y());
    scale = (1/largest)*0.95;
    bg = 1;
    p1 = true;
    p2 = true;

    if (qApp->arguments().indexOf(QRegExp("-writefib"))!=-1) cons->writeBinaryVTK(filename+".fib");

    if (qApp->arguments().indexOf(QRegExp("-screenshot"))!=-1) screenshot(filename+".png");
    if (qApp->arguments().indexOf(QRegExp("-csv"))!=-1) cons->writeCSVs();
    setFocus();

}
Пример #14
0
SchemaEditor::SchemaEditor(QWidget *parent, SchemaGui *schemaGui, Engine * engine, PanelScrollView *panelScrollView) :
  QGraphicsView(schemaGui, parent),
  _contextMenuPos(0,0),
  _contextGear(NULL),
  _engine(engine),
  _schemaGui(schemaGui),
  _scale(1),
  _panelScrollView(panelScrollView),
  _maxZValue(1),
  _selectionChangeBypass(false)
  

{
  _schemaGui->setSchemaEditor(this);
  setDragMode(QGraphicsView::RubberBandDrag);
  setRenderHint(QPainter::Antialiasing, true);

  setFrameStyle(Sunken | StyledPanel);
  setOptimizationFlags(QGraphicsView::DontSavePainterState | QGraphicsView::IndirectPainting);
  setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
  setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
  
  // render with OpenGL
  if(0)
    setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers)));

  resetTransform();
  setAcceptDrops(TRUE);
}
Пример #15
0
MainWindow::MainWindow() : QMainWindow(0)
{
    QMenu *file = menuBar()->addMenu(tr("&File"));

    QAction *newAction = file->addAction(tr("New Game"));
    newAction->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_N));
    QAction *quitAction = file->addAction(tr("Quit"));
    quitAction->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_Q));

    if (QApplication::arguments().contains("-fullscreen")) {
        scene = new GraphicsScene(0, 0, 750, 400, GraphicsScene::Small);
        setWindowState(Qt::WindowFullScreen);
    } else {
        scene = new GraphicsScene(0, 0, 880, 630);
        layout()->setSizeConstraint(QLayout::SetFixedSize);
    }

    view = new QGraphicsView(scene, this);
    view->setAlignment(Qt::AlignLeft | Qt::AlignTop);
    scene->setupScene(newAction, quitAction);
#ifndef QT_NO_OPENGL
    view->setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers)));
#endif

    setCentralWidget(view);
}
Пример #16
0
int main(int argc, char *argv[]) {
  QApplication app(argc, argv);
  GLWindow *window = new GLWindow(QGLFormat());
  window->show();

  return app.exec();
}
Пример #17
0
//constructor
GlWidget::GlWidget(QWidget *parent)
    : QGLWidget(parent)
{
    theta=90;
    phi=90;
    r=20;
    eyeX=0;
    eyeY=0;
    eyeZ=r;

    upX=0;
    upY=1;
    upZ=0;
    sizeX=20;
    sizeY=20;
    zoom = 2.5;
    xMove = 0;
    yMove = 0;
    currentLayer=0;
    layers = 5000;
    show_travel=false;
    qtGreen = QColor::fromCmykF(0.40, 0.0, 1.0, 0.0);
    qtPurple = QColor::fromCmykF(0.39, 0.39, 0.0, 0.0);
    this->setFormat(QGLFormat(QGL::SampleBuffers));
}
Пример #18
0
ModelViewGadgetWidget::ModelViewGadgetWidget(QWidget *parent)
    : QGLWidget(new GLC_Context(QGLFormat(QGL::SampleBuffers)), parent)
    , m_Light()
    , m_World()
    , m_GlView()
    , m_MoverController()
    , m_ModelBoundingBox()
    , m_MotionTimer()
    , acFilename()
    , bgFilename()
    , vboEnable(false)
{
    connect(&m_GlView, SIGNAL(updateOpenGL()), this, SLOT(updateGL()));
    setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);

    m_Light.setPosition(4000.0, 40000.0, 80000.0);
    // m_GlView.setBackgroundColor(Qt::white);
    m_Light.setAmbientColor(Qt::lightGray);

    m_GlView.cameraHandle()->setDefaultUpVector(glc::Z_AXIS);
    m_GlView.cameraHandle()->setRearView();

    QColor repColor;
    repColor.setRgbF(1.0, 0.11372, 0.11372, 0.0);
    m_MoverController = GLC_Factory::instance()->createDefaultMoverController(repColor, &m_GlView);

    CreateScene();
    // Get required UAVObjects
    ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
    UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
    attState = AttitudeActual::GetInstance(objManager);

    connect(&m_MotionTimer, SIGNAL(timeout()), this, SLOT(updateAttitude()));
}
Пример #19
0
LifeWidget::LifeWidget(LifePlugin *plug, QWidget *parent) : QGLWidget(parent), curPlugin(plug), curIter(0) {
    setFormat(QGLFormat(QGL::DoubleBuffer | QGL::DepthBuffer // | QGL::SampleBuffers
                        | QGL::AlphaChannel | QGL::DirectRendering));

    connect(&timer, SIGNAL(timeout()), this, SLOT(timeout()));

}
Пример #20
0
GLWidget3D::GLWidget3D(MainWindow* mainWin) : QGLWidget(QGLFormat(QGL::SampleBuffers), (QWidget*)mainWin) {
	this->mainWin = mainWin;

	camera2D.resetCamera();
	camera3D.resetCamera();
	camera = &camera2D;
	//G::global()["rend_mode"]=0;//2D	setRender2D_3D();

	spaceRadius=30000.0;
	farPlaneToSpaceRadiusFactor=5.0f;//N 5.0f

	rotationSensitivity = 0.4f;
	zoomSensitivity = 10.0f;

	controlPressed=false;
	shiftPressed=false;
	altPressed=false;
	keyMPressed=false;

	camera->setRotation(0, 0, 0);
	camera->setTranslation(0, 0, G::getFloat("MAX_Z"));//6000);

	vertexSelected = false;
	edgeSelected = false;

	shadowEnabled=true;
}
Пример #21
0
DisplayWidget::DisplayWidget(QWidget *parent,bool FullScreen)
:QGLWidget(QGLFormat(QGL::DoubleBuffer|QGL::AlphaChannel|QGL::SampleBuffers|QGL::AccumBuffer), parent, 0, FullScreen?Qt::X11BypassWindowManagerHint:Qt::Widget)
{
	//Take care of window and input initialization.
	timer.start(16, this); //Draw again shortly after constructor finishes
	if(FullScreen)
	{
		setWindowState(Qt::WindowFullScreen); 
		setCursor(QCursor(Qt::BlankCursor)); //Hide the cursor
		raise(); //Make sure it's the top window
	}
	setPalette(QPalette(QColor(0, 0, 0))); //IF the background draws, draw it black.
	setAutoFillBackground(false); //Try to let glClear work...
	setAutoBufferSwap(false); //Don't let QT swap automatically, we want to control timing.
	backgroundColor=point(0,0,0);
	deepBackgroundColor=point(0,0,0);

	for(int k=0;k<4;k++) drawShapes[k]=false;
	calibrationMode=true;
	
	//Set up a "calibration" field. Should be a 1/4 circle in each corner
	Sphere sphere;
	spheres.clear();
	sphere.color=point(1,0,0);
	sphere.position=point(0,0,HANDLEDEPTH);
	sphere.radius=.018;
	spheres.push_back(sphere);
	sphere.color=point(0,1,0);
	sphere.position=point(LEFTPROBE,0,HANDLEDEPTH);
	spheres.push_back(sphere);
	sphere.color=point(0,0,1);
	sphere.position=point(0, UPPROBE,HANDLEDEPTH);
	spheres.push_back(sphere);
}
Пример #22
0
//! [0]
GLWidget::GLWidget(Helper *helper, QWidget *parent)
    : QGLWidget(QGLFormat(QGL::SampleBuffers), parent), helper(helper)
{
    elapsed = 0;
    setFixedSize(200, 200);
    setAutoFillBackground(false);
}
//! [0]
Visualizer::Visualizer(QWidget *parent)
    : QGLWidget(QGLFormat(QGL::SampleBuffers), parent)
{
    frames = 0;

    setMinimumHeight(500);
    setMinimumWidth(500);

    xRot = 0;
    yRot = 0;
    zRot = 0;
    scale = 0.001f;

    x_min_bound = -1;
    y_min_bound = -1;
    z_min_bound = -1;

    x_max_bound = 1;
    y_max_bound = 1;
    z_max_bound = 1;

    horz_pan = -0.4f;
    vert_pan = -0.4f;

    target_display_radius = 5.0;
    target_detect_radius = 5.0;

}
Пример #24
0
GLWidget::GLWidget(QWidget *pParent)
: QGLWidget(new GLC_Context(QGLFormat(QGL::SampleBuffers)), pParent)
, m_Circle(GLC_Factory::instance()->createCircle(0.2))  // Circle radius
, m_GlView()
{
	m_Circle.geomAt(0)->setWireColor(Qt::white);
}
Пример #25
0
void MainWindow::setRenderingSystem()
{
    QWidget *viewport = 0;

#ifndef QT_NO_OPENGL
    if (Colors::openGlRendering) {
        QGLWidget *glw = new QGLWidget(QGLFormat(QGL::SampleBuffers));
        if (Colors::noScreenSync)
            glw->format().setSwapInterval(0);
        glw->setAutoFillBackground(false);
        viewport = glw;
        setCacheMode(QGraphicsView::CacheNone);
        if (Colors::verbose)
            qDebug() << "- using OpenGL";
    } else // software rendering
#endif
    {
        // software rendering
        viewport = new QWidget;
        setCacheMode(QGraphicsView::CacheBackground);
        if (Colors::verbose)
            qDebug() << "- using software rendering";
    }

    setViewport(viewport);
}
Пример #26
0
GLWidget::GLWidget(QWidget *parent) :
    QGLWidget(QGLFormat(QGL::SampleBuffers),parent),
          m_camera( new Camera( this ) )
{
    setFocusPolicy(Qt::StrongFocus);
    glEnable(GL_MULTISAMPLE);
    glEnable(GL_STENCIL_FUNC);
    simTimer = new QTimer(this);
    connect(simTimer, SIGNAL(timeout()), this, SLOT(updateGL()));
    simTimer->start(0);

    // Initialize the camera position and orientation
    m_camera->setPosition( QVector3D( 5.0f, 5.0f, 5.0f ) );
    m_camera->setViewCenter( QVector3D( 0.0f, 0.0f, 0.0f ) );
    m_camera->setUpVector( QVector3D( 0.0f, 1.0f, 0.0f ) );

    QGLFormat glFormat;
    glFormat.setVersion( 3, 3 );
    glFormat.setProfile( QGLFormat::CoreProfile ); // Requires >=Qt-4.8.0
    glFormat.setSampleBuffers( true );
    glFormat.setSamples(16);

    this->setFormat(glFormat);

    scene = new Scene(this);
    scene->setCamera(m_camera);
    withshadow = true;
}
Пример #27
0
void PhotoKitView::setRenderingSystem()
{
	QWidget *viewport = 0;

#ifndef QT_NO_OPENGL
	if (Config::openGlRendering) {
        setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
		QGLWidget *glw = new QGLWidget(QGLFormat(QGL::SampleBuffers));
		if (Config::noScreenSync)
			glw->format().setSwapInterval(0);
		glw->setAutoFillBackground(false);
		viewport = glw;
		setCacheMode(QGraphicsView::CacheNone);
		if (Config::verbose)
			ezlog_debug("- using OpenGL");
	} else // software rendering
#endif
	{
		// software rendering
        setViewportUpdateMode(QGraphicsView::MinimalViewportUpdate);
		viewport = new QWidget;
		setCacheMode(QGraphicsView::CacheBackground);
		if (Config::verbose)
			ezlog_debug("- using software rendering");
	}

	setViewport(viewport);
}
GLWidget::GLWidget(QWidget *parent)
    : QGLWidget(QGLFormat(QGL::SampleBuffers), parent)
{

    xRot = 0;
    yRot = 0;
    zRot = 0;
    viewPointLeng = 50;

    //
    vectorGroupCreated = false;
    gridPointGroupCreated = false;

    gridPointList = new QList<GridPoint *>;
    vector3d_list = vector<Vector3D *>();
    \
    pivdata = NULL;

    xSpan = 10.0;
    ySpan = 10.0;
    zSpan = 10.0;
    xAxisArrow = new Vector3D(this,4.0,0.1, QColor(1.0,1.0,0.0),false);
    yAxisArrow = new Vector3D(this,4.0,0.1, QColor(1.0,1.0,0.0),false);
    zAxisArrow = new Vector3D(this,4.0,0.1, QColor(1.0,1.0,0.0),false);

    createCoordinateGrid = true;
}
Пример #29
0
Base3DView::Base3DView(QWidget *parent)
    : QGLWidget(QGLFormat(QGL::SampleBuffers), parent)
{
    m_backgroundColor = QColor::fromCmykF(0.29, 0.29, 0.20, 0.0);
	m_orthoCamera = new BaseCamera;
	m_perspCamera = new PerspectiveCamera;
	fCamera = m_orthoCamera;
	m_drawer = new KdTreeDrawer;
	m_activeComponent = new SelectionArray;
	m_activeComponent->setComponentFilterType(PrimitiveFilter::TVertex);
	m_intersectCtx = new IntersectionContext;
	m_intersectCtx->setComponentFilterType(PrimitiveFilter::TVertex);
	m_brush = new BaseBrush;
	
	m_timer = new QTimer(this);
	//connect(m_timer, SIGNAL(timeout()), this, SLOT(update()));
	m_timer->start(34);
	setFocusPolicy(Qt::ClickFocus);
	m_isFocused = 0;
	m_interactContext = 0;
		
	m_hud = new GLHUD;
	m_hud->setCamera(fCamera);
	
	m_lastTime = m_startTime = (boost::posix_time::ptime(boost::posix_time::microsec_clock::local_time()) - time_t_epoch).total_milliseconds();
}
Пример #30
0
void View::setOpenGL( const bool enabled )
{
    if ( enabled == hasOpenGL_ )
        return;

    hasOpenGL_ = enabled;
    if (hasOpenGL_)
    {
        viewport_ = new QGLWidget( QGLFormat(QGL::SampleBuffers), this );
        setViewport(viewport_);

        viewport_->makeCurrent();
        glClearColor( 0, 0, 0, 1.0 );
        glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
    //     glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
        glPolygonMode( GL_FRONT, GL_FILL );
        glPolygonMode( GL_BACK, GL_LINE );
        glEnable(GL_POLYGON_OFFSET_FILL);
        glPolygonOffset( 1.0, 2.0 );
        glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR );
        glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
    }
    else
    {
        defaultVP_ = new QWidget(this);
        setViewport(defaultVP_);
    }
    setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
    setCacheMode(QGraphicsView::CacheNone);
    setRenderHints(QPainter::Antialiasing|QPainter::SmoothPixmapTransform);
    setForegroundBrush(Qt::NoBrush);
    setBackgroundBrush(Qt::NoBrush);
}