Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-add direct setter and getter for camera type #793

Merged
merged 1 commit into from
Jun 16, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions android/tangram/jni/jniExports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,14 @@ extern "C" {
Tangram::setPixelScale(scale);
}

JNIEXPORT void JNICALL Java_com_mapzen_tangram_MapController_nativeSetCameraType(JNIEnv* jniEnv, jobject obj, jint type) {
Tangram::setCameraType(type);
}

JNIEXPORT jint JNICALL Java_com_mapzen_tangram_MapController_nativeGetCameraType(JNIEnv* jniEnv, jobject obj) {
return Tangram::getCameraType();
}

JNIEXPORT void JNICALL Java_com_mapzen_tangram_MapController_nativeHandleTapGesture(JNIEnv* jniEnv, jobject obj, jfloat posX, jfloat posY) {
Tangram::handleTapGesture(posX, posY);
}
Expand Down
27 changes: 27 additions & 0 deletions android/tangram/src/com/mapzen/tangram/MapController.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ public enum EaseType {
SINE,
}

/**
* Options for changing the appearance of 3D geometry
*/
public enum CameraType {
PERSPECTIVE,
ISOMETRIC,
FLAT,
}

protected static EaseType DEFAULT_EASE_TYPE = EaseType.CUBIC;

/**
Expand Down Expand Up @@ -349,6 +358,22 @@ public float getTilt() {
return nativeGetTilt();
}

/**
* Set the camera type for the map view
* @param type A {@code CameraType}
*/
public void setCameraType(CameraType type) {
nativeSetCameraType(type.ordinal());
}

/**
* Get the camera type currently in use for the map view
* @return A {@code CameraType}
*/
public CameraType getCameraType() {
return CameraType.values()[nativeGetCameraType()];
}

/**
* Find the geographic coordinates corresponding to the given position on screen
* @param screenX Pixels from the left edge of the screen
Expand Down Expand Up @@ -636,6 +661,8 @@ public void applySceneUpdates() {
private synchronized native float nativeGetTilt();
private synchronized native void nativeScreenToWorldCoordinates(double[] screenCoords);
private synchronized native void nativeSetPixelScale(float scale);
private synchronized native void nativeSetCameraType(int type);
private synchronized native int nativeGetCameraType();
private synchronized native void nativeHandleTapGesture(float posX, float posY);
private synchronized native void nativeHandleDoubleTapGesture(float posX, float posY);
private synchronized native void nativeHandlePanGesture(float startX, float startY, float endX, float endY);
Expand Down
13 changes: 13 additions & 0 deletions core/src/tangram.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,19 @@ void setPixelScale(float _pixelsPerPoint) {
}
}

void setCameraType(int _type) {

m_view->setCameraType(static_cast<CameraType>(_type));
requestRender();

}

int getCameraType() {

return static_cast<int>(m_view->cameraType());

}

void addDataSource(std::shared_ptr<DataSource> _source) {
if (!m_tileManager) { return; }
std::lock_guard<std::mutex> lock(m_tilesMutex);
Expand Down
6 changes: 6 additions & 0 deletions core/src/tangram.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ void screenToWorldCoordinates(double& _x, double& _y);
// Set the ratio of hardware pixels to logical pixels (defaults to 1.0)
void setPixelScale(float _pixelsPerPoint);

// Set the camera type (0 = perspective, 1 = isometric, 2 = flat)
void setCameraType(int _type);

// Get the camera type (0 = perspective, 1 = isometric, 2 = flat)
int getCameraType();

// Add a data source for adding drawable map data, which will be styled
// according to the scene file using the provided data source name;
void addDataSource(std::shared_ptr<DataSource> _source);
Expand Down
2 changes: 2 additions & 0 deletions core/src/view/view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,11 @@ void View::setPixelScale(float _pixelsPerPoint) {
}

void View::setCameraType(CameraType _type) {

m_type = _type;
m_dirtyMatrices = true;
m_dirtyTiles = true;

}

void View::setSize(int _width, int _height) {
Expand Down