home *** CD-ROM | disk | FTP | other *** search
/ Dream 52 / Amiga_Dream_52.iso / Linux / Divers / freedraft.tar.gz / freedraft.tar / FREEdraft-050298 / CORE / registeredentity.cpp < prev    next >
C/C++ Source or Header  |  1998-04-23  |  3KB  |  81 lines

  1. // registeredentity.cpp
  2.  
  3. // Copyright (C) 1997  Cliff Johnson                                       //
  4. //                                                                         //
  5. // This program is free software; you can redistribute it and/or           //
  6. // modify it under the terms of the GNU  General Public                    //
  7. // License as published by the Free Software Foundation; either            //
  8. // version 2 of the License, or (at your option) any later version.        //
  9. //                                                                         //
  10. // This software is distributed in the hope that it will be useful,        //
  11. // but WITHOUT ANY WARRANTY; without even the implied warranty of          //
  12. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU       //
  13. // General Public License for more details.                                //
  14. //                                                                         //
  15. // You should have received a copy of the GNU General Public License       //
  16. // along with this software (see COPYING.LIB); if not, write to the        //
  17. // Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. //
  18.  
  19. #include <registeredentity.h>
  20.  
  21. #include <drawablegeom.h>    
  22.  
  23.  // default constructor - principally needed for STL
  24. RegisteredEntity::RegisteredEntity(): handle(), attributes() {}
  25.  
  26. // standard constructor
  27. RegisteredEntity::RegisteredEntity(    const Handle& h, 
  28.                     const Attributes& a, 
  29.                     const DrawableGeom* d ,
  30.                     bool v)
  31. : handle(h), attributes(a), drawable(d), visible(v),highlight(false) {}
  32.  
  33. RegisteredEntity::~RegisteredEntity(){} //destructor
  34.  
  35. // copy constructor
  36. RegisteredEntity::RegisteredEntity(const RegisteredEntity& re)
  37. {
  38.     handle = re.handle;
  39.     attributes = re.attributes;
  40.     drawable = re.drawable;
  41.     visible = re.visible;
  42.     highlight = re.highlight;
  43. }
  44.  
  45. // assignment operator
  46. RegisteredEntity& RegisteredEntity::operator=(const RegisteredEntity& re)
  47. {
  48.     handle = re.handle;
  49.     attributes = re.attributes;
  50.     drawable = re.drawable;
  51.     visible = re.visible;
  52.     highlight = re.highlight;
  53.     return *this;
  54. }
  55.  
  56. // STL operators
  57. bool operator==(const RegisteredEntity& re1, const RegisteredEntity& re2) // equivalence of handle
  58. {                            
  59.     return re1.handle == re2.handle;
  60. }
  61.  
  62. bool operator==(const RegisteredEntity& re, const Handle& h) // equivalence of handle
  63. {                            
  64.     return re.handle == h;
  65. }
  66.  
  67. bool operator!=(const RegisteredEntity& re, const Handle& h) // equivalence of handle
  68. {                            
  69.     return !(re.handle == h);
  70. }
  71.  
  72. void RegisteredEntity::Draw(const float& ppmm) const
  73. {
  74.     drawable->Draw(handle.PointsAt(),ppmm);
  75. }
  76.  
  77. void RegisteredEntity::Select(const float& ppmm) const
  78. {    // only visible non-highlighted stuff can be selected  
  79.     if(visible && !highlight) drawable->Select(handle.PointsAt(),handle,ppmm);
  80. }
  81.