scale.h 4.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #ifndef _scale_h_
  2. #define _scale_h_
  3. /*----------------------------------------------------------\
  4. Includes
  5. \----------------------------------------------------------*/
  6. #include <string>
  7. #include <cmath>
  8. #include <assert.h>
  9. #include "vector.h"
  10. #define DICOM_SCALE_NAME "DICOM"
  11. /*----------------------------------------------------------\
  12. Classes
  13. \----------------------------------------------------------*/
  14. class CScale
  15. {
  16. public:
  17. double m_dblVer, // distance verticale pour 1 pixel
  18. m_dblHor; // distance horizontale pour 1 pixel
  19. std::string m_strName; // nom de l'échelle
  20. CScale(std::string pszName, double dblHor = 0.0, double dblVer = 0.0, bool fOrthonorme = true);
  21. inline bool operator != (const CScale &sce) { return (!(*this == sce)); };
  22. inline bool operator == (const CScale &sce)
  23. {
  24. return ( (m_fVerOK == sce.m_fVerOK)
  25. && (m_fHorOK == sce.m_fHorOK)
  26. && (m_fOrthonorme == sce.m_fOrthonorme)
  27. && (m_dblVer == sce.m_dblVer)
  28. && (m_dblHor == sce.m_dblHor)
  29. && (m_isDicom == sce.m_isDicom )
  30. );
  31. }
  32. void Update (double dblHor, double dblVer);
  33. void SetScaleLire (double, double);
  34. void SetScale (double, double);
  35. void SetScale (double, const CVector &);
  36. void SetVerticalScale (double, const CVector &);
  37. void SetHorizontalScale (double, const CVector &);
  38. double Surface (Rect &rc) const { return (Surface (rc.Width (), rc.Height ())); }
  39. double Surface (double dblX, double dblY) const;
  40. double Surface (double dblSurface) const;
  41. double Distance (const Point&, const Point&) const;
  42. bool Valid (void) const { return (m_fVerOK || m_fHorOK); };
  43. bool IsDicom (void) const { return m_isDicom; }
  44. // les membres m_dblXXX sont initialisés à 0, donc si le calibrage n'est pas défini
  45. // ces fonctions retournent 0
  46. double DistanceX (long lDistance) const { assert (m_fHorOK);
  47. return (abs (lDistance) * m_dblHor); };
  48. double DistanceY (long lDistance) const { assert (m_fVerOK);
  49. return (abs (lDistance) * m_dblVer); };
  50. double DistanceX (int dwDistance) const { assert (m_fHorOK);
  51. return (dwDistance * m_dblHor); };
  52. double DistanceY (int dwDistance) const { assert (m_fVerOK);
  53. return (dwDistance * m_dblVer); };
  54. double Distance (double dblDistance) const { assert (Valid () && (m_dblHor == m_dblVer) && (dblDistance >= 0.));
  55. return (fabs (dblDistance) * m_dblHor); };
  56. double DistanceX (double dblDistance) const { assert (m_fHorOK);
  57. return (fabs (dblDistance) * m_dblHor); };
  58. double DistanceY (double dblDistance) const { assert (m_fVerOK);
  59. return (fabs (dblDistance) * m_dblVer); };
  60. protected:
  61. bool m_fVerOK, // calibration verticale effectuée
  62. m_fHorOK, // calibration horizontale effectuée
  63. m_fOrthonorme,// calbiration horizontale = calibration verticale
  64. m_isDicom;
  65. };
  66. /*----------------------------------------------------------\
  67. Variables globales
  68. \----------------------------------------------------------*/
  69. extern const CScale *g_pCurrentScale;
  70. #endif