void QGLGraphicsViewportItemPrivate::changeCamera(QGLCamera *c)
{
    disconnect(camera, SIGNAL(projectionChanged()),
               this, SLOT(cameraChanged()));
    disconnect(camera, SIGNAL(viewChanged()),
               this, SLOT(cameraChanged()));
    camera = c;
    connect(camera, SIGNAL(projectionChanged()),
            this, SLOT(cameraChanged()));
    connect(camera, SIGNAL(viewChanged()),
            this, SLOT(cameraChanged()));
}
Esempio n. 2
0
void ViewCameraGL::read(const QString& filename)
{
    QFile file(filename);
    if(file.exists() && file.open( QIODevice::ReadOnly )) {
    QTextStream stream ( &file );

        stream >> __azimuth >> __elevation;
        printf("%d\n",__azimuth);
        printf("%d\n",__elevation);
        stream >> __stepMove;
        printf("%i\n",__stepMove);

        IV(stream,__center);
        IV(stream,__eye);
        IV(stream,__translation);

        stream >> __radius >> __far_plane >> __near_plane;
    stream >> __default_view_angle >> __view_angle;
        int i = 0;
    stream >> i;
        __projectionmode = (i != 0);
    stream >> i;
        __geomsys = (i != 0);
//    emit azimuthChanged(QString::number(__azimuth));
//    emit elevationChanged(QString::number(__elevation));
//    emit zoomChanged(QString::number(__translation.x()));
    emit azimuthChanged(__azimuth);
    emit elevationChanged(__elevation);
    emit zoomChanged(__translation.x());
    emit farPlaneChanged(QString::number(__far_plane));
    emit nearPlaneChanged(QString::number(__near_plane));
    emit projectionChanged(__projectionmode);
    emit coordSysChanged(__geomsys);
    emit valueChanged();
        }
Esempio n. 3
0
void QGLCamera::setNearPlane(qreal value)
{
    Q_D(QGLCamera);
    if (d->nearPlane != value) {
        d->nearPlane = value;
        emit projectionChanged();
    }
}
Esempio n. 4
0
void Camera::setProjectionType(Camera::ProjectionType value)
{
    Q_D(Camera);
    if (d->projectionType != value) {
        d->projectionType = value;
        emit projectionChanged();
    }
}
Esempio n. 5
0
void Camera::setFieldOfView(qreal angle)
{
    Q_D(Camera);
    if (d->fieldOfView != angle) {
        d->fieldOfView = angle;
        emit projectionChanged();
    }
}
Esempio n. 6
0
void QGLCamera::setFarPlane(float value)
{
    Q_D(QGLCamera);
    if (d->farPlane != value) {
        d->farPlane = value;
        emit projectionChanged();
    }
}
Esempio n. 7
0
void QGLCamera::setFieldOfView(float angle)
{
    Q_D(QGLCamera);
    if (d->fieldOfView != angle) {
        d->fieldOfView = angle;
        emit projectionChanged();
    }
}
Esempio n. 8
0
void Camera::setFarPlane(qreal value)
{
    Q_D(Camera);
    if (d->farPlane != value) {
        d->farPlane = value;
        emit projectionChanged();
    }
}
Esempio n. 9
0
void Camera::setMinViewSize(const QSizeF& size)
{
    Q_D(Camera);
    if (d->viewSize != size) {
        d->viewSize = size;
        emit projectionChanged();
    }
}
Esempio n. 10
0
void Camera::setScreenRotation(int angle)
{
    Q_D(Camera);
    if (d->screenRotation != angle) {
        d->screenRotation = angle;
        emit projectionChanged();
    }
}
Esempio n. 11
0
TemplateImage::TemplateImage(const QString& path, Map* map) : Template(path, map)
{
	undo_index = 0;
	georef.reset(new Georeferencing());
	
	const Georeferencing& georef = map->getGeoreferencing();
	connect(&georef, SIGNAL(projectionChanged()), this, SLOT(updateGeoreferencing()));
	connect(&georef, SIGNAL(transformationChanged()), this, SLOT(updateGeoreferencing()));
}
Esempio n. 12
0
void
ViewCameraGL::changeCameraMode()
{
  __projectionmode = ! __projectionmode;
  if( __projectionmode)status(tr("Perspective Camera"),5000);
  else status(tr("Orthographic Camera"),5000);
  glInitProjectionMatrix();
  emit projectionChanged(__projectionmode);
  emit valueChanged();
}
Esempio n. 13
0
void Viewport::setCamera(QGLCamera *value)
{
    if (d->camera != value) {
        if (d->camera) {
            disconnect(d->camera, SIGNAL(projectionChanged()),
                       this, SLOT(cameraChanged()));
            disconnect(d->camera, SIGNAL(viewChanged()),
                       this, SLOT(cameraChanged()));
        }
        d->camera = value;
        if (d->camera) {
            connect(d->camera, SIGNAL(projectionChanged()),
                    this, SLOT(cameraChanged()));
            connect(d->camera, SIGNAL(viewChanged()),
                    this, SLOT(cameraChanged()));
        }
        cameraChanged();
    }
}
Esempio n. 14
0
void MarbleMap::setProjection( Projection projection )
{
    emit projectionChanged( projection );

    d->m_viewport.setProjection( projection );

    d->m_textureLayer.setupTextureMapper( projection );

    emit visibleLatLonAltBoxChanged( d->m_viewport.viewLatLonAltBox() );
}
Esempio n. 15
0
void
ViewCameraGL::setPerspectiveMode()
{
  if(!__projectionmode){
    status(tr("Perspective Camera"),5000);
    __projectionmode = true;
    glInitProjectionMatrix();
    emit projectionChanged(__projectionmode);
    emit valueChanged();
  }
}
Esempio n. 16
0
void
ViewCameraGL::setOrthographicMode()
{
  if(__projectionmode){
    status(tr("Orthographic Camera"),5000);
    __projectionmode = false;
    glInitProjectionMatrix();
    emit projectionChanged(__projectionmode);
    emit valueChanged();
  }
}
Esempio n. 17
0
TemplateTrack::TemplateTrack(const QString& path, Map* map)
 : Template(path, map)
{
	// set default value
	track_crs_spec = QString::fromLatin1("+proj=latlong +datum=WGS84");
	
	const Georeferencing& georef = map->getGeoreferencing();
	connect(&georef, SIGNAL(projectionChanged()), this, SLOT(updateGeoreferencing()));
	connect(&georef, SIGNAL(transformationChanged()), this, SLOT(updateGeoreferencing()));
	connect(&georef, SIGNAL(stateChanged()), this, SLOT(updateGeoreferencing()));
	connect(&georef, SIGNAL(declinationChanged()), this, SLOT(updateGeoreferencing()));
}
Esempio n. 18
0
void
ViewCameraGL::setProjectionMode(bool b)
{
  if(__projectionmode != b){
    __projectionmode = b;
    if( __projectionmode)status(tr("Perspective Camera"),5000);
    else status(tr("Orthographic Camera"),5000);
    glInitProjectionMatrix();
    emit projectionChanged(__projectionmode);
    emit valueChanged();
  }
}
Esempio n. 19
0
void Camera::setViewSize(const QSizeF& size)
{
    Q_D(Camera);
    QSizeF sz(size);
    if (sz.width() < d->minViewSize.width())
        sz.setWidth(d->minViewSize.width());
    if (sz.height() < d->minViewSize.height())
        sz.setHeight(d->minViewSize.height());
    if (d->viewSize != sz) {
        d->viewSize = sz;
        emit projectionChanged();
    }
}
Esempio n. 20
0
/*!
    Sets the camera parameters to \a value.  The camera defines the
    projection to apply to convert eye co-ordinates into window
    co-ordinates, and the position and orientation of the viewer's eye.

    If \a value is null, then the default camera object will be used.

    This function will call update() to force the view to
    update with the new camera parameters upon the next event loop.

    \sa camera()
*/
void QGLView::setCamera(QGLCamera *value)
{
    if (!value)
        value = d->defaultCamera;

    if (d->camera == value)
        return;

    disconnect(d->camera, SIGNAL(projectionChanged()),
               this, SLOT(cameraChanged()));
    disconnect(d->camera, SIGNAL(viewChanged()),
               this, SLOT(cameraChanged()));

    d->camera = value;

    connect(d->camera, SIGNAL(projectionChanged()),
            this, SLOT(cameraChanged()));
    connect(d->camera, SIGNAL(viewChanged()),
            this, SLOT(cameraChanged()));

    cameraChanged();
}
Esempio n. 21
0
void QGLCamera::setViewSize(const QSizeF& size)
{
    Q_D(QGLCamera);
    QSizeF sz(size);
    if (qAbs(sz.width()) < d->minViewSize.width()) {
        if (sz.width() >= 0.0f)
            sz.setWidth(d->minViewSize.width());
        else
            sz.setWidth(-d->minViewSize.width());
    }
    if (qAbs(sz.height()) < d->minViewSize.height()) {
        if (sz.height() >= 0.0f)
            sz.setHeight(d->minViewSize.height());
        else
            sz.setHeight(-d->minViewSize.height());
    }
    if (d->viewSize != sz) {
        d->viewSize = sz;
        emit projectionChanged();
    }
}
Esempio n. 22
0
// slot
void GeoreferencingDialog::georefStateChanged()
{
	const QSignalBlocker block(crs_selector);
	
	switch (georef->getState())
	{
	case Georeferencing::Local:
		crs_selector->setCurrentItem(Georeferencing::Local);
		keep_geographic_radio->setEnabled(false);
		keep_projected_radio->setChecked(true);
		break;
	default:
		qDebug() << "Unhandled georeferencing state:" << georef->getState();
		// fall through
	case Georeferencing::Normal:
		projectionChanged();
		keep_geographic_radio->setEnabled(true);
	}
	
	updateWidgets();
}
Esempio n. 23
0
    QGLViewPrivate(QGLView *parent)
        : view(parent), mainSurface(parent)
    {
        options = QGLView::CameraNavigation;
        fbo = 0;
        leftSurface = 0;
        rightSurface = 0;

        if (parent->format().stereo())
            stereoType = QGLView::Hardware;
        else
            stereoType = QGLView::RedCyanAnaglyph;

        pickBufferForceUpdate = true;
        pickBufferMaybeInvalid = true;
        updateQueued = false;

        pressedObject = 0;
        pressedButton = Qt::NoButton;
        enteredObject = 0;

        defaultCamera = new QGLCamera(parent);
        camera = defaultCamera;

        panning = false;
        startPan = QPoint(-1, -1);
        lastPan = QPoint(-1, -1);
        panModifiers = Qt::NoModifier;
        QObject::connect(defaultCamera, SIGNAL(projectionChanged()),
                         parent, SLOT(cameraChanged()));
        QObject::connect(defaultCamera, SIGNAL(viewChanged()),
                         parent, SLOT(cameraChanged()));

        logTime.start();
        lastFrameTime.start();
        QByteArray env = qgetenv("Quick3D_LOG_EVENTS");
        if (env == "1")
            options |= QGLView::PaintingLog;
    }
Esempio n. 24
0
void MapMatrix::slotInitMatrix()
{
  GeneralConfig *conf = GeneralConfig::instance();

  // The scale is set to 0 in the constructor. Here we read the scale and
  // the map center only the first time. Otherwise the values would change
  // after configuring Cumulus.
  if (cScale <= 0)
    {
      // @ee we want to center to the last position !
      mapCenterLat = conf->getCenterLat();
      mapCenterLon = conf->getCenterLon();

      if ((mapCenterLat == 0) && (mapCenterLon == 0))
        {
          // ok, that point is not valid
          qWarning("Center coordinates not valid");
          mapCenterLat = conf->getHomeLat();
          mapCenterLon = conf->getHomeLon();
        }

      cScale = conf->getMapScale();
    }

  homeLat = conf->getHomeLat();
  homeLon = conf->getHomeLon();

  int newProjectionType = conf->getMapProjectionType();

  bool projChanged = newProjectionType != currentProjection->projectionType();

  if (projChanged)
    {
      delete currentProjection;
      switch(newProjectionType)
      {
        case ProjectionBase::Lambert:
          currentProjection = new ProjectionLambert(conf->getLambertParallel1(),
                                                    conf->getLambertParallel2(),
                                                    conf->getLambertOrign());
          qDebug ("Map projection changed to Lambert");
          break;

        case ProjectionBase::Cylindric:
        default:
          // fall back is cylindrical
          currentProjection = new ProjectionCylindric(conf->getCylinderParallel());
          qDebug ("Map projection changed to Cylinder");
          break;
      }
  }

  scaleBorders[UpperLimit]  = conf->getMapUpperLimit();
  scaleBorders[LowerLimit]  = conf->getMapLowerLimit();
  scaleBorders[Border1]     = conf->getMapBorder1();
  scaleBorders[Border2]     = conf->getMapBorder2();
  scaleBorders[Border3]     = conf->getMapBorder3();
  scaleBorders[SwitchScale] = conf->getMapSwitchScale();

  cScale = qMin( (int) cScale, scaleBorders[UpperLimit]);
  cScale = qMax( (int) cScale, scaleBorders[LowerLimit]);

  bool initChanged = false;

  if (currentProjection->projectionType() == ProjectionBase::Lambert)
    {
      initChanged = ((ProjectionLambert*)currentProjection)->initProjection( conf->getLambertParallel1(),
                                                                             conf->getLambertParallel2(),
                                                                             conf->getLambertOrign() );
    }
  else if (currentProjection->projectionType() == ProjectionBase::Cylindric)
    {
      initChanged = ((ProjectionCylindric*)currentProjection)->initProjection( conf->getCylinderParallel() );
    }

  if( mapRootDir != conf->getMapRootDir() )
    {
      // The user has defined a new map root directory at run-time. We should take
      // that as new source for map files and trigger a reload of all map files.
      mapRootDir = conf->getMapRootDir();
      initChanged = true;
    }

  if( initChanged )
    {
      // qDebug ("MapMatrix::slotInitMatrix has detected a change");
    }

  if( projChanged || initChanged )
    {
      emit projectionChanged();
    }
}
Esempio n. 25
0
//------------------------------------------------------------------------------
View3D::View3D(GeometryCollection* geometries, const QGLFormat& format, QWidget *parent)
    : QGLWidget(format, parent),
    m_camera(false, false),
    m_mouseButton(Qt::NoButton),
    m_explicitCursorPos(false),
    m_cursorPos(0),
    m_prevCursorSnap(0),
    m_backgroundColor(60, 50, 50),
    m_drawBoundingBoxes(true),
    m_drawCursor(true),
    m_drawAxes(true),
    m_drawGrid(false),
    m_drawAnnotations(true),
    m_badOpenGL(false),
    m_shaderProgram(),
    m_geometries(geometries),
    m_selectionModel(0),
    m_shaderParamsUI(0),
    m_incrementalFrameTimer(0),
    m_incrementalFramebuffer(),
    m_incrementalDraw(false),
    m_drawAxesBackground(QImage(":/resource/axes.png")),
    m_drawAxesLabelX(QImage(":/resource/x.png")),
    m_drawAxesLabelY(QImage(":/resource/y.png")),
    m_drawAxesLabelZ(QImage(":/resource/z.png")),
    m_cursorVertexArray(0),
    m_axesVertexArray(0),
    m_gridVertexArray(0),
    m_quadVertexArray(0),
    m_quadLabelVertexArray(0),
    m_devicePixelRatio(1.0)
{
    connect(m_geometries, SIGNAL(layoutChanged()),                      this, SLOT(geometryChanged()));
    //connect(m_geometries, SIGNAL(destroyed()),                          this, SLOT(modelDestroyed()));
    connect(m_geometries, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(geometryChanged()));
    connect(m_geometries, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(dataChanged(QModelIndex,QModelIndex)));
    connect(m_geometries, SIGNAL(rowsInserted(QModelIndex,int,int)),    this, SLOT(geometryInserted(const QModelIndex&, int,int)));
    connect(m_geometries, SIGNAL(rowsRemoved(QModelIndex,int,int)),     this, SLOT(geometryChanged()));

    setSelectionModel(new QItemSelectionModel(m_geometries, this));

    setFocusPolicy(Qt::StrongFocus);
    setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
    setFocus();

    connect(&m_camera, SIGNAL(projectionChanged()), this, SLOT(restartRender()));
    connect(&m_camera, SIGNAL(viewChanged()), this, SLOT(restartRender()));

    makeCurrent();
    m_shaderProgram.reset(new ShaderProgram());
    connect(m_shaderProgram.get(), SIGNAL(uniformValuesChanged()),
            this, SLOT(restartRender()));
    connect(m_shaderProgram.get(), SIGNAL(shaderChanged()),
            this, SLOT(restartRender()));
    connect(m_shaderProgram.get(), SIGNAL(paramsChanged()),
            this, SLOT(setupShaderParamUI()));

    m_incrementalFrameTimer = new QTimer(this);
    m_incrementalFrameTimer->setSingleShot(false);
    connect(m_incrementalFrameTimer, SIGNAL(timeout()), this, SLOT(updateGL()));
}
Esempio n. 26
0
//------------------------------------------------------------------------------
View3D::View3D(GeometryCollection* geometries, const QGLFormat& format, QWidget *parent)
    : QGLWidget(format, parent),
    m_camera(false, false),
    m_mouseButton(Qt::NoButton),
    m_explicitCursorPos(false),
    m_cursorPos(0),
    m_prevCursorSnap(0),
    m_backgroundColor(60, 50, 50),
    m_drawBoundingBoxes(true),
    m_drawCursor(true),
    m_drawAxes(true),
    m_drawGrid(false),
    m_badOpenGL(false),
    m_shaderProgram(),
    m_geometries(geometries),
    m_selectionModel(0),
    m_shaderParamsUI(0),
    m_incrementalFrameTimer(0),
    m_incrementalFramebuffer(0),
    m_incrementalDraw(false),
    m_drawAxesBackground(QImage(":/resource/axes.png")),
    m_drawAxesLabelX(QImage(":/resource/x.png")),
    m_drawAxesLabelY(QImage(":/resource/y.png")),
    m_drawAxesLabelZ(QImage(":/resource/z.png")),
    m_cursorVertexArray(0),
    m_axesVertexArray(0),
    m_gridVertexArray(0),
    m_quadVertexArray(0),
    m_quadLabelVertexArray(0),
    m_devicePixelRatio(1.0)
{
    connect(m_geometries, SIGNAL(layoutChanged()),                      this, SLOT(geometryChanged()));
    //connect(m_geometries, SIGNAL(destroyed()),                          this, SLOT(modelDestroyed()));
    connect(m_geometries, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(geometryChanged()));
    connect(m_geometries, SIGNAL(rowsInserted(QModelIndex,int,int)),    this, SLOT(geometryInserted(const QModelIndex&, int,int)));
    connect(m_geometries, SIGNAL(rowsRemoved(QModelIndex,int,int)),     this, SLOT(geometryChanged()));

    setSelectionModel(new QItemSelectionModel(m_geometries, this));

    setFocusPolicy(Qt::StrongFocus);
    setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
    setFocus();

    m_camera.setClipFar(FLT_MAX*0.5f); //using FLT_MAX appears to cause issues under OS X for Qt to handle
    // Setting a good value for the near camera clipping plane is difficult
    // when trying to show a large variation of length scales:  Setting a very
    // small value allows us to see objects very close to the camera; the
    // tradeoff is that this reduces the resolution of the z-buffer leading to
    // z-fighting in the distance.
    m_camera.setClipNear(1);
    connect(&m_camera, SIGNAL(projectionChanged()), this, SLOT(restartRender()));
    connect(&m_camera, SIGNAL(viewChanged()), this, SLOT(restartRender()));

    makeCurrent();
    m_shaderProgram.reset(new ShaderProgram());
    connect(m_shaderProgram.get(), SIGNAL(uniformValuesChanged()),
            this, SLOT(restartRender()));
    connect(m_shaderProgram.get(), SIGNAL(shaderChanged()),
            this, SLOT(restartRender()));
    connect(m_shaderProgram.get(), SIGNAL(paramsChanged()),
            this, SLOT(setupShaderParamUI()));

    m_incrementalFrameTimer = new QTimer(this);
    m_incrementalFrameTimer->setSingleShot(false);
    connect(m_incrementalFrameTimer, SIGNAL(timeout()), this, SLOT(updateGL()));
}