⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 v4commandpanel.cpp

📁 一个用于智能手机的多媒体库适合S60 WinCE的跨平台开发库
💻 CPP
📖 第 1 页 / 共 2 页
字号:
          succeed = true;          break;        }      }            break;    }    case GF_SG_NODE_INSERT: {      break;    }    case GF_SG_NODE_DELETE: {      break;    }  }  if (!succeed) {    gf_sg_command_del(c);    return;  }  V4SceneManager * sm = parent->GetV4SceneManager();  // The command is created, now searching for an AU to put it in  GF_StreamContext * ctx = sm->GetBifsStream();  u32 count = gf_list_count (ctx->AUs);  GF_AUContext * au = NULL;  for (u32 i = 0; i < count; i++) {     au = (GF_AUContext *) gf_list_get(ctx->AUs, i);     // V4Studio only uses timing     // TODO : FPS is defined in V4SceneGraph.h, should change and become a property somewhere     // TODO : units is a constant     if ( au->timing == sm->GetUnits() / sm->GetFrameRate() * frame ) break;     au = NULL;  }  // creates new AU at the right time if none found  if (!au) au = gf_sm_stream_au_new(ctx, sm->GetUnits() / sm->GetFrameRate() * frame, 0, false);  // adds command to AU and to the cell  gf_list_add(au->commands, (void *) c);  parent->GetTimeLine()->AddCommand(c);  //gf_sg_command_apply(parent->GetV4Scene()->GetSceneGraph(), c, 0);/*  // checks whether there is already a command for this object  GF_List * chain = parent->timeLine->GetCommands();  // if we can fuse the two commands together, we do it  if (gf_list_count(chain) > 0) {    GF_Command * old;    old = (GF_Command *) gf_list_get(chain, gf_list_count(chain) - 1);    if ( (old->tag =   }*/}/************************//*       Refresh        *//************************/// refresh -- refresh the node and the command combo boxesvoid V4CommandPanel::Refresh(u32 frame_) {  frame = frame_;  // update the GUI  // cmbCommands updates in turns cmbNodes and/or cmbFields  RefreshCommands();  // update the list of the existing command for the cell currently selected  RefreshListCommands();}//  RefreshListCommands --void V4CommandPanel::RefreshListCommands() {  // retrieves pointer to the node  GF_Node * node = GetCurrentNode();  if (!node) return;  cmbListCommands.Clear();  GF_Command * c;  int i=0;  while ( c = parent->GetTimeLine()->GetCommand(i) ) {    cmbListCommands.Append(wxString(cmdNames[c->tag]), (void *) i);    i++;  }}// RefreshCommands -- lists the available commands for the selected nodevoid V4CommandPanel::RefreshCommands() {  // retrieves pointer to the node  GF_Node * node = GetCurrentNode();  if (!node) return;  u32 oldSel = cmbCommands.GetSelection();  // deletes all items from the combo box  cmbCommands.Clear();  // Prints the different possible commands, associates them with their id  for (int i=0; i<sizeof(cmdNames)/sizeof(wxString); i++) {    if ( cmdNames[i].CompareTo(wxT("")) )       if (IsCommandValidForNode(i, node)) cmbCommands.Append(cmdNames[i], (void *)i);  }  // updates other controls by signaling a new selection on the command combo box  cmbCommands.SetSelection(oldSel);  OnCommandCombo(wxCommandEvent());}// RefreshNodes -- lists the available nodes for the given actionvoid V4CommandPanel::RefreshNodes() {  // retrieves pointer to the node  GF_Node * node = GetCurrentNode();  if (!node) return;  // refresh the node combo box with the nodePool  cmbNodes.Clear();  // Adds nodes selectable for this frame and action (selectable nodes have a NodeID != 0)  // associates in the comboBox each element with its pointer  u32 command = (u32) cmbCommands.GetClientData(cmbCommands.GetSelection());  // according to command type selets a node pool  switch (command) {    case GF_SG_NODE_REPLACE: {      // we replace this node, so we need the node from the pool for its type      V4NodePool &pool = parent->GetV4SceneManager()->pools.pool(gf_node_get_tag(node));      // fills the combo box      PopulateNodes(pool, node);      break;    }    case GF_SG_FIELD_REPLACE: {      // checks if the field combo box has a valid selection      u32 index = cmbFields.GetSelection();      if ( index == wxNOT_FOUND ) break;      // get the field selected      GF_FieldInfo field;      gf_node_get_field(node, index, &field);      // if field is not a node field then exits      if ( (field.fieldType != GF_SG_VRML_SFNODE) && (field.fieldType != GF_SG_VRML_MFNODE) ) break;      // get the pool corresponding to that field      V4NodePool &pool = parent->GetV4SceneManager()->pools.poolFromFieldName(field.name);      // fills the combo box      PopulateNodes(pool, node);            break;    }    case GF_SG_NODE_INSERT: {      // we add a child, that is to say we can add any generic node, we use "shape" to find that pool      V4NodePool &pool = parent->GetV4SceneManager()->pools.pool(TAG_MPEG4_Shape);      // fills the combo box      PopulateNodes(pool, node);      break;    }    default: {      return;    }  }}// RefreshFields -- lists the fields this nodes hasvoid V4CommandPanel::RefreshFields() {  // retrieves pointer to the node  GF_Node * node = GetCurrentNode();  if (!node) return;  // clears the combo box  cmbFields.Clear();  int count = gf_node_get_field_count(node);  GF_FieldInfo field;  for (u32 i = 0; i < count; i++) {    gf_node_get_field(node, i, &field);    cmbFields.Append(field.name, (void *) i);  }  // TODO : are there some nodes with no fields ?  cmbFields.SetSelection(0);  OnFieldCombo(wxCommandEvent());}// ShowNodeSizer -- shows or hides controls in the szSelectNode sizervoid V4CommandPanel::ShowNodeSizer(bool show) {  cmbNodes.Show(show);  lblNodes.Show(show);  // always detaches to avoid accumulation of objects  sizerM->Detach(szSelectNode);  if (show) {    sizerM->Add(szSelectNode, 1, wxEXPAND);    RefreshNodes();  }  tabAdd.Layout();}// ShowFieldSizer -- shows or hides controls in the szSelectField sizervoid V4CommandPanel::ShowFieldSizer(bool show) {  cmbFields.Show(show);  lblFields.Show(show);  txtField.Show(false); // always hide, RefreshField may bring it back  // always detaches to avoid accumulation of objects  sizerM->Detach(szSelectField);  sizerM->Detach(szTxtField);  if (show) {    // here order matters, RefreshFields may add szSelectNode, so we have to had ourselves before that    sizerM->Add(szSelectField, 1, wxEXPAND);    RefreshFields();  }  tabAdd.Layout();}/************************//*        Utils         *//************************/// IsCommandValidForNode -- tells if we can apply this command to that nodebool V4CommandPanel::IsCommandValidForNode(u32 command, GF_Node * node) {  switch (command) {    case GF_SG_FIELD_REPLACE:    case GF_SG_NODE_DELETE:    case GF_SG_NODE_REPLACE: {      return true;      break;    }    case GF_SG_NODE_INSERT: {      // to insert a child, node must have a GF_SG_VRML_MFNODE field, other children are not "inserted"      return parent->GetV4SceneManager()->pools.NodeHasField(node, GF_SG_VRML_MFNODE);      break;    }  }  return false;}// GetCurrentNode -- returns the node currently selected in the timelineGF_Node * V4CommandPanel::GetCurrentNode() {  u32 id = parent->GetTimeLine()->GetSelectedID();  if (!id) return NULL;  return gf_sg_find_node(parent->GetV4SceneManager()->GetSceneGraph(), id);}// PopulateNodes -- fills the cmdNodes with nodes from pool, do not add the specified node if foundvoid V4CommandPanel::PopulateNodes(V4NodePool& pool, GF_Node * node) {  for (u32 i = 0; i != pool.GetNodesCount(); i++)    if (pool.at(i).GetNode() != node)      cmbNodes.Append(pool.at(i).GetName(), (void *) pool.at(i).GetNode());}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -