You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

100 lines
2.4 KiB

18 years ago
  1. /****************************************************/
  2. /* class_drawpickedstruct.cpp */
  3. /****************************************************/
  4. #include "fctsys.h"
  5. #include "common.h"
  6. #include "sch_item_struct.h"
  7. /* Constructor and destructor for SCH_ITEM */
  8. /* They are not inline because this creates problems with gcc at linking time
  9. * in debug mode
  10. */
  11. SCH_ITEM::SCH_ITEM( EDA_BaseStruct* aParent, KICAD_T aType ) :
  12. EDA_BaseStruct( aParent, aType )
  13. {
  14. m_Layer = 0;
  15. }
  16. SCH_ITEM::~SCH_ITEM()
  17. {
  18. }
  19. /**************************/
  20. /* class DrawPickedStruct */
  21. /**************************/
  22. /* This class has only one useful member: .m_PickedStruct, used as a link.
  23. * It does not describe really an item.
  24. * It is used to create a linked list of selected items (in block selection).
  25. * Each DrawPickedStruct item has is member: .m_PickedStruct pointing the
  26. * real selected item
  27. */
  28. /*******************************************************************/
  29. DrawPickedStruct::DrawPickedStruct( SCH_ITEM * pickedstruct ) :
  30. SCH_ITEM( NULL, DRAW_PICK_ITEM_STRUCT_TYPE )
  31. /*******************************************************************/
  32. {
  33. m_PickedStruct = pickedstruct;
  34. }
  35. DrawPickedStruct::~DrawPickedStruct()
  36. {
  37. }
  38. #if defined(DEBUG)
  39. void DrawPickedStruct::Show( int nestLevel, std::ostream& os )
  40. {
  41. NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() << "/>\n";
  42. }
  43. #endif
  44. EDA_Rect DrawPickedStruct::GetBoundingBox()
  45. {
  46. if( m_PickedStruct )
  47. return m_PickedStruct->GetBoundingBox();
  48. else
  49. {
  50. return EDA_Rect(); // empty rectangle
  51. }
  52. }
  53. EDA_Rect DrawPickedStruct::GetBoundingBoxUnion()
  54. {
  55. EDA_Rect ret;
  56. DrawPickedStruct* cur = this;
  57. SCH_ITEM* item;
  58. while( cur && (item = cur->m_PickedStruct) != NULL )
  59. {
  60. ret.Merge( item->GetBoundingBox() );
  61. cur = cur->Next();
  62. }
  63. return ret;
  64. }
  65. /*********************************************/
  66. void DrawPickedStruct::DeleteWrapperList()
  67. /*********************************************/
  68. /* Delete this item all the items of the linked list
  69. * Free the wrapper, but DOES NOT delete the picked items linked by .m_PickedStruct
  70. */
  71. {
  72. DrawPickedStruct* wrapp_struct, * next_struct;
  73. for( wrapp_struct = Next(); wrapp_struct != NULL; wrapp_struct = next_struct )
  74. {
  75. next_struct = wrapp_struct->Next();
  76. delete wrapp_struct;
  77. }
  78. }