//! The set model callback
void Menu::setModel(Gui::GuiElement* elem){
  Dialog* dia = dynamic_cast<Dialog*>(elem->getParent());
  ListBox* lb = dynamic_cast<ListBox*>(dia->getElement(0));
  int sel = lb->selected();
  if (sel >= 0){
    Graphic::instance()->addModel(sel);
  }
}
//! the assign texture dialog handler
void Menu::assignTextureDialog(Gui::GuiElement* elem){
  //current model needed
  Model* mdl = Graphic::instance()->getCurrModel();
  if (!mdl)
    return;
  //get the chosen texture
  Texture* tex = NULL;
  Dialog* dia = dynamic_cast<Dialog*>(elem->getParent());
  ListBox* lb = dynamic_cast<ListBox*>(dia->getElement(0));
  int sel = lb->selected();
  if (sel >= 0){
    tex = Graphic::instance()->getScene().getTextures()[sel];
  }
  if (!tex)
    return;
  //get the texture stage
  DropDownButton* dd = dynamic_cast<DropDownButton*>(dia->getElement(1));
  int stage = dd->getSelection();
  //assign the texture
  mdl->assignTexture(tex,stage);
}