ThreeB 1.1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Hierarchy
- Class Members

Public Member Functions | Private Attributes
JNIUserInterface Class Reference
Classes related to the ImageJ Plugin

3B User interface for the Java plugin. More...

Inheritance diagram for JNIUserInterface:

List of all members.

## 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

## Detailed Description

3B User interface for the Java plugin.

This particular UI ferries various messages between Java and C++ via callbacks and polling.

Definition at line 52 of file multispot5_jni.cc.

## Constructor & Destructor Documentation

JNIUserInterface::JNIUserInterface | ( | JNIEnv * | env_,
|  | jobject | jthis
| ) |  | `[inline]`

Definition at line 64 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");
            }

## Member Function Documentation

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

Parameters:

  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 80 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

Parameters:

  iteration | Iteration number
  spot_num | Spot currently being optimized
  total_spots | Total number of spots to be optimized

Implements UserInterfaceCallback.

Definition at line 85 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.

Parameters:

  iteration | Iteration number
  pass | Pass number
  spots | Data to be reconstructed

Implements UserInterfaceCallback.

Definition at line 90 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 114 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 122 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 130 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);
            }

## Member Data Documentation

JNIEnv* JNIUserInterface::env`[private]`

Definition at line 55 of file multispot5_jni.cc.

jobject JNIUserInterface::ThreeBRunner_this`[private]`

Definition at line 56 of file multispot5_jni.cc.

jmethodID JNIUserInterface::send_message_string`[private]`

Definition at line 57 of file multispot5_jni.cc.

jmethodID JNIUserInterface::die`[private]`

Definition at line 58 of file multispot5_jni.cc.

jmethodID JNIUserInterface::should_stop`[private]`

Definition at line 59 of file multispot5_jni.cc.

jmethodID JNIUserInterface::send_new_points`[private]`

Definition at line 60 of file multispot5_jni.cc.

int JNIUserInterface::passes`[private]`

Definition at line 61 of file multispot5_jni.cc.

The documentation for this class was generated from the following file:

- multispot5_jni.cc