Graphics properties implementation
Shai Ayal
shaiay at gmail.com
Thu Jan 17 13:55:41 CST 2008
On Jan 17, 2008 6:00 PM, Michael Goffioul <michael.goffioul at gmail.com> wrote:
> On 1/14/08, Kai Habel <kai.habel at gmx.de> 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?
This is similar to the postset checks I suggested. Maybe we should
make it more generic and add a preset & postset functions which would
be called from set (with the "v" modifier):
void set_faces (const octave_value& v)
{
if (! error_state)
{
preset ("faces", v);
if (! error_state)
{
faces = v;
postset ("faces");
mark_modified ();
}
}
}
this allows for further checks of the input before setting the value
-- I'm sure it will come in handy sometime ...
Shai
More information about the Octave-maintainers
mailing list