Skip to content
Snippets Groups Projects
Commit 40a82e3f authored by Maxime Graulich's avatar Maxime Graulich
Browse files

Android: add raise(Z) for PViews

parent fa62b377
No related branches found
No related tags found
No related merge requests found
......@@ -28,11 +28,11 @@
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/postpro_raizez" />
android:text="@string/postpro_raisez" />
<SeekBar
android:id="@+id/raisez"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:max="1" />
android:max="5" />
</LinearLayout>
\ No newline at end of file
......@@ -29,7 +29,7 @@ public class Gmsh implements Parcelable {
public native double getDoubleOption(String category, String name);
public native int getIntegerOption(String category, String name);
public native String[] getPView(); // get a list of PViews
public native void setPView(int position, int intervalsType,int visible,int nbIso); // Change options for a PView
public native void setPView(int position, int intervalsType,int visible,int nbIso, float raisez); // Change options for a PView
public native int onelabCB(String action); // Call onelab
/** Java CLASS **/
......
......@@ -50,7 +50,8 @@ public class MainActivity extends Activity{
actionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#64000000")));
Intent intent = getIntent();
Bundle extras = intent.getExtras();
if(intent != null && intent.getAction() != null && intent.getAction().equals(Intent.ACTION_VIEW)) {
if(savedInstanceState != null);
else if(intent != null && intent.getAction() != null && intent.getAction().equals(Intent.ACTION_VIEW)) {
String tmp = intent.getData().getPath();
_gmsh.load(tmp);
}
......@@ -81,6 +82,11 @@ public class MainActivity extends Activity{
});
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
......@@ -88,7 +94,7 @@ public class MainActivity extends Activity{
_switchFragmentMenuItem = menu.add(R.string.menu_parameters);
_switchFragmentMenuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
}
_runStopMenuItem = menu.add(R.string.menu_run);
_runStopMenuItem = menu.add((_compute)?R.string.menu_stop:R.string.menu_run);
_runStopMenuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
return true;
}
......@@ -201,6 +207,12 @@ public class MainActivity extends Activity{
_notify = false;
}
@Override
protected void onStop() {
super.onStop();
_notify = true;
}
private void notifyEndOfCompute() {
Intent intent = new Intent(this, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
......@@ -211,6 +223,7 @@ public class MainActivity extends Activity{
.setContentIntent(pendingIntent)
.setContentTitle("ONELAB")
.setDefaults(Notification.DEFAULT_ALL)
.setAutoCancel(true)
.setContentText("The compute is finished");
NotificationManager mNotificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
......
......@@ -105,7 +105,7 @@ public class OptionsDisplayFragment extends Fragment{
checkbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
_gmsh.setPView(myID, -1, (isChecked)? 1 : 0, -1);
_gmsh.setPView(myID, -1, (isChecked)? 1 : 0, -1, -1);
if(mListener != null) mListener.OnModelOptionsChanged();
}
});
......
......@@ -7,6 +7,7 @@ import android.content.Context;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
......@@ -48,11 +49,22 @@ public class OptionsPostProcessingFragment extends Fragment{
Bundle savedInstanceState) {
String[] PViews = _gmsh.getPView();
String[] infos = PViews[_pview].split("\n");
if(infos.length != 5){ Log.e("Gmsh", "Pview length is incorect"); return null;}
getActivity().getActionBar().setTitle(infos[0]);
LinearLayout layout = (LinearLayout)inflater.inflate(R.layout.fragment_postprocessing, container, false);
final Spinner intervalsType = (Spinner)layout.findViewById(R.id.intervals_type);
final EditText intervals = (EditText)layout.findViewById(R.id.intervals);
final SeekBar raiseZ = (SeekBar)layout.findViewById(R.id.raisez); // TODO
final SeekBar raiseZ = (SeekBar)layout.findViewById(R.id.raisez);
raiseZ.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
public void onStopTrackingTouch(SeekBar seekBar) {} // UNUSED Auto-generated method stub
public void onStartTrackingTouch(SeekBar seekBar) {} // UNUSED Auto-generated method stub
public void onProgressChanged(SeekBar seekBar, int progress,
boolean fromUser) {
_gmsh.setPView(_pview, -1, -1, -1, progress);
}
});
raiseZ.setProgress(Integer.parseInt(infos[4]));
intervalsType.setEnabled(infos[2].equals("1"));
ArrayList<String> choices;
ArrayAdapter<String> adapter;
......@@ -66,7 +78,7 @@ public class OptionsPostProcessingFragment extends Fragment{
intervalsType.setSelection(Integer.parseInt(infos[1])-1);
intervalsType.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
_gmsh.setPView(_pview, pos+1, -1, -1);
_gmsh.setPView(_pview, pos+1, -1, -1, -1);
//TODO glView.requestRender();
intervals.setEnabled(pos == 0 || pos == 2);
}
......@@ -98,10 +110,9 @@ public class OptionsPostProcessingFragment extends Fragment{
nIso = 1;
intervals.setText("");
}
if(nIso > 1000) {_gmsh.setPView(_pview, -1, -1, 1000); intervals.setText("1000");}
else if(nIso > 0) _gmsh.setPView(_pview, -1, -1, nIso);
else _gmsh.setPView(_pview, -1, -1, 1);
//glView.requestRender();
if(nIso > 1000) {_gmsh.setPView(_pview, -1, -1, 1000, -1); intervals.setText("1000");}
else if(nIso > 0) _gmsh.setPView(_pview, -1, -1, nIso, -1);
else _gmsh.setPView(_pview, -1, -1, 1, -1);
}
public void beforeTextChanged(CharSequence s, int start, int count, int after) {} // UNUSED Auto-generated method stub
......
......@@ -2,6 +2,7 @@ package org.geuz.onelab;
import android.app.Activity;
import android.os.Bundle;
import android.view.MenuItem;
public class PostProcessingActivity extends Activity{
@Override
......@@ -15,4 +16,11 @@ public class PostProcessingActivity extends Activity{
OptionsPostProcessingFragment optionsFragment = OptionsPostProcessingFragment.newInstance(gmsh, id);
getFragmentManager().beginTransaction().add(R.id.model_fragment, optionsFragment).commit();
}
@Override
public boolean onMenuItemSelected(int featureId, MenuItem item) {
if(item.getItemId() == android.R.id.home)
this.finish();
return super.onMenuItemSelected(featureId, item);
}
}
......@@ -90,9 +90,10 @@ class mGLSurfaceView extends GLSurfaceView {
public boolean onScroll(MotionEvent e1, MotionEvent e2,
float distanceX, float distanceY) {
if(e1.getPointerCount() > 1 || e2.getPointerCount() > 1) return false;
_renderer.translateModel(e2.getX(), e2.getY());
requestRender();
return false;
return true;
}
public void onShowPress(MotionEvent e) {
......@@ -112,7 +113,7 @@ class mGLSurfaceView extends GLSurfaceView {
scaleFactor = 1f;
_renderer.resetModelPosition();
requestRender();
return false;
return true;
}
public boolean onSingleTapConfirmed(MotionEvent e) {
// UNUSED Auto-generated method stub
......
......@@ -275,7 +275,8 @@ JNIEXPORT jobjectArray JNICALL Java_org_geuz_onelab_Gmsh_getPView
sstream << PView::list[i]->getData()->getName().c_str()
<< "\n" << PView::list[i]->getOptions()->intervalsType
<< "\n" << ((PView::list[i]->getOptions()->visible) ? 1 : 0)
<< "\n" << PView::list[i]->getOptions()->nbIso;
<< "\n" << PView::list[i]->getOptions()->nbIso
<< "\n" << PView::list[i]->getOptions()->raise[2];
jstring s = env->NewStringUTF(sstream.str().c_str());
env->SetObjectArrayElement(jPView, i, s);
env->DeleteLocalRef(s);
......@@ -284,11 +285,12 @@ JNIEXPORT jobjectArray JNICALL Java_org_geuz_onelab_Gmsh_getPView
}
JNIEXPORT void JNICALL Java_org_geuz_onelab_Gmsh_setPView
(JNIEnv *env, jobject, jint pos, jint intervalsType, jint visible, jint nIntervals)
(JNIEnv *env, jobject, jint pos, jint intervalsType, jint visible, jint nIntervals, jfloat raisez)
{
if(intervalsType > 0 && intervalsType < 4) PView::list[pos]->getOptions()->intervalsType = intervalsType;
if(visible >= 0) PView::list[pos]->getOptions()->visible = visible;
if(nIntervals > 0) PView::list[pos]->getOptions()->nbIso = nIntervals;
if(raisez>0) PView::list[pos]->getOptions()->raise[2] = raisez;
PView::list[pos]->setChanged(true);
}
......
......@@ -124,10 +124,10 @@ JNIEXPORT jobjectArray JNICALL Java_org_geuz_onelab_Gmsh_getPView
/*
* Class: org_geuz_onelab_Gmsh
* Method: setPView
* Signature: (IIII)V
* Signature: (IIIIF)V
*/
JNIEXPORT void JNICALL Java_org_geuz_onelab_Gmsh_setPView
(JNIEnv *, jobject, jint, jint, jint, jint);
(JNIEnv *, jobject, jint, jint, jint, jint, jfloat);
/*
* Class: org_geuz_onelab_Gmsh
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment