<commit_before>/// \file ROOT/TFrame.hxx
/// \ingroup Gpad ROOT7
/// \author <NAME> <<EMAIL>>
/// \date 2017-09-26
/// \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_TFrame
#define ROOT7_TFrame

#include "ROOT/TDrawingAttr.hxx"
#include "ROOT/TDrawingOptsBase.hxx"
#include "ROOT/TPadExtent.hxx"
#include "ROOT/TPadPos.hxx"
#include "ROOT/TPadUserAxis.hxx"
#include "ROOT/TPalette.hxx"

#include <memory>

namespace ROOT {
namespace Experimental {

/** \class ROOT::Experimental::TFrame
  Holds a user coordinate system with a palette.
  */

class TFrame {
public:
   class DrawingOpts: public TDrawingOptsBase {
   public:
      /// Position of the frame in parent TPad coordinates.
      TDrawingAttr<TPadPos> fPos{*this, "frame.pos", 0.1_normal, 0.1_normal};
      /// Size of the frame in parent TPad coordinates.
      TDrawingAttr<TPadExtent> fSize{*this, "frame.size", 0.8_normal, 0.8_normal};
   };

private:
   /// Mapping of user coordinates to normal coordinates, one entry per dimension.
   std::vector<std::unique_ptr<Detail::TPadUserAxisBase>> fUserCoord;

   /// Palette used to visualize user coordinates.
   TPalette fPalette;

   /// Offset with respect to parent TPad.
   TPadPos fPos;

   /// Size of the frame, in parent TPad coordinates.
   TPadExtent fSize;

public:
   /// Constructor taking user coordinate system, position and extent.
   explicit TFrame(std::vector<std::unique_ptr<Detail::TPadUserAxisBase>> &&coords, const DrawingOpts &opts);

   // Constructor taking position and extent.
   explicit TFrame(const DrawingOpts &opts)
      : TFrame({}, opts)
   {}

   /// Get the current user coordinate system for a given dimension.
   Detail::TPadUserAxisBase &GetUserAxis(size_t dimension) const { return *fUserCoord[dimension]; }

   /// Set the user coordinate system.
   void SetUserAxis(std::vector<std::unique_ptr<Detail::TPadUserAxisBase>> &&axes) { fUserCoord = std::move(axes); }

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

} // namespace Experimental
} // namespace ROOT

#endif
<commit_msg>Give access to the number of dimensions of user coordinates.<commit_after>/// \file ROOT/TFrame.hxx
/// \ingroup Gpad ROOT7
/// \author <NAME> <<EMAIL>>
/// \date 2017-09-26
/// \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_TFrame
#define ROOT7_TFrame

#include "ROOT/TDrawingAttr.hxx"
#include "ROOT/TDrawingOptsBase.hxx"
#include "ROOT/TPadExtent.hxx"
#include "ROOT/TPadPos.hxx"
#include "ROOT/TPadUserAxis.hxx"
#include "ROOT/TPalette.hxx"

#include <memory>

namespace ROOT {
namespace Experimental {

/** \class ROOT::Experimental::TFrame
  Holds a user coordinate system with a palette.
  */

class TFrame {
public:
   class DrawingOpts: public TDrawingOptsBase {
   public:
      /// Position of the frame in parent TPad coordinates.
      TDrawingAttr<TPadPos> fPos{*this, "frame.pos", 0.1_normal, 0.1_normal};
      /// Size of the frame in parent TPad coordinates.
      TDrawingAttr<TPadExtent> fSize{*this, "frame.size", 0.8_normal, 0.8_normal};
   };

private:
   /// Mapping of user coordinates to normal coordinates, one entry per dimension.
   std::vector<std::unique_ptr<Detail::TPadUserAxisBase>> fUserCoord;

   /// Palette used to visualize user coordinates.
   TPalette fPalette;

   /// Offset with respect to parent TPad.
   TPadPos fPos;

   /// Size of the frame, in parent TPad coordinates.
   TPadExtent fSize;

public:
   /// Constructor taking user coordinate system, position and extent.
   explicit TFrame(std::vector<std::unique_ptr<Detail::TPadUserAxisBase>> &&coords, const DrawingOpts &opts);

   // Constructor taking position and extent.
   explicit TFrame(const DrawingOpts &opts)
      : TFrame({}, opts)
   {}

   /// Get the number of axes.
   size_t GetNDimensions() const { return fUserCoord.size(); }

   /// Get the current user coordinate system for a given dimension.
   Detail::TPadUserAxisBase &GetUserAxis(size_t dimension) const { return *fUserCoord[dimension]; }

   /// Set the user coordinate system.
   void SetUserAxis(std::vector<std::unique_ptr<Detail::TPadUserAxisBase>> &&axes) { fUserCoord = std::move(axes); }

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

} // namespace Experimental
} // namespace ROOT

#endif

{'fraction_non_alphanumeric': 0.16308060109289618, 'fraction_numerical': 0.011612021857923498, 'mean_word_length': 3.0958041958041957, 'pattern_counts': {'":': 0, '<': 35, '<?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': '6595966', 'n_tokens_mistral': 1764, 'n_tokens_neox': 1684, 'n_words': 485}