ThreeB 1.1
|
3B User interface for the Java plugin. More...
Public Member Functions | |
JNIUserInterface (JNIEnv *env_, jobject jthis) | |
virtual void | per_spot (int iteration, int pass, int spot_num, int total_spots) |
virtual void | per_modification (int iteration, int spot_num, int total_spots) |
virtual void | per_pass (int, int, const std::vector< TooN::Vector< 4 > > &spots) |
virtual void | perhaps_stop () |
void | send_message (const string &s) |
void | fatal (const string &s) |
Private Attributes | |
JNIEnv * | env |
jobject | ThreeBRunner_this |
jmethodID | send_message_string |
jmethodID | die |
jmethodID | should_stop |
jmethodID | send_new_points |
int | passes |
3B User interface for the Java plugin.
This particular UI ferries various messages between Java and C++ via callbacks and polling.
Definition at line 33 of file multispot5_jni.cc.
JNIUserInterface::JNIUserInterface | ( | JNIEnv * | env_, |
jobject | jthis | ||
) | [inline] |
Definition at line 45 of file multispot5_jni.cc.
:env(env_),ThreeBRunner_this(jthis) { jclass cls = env->GetObjectClass(jthis); send_message_string = env->GetMethodID(cls, "send_message_string", "(Ljava/lang/String;)V"); die = env->GetMethodID(cls, "die", "(Ljava/lang/String;)V"); should_stop = env->GetMethodID(cls, "should_stop", "()Z"); send_new_points = env->GetMethodID(cls, "send_new_points", "([F)V"); passes = GV3::get<int>("main.passes"); }
virtual void JNIUserInterface::per_spot | ( | int | iteration, |
int | pass, | ||
int | spot_num, | ||
int | total_spots | ||
) | [inline, virtual] |
This function is called once per spot in each pass.
The idea is to provide a display along the lines of: Iteration #1 optimizing #2% complete
iteration | Iteration number |
pass | Pass number |
spot_num | Spot currently being optimized |
total_spots | Total number of spots to be optimized |
Implements UserInterfaceCallback.
Definition at line 61 of file multispot5_jni.cc.
{ send_message(sPrintf("Iteration %i, optimizing %4i%%", iteration*passes+pass, 100 *spot_num / total_spots)); }
virtual void JNIUserInterface::per_modification | ( | int | iteration, |
int | spot_num, | ||
int | total_spots | ||
) | [inline, virtual] |
This function is called once per spot in the modification phase.
The idea is to provide a display along the lines of: Iteration #1 modifying #2% complete
iteration | Iteration number |
spot_num | Spot currently being optimized |
total_spots | Total number of spots to be optimized |
Implements UserInterfaceCallback.
Definition at line 66 of file multispot5_jni.cc.
{ send_message(sPrintf("Iteration %i, modifying %4i%%", iteration*passes+passes-1, 100 *spot_num / total_spots)); }
virtual void JNIUserInterface::per_pass | ( | int | iteration, |
int | pass, | ||
const std::vector< TooN::Vector< 4 > > & | spots | ||
) | [inline, virtual] |
This function is called once each time PASS data is outputted.
It will allow the GUI to build up a reconstruction.
iteration | Iteration number |
pass | Pass number |
spots | Data to be reconstructed |
Implements UserInterfaceCallback.
Definition at line 71 of file multispot5_jni.cc.
{ //Copy data into the correct format vector<jfloat> pts_data; for(unsigned int i=0; i < spots.size(); i++) { pts_data.push_back(spots[i][2]); pts_data.push_back(spots[i][3]); } //Allocate a java array and copy data into it jfloatArray pts = env->NewFloatArray(pts_data.size()); env->SetFloatArrayRegion(pts, 0, pts_data.size(), pts_data.data()); //Make the call... jvalue pts_obj; pts_obj.l = pts; env->CallVoidMethod(ThreeBRunner_this, send_new_points, pts_obj); //Free the object env->DeleteLocalRef(pts); }
virtual void JNIUserInterface::perhaps_stop | ( | ) | [inline, virtual] |
The user wishes to issue a stop instruction to the program (perhaps done via an asynchronus call to an instance of of UserInterfaceCallback).
This function is called as often as possible and will throw UserIssuedStop when the condition is met.
Implements UserInterfaceCallback.
Definition at line 95 of file multispot5_jni.cc.
{ bool stop = env->CallBooleanMethod(ThreeBRunner_this, should_stop); if(stop) throw UserIssuedStop(); }
void JNIUserInterface::send_message | ( | const string & | s | ) | [inline] |
Definition at line 103 of file multispot5_jni.cc.
Referenced by Java_ThreeBRunner_call().
{ jvalue message_string; message_string.l = env->NewStringUTF(s.c_str()); env->CallVoidMethod(ThreeBRunner_this, send_message_string, message_string); env->DeleteLocalRef(message_string.l); }
void JNIUserInterface::fatal | ( | const string & | s | ) | [inline] |
Definition at line 111 of file multispot5_jni.cc.
Referenced by Java_ThreeBRunner_call().
{ jvalue message_string; message_string.l = env->NewStringUTF(s.c_str()); env->CallVoidMethod(ThreeBRunner_this, die, message_string); env->DeleteLocalRef(message_string.l); }
JNIEnv* JNIUserInterface::env [private] |
Definition at line 36 of file multispot5_jni.cc.
jobject JNIUserInterface::ThreeBRunner_this [private] |
Definition at line 37 of file multispot5_jni.cc.
jmethodID JNIUserInterface::send_message_string [private] |
Definition at line 38 of file multispot5_jni.cc.
jmethodID JNIUserInterface::die [private] |
Definition at line 39 of file multispot5_jni.cc.
jmethodID JNIUserInterface::should_stop [private] |
Definition at line 40 of file multispot5_jni.cc.
jmethodID JNIUserInterface::send_new_points [private] |
Definition at line 41 of file multispot5_jni.cc.
int JNIUserInterface::passes [private] |
Definition at line 42 of file multispot5_jni.cc.