void Projection::fromXML(QXmlStreamReader& stream) { if (stream.name() == "Projection") { QString proj; if (stream.attributes().hasAttribute("type")) proj = stream.attributes().value("type").toString(); else proj = QCoreApplication::translate("Projection", "Document"); stream.readNext(); if (stream.tokenType() == QXmlStreamReader::Characters) { setProjectionType(stream.text().toString()); p->projType = proj; stream.readNext(); } else setProjectionType(proj); } }
ObjectCamera::ObjectCamera(float p_distance): Camera(), m_mouseX(0), m_mouseY(0), m_prevMouseX(0), m_prevMouseY(0), m_startPosition(0, 0, p_distance) { setTarget(Vector3(0, 0, 0)); setPosition(m_startPosition); setProjectionType(ProjectionType::Perspective); }
/*! * Defines a perspective projection based on \a fieldOfView, \a aspectRatio, \a * nearPlane, \a farPlane. */ void QCameraLens::setPerspectiveProjection(float fieldOfView, float aspectRatio, float nearPlane, float farPlane) { Q_D(QCameraLens); bool block = blockNotifications(true); setFieldOfView(fieldOfView); setAspectRatio(aspectRatio); setNearPlane(nearPlane); setFarPlane(farPlane); setProjectionType(PerspectiveProjection); blockNotifications(block); d->updateProjectionMatrix(); }
Projection::Projection(void) : p(new ProjectionPrivate) { #if defined(Q_OS_WIN) && !defined(_MOBILE) QString pdir(QDir::toNativeSeparators(qApp->applicationDirPath() + "/" STRINGIFY(SHARE_DIR) "/proj")); const char* proj_dir = pdir.toUtf8().constData(); // const char* proj_dir = "E:\\cbro\\src\\merkaartor-devel\\binaries\\bin\\share\\proj"; pj_set_searchpath(1, &proj_dir); #endif // Q_OS_WIN #ifndef _MOBILE theProj = NULL; p->theWGS84Proj = Projection::getProjection("+proj=longlat +ellps=WGS84 +datum=WGS84"); setProjectionType(M_PREFS->getProjectionType()); #endif }
/*! * Defines an orthographic projection based on \a left, \a right, \a bottom, \a * top, \a nearPlane, \a farPlane. */ void QCameraLens::setFrustumProjection(float left, float right, float bottom, float top, float nearPlane, float farPlane) { Q_D(QCameraLens); bool block = blockNotifications(true); setLeft(left); setRight(right); setBottom(bottom); setTop(top); setNearPlane(nearPlane); setFarPlane(farPlane); setProjectionType(FrustumProjection); blockNotifications(block); d->updateProjectionMatrix(); }
void OctreeProjectedPolygon::merge(const OctreeProjectedPolygon& that) { // RIGHT/NEAR // LEFT/NEAR if ( (getProjectionType() == that.getProjectionType()) && ( getProjectionType() == (PROJECTION_RIGHT | PROJECTION_NEAR) || getProjectionType() == (PROJECTION_LEFT | PROJECTION_NEAR) ) ) { if (getVertex(1) == that.getVertex(0) && getVertex(4) == that.getVertex(5)) { //setVertex(0, this.getVertex(0)); // no change setVertex(1, that.getVertex(1)); setVertex(2, that.getVertex(2)); setVertex(3, that.getVertex(3)); setVertex(4, that.getVertex(4)); //setVertex(5, this.getVertex(5)); // no change return; // done } if (getVertex(0) == that.getVertex(1) && getVertex(5) == that.getVertex(4)) { setVertex(0, that.getVertex(0)); //setVertex(1, this.getVertex(1)); // no change //setVertex(2, this.getVertex(2)); // no change //setVertex(3, this.getVertex(3)); // no change //setVertex(4, that.getVertex(4)); // no change setVertex(5, that.getVertex(5)); return; // done } if (getVertex(2) == that.getVertex(1) && getVertex(3) == that.getVertex(4)) { //setVertex(0, this.getVertex(0)); // no change //setVertex(1, this.getVertex(1)); // no change setVertex(2, that.getVertex(2)); setVertex(3, that.getVertex(3)); //setVertex(4, this.getVertex(4)); // no change //setVertex(5, that.getVertex(5)); // no change return; // done } if (getVertex(1) == that.getVertex(2) && getVertex(4) == that.getVertex(3)) { setVertex(0, that.getVertex(0)); setVertex(1, that.getVertex(1)); //setVertex(2, this.getVertex(2)); // no change //setVertex(3, that.getVertex(3)); // no change setVertex(4, that.getVertex(4)); setVertex(5, that.getVertex(5)); return; // done } } // NEAR/BOTTOM if ( (getProjectionType() == that.getProjectionType()) && ( getProjectionType() == (PROJECTION_NEAR | PROJECTION_BOTTOM) ) ) { if (getVertex(0) == that.getVertex(5) && getVertex(3) == that.getVertex(4)) { setVertex(0, that.getVertex(0)); setVertex(1, that.getVertex(1)); setVertex(2, that.getVertex(2)); setVertex(3, that.getVertex(3)); //setVertex(4, this.getVertex(4)); // no change //setVertex(5, that.getVertex(5)); // no change return; // done } if (getVertex(5) == that.getVertex(0) && getVertex(4) == that.getVertex(3)) { //setVertex(0, this.getVertex(0)); // no change //setVertex(1, that.getVertex(1)); // no change //setVertex(2, this.getVertex(2)); // no change //setVertex(3, that.getVertex(3)); // no change setVertex(4, that.getVertex(4)); setVertex(5, that.getVertex(5)); return; // done } if (getVertex(1) == that.getVertex(0) && getVertex(2) == that.getVertex(3)) { //setVertex(0, this.getVertex(0)); // no change setVertex(1, that.getVertex(1)); setVertex(2, that.getVertex(2)); //setVertex(3, that.getVertex(3)); // no change //setVertex(4, this.getVertex(4)); // no change //setVertex(5, that.getVertex(5)); // no change return; // done } if (getVertex(0) == that.getVertex(1) && getVertex(3) == that.getVertex(2)) { setVertex(0, that.getVertex(0)); //setVertex(1, this.getVertex(1)); // no change //setVertex(2, that.getVertex(2)); // no change setVertex(3, that.getVertex(3)); setVertex(4, that.getVertex(4)); setVertex(5, that.getVertex(5)); return; // done } } // NEAR/TOP if ( (getProjectionType() == that.getProjectionType()) && ( getProjectionType() == (PROJECTION_NEAR | PROJECTION_TOP) ) ) { if (getVertex(0) == that.getVertex(5) && getVertex(1) == that.getVertex(2)) { setVertex(0, that.getVertex(0)); setVertex(1, that.getVertex(1)); //setVertex(2, this.getVertex(2)); // no change //setVertex(3, that.getVertex(3)); // no change //setVertex(4, this.getVertex(4)); // no change //setVertex(5, that.getVertex(5)); // no change return; // done } if (getVertex(5) == that.getVertex(0) && getVertex(2) == that.getVertex(1)) { //setVertex(0, this.getVertex(0)); // no change //setVertex(1, that.getVertex(1)); // no change setVertex(2, that.getVertex(2)); setVertex(3, that.getVertex(3)); setVertex(4, that.getVertex(4)); setVertex(5, that.getVertex(5)); return; // done } if (getVertex(4) == that.getVertex(5) && getVertex(3) == that.getVertex(2)) { //setVertex(0, this.getVertex(0)); // no change //setVertex(1, that.getVertex(1)); // no change //setVertex(2, that.getVertex(2)); // no change setVertex(3, that.getVertex(3)); setVertex(4, that.getVertex(4)); //setVertex(5, that.getVertex(5)); // no change return; // done } if (getVertex(5) == that.getVertex(4) && getVertex(2) == that.getVertex(3)) { setVertex(0, that.getVertex(0)); setVertex(1, that.getVertex(1)); setVertex(2, that.getVertex(2)); //setVertex(3, this.getVertex(3)); // no change //setVertex(4, that.getVertex(3)); // no change setVertex(5, that.getVertex(5)); return; // done } } // RIGHT/NEAR & NEAR/RIGHT/TOP // LEFT/NEAR & NEAR/LEFT/TOP if ( ((getProjectionType() == (PROJECTION_RIGHT | PROJECTION_NEAR | PROJECTION_TOP)) && (that.getProjectionType() == (PROJECTION_RIGHT | PROJECTION_NEAR))) || ((getProjectionType() == (PROJECTION_LEFT | PROJECTION_NEAR | PROJECTION_TOP)) && (that.getProjectionType() == (PROJECTION_LEFT | PROJECTION_NEAR))) ) { if (getVertex(5) == that.getVertex(0) && getVertex(3) == that.getVertex(2)) { //setVertex(0, this.getVertex(0)); // no change //setVertex(1, this.getVertex(1)); // no change //setVertex(2, this.getVertex(2)); // no change setVertex(3, that.getVertex(3)); setVertex(4, that.getVertex(4)); setVertex(5, that.getVertex(5)); setProjectionType((PROJECTION_RIGHT | PROJECTION_NEAR)); return; // done } } // RIGHT/NEAR & NEAR/RIGHT/TOP // LEFT/NEAR & NEAR/LEFT/TOP if ( ((that.getProjectionType() == (PROJECTION_RIGHT | PROJECTION_NEAR | PROJECTION_TOP)) && (getProjectionType() == (PROJECTION_RIGHT | PROJECTION_NEAR))) || ((that.getProjectionType() == (PROJECTION_LEFT | PROJECTION_NEAR | PROJECTION_TOP)) && (getProjectionType() == (PROJECTION_LEFT | PROJECTION_NEAR))) ) { if (getVertex(0) == that.getVertex(5) && getVertex(2) == that.getVertex(3)) { setVertex(0, that.getVertex(0)); setVertex(1, that.getVertex(1)); setVertex(2, that.getVertex(2)); //setVertex(3, this.getVertex(3)); // no change //setVertex(4, this.getVertex(4)); // no change //setVertex(5, this.getVertex(5)); // no change //setProjectionType((PROJECTION_RIGHT | PROJECTION_NEAR)); // no change return; // done } } // RIGHT/NEAR & NEAR/RIGHT/BOTTOM // NEAR/LEFT & NEAR/LEFT/BOTTOM if ( ((that.getProjectionType() == (PROJECTION_RIGHT | PROJECTION_NEAR | PROJECTION_BOTTOM)) && (getProjectionType() == (PROJECTION_RIGHT | PROJECTION_NEAR))) || ((that.getProjectionType() == (PROJECTION_LEFT | PROJECTION_NEAR | PROJECTION_BOTTOM)) && (getProjectionType() == (PROJECTION_LEFT | PROJECTION_NEAR))) ) { if (getVertex(5) == that.getVertex(0) && getVertex(3) == that.getVertex(2)) { //setVertex(0, this.getVertex(0)); // no change //setVertex(1, this.getVertex(1)); // no change //setVertex(2, this.getVertex(2)); // no change setVertex(3, that.getVertex(3)); setVertex(4, that.getVertex(4)); setVertex(5, that.getVertex(5)); //setProjectionType((PROJECTION_RIGHT | PROJECTION_NEAR)); // no change return; // done } } // RIGHT/NEAR & NEAR/RIGHT/BOTTOM // NEAR/LEFT & NEAR/LEFT/BOTTOM if ( ((getProjectionType() == (PROJECTION_RIGHT | PROJECTION_NEAR | PROJECTION_BOTTOM)) && (that.getProjectionType() == (PROJECTION_RIGHT | PROJECTION_NEAR))) || ((getProjectionType() == (PROJECTION_LEFT | PROJECTION_NEAR | PROJECTION_BOTTOM)) && (that.getProjectionType() == (PROJECTION_LEFT | PROJECTION_NEAR))) ) { if (getVertex(0) == that.getVertex(5) && getVertex(2) == that.getVertex(3)) { setVertex(0, that.getVertex(0)); setVertex(1, that.getVertex(1)); setVertex(2, that.getVertex(2)); //setVertex(3, this.getVertex(3)); // no change //setVertex(4, this.getVertex(4)); // no change //setVertex(5, this.getVertex(5)); // no change setProjectionType((PROJECTION_RIGHT | PROJECTION_NEAR)); return; // done } } // NEAR/TOP & NEAR if ( (getProjectionType() == (PROJECTION_NEAR )) && (that.getProjectionType() == (PROJECTION_NEAR | PROJECTION_TOP )) ) { if (getVertex(0) == that.getVertex(5) && getVertex(1) == that.getVertex(2)) { setVertex(0, that.getVertex(0)); setVertex(1, that.getVertex(1)); //setVertex(2, this.getVertex(2)); // no change //setVertex(3, this.getVertex(3)); // no change //setVertexCount(4); // no change //setProjectionType((PROJECTION_NEAR)); // no change return; // done } } // NEAR/TOP & NEAR if ( (that.getProjectionType() == (PROJECTION_NEAR )) && (getProjectionType() == (PROJECTION_NEAR | PROJECTION_TOP )) ) { if (getVertex(5) == that.getVertex(0) && getVertex(2) == that.getVertex(1)) { //setVertex(0, this.getVertex(0)); // no change //setVertex(1, this.getVertex(1)); // no change setVertex(2, that.getVertex(2)); setVertex(3, that.getVertex(3)); setVertexCount(4); setProjectionType((PROJECTION_NEAR)); return; // done } } // NEAR/BOTTOM & NEAR if ( (getProjectionType() == (PROJECTION_NEAR )) && (that.getProjectionType() == (PROJECTION_NEAR | PROJECTION_BOTTOM )) ) { if (getVertex(2) == that.getVertex(3) && getVertex(3) == that.getVertex(0)) { //setVertex(0, this.getVertex(0)); // no change //setVertex(1, this.getVertex(1)); // no change setVertex(2, that.getVertex(4)); setVertex(3, that.getVertex(5)); //setVertexCount(4); // no change //setProjectionType((PROJECTION_NEAR)); // no change } } // NEAR/BOTTOM & NEAR if ( (that.getProjectionType() == (PROJECTION_NEAR )) && (getProjectionType() == (PROJECTION_NEAR | PROJECTION_BOTTOM )) ) { if (getVertex(3) == that.getVertex(2) && getVertex(0) == that.getVertex(3)) { setVertex(0, that.getVertex(0)); setVertex(1, that.getVertex(1)); setVertex(2, getVertex(4)); setVertex(3, getVertex(5)); setVertexCount(4); setProjectionType((PROJECTION_NEAR)); return; // done } } // NEAR/RIGHT & NEAR if ( (getProjectionType() == (PROJECTION_NEAR )) && (that.getProjectionType() == (PROJECTION_NEAR | PROJECTION_RIGHT )) ) { if (getVertex(0) == that.getVertex(1) && getVertex(3) == that.getVertex(4)) { setVertex(0, that.getVertex(0)); //setVertex(1, this.getVertex(1)); // no change //setVertex(2, this.getVertex(2)); // no change setVertex(3, that.getVertex(5)); //setVertexCount(4); // no change //setProjectionType((PROJECTION_NEAR)); // no change } } // NEAR/RIGHT & NEAR if ( (that.getProjectionType() == (PROJECTION_NEAR )) && (getProjectionType() == (PROJECTION_NEAR | PROJECTION_RIGHT )) ) { if (getVertex(1) == that.getVertex(0) && getVertex(4) == that.getVertex(3)) { //setVertex(0, this.getVertex(0)); // no change setVertex(1, that.getVertex(1)); setVertex(2, that.getVertex(2)); setVertex(3, getVertex(5)); setVertexCount(4); setProjectionType((PROJECTION_NEAR)); return; // done } } // NEAR/LEFT & NEAR if ( (getProjectionType() == (PROJECTION_NEAR )) && (that.getProjectionType() == (PROJECTION_NEAR | PROJECTION_LEFT )) ) { if (getVertex(1) == that.getVertex(1) && getVertex(2) == that.getVertex(4)) { //setVertex(0, this.getVertex()); // no change setVertex(1, that.getVertex(2)); setVertex(2, that.getVertex(3)); //setVertex(3, this.getVertex(3)); // no change //setVertexCount(4); // no change //setProjectionType((PROJECTION_NEAR)); // no change return; // done } } // NEAR/LEFT & NEAR if ( (that.getProjectionType() == (PROJECTION_NEAR )) && (getProjectionType() == (PROJECTION_NEAR | PROJECTION_LEFT )) ) { if (getVertex(1) == that.getVertex(0) && getVertex(4) == that.getVertex(3)) { setVertex(0, that.getVertex(0)); setVertex(1, getVertex(2)); setVertex(2, getVertex(3)); setVertex(3, that.getVertex(3)); setVertexCount(4); setProjectionType((PROJECTION_NEAR)); return; // done } } // NEAR/RIGHT/TOP & NEAR/TOP if ( ((getProjectionType() == (PROJECTION_TOP | PROJECTION_NEAR )) && (that.getProjectionType() == (PROJECTION_TOP | PROJECTION_NEAR | PROJECTION_RIGHT ))) ) { if (getVertex(0) == that.getVertex(1) && getVertex(4) == that.getVertex(3)) { setVertex(0, that.getVertex(0)); //setVertex(1, this.getVertex(1)); // no change //setVertex(2, this.getVertex(2)); // no change //setVertex(3, this.getVertex(3)); // no change setVertex(4, that.getVertex(4)); setVertex(5, that.getVertex(5)); return; // done } } // NEAR/RIGHT/TOP & NEAR/TOP if ( ((that.getProjectionType() == (PROJECTION_TOP | PROJECTION_NEAR )) && (getProjectionType() == (PROJECTION_TOP | PROJECTION_NEAR | PROJECTION_RIGHT ))) ) { if (getVertex(1) == that.getVertex(0) && getVertex(3) == that.getVertex(4)) { //setVertex(0, this.getVertex(0)); // no change setVertex(1, that.getVertex(1)); setVertex(2, that.getVertex(2)); setVertex(3, that.getVertex(3)); //setVertex(4, this.getVertex(4)); // no change //setVertex(5, this.getVertex(5)); // no change setProjectionType((PROJECTION_TOP | PROJECTION_NEAR)); return; // done } } // NEAR/RIGHT/BOTTOM & NEAR/BOTTOM if ( ((getProjectionType() == (PROJECTION_BOTTOM | PROJECTION_NEAR )) && (that.getProjectionType() == (PROJECTION_BOTTOM | PROJECTION_NEAR | PROJECTION_RIGHT ))) ) { if (getVertex(1) == that.getVertex(2) && getVertex(5) == that.getVertex(4)) { setVertex(0, that.getVertex(0)); setVertex(1, that.getVertex(1)); //setVertex(2, this.getVertex(2)); // no change //setVertex(3, this.getVertex(3)); // no change //setVertex(4, this.getVertex(4)); // no change setVertex(5, that.getVertex(5)); return; // done } } // NEAR/RIGHT/BOTTOM & NEAR/BOTTOM if ( ((that.getProjectionType() == (PROJECTION_BOTTOM | PROJECTION_NEAR )) && (getProjectionType() == (PROJECTION_BOTTOM | PROJECTION_NEAR | PROJECTION_RIGHT ))) ) { if (getVertex(2) == that.getVertex(1) && getVertex(4) == that.getVertex(5)) { //setVertex(0, this.getVertex(0)); // no change //setVertex(1, this.getVertex(1)); // no change setVertex(2, that.getVertex(2)); setVertex(3, that.getVertex(3)); setVertex(4, that.getVertex(4)); //setVertex(5, this.getVertex(5)); // no change setProjectionType((PROJECTION_BOTTOM | PROJECTION_NEAR)); return; // done } } // NEAR/LEFT/BOTTOM & NEAR/BOTTOM if ( ((getProjectionType() == (PROJECTION_BOTTOM | PROJECTION_NEAR )) && (that.getProjectionType() == (PROJECTION_BOTTOM | PROJECTION_NEAR | PROJECTION_LEFT ))) ) { if (getVertex(2) == that.getVertex(0) && getVertex(4) == that.getVertex(4)) { //setVertex(0, this.getVertex(0)); // no change //setVertex(1, this.getVertex(1)); // no change setVertex(2, that.getVertex(1)); setVertex(3, that.getVertex(2)); setVertex(4, that.getVertex(3)); //setVertex(5, this.getVertex(5)); // no change return; // done } } // NEAR/LEFT/BOTTOM & NEAR/BOTTOM if ( ((that.getProjectionType() == (PROJECTION_BOTTOM | PROJECTION_NEAR )) && (getProjectionType() == (PROJECTION_BOTTOM | PROJECTION_NEAR | PROJECTION_LEFT ))) ) { if (getVertex(0) == that.getVertex(2) && getVertex(4) == that.getVertex(4)) { // we need to do this in an unusual order, because otherwise we'd overwrite our own values setVertex(4, getVertex(3)); setVertex(3, getVertex(2)); setVertex(2, getVertex(1)); setVertex(0, that.getVertex(0)); setVertex(1, that.getVertex(1)); setVertex(5, that.getVertex(5)); setProjectionType((PROJECTION_BOTTOM | PROJECTION_NEAR)); return; // done } } // RIGHT/NEAR/BOTTOM // RIGHT/NEAR/TOP // LEFT/NEAR/BOTTOM // LEFT/NEAR/TOP if ( (getProjectionType() == that.getProjectionType()) && ( getProjectionType() == (PROJECTION_RIGHT | PROJECTION_NEAR | PROJECTION_BOTTOM ) || getProjectionType() == (PROJECTION_RIGHT | PROJECTION_NEAR | PROJECTION_TOP ) || getProjectionType() == (PROJECTION_LEFT | PROJECTION_NEAR | PROJECTION_BOTTOM ) || getProjectionType() == (PROJECTION_LEFT | PROJECTION_NEAR | PROJECTION_TOP ) ) ) { if (getVertex(0) == that.getVertex(5) && getVertex(2) == that.getVertex(3)) { setVertex(0, that.getVertex(0)); setVertex(1, that.getVertex(1)); setVertex(2, that.getVertex(2)); //setVertex(3, this.getVertex(3)); // no change //setVertex(4, this.getVertex(4)); // no change //setVertex(5, this.getVertex(5)); // no change return; // done } if (getVertex(5) == that.getVertex(0) && getVertex(3) == that.getVertex(2)) { //setVertex(0, this.getVertex(0)); // no change //setVertex(1, this.getVertex(1)); // no change //setVertex(2, this.getVertex(2)); // no change setVertex(3, that.getVertex(3)); setVertex(4, that.getVertex(4)); setVertex(5, that.getVertex(5)); return; // done } if (getVertex(2) == that.getVertex(1) && getVertex(4) == that.getVertex(5)) { //setVertex(0, this.getVertex(0)); // no change //setVertex(1, this.getVertex(1)); // no change setVertex(2, that.getVertex(2)); setVertex(3, that.getVertex(3)); setVertex(4, that.getVertex(4)); //setVertex(5, this.getVertex(5)); // no change return; // done } if (getVertex(1) == that.getVertex(2) && getVertex(5) == that.getVertex(4)) { setVertex(0, that.getVertex(0)); setVertex(1, that.getVertex(1)); //setVertex(2, this.getVertex(2)); // no change //setVertex(3, this.getVertex(3)); // no change //setVertex(4, this.getVertex(4)); // no change setVertex(5, that.getVertex(5)); return; // done } // if this.([1],[3]) == that.([0],[4]) then create polygon: this.[0], that.[1], that.[2], that.[3], this.[4], this.[5] if (getVertex(1) == that.getVertex(0) && getVertex(3) == that.getVertex(4)) { //setVertex(0, this.getVertex(0)); // no change setVertex(1, that.getVertex(1)); setVertex(2, that.getVertex(2)); setVertex(3, that.getVertex(3)); //setVertex(4, this.getVertex(4)); // no change //setVertex(5, this.getVertex(5)); // no change return; // done } // if this.([0],[4]) == that.([1],[3]) then create polygon: that.[0], this.[1], this.[2], this.[3], that.[4], that.[5] if (getVertex(0) == that.getVertex(1) && getVertex(4) == that.getVertex(3)) { setVertex(0, that.getVertex(0)); //setVertex(1, this.getVertex(1)); // no change //setVertex(2, this.getVertex(2)); // no change //setVertex(3, this.getVertex(3)); // no change setVertex(4, that.getVertex(4)); setVertex(5, that.getVertex(5)); return; // done } } }