octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Graphics properties implementation


From: John W. Eaton
Subject: Re: Graphics properties implementation
Date: Thu, 17 Jan 2008 15:03:55 -0500

On 17-Jan-2008, Michael Goffioul wrote:

| On 1/14/08, Kai Habel <address@hidden> wrote:
| > Hello Michael,
| >
| > yes I will look into the additional method needed, but it will take some
| > time. After a first look into the respective jhandles file [1] it seems
| > straightforward to translate the methods for face/vertex <-->  X/Y/Z
| > conversion and normals computation into C++.
| >
| > I assume these functions should be called (if needed) from a not yet
| > existing validate method as well.
| 
| Indeed, that's a possible solution. Actually, IMO there's a need for a
| built-in self-listener mechanism in the properties classes (the one
| derived from base_properties); this mechanism would be responsible
| for calling the appropriate update function. In practice, I mean something
| like the following (I just included the relevant code):
| 
| class base_properties
| {
| public:
|   virtual void validate (const std::string& pname) { }
| };
| 
| class patch
| {
| public:
|   class properties : public base_properties
|   {
|   public:
|     void update_xyz_data (void);
|     void validate (const std::string& pname)
|     {
|       if (pname == "faces" || pname == "vertices")
|         update_xyz ();
|     }
| 
|     BEGIN_PROPERTIES(patch)
|       array_property faces v , Matrix ()
|     END_PROPERTIES
|   };
| };
| 
| The 'v' modifier would expand set_faces as
| 
| void set_faces (const octave_value& v)
| {
|   if (! error_state)
|   {
|     faces = v;
|     validate ("faces");
|     mark_modified ();
|   }
| }
| 
| This should fit pretty easy in the code generation. Shai, John: comments?

So there would be a single validate function that switches on the
property name?  That seems odd to me.  Why not individual functions
like validate_faces (inserted automatically if the v qualifier is
present)?  Then you would have to provide the validate_faces function
by hand.  Or, just provide the set_faces function by hand so that it
can do the work directly.  Or is the problem with that approach that
this kind of thing is needed for many properties?

Is validate the right name?  Maybe "update_dependent_properites" (or
something similar)?

jwe


reply via email to

[Prev in Thread] Current Thread [Next in Thread]