appview.cpp 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. #include "appview.h"
  2. #include "appmodel.h"
  3. #include "appselectionset.h"
  4. #include "ha_bridge.h"
  5. #include "part_api.hxx"
  6. #include "HSharedKey.h"
  7. #include "body.hxx"
  8. #include "face.hxx"
  9. #include "edge.hxx"
  10. AppView:: AppView(HBaseModel *model,
  11. const char * alias ,
  12. const char * driver_type ,
  13. const char * instance_name ,
  14. void * window_handle ,
  15. void * colormap ):HBaseView(model, alias, driver_type, instance_name, window_handle, colormap){
  16. }
  17. AppView::~AppView()
  18. {
  19. }
  20. void AppView::Init()
  21. {
  22. HBaseView::Init();
  23. m_pSelection = new AppSelectionSet(this);
  24. m_pSelection->Init();
  25. }
  26. void AppView::DeleteSelectionList( bool emit_message )
  27. {
  28. int i, numSolidSelections, numHoopsSelections;
  29. char type[4096];
  30. AppSelectionSet* selection = (AppSelectionSet *)GetSelection();;
  31. ENTITY* current = 0;
  32. numHoopsSelections = selection->GetSize();
  33. numSolidSelections = selection->GetSolidListSize();
  34. if (numHoopsSelections == 0)
  35. return;
  36. // loop through the list of selected HOOPS primitives, filtering
  37. // out the ones associated with solid model entities, and deleting
  38. // the non-solid model primitives directly using Delete_By_Key
  39. // The primitives associated with solid model entities need to be
  40. // deleted using the HOOPS/GM deletion functions so that the HOOPS<->GM
  41. // mapping tables will remain in sync
  42. for (i = numHoopsSelections; i > 0; i--)
  43. {
  44. HC_KEY key = selection->GetAt(i-1);
  45. // if it's a HOOPS primitive that is not associated with a solid model entity,
  46. // deselect and delete it
  47. current = HA_Compute_Entity_Pointer(key, BODY_TYPE);
  48. if (current == 0)
  49. {
  50. selection->DeSelect(key, false);
  51. HC_Delete_By_Key(key);
  52. }
  53. }
  54. int depth = 0;
  55. outcome result;
  56. api_part_start_state(depth);
  57. {
  58. API_BEGIN
  59. // loop through the list of selected solid model entities,
  60. // delete the HOOPS geometry associated with each
  61. // and then delete the entity
  62. for (i = numSolidSelections; i > 0; i--)
  63. {
  64. current = (ENTITY*)selection->GetAtSolidEntity(i-1);
  65. if (current)
  66. {
  67. selection->DeSelectEntity(current);
  68. ((AppModel*)GetModel())->DeleteAcisEntity(current);
  69. }
  70. }
  71. API_END
  72. }
  73. api_part_note_state(result, depth);
  74. ((AppModel*)GetModel())->Update();
  75. if( emit_message )
  76. EmitDeleteSelectionListMessage();
  77. // Reset the selection set lists since we've deleted all the entities that
  78. // were in them (we can't DeSelect the entities because they no longer exist)
  79. selection->Reset();
  80. SetGeometryChanged();
  81. }