PDA

View Full Version : I just don't get - total lack of general understanding...


eightyf
02-02-2007, 01:16 AM
If I handle a variable from a non-modal dialog to a user area, how can I work with this variable in the other methods of the userarea class.
In this special case, I have a user area which draws a spline path control. The variable which needs to be passed on are the 5 knots of the spline graph.
They are stored as vectors in an array, this array can be accesed in the main Userare method... but in no other method. The only way I found was to declare the variable globally, but then I cannot use more than one userare.
If declaration is placed in public, the passed on variable is not known in all other methods, same - of course - when I declare the variable in private....
Any ideas, where my mistake is?

Thank you for your help,
André

Per-Anders
02-02-2007, 01:54 AM
I think that perhaps you're not understand the wy that object oriented programming works.

If you have access to an object, then you have access to it's children, including any variables in there (provided they're "public"). e.g. "myobject" has a variable "x", so i can access it with myobject->x (or myobject.x depending on the language syntax). A user area is also an object, and the dialog itself is also an object so you can access data from outside directly with dialog->userarea->x for instance. You can also make a special function in your user area for retrieving it's data, like function Retrieve() { return x; }, then in the parent object call "var myx = myobject->Retrieve();".

Now the thing is with many objects there's a two way link, for instance user areas have a link to their dialog usually in the protected variable "dlg" (not sure if this applies to COFFEE though), and the "SendParentMessage" routine, which as the name uggests allows you to send a message upwards. Typically when dealing with non modal dialogs you actually have your functinoality happening in the dialog code itself, so if it's modifying objects in a scene the code for doing that isn't elsewhere, but is in the dialogs own code. Now if you do want to communicate elsewhere then what you normally do is use the "Message" system and CoreMessage or SpecialEventAdd routines.

Anyhow, hopefully that should answer your questions (and allow you to get on with doing what you need to do).

eightyf
02-02-2007, 02:29 PM
Thank you for your prompt response.
I think that perhaps you're not understand the wy that object oriented programming works.
You don't know how right you are ;-)
No, seriously, there seems to be some really bad misunderstanding between me and Coffee.
I tried to apply your suggestions to my code, but it somehow didn't work.
Maybe it helps if I explain the situation.
I have a plugin that animates text. For that I started with an expressiontagplugin and - besides some sever crashes - everything was just fine. Since I wanted to implement a non-modal dialog, I decided to solve this with another, a second menu plugin.
The menu plugin checks, if a textobject with an expressionplugintag attached is active. If so, the menu plugin retrieves the animation data from the expressions basecontainer.
The changes in the dialog are then stored back to the expression, where the actual animation takes place.
Currently I am trying to implement a spline graph path control. This worked just fine - as long as the data is not stored anywhere. What I did was this:
The spline graph's control points (up to five) are stored as single vectors in the expressions basecontainer. If you select the textobject, the menuplugin reads out those control points (knots), transform then into an array and passes this to the UserArea of the class DrawSpline.
The Class DrawSpline is built like this:
class DrawSpline:GeUserArea
private:
//some helpvariables etc.)
public:
DrawSpline(id,dialog,splineknots); //splineknots is the array from dialog
Init();
SortKnots(dragged); //those are some methods that deal
DeleteKnots(deleted); // with the actual handling of the Graph
PaintGraph() // this is the method that actually paints the bezier spline curve

What I need access to is the array splineknots, which I can only read in the method DrawSpline(id,dialog,splineknots).
Unfortunately, for a Redraw the method Init() is called from within the dialog. When executing, it works with the "old" splineknots and there is no chance for me to tell him the new values of splineknots.
Any idea, what I mean, or how I can solve this problem?
If the solution was in your previous posting I am sorry, since I thoroughly read it and tried all the alternatives suggested.
Thank you very much
André

CGTalk Moderation
02-02-2007, 02:29 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.