aAVis
Processing Based Visualsation Tool
Navigate/Search

Archive for the 'GUI' Category

Presets, and Array Questions

Tuesday, October 2nd, 2007

A quick status update for all of you listening out there.

I’ve now created a simple load/save preset system. It’s not pretty, but it works perfectly! ( wish I could say the same for that bloody remove option…More on that later )

I’m using simple .txt file exporting and importing to do the preset saving/loading. When the ’save’ button is pressed, all the current elements are saved into a ‘.aav’ file, Which is simply a sneaky .txt file in disguise. for example :

0*default sphere*72.0*300.0*0.0*100.0
1*default cube*400.0*300.0*0.0*100.0
0*default sphere*720.0*300.0*0.0*100.0

This preset file will created 3 objects. Two Spheres, and a Cube ( oh yeah, I added cubes ). It’s fairly simple, each value is separated by a *, and each new line is a new element. The object “type” is dictated by the number at the front of the line. 0 for sphere, 1 for cube, etc. This text file is imported back into the program, the current element list is cleared ( though, in the final version I hope for a fadeout, but for now, it just vanishes like my social life while completing this assignment ), and is replaced by our new friends there.

So that’s rad.
Now I need some help.

I’ve been puzzling over this stupid remove function all day, and just when I think I’ve got it working again, I manage to break it. It wouldn’t be so complicated, however the GUI library I’m using is still in the early stages of development ( especially with the MultiList system I’m using ) and so it’s still missing some things ( such as items that remove properly … ). This is how my remove system works :

REMOVE BUTTON IS SELECTED.
REMOVE BUTTON TEXT IS CHANGED TO -REMOVED-
ELEMENT CORRESPONDING TO REMOVE BUTTON IS REMOVED

Seems simple enough. And it is for the *first* item. However I’m storing the elements in an ArrayList, which means if I remove one, the rest cascade through the list and fill in the spots, which means I have to keep an array which holds the relative button positions for the elements place in the elements ArrayList.

Confused yet ? So Am I.
SO

ArrayList elements = new ArrayList();
int[] currentElementPos;

and the remove code :

// set "edit" label to "-removed-"
gui.controller(Integer.toString(theEvent.controller().id()+1000)).setLabel("-removed-");


// set "removed" label to "-removed-"
gui.controller(Integer.toString(theEvent.controller().id())).setLabel("-removed-");


// remove item
elements.remove(currentElementPos[theEvent.controller().id()-1000]);


for (int i=theEvent.controller().id()-1000;i<=elements.size();i++){
currentElementPos[i]=currentElementPos[i]-1;
}

Yes, there are some magic numbers there, and that’s where the GUI Issues come in to play. Each button is assigned an ID number. the ‘remove’ buttons I’ve assigned incremental ID’s from 1000 upwards. ( to 2000, so don’t add more than 1000 elements :P ). so “theEvent.controller().id()” is the ID of the button that was pressed. so, 1000 would be the first element created, hence 1000-1000 = 0. Which means it is element 0. However, once I delete element 0, element 1 should now be element 0, element 2 should be element 1 etc. That’s what the for loop *should* do. But it’s … not. Maybe with a fresh mind in the morning I can work this out, but right now - I’ve tried 4 different solutions, each one works for a bit, then falls apart.

Any Ideas ? Even if it’s not in java, psuedocode is fine.

Thanks
- Anthony

GUI version 8

Friday, September 28th, 2007

You can tell you’ve been working on something for a while when you *finally* figure it out, it’s like the world is a happier and more amazing place with furry little animals singing songs to eachother about mountain streams and … pez.

I *finally* figured out the annoying parts of my GUI today ( woo yeah! go me ! ). No, it’s not perfect, but it’s definitely the best it’s ever been, so I thought I’d show it off. Now, it is very simple at the moment, and it still has quite a few bugs in it. But I’ve had to sacrifice ease of use, just so I can get it finished. I’ll fix the problems later. So this is it :

addsphere.JPG

Currently you can only add spheres, so you’ll have to be content with that. It also takes quite a while to load, but just be patient. Now there are certain “rules” you’ve got to follow, or you’re going to break it. So this is what you can and can’t do.

1) Hover over Add -> Click Sphere

2) You’ll see a tab appear at the top of the screen saying “sphere”. Click that tab. DO NOT add another shape, you will break it. You can add more LATER

addsphere02.JPG

 

3) You’ll now see the “create/edit sphere” menu. Change what values you want, give the sphere a name, change the x,y,z and diameter, and when you’re done, press “save_sphere”. HOWEVER, remember the position of the ‘default’ tab at the top of the screen. As when you select ’sphere’, they will both vanish. Click in the area where the “default” tab was before, and the original menu will display itself once more. No, I don’t know why this happens - it’s something I’m still yet to figure out.

addsphere03.JPG

And that’s my GUI so far. From there you can Edit or Remove spheres. Remember, only one Sphere tab at a time. I will eventually change this, so that it makes a new tab for each sphere, but for now, this is how it will be! So enjoy.  Here is the link to the applet :

aAVis GUIPrototypev8 Applet

Thanks to Andrew Dekker, the Processing Forums, Wonko and Sojamo ( Creator of the GUI Library I’m using ) for their patience.  Thanks!

GUI’s and OpenGL

Monday, September 3rd, 2007

First things first, thought I’d just mention the latest update to my blog, on the right hand side you can now see a list of what needs to be done in order to complete my prototype. Highlighted in green are the elements that are complete, highlighted in orange are the elements I’m currently working on. So you can keep track of my progress. And this leads in to my current problem.

In processing there are two options for GUI’s ( Graphical User Interfaces ).

1) Use a GUI Library
2) Code it all yourself from scratch

Option 2 would take a *long* time, so this leaves option 1. However, even option 1 has problems. Processing has 4 GUI Libraries ( that I am aware of ).
- controlP5
- MyGUI
- Interfascia
- SpringGUI
They all work fine by themselves. However add P3D or OpenGL, and they tend to break. MyGUI and Interfascia seem to die all together. SpringGUI works with P3D but not OpenGL, and controlP5 works with openGL, however the 3D elements always draw on TOP of the GUI. I tried running the GUI elements in a separate window, however that caused issues, and it seems to only work part of the time.

I have heard rumors of a way of re-coding MyGUI to work in conjunction with OpenGL, but I am not 100% sure of its authenticity ( or on the re-compiling process, I’d have to brush up on that ).

So I’ve gone to the processing forums for support, I’m hoping someone there can offer a suitable solution - Until then, I’m sort of forced to put everything on hold - so hopefully I’ll get a solution before then.

Processing Forum Thread

If I can’t get a solution, I will have to work out a possible solution. Even if this means ensuring no 3D elements move closer than 0 on the Z axis, and drawing all the GUI elements on that point. This will mess up perspective, but it may be the only compromise open to me.

- Anthony