best way to input lines of text

Ideally, I would like to have a separate window where the user can input a line of text which will then be parsed and acted on in a plugin function. I am familiar with the plugin portion but I don't know the best way to receive the text input. Any suggestions would be welcome.

P.S. I think that Interface Builder would probably do the trick under OS X but I need this to work under Linux as well.

see below

see below

Thanks Join for sharing this

Thanks Join for sharing this code. Have you got any IT certification?

+ to iterate:
command = myPluginGetCommand();

if command != "": {
# do something with command
}

One again thanks for this useful code.

best way to input lines of text

Aside from the Interface Builder approach which currently works only on OS X, there is no built-in way to do this. It is something I'm working on adding though.

However, if you're already writing a plugin to do some sort of processing of the information, then you could also have the plugin function pop up a dialog box yourself.

- jon

best way to input lines of text

Thanks for the quick reply.

I was looking into using wxWidgets to pop up a window from within my plugin function but I'm not sure how this would work. wxWidgets apps seem to have their own main() function defined through a macro so the situation is not exactly like the Breve sample plugins, which are only classes with no main(). I haven't tried it but maybe a simple widget instantiation (ie. without a main()) within my plugin function will work...I'll give it a go.

Jeff

best way to input lines of text

I'm not familiar with writing plugins, nor have I checked the code, but could you modify the existing code for the Yes/No dialog box so that it can retrieve strings?

best way to input lines of text

Well, I tried to create an instance of a wxWidget window within my plugin and everything compiled ok and I now have a library for my plugin. However, when running breveIDE and loading the associated steve file to load my plugin, breve crashes with the following error:

Fatal Error: Mismatch between the program and library build versions detected.
The library used 2.5.4 (no debug,ANSI,compiler with C++ ABI 1002,wx containers,compatible with 2.4),
and wxCore used 2.6 (no debug,ANSI,compiler with C++ ABI 1002,wx containers,compatible with 2.4).
Aborted

Does this mean that the version of breve was compiled with wxWidgets 2.5.4? The current version of wxWidgets that I have installed is 2.6.3. If this is indeed the problem, is my only option to recompile breve with wxWidgets 2.6.3?

MotoZarkov:
I will look into your suggestion if my current approach doesn't work...I think, however, it would be more complicated as it would involve compiling breve from source.

Thanks,
Jeff.

best way to input lines of text

Jeff wrote:Well, I tried to create an instance of a wxWidget window within my plugin and everything compiled ok and I now have a library for my plugin. However, when running breveIDE and loading the associated steve file to load my plugin, breve crashes with the following error:

Fatal Error: Mismatch between the program and library build versions detected.
The library used 2.5.4 (no debug,ANSI,compiler with C++ ABI 1002,wx containers,compatible with 2.4),
and wxCore used 2.6 (no debug,ANSI,compiler with C++ ABI 1002,wx containers,compatible with 2.4).
Aborted

Does this mean that the version of breve was compiled with wxWidgets 2.5.4? The current version of wxWidgets that I have installed is 2.6.3. If this is indeed the problem, is my only option to recompile breve with wxWidgets 2.6.3?

Hmm... I'm not entirely sure on this, but I think if you use the 2.5.4 headers to compile your plugin, it should work fine. If I'm not mistaken, on Linux there should be no need to actually "link" the plugin against the Wx libraries -- the fact that the symbols are defined in breve should do the trick.

- jon

best way to input lines of text

Still stuck on this one. I have created a very simple plugin based on the sample code provided with breve. In it I have 2 classes that inherit from wxWidget classes. This compiles fine and the plugin loads within breve without any errors, but only when I don't actually use the classes, ie. when I don't create an instance of a wx based class such as:

wxFrame *wf = new wxWindowFrame(wxT("Hello World") );

If I include the line above then the breve log window displays the following:

error loading plugin plugins/samples/wxSample_plugin.o: plugins/samples/wxSample_plugin.o: undefined symbol: _ZN13wxWindowFrameC1ERK8wxString

It seems that the plugin is not able to resolve the sybols relating to wx, but Jon, you mention that you think the plugin does not need to be linked against the wx library. Well I tried linking against the wx library anyway but I still get the same result. (Being relatively new to wxWidgets I hope that this was done correctly by using wx-config --libs to locate the necessary libraries.)

If I list the libraries required by breveIDE (using the ldd command) I don't see anything relating to libwx..... there are some references to libgtk and libgdk which wxWidgets uses but no libwx. Is this normal? Or does this version of breveIDE not use wxWidgets? (I downloaded it from the breve web site but it doesn't say anywhere if wxWidgets was used to build the binary)
[/code]

best way to input lines of text

Sorry that you're continuing to have trouble.

Here's you'll find a build of breve compiled with wx 2.6:

http://www.spiderland.org/breve_2.5d/

Hope this solves the problem!

- jon

best way to input lines of text

Thanks jon!

I managed to get something working although it is not ideal. I can pop up a wx window now but I can't create my own classes that derive from any wxWidgets classes (otherwise I get undefined symbol errors as before). So that limits me to only using wxWidgets classes for now. If I can receive input events without having to create my own classes then I can live with this. I will post a followup with the results for anyone interested.

Thanks for your help
jeff

Sending events to breve from a plugin

I posted this in the wrong spot before...so here it is again.

I need some help with one more question (I hope!)

Now that I have a text input window, I am parsing the text within the plugin and I would like to then send the new information back to breve so that the running simulation can be altered in some way that the user has specified.

My question is how can the breve simulation that is running receive events from a plugin? I found some vague references to methods like brMethodCall but I don't quite understand how to use it to change values within a steve file. Or is there another way?

brMethodCall is one way...

brMethodCall should do what you need -- or better yet, the related function brMethodCallByNameWithArgs. brMethodCallByNameWithArgs is probably the easiest function to use to execute a breveMethod. Since the interface is probably running in another thread though, you might have to pay attention to thread safety issues. These are not well documented in breve right now, but use the functions brEngineLock() and brEngineUnlock(). Let me know if you go down this route and end up running into those problems.

Another way is to "poll" the plugin every iteration, for example:


+ to iterate:
command = myPluginGetCommand();

if command != "": {
# do something with command
}

The job of myPluginGetCommand is to retrieve the latest user input, and probably to clear that input so that the command does not get executed next iteration.

- jon

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.