ok, for documentation purposes I'm going to describe the high level interface code.
this code is all that is needed for a minimal chunk level editor, it has no repetition of code anywhere in the work flow. other than the repetition of adding the specific controls and getting setting data from them, the primitive editors do a lot of work for you.
this is a minimal editor panel
#pragma once
#include"model_editor_ctrl.h"
#include"array_ctrl.h"
#include"primitive_ctrl.h"
#include"pcs_file.h"
class ACEN_ctrl
:public editor_ctrl<vector3d>
{
vector_ctrl*auto_center;
public:
ACEN_ctrl(wxWindow*parent)
:editor_ctrl<vector3d>(parent, "Auto-Center")
{
//add controls
add_control(auto_center=new vector_ctrl(this,0,0,60,40,"Point"),0,wxEXPAND );
}
//do nothing, needed so the base destructor will get called
virtual~ACEN_ctrl(){}
//set's the control's value
void set_value(const vector3d&t){
data=t;
auto_center->set_value(t);
}
//return's the control's value
vector3d get_value(){
return auto_center->get_value();
}
//populates the control with data from the model
void set_data(PCS_Model &model){
set_value(model.GetAutoCenter());
}
//applies the data in the control to the model
void apply_data(PCS_Model &model){
model.SetAutoCenter(get_value());
}
};
for each control there are six (minimum, you can overide preset behaviours to get diferent sizer behaviour) steps
1) make a derived class from editor_ctrl<chunk_type> with a pointer to a class derived from editor<member_type> for each member
2) in the constructor instantiate the controls with 'new' providing there minimum size, and the member title, be sure to use the add_control function on the resultant control so the control adds it to the proper sizers (the sown additional parameters ensure the normal resizeing behaviour). if you want to make a sub sizer use the function add_sizer on the top level sizer of a group of controls, this is usualy only needed if you want two controls on the same row.
3)override the set_value function, mostly this involves finding the member of the passed structure and calling the related control's set value function
4)override the get_value function, you need to build a structure from the data in the control and return it, this mostly consists of calling the get_value function of the editors in the control
5)override the set_data function, sets the editor's data, this is usually little more than getting the structure representing the chunk from the model or making one, then calling set_value with it.
6)override the apply_data function, applys the value in the editor to the model, usualy little more than calling the appropriate SetData function in the model with get_value() as the parameter.
setting the editor will be little more than
control_panel = new model_editor_ctrl<vector3d, ACEN_ctrl>(control_pane, model)
model_editor_ctrl is a template that has the scroll window functionality and a common interface for setting and getting data.
note ACEN isn't the perfict example cause it is just one simple data type.
with this I should be able to build the whole inter face in a day or two, but it might be untill this weekend untill I get the time to actually do this. though I'll try to get at least two done tonight.
then I'll be able to get the tree working.
now unfortunately this requiers more direct access to the data elements of the model, but I implemented simple accessors for it so if there are any tricks it can be handeled there.