From: Gehua Y. <ya...@rp...> - 2005-01-20 22:40:56
|
I am going to design the gui to display some sophisticated geometric structures(2D). Because some may overlap on top of each other, my idea is to display a simplified & smaller version of all the geometric objects. Once one is selected/highlighted, it will switch to display full details. According to my understanding of VGUI, I have two candidate ways to implement this idea: 1. Simple soview classes, but a powerful tableau that expands the functionality of vgui_easy2D_tableau. This new tableau will insert/delete the detailed soview objects when objects are selected/deselected, respectively. 2. Powerful soview2D object that knows when to display a sketch and when to display full details. No1. looks quite expensive. I am more inclined to choose No.2. However, to implement No.2, a soview object must know its status, i.e. selected/deselected. In the following functions, it looks like such mechanism already exists. But the notify() function is not virtual, and it is defined in base class (vgui_soview). Currently all this function does is to broadcast the message to ALL observers. The code looks ported from TargetJr. Does anyone has experience with this code? Or any suggestion of how to solve this problem? Thanks. Gehua // =========================================== bool vgui_displaybase_tableau::select(unsigned id) { vcl_vector<unsigned>::iterator result = vcl_find(selections.begin(), selections.end(), id); if (result == selections.end()) { // add selection to vcl_list selections.push_back(id); // notify so's observers vgui_soview* so = vgui_soview::id_to_object(id); if ( so->get_selectable()) { vgui_message msg; //msg.text = "soview select"; msg.user = (void const*) &vgui_soview::msg_select; so->notify(msg); if (cb_) cb_->select(id); } } return true; } // =========================================== void vgui_soview::notify(vgui_message const &msg) const { vcl_vector<vgui_observer*> vobs; get_observers(vobs); for (unsigned i=0; i<vobs.size(); ++i) vobs[i]->update(msg); } |