<commit_before>/// \file ROOT/TPadUserCoord.hxx
/// \ingroup Gpad ROOT7
/// \author <NAME> <<EMAIL>>
/// \date 2017-07-15
/// \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback
/// is welcome!

/*************************************************************************
 * Copyright (C) 1995-2017, <NAME> and <NAME>.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#ifndef ROOT7_TPadUserCoord
#define ROOT7_TPadUserCoord

#include <ROOT/TPadCoord.hxx>

#include <array>
#include <limits>

namespace ROOT {
namespace Experimental {

namespace Detail {

/** \class ROOT::Experimental::Internal::Detail::TPadUserCoordBase
  Base class for user coordinates (e.g. for histograms) used by `TPad` and `TCanvas`.
  */

class TPadUserCoordBase {
private:
   /// Disable copy construction.
   TPadUserCoordBase(const TPadUserCoordBase &) = delete;

   /// Disable assignment.
   TPadUserCoordBase &operator=(const TPadUserCoordBase &) = delete;

protected:
   /// Allow derived classes to default construct a TPadUserCoordBase.
   TPadUserCoordBase() = default;

public:
   virtual ~TPadUserCoordBase();

   /// Convert user coordinates to normal coordinates.
   virtual std::array<TPadCoord::Normal, 2> ToNormal(const std::array<TPadCoord::User, 2> &) const = 0;
};

/** \class ROOT::Experimental::Detail::TPadLinearUserCoord
  The default, linear min/max coordinate system for `TPad`, `TCanvas`.
  */

class TPadLinearUserCoord: public TPadUserCoordBase {
private:
   std::array<double, 2> fMin; ///< (x,y) user coordinate of bottom-left corner
   std::array<double, 2> fMax; ///< (x,y) user coordinate of top-right cornder

   /// For (pos-min)/(max-min) calculations, return a sensible, div-by-0 protected denominator.
   double GetDenominator(int idx) const
   {
      if (fMin[idx] < fMax[idx])
         return std::max(std::numeric_limits<double>::min(), fMin[idx] - fMax[idx]);
      return std::min(-std::numeric_limits<double>::min(), fMin[idx] - fMax[idx]);
   }

public:
   /// Initialize a TPadLinearUserCoord.
   TPadLinearUserCoord(const std::array<double, 2> &min, const std::array<double, 2> &max): fMin(min), fMax(max) {}

   /// Destructor to have a vtable.
   virtual ~TPadLinearUserCoord();

   /// Convert user coordinates to normal coordinates.
   std::array<TPadCoord::Normal, 2> ToNormal(const std::array<TPadCoord::User, 2> &pos) const override
   {
      return {{(pos[0] - fMin[0]) / GetDenominator(0), (pos[1] - fMin[1]) / GetDenominator(1)}};
   }
};

} // namespace Detail
} // namespace Experimental
} // namespace ROOT

#endif
<commit_msg>webgui: implement missing destructor in coordinate classes<commit_after>/// \file ROOT/TPadUserCoord.hxx
/// \ingroup Gpad ROOT7
/// \author <NAME> <<EMAIL>>
/// \date 2017-07-15
/// \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback
/// is welcome!

/*************************************************************************
 * Copyright (C) 1995-2017, <NAME> and <NAME>.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#ifndef ROOT7_TPadUserCoord
#define ROOT7_TPadUserCoord

#include <ROOT/TPadCoord.hxx>

#include <array>
#include <limits>

namespace ROOT {
namespace Experimental {

namespace Detail {

/** \class ROOT::Experimental::Internal::Detail::TPadUserCoordBase
  Base class for user coordinates (e.g. for histograms) used by `TPad` and `TCanvas`.
  */

class TPadUserCoordBase {
private:
   /// Disable copy construction.
   TPadUserCoordBase(const TPadUserCoordBase &) = delete;

   /// Disable assignment.
   TPadUserCoordBase &operator=(const TPadUserCoordBase &) = delete;

protected:
   /// Allow derived classes to default construct a TPadUserCoordBase.
   TPadUserCoordBase() = default;

public:
   virtual ~TPadUserCoordBase() {}

   /// Convert user coordinates to normal coordinates.
   virtual std::array<TPadCoord::Normal, 2> ToNormal(const std::array<TPadCoord::User, 2> &) const = 0;
};

/** \class ROOT::Experimental::Detail::TPadLinearUserCoord
  The default, linear min/max coordinate system for `TPad`, `TCanvas`.
  */

class TPadLinearUserCoord: public TPadUserCoordBase {
private:
   std::array<double, 2> fMin; ///< (x,y) user coordinate of bottom-left corner
   std::array<double, 2> fMax; ///< (x,y) user coordinate of top-right corner

   /// For (pos-min)/(max-min) calculations, return a sensible, div-by-0 protected denominator.
   double GetDenominator(int idx) const
   {
      if (fMin[idx] < fMax[idx])
         return std::max(std::numeric_limits<double>::min(), fMin[idx] - fMax[idx]);
      return std::min(-std::numeric_limits<double>::min(), fMin[idx] - fMax[idx]);
   }

public:
   /// Initialize a TPadLinearUserCoord.
   TPadLinearUserCoord(const std::array<double, 2> &min, const std::array<double, 2> &max): fMin(min), fMax(max) {}

   /// Destructor to have a vtable.
   virtual ~TPadLinearUserCoord() {}

   /// Convert user coordinates to normal coordinates.
   std::array<TPadCoord::Normal, 2> ToNormal(const std::array<TPadCoord::User, 2> &pos) const override
   {
      return {{(pos[0] - fMin[0]) / GetDenominator(0), (pos[1] - fMin[1]) / GetDenominator(1)}};
   }
};

} // namespace Detail
} // namespace Experimental
} // namespace ROOT

#endif

{'fraction_non_alphanumeric': 0.17673564753004006, 'fraction_numerical': 0.012016021361815754, 'mean_word_length': 3.2115249472944485, 'pattern_counts': {'":': 0, '<': 45, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2127162', 'n_tokens_mistral': 1829, 'n_tokens_neox': 1728, 'n_words': 476}