<commit_before>//* This file is part of the MOOSE framework
//* https://www.mooseframework.org
//*
//* All rights reserved, see COPYRIGHT for full restrictions
//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
//*
//* Licensed under LGPL 2.1, please see LICENSE for details
//* https://www.gnu.org/licenses/lgpl-2.1.html

#include "MooseCoordTransform.h"
#include "InputParameters.h"
#include "MultiMooseEnum.h"
#include "MooseEnum.h"
#include "MooseMesh.h"

#include "libmesh/tensor_value.h"
#include "libmesh/point.h"

using namespace libMesh;

MooseCoordTransform::MooseCoordTransform() {}
MooseCoordTransform::~MooseCoordTransform() {}

MooseCoordTransform::Direction
MooseCoordTransform::processZAxis(const Direction z_axis)
{
  return _coord_type == Moose::COORD_RZ ? z_axis : INVALID;
}

void
MooseCoordTransform::setUpDirection(const Direction up_direction)
{
  Real alpha = 0, beta = 0, gamma = 0;

  const bool must_rotate_axes =
      _coord_type == Moose::COORD_RZ || _coord_type == Moose::COORD_RSPHERICAL;
  // Don't error immediately for unit testing purposes
  bool negative_radii = false;

  if (up_direction == X)
  {
    alpha = 90, beta = 0, gamma = 0;
    if (must_rotate_axes)
    {
      if (_r_axis == X)
      {
        _r_axis = Y;
        _z_axis = processZAxis(X);
      }
      else if (_r_axis == Y)
      {
        negative_radii = true;
        _r_axis = X;
        _z_axis = processZAxis(Y);
      }
      else
        mooseAssert(false, "we should never get here");
    }
  }
  else if (up_direction == Y)
    alpha = 0, beta = 0, gamma = 0;
  else if (up_direction == Z)
  {
    alpha = 0, beta = -90, gamma = 0;
    if (must_rotate_axes)
    {
      if (_r_axis == X)
      {
        _r_axis = X;
        _z_axis = processZAxis(Z);
      }
      else if (_r_axis == Y)
      {
        negative_radii = true;
        _r_axis = Z;
        _z_axis = processZAxis(X);
      }
      else
        mooseAssert(false, "we should never get here");
    }
  }
  else
    mooseAssert(false, "we should never get here");

  _rotate = std::make_unique<RealTensorValue>(
      RealTensorValue::extrinsic_rotation_matrix(alpha, beta, gamma));

  if (negative_radii)
    mooseError("Rotation yields negative radial values");
}

void
MooseCoordTransform::setRotation(const Real alpha, const Real beta, const Real gamma)
{
  const bool must_rotate_axes =
      _coord_type == Moose::COORD_RZ || _coord_type == Moose::COORD_RSPHERICAL;
  bool axes_rotated = false;
  if (must_rotate_axes)
  {
    const auto angles = std::make_tuple(alpha, beta, gamma);
    if (angles == std::make_tuple(0, 90, 0))
    {
      if (_r_axis == X)
      {
        mooseAssert((_coord_type == Moose::COORD_RZ && _z_axis == Y) ||
                        (_coord_type == Moose::COORD_RSPHERICAL && _z_axis == INVALID),
                    "'_z_axis' is not an expected value");
        _r_axis = X;
        _z_axis = _coord_type == Moose::COORD_RZ ? Z : INVALID;
      }
      else if (_r_axis == Y)
      {
        mooseAssert((_coord_type == Moose::COORD_RZ && _z_axis == X) ||
                        (_coord_type == Moose::COORD_RSPHERICAL && _z_axis == INVALID),
                    "'_z_axis' is not an expected value");
        _r_axis = Z;
        _z_axis = _coord_type == Moose::COORD_RZ ? X : INVALID;
      }
      axes_rotated = true;
    }
  }

  _rotate = std::make_unique<RealTensorValue>(
      RealTensorValue::extrinsic_rotation_matrix(alpha, beta, gamma));

  if (must_rotate_axes && !axes_rotated)
    mooseError("Unsupported manual angle prescription in 'MooseCoordTransform::setRotation'");
}

void
MooseCoordTransform::setLengthUnitsPerMeter(const Real length_units_per_meter)
{
  const auto scale = 1 / length_units_per_meter;

  _scale =
      std::make_unique<RealTensorValue>(RealTensorValue(scale, 0, 0, 0, scale, 0, 0, 0, scale));
}

void
MooseCoordTransform::setCoordinateSystem(const Moose::CoordinateSystemType coord_type,
                                         const Direction rz_symmetry_axis)
{
  _coord_type = coord_type;

  if (_coord_type == Moose::COORD_RZ)
  {
    if (rz_symmetry_axis == INVALID)
      mooseError("For RZ coordinate systems, the 'rz_symmetry_axis' parameter must be provided to "
                 "'MooseCoordTransform::setCoordinateSystem'");

    _z_axis = rz_symmetry_axis;
    _r_axis = _z_axis == X ? Y : X;
  }
  else if (_coord_type == Moose::COORD_RSPHERICAL)
    _r_axis = X;
}

InputParameters
MooseCoordTransform::validParams()
{
  auto params = emptyInputParameters();
  /// One entry of coord system per block, the size of _blocks and _coord_sys has to match, except:
  /// 1. _blocks.size() == 0, then there needs to be just one entry in _coord_sys, which will
  ///    be set for the whole domain
  /// 2. _blocks.size() > 0 and no coordinate system was specified, then the whole domain will be XYZ.
  /// 3. _blocks.size() > 0 and one coordinate system was specified, then the whole domain will be that system.
  params.addParam<std::vector<SubdomainName>>("block", "Block IDs for the coordinate systems");
  MultiMooseEnum coord_types("XYZ RZ RSPHERICAL", "XYZ");
  MooseEnum rz_coord_axis("X=0 Y=1", "Y");
  params.addParam<MultiMooseEnum>(
      "coord_type", coord_types, "Type of the coordinate system per block param");
  params.addParam<MooseEnum>(
      "rz_coord_axis", rz_coord_axis, "The rotation axis (X | Y) for axisymetric coordinates");
  params.addParam<Real>("length_units_per_meter",
                        "How many mesh length units are in a meter, e.g. if your mesh units are "
                        "centimeters, then this parameter value should be 100.");
  params.addRangeCheckedParam<Real>(
      "alpha_rotation",
      "-180<alpha_rotation<=180",
      "The number of degrees that the domain should be alpha-rotated using the Euler "
      "angle ZXZ convention from https://en.wikipedia.org/wiki/Euler_angles#Rotation_matrix in "
      "order to align with a canonical physical space of your choosing.");
  params.addRangeCheckedParam<Real>(
      "beta_rotation",
      "-180<beta_rotation<=180",
      "The number of degrees that the domain should be beta-rotated using the Euler "
      "angle ZXZ convention from https://en.wikipedia.org/wiki/Euler_angles#Rotation_matrix in "
      "order to align with a canonical physical space of your choosing.");
  params.addRangeCheckedParam<Real>(
      "gamma_rotation",
      "-180<gamma_rotation<=180",
      "The number of degrees that the domain should be gamma-rotated using the Euler "
      "angle ZXZ convention from https://en.wikipedia.org/wiki/Euler_angles#Rotation_matrix in "
      "order to align with a canonical physical space of your choosing.");
  MooseEnum up_direction("X=0 Y=1 Z=2");
  params.addParam<MooseEnum>(
      "up_direction",
      up_direction,
      "Specify what axis corresponds to the up direction in physical space (the opposite of the "
      "gravity vector if you will). If this parameter is provided, we will perform a single 90 "
      "degree rotation of the domain--if the provided axis is 'x' or 'z', we will not rotate if "
      "the axis is 'y'--such that a point which was on the provided axis will now lie on the "
      "y-axis, e.g. the y-axis is our canonical up direction. If you want finer grained control "
      "than this, please use the 'alpha_rotation', 'beta_rotation', and 'gamma_rotation' "
      "parameters.");
  return params;
}

MooseCoordTransform::MooseCoordTransform(const InputParameters & params)
{
  //
  // coordinate system transformation. If we have multiple different coordinate system types in our
  // problem, we take note of it because that can cause issues if there is a non-Cartesian
  // destination coordinate system
  //
  const auto & mesh = *params.getCheckedPointerParam<MooseMesh *>("mesh");
  const auto & coord_sys = mesh.getCoordSystem();
  std::unordered_set<Moose::CoordinateSystemType> coord_types;
  auto map_it = coord_sys.begin();
  // It's possible that the mesh is not in a complete state
  if (map_it == coord_sys.end())
    setCoordinateSystem(Moose::COORD_XYZ);
  else
    setCoordinateSystem(
        map_it->second,
        Direction(static_cast<unsigned int>(int(params.get<MooseEnum>("rz_coord_axis")))));
  for (; map_it != coord_sys.end(); ++map_it)
    coord_types.insert(map_it->second);

  _has_different_coord_sys = coord_types.size() > 1;

  //
  // rotation
  //
  const bool has_alpha = params.isParamValid("alpha_rotation");
  const bool has_beta = params.isParamValid("beta_rotation");
  const bool has_gamma = params.isParamValid("gamma_rotation");
  const auto & up_direction = params.get<MooseEnum>("up_direction");

  if (has_alpha || has_beta || has_gamma)
  {
    if (up_direction.isValid())
      mooseError("Cannot simultaneously set rotation angles as well as an up direction");

    const auto alpha = (has_alpha ? params.get<Real>("alpha_rotation") : Real(0));
    const auto beta = (has_beta ? params.get<Real>("beta_rotation") : Real(0));
    const auto gamma = (has_gamma ? params.get<Real>("gamma_rotation") : Real(0));

    setRotation(alpha, beta, gamma);
  }
  else if (up_direction.isValid())
    setUpDirection(Direction(static_cast<unsigned int>(int(up_direction))));

  //
  // Scale
  //
  if (params.isParamValid("length_units_per_meter"))
    setLengthUnitsPerMeter(params.get<Real>("length_units_per_meter"));
}

Point
MooseCoordTransform::operator()(const Point & point) const
{
  Point ret(point);
  if (_rotate)
    ret = (*_rotate) * ret;
  if (_scale)
    ret = (*_scale) * ret;

  // If this shows up in profiling we can make _translation a pointer
  ret += _translation;

  // Finally, coordinate system conversions
  if (_coord_type == Moose::COORD_XYZ && _destination_coord_type == Moose::COORD_RZ)
  {
    Real r_squared = 0;
    for (unsigned int i = 0; i < LIBMESH_DIM; ++i)
      if (i != _destination_z_axis)
        r_squared += ret(i) * ret(i);

    const auto r = std::sqrt(r_squared);
    const auto z = ret(_destination_z_axis);
    ret = 0;
    ret(_destination_r_axis) = r;
    ret(_destination_z_axis) = z;
  }
  else if (_coord_type == Moose::COORD_XYZ && _destination_coord_type == Moose::COORD_RSPHERICAL)
  {
    Real r_squared = 0;
    for (unsigned int i = 0; i < LIBMESH_DIM; ++i)
      r_squared += ret(i) * ret(i);

    const auto r = std::sqrt(r_squared);
    ret = 0;
    ret(_destination_r_axis) = r;
  }
  else if (_coord_type == Moose::COORD_RZ && _destination_coord_type == Moose::COORD_RSPHERICAL)
  {
    Real r_squared = 0;
    for (unsigned int i = 0; i < LIBMESH_DIM; ++i)
    {
      mooseAssert(
          i == _r_axis || i == _z_axis || MooseUtils::absoluteFuzzyEqual(ret(i), 0),
          "Our point should be 0 if we are evaluating at an index that is neither our r or z-axis");
      r_squared += ret(i) * ret(i);
    }

    const auto r = std::sqrt(r_squared);
    ret = 0;
    ret(_destination_r_axis) = r;
  }

  return ret;
}

void
MooseCoordTransform::setTranslationVector(const Point & translation)
{
  _translation = translation;
}

void
MooseCoordTransform::setDestinationCoordinateSystem(
    const MooseCoordTransform & destination_coord_transform)
{
  _destination_coord_type = destination_coord_transform._coord_type;
  _destination_r_axis = destination_coord_transform._r_axis;
  _destination_z_axis = destination_coord_transform._z_axis;

  if ((_destination_coord_type == Moose::COORD_RZ ||
       _destination_coord_type == Moose::COORD_RSPHERICAL) &&
      _has_different_coord_sys)
    mooseError("When the destination coordinate system is RZ or RSPHERICAL, we have to perform "
               "coordinate collapsing based on *our* coordinate system. However, we have multiple "
               "coordinate systems, and since when evaluating transformations, we are only "
               "called with a Point argument, we do not know what subdomain we are on and "
               "consequently we do not know what transformation to apply.");
}
<commit_msg>Per Gary's suggestion, error when destination has multiple coord types<commit_after>//* This file is part of the MOOSE framework
//* https://www.mooseframework.org
//*
//* All rights reserved, see COPYRIGHT for full restrictions
//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
//*
//* Licensed under LGPL 2.1, please see LICENSE for details
//* https://www.gnu.org/licenses/lgpl-2.1.html

#include "MooseCoordTransform.h"
#include "InputParameters.h"
#include "MultiMooseEnum.h"
#include "MooseEnum.h"
#include "MooseMesh.h"

#include "libmesh/tensor_value.h"
#include "libmesh/point.h"

using namespace libMesh;

MooseCoordTransform::MooseCoordTransform() {}
MooseCoordTransform::~MooseCoordTransform() {}

MooseCoordTransform::Direction
MooseCoordTransform::processZAxis(const Direction z_axis)
{
  return _coord_type == Moose::COORD_RZ ? z_axis : INVALID;
}

void
MooseCoordTransform::setUpDirection(const Direction up_direction)
{
  Real alpha = 0, beta = 0, gamma = 0;

  const bool must_rotate_axes =
      _coord_type == Moose::COORD_RZ || _coord_type == Moose::COORD_RSPHERICAL;
  // Don't error immediately for unit testing purposes
  bool negative_radii = false;

  if (up_direction == X)
  {
    alpha = 90, beta = 0, gamma = 0;
    if (must_rotate_axes)
    {
      if (_r_axis == X)
      {
        _r_axis = Y;
        _z_axis = processZAxis(X);
      }
      else if (_r_axis == Y)
      {
        negative_radii = true;
        _r_axis = X;
        _z_axis = processZAxis(Y);
      }
      else
        mooseAssert(false, "we should never get here");
    }
  }
  else if (up_direction == Y)
    alpha = 0, beta = 0, gamma = 0;
  else if (up_direction == Z)
  {
    alpha = 0, beta = -90, gamma = 0;
    if (must_rotate_axes)
    {
      if (_r_axis == X)
      {
        _r_axis = X;
        _z_axis = processZAxis(Z);
      }
      else if (_r_axis == Y)
      {
        negative_radii = true;
        _r_axis = Z;
        _z_axis = processZAxis(X);
      }
      else
        mooseAssert(false, "we should never get here");
    }
  }
  else
    mooseAssert(false, "we should never get here");

  _rotate = std::make_unique<RealTensorValue>(
      RealTensorValue::extrinsic_rotation_matrix(alpha, beta, gamma));

  if (negative_radii)
    mooseError("Rotation yields negative radial values");
}

void
MooseCoordTransform::setRotation(const Real alpha, const Real beta, const Real gamma)
{
  const bool must_rotate_axes =
      _coord_type == Moose::COORD_RZ || _coord_type == Moose::COORD_RSPHERICAL;
  bool axes_rotated = false;
  if (must_rotate_axes)
  {
    const auto angles = std::make_tuple(alpha, beta, gamma);
    if (angles == std::make_tuple(0, 90, 0))
    {
      if (_r_axis == X)
      {
        mooseAssert((_coord_type == Moose::COORD_RZ && _z_axis == Y) ||
                        (_coord_type == Moose::COORD_RSPHERICAL && _z_axis == INVALID),
                    "'_z_axis' is not an expected value");
        _r_axis = X;
        _z_axis = _coord_type == Moose::COORD_RZ ? Z : INVALID;
      }
      else if (_r_axis == Y)
      {
        mooseAssert((_coord_type == Moose::COORD_RZ && _z_axis == X) ||
                        (_coord_type == Moose::COORD_RSPHERICAL && _z_axis == INVALID),
                    "'_z_axis' is not an expected value");
        _r_axis = Z;
        _z_axis = _coord_type == Moose::COORD_RZ ? X : INVALID;
      }
      axes_rotated = true;
    }
  }

  _rotate = std::make_unique<RealTensorValue>(
      RealTensorValue::extrinsic_rotation_matrix(alpha, beta, gamma));

  if (must_rotate_axes && !axes_rotated)
    mooseError("Unsupported manual angle prescription in 'MooseCoordTransform::setRotation'");
}

void
MooseCoordTransform::setLengthUnitsPerMeter(const Real length_units_per_meter)
{
  const auto scale = 1 / length_units_per_meter;

  _scale =
      std::make_unique<RealTensorValue>(RealTensorValue(scale, 0, 0, 0, scale, 0, 0, 0, scale));
}

void
MooseCoordTransform::setCoordinateSystem(const Moose::CoordinateSystemType coord_type,
                                         const Direction rz_symmetry_axis)
{
  _coord_type = coord_type;

  if (_coord_type == Moose::COORD_RZ)
  {
    if (rz_symmetry_axis == INVALID)
      mooseError("For RZ coordinate systems, the 'rz_symmetry_axis' parameter must be provided to "
                 "'MooseCoordTransform::setCoordinateSystem'");

    _z_axis = rz_symmetry_axis;
    _r_axis = _z_axis == X ? Y : X;
  }
  else if (_coord_type == Moose::COORD_RSPHERICAL)
    _r_axis = X;
}

InputParameters
MooseCoordTransform::validParams()
{
  auto params = emptyInputParameters();
  /// One entry of coord system per block, the size of _blocks and _coord_sys has to match, except:
  /// 1. _blocks.size() == 0, then there needs to be just one entry in _coord_sys, which will
  ///    be set for the whole domain
  /// 2. _blocks.size() > 0 and no coordinate system was specified, then the whole domain will be XYZ.
  /// 3. _blocks.size() > 0 and one coordinate system was specified, then the whole domain will be that system.
  params.addParam<std::vector<SubdomainName>>("block", "Block IDs for the coordinate systems");
  MultiMooseEnum coord_types("XYZ RZ RSPHERICAL", "XYZ");
  MooseEnum rz_coord_axis("X=0 Y=1", "Y");
  params.addParam<MultiMooseEnum>(
      "coord_type", coord_types, "Type of the coordinate system per block param");
  params.addParam<MooseEnum>(
      "rz_coord_axis", rz_coord_axis, "The rotation axis (X | Y) for axisymetric coordinates");
  params.addParam<Real>("length_units_per_meter",
                        "How many mesh length units are in a meter, e.g. if your mesh units are "
                        "centimeters, then this parameter value should be 100.");
  params.addRangeCheckedParam<Real>(
      "alpha_rotation",
      "-180<alpha_rotation<=180",
      "The number of degrees that the domain should be alpha-rotated using the Euler "
      "angle ZXZ convention from https://en.wikipedia.org/wiki/Euler_angles#Rotation_matrix in "
      "order to align with a canonical physical space of your choosing.");
  params.addRangeCheckedParam<Real>(
      "beta_rotation",
      "-180<beta_rotation<=180",
      "The number of degrees that the domain should be beta-rotated using the Euler "
      "angle ZXZ convention from https://en.wikipedia.org/wiki/Euler_angles#Rotation_matrix in "
      "order to align with a canonical physical space of your choosing.");
  params.addRangeCheckedParam<Real>(
      "gamma_rotation",
      "-180<gamma_rotation<=180",
      "The number of degrees that the domain should be gamma-rotated using the Euler "
      "angle ZXZ convention from https://en.wikipedia.org/wiki/Euler_angles#Rotation_matrix in "
      "order to align with a canonical physical space of your choosing.");
  MooseEnum up_direction("X=0 Y=1 Z=2");
  params.addParam<MooseEnum>(
      "up_direction",
      up_direction,
      "Specify what axis corresponds to the up direction in physical space (the opposite of the "
      "gravity vector if you will). If this parameter is provided, we will perform a single 90 "
      "degree rotation of the domain--if the provided axis is 'x' or 'z', we will not rotate if "
      "the axis is 'y'--such that a point which was on the provided axis will now lie on the "
      "y-axis, e.g. the y-axis is our canonical up direction. If you want finer grained control "
      "than this, please use the 'alpha_rotation', 'beta_rotation', and 'gamma_rotation' "
      "parameters.");
  return params;
}

MooseCoordTransform::MooseCoordTransform(const InputParameters & params)
{
  //
  // coordinate system transformation. If we have multiple different coordinate system types in our
  // problem, we take note of it because that can cause issues if there is a non-Cartesian
  // destination coordinate system
  //
  const auto & mesh = *params.getCheckedPointerParam<MooseMesh *>("mesh");
  const auto & coord_sys = mesh.getCoordSystem();
  std::unordered_set<Moose::CoordinateSystemType> coord_types;
  auto map_it = coord_sys.begin();
  // It's possible that the mesh is not in a complete state
  if (map_it == coord_sys.end())
    setCoordinateSystem(Moose::COORD_XYZ);
  else
    setCoordinateSystem(
        map_it->second,
        Direction(static_cast<unsigned int>(int(params.get<MooseEnum>("rz_coord_axis")))));
  for (; map_it != coord_sys.end(); ++map_it)
    coord_types.insert(map_it->second);

  _has_different_coord_sys = coord_types.size() > 1;

  //
  // rotation
  //
  const bool has_alpha = params.isParamValid("alpha_rotation");
  const bool has_beta = params.isParamValid("beta_rotation");
  const bool has_gamma = params.isParamValid("gamma_rotation");
  const auto & up_direction = params.get<MooseEnum>("up_direction");

  if (has_alpha || has_beta || has_gamma)
  {
    if (up_direction.isValid())
      mooseError("Cannot simultaneously set rotation angles as well as an up direction");

    const auto alpha = (has_alpha ? params.get<Real>("alpha_rotation") : Real(0));
    const auto beta = (has_beta ? params.get<Real>("beta_rotation") : Real(0));
    const auto gamma = (has_gamma ? params.get<Real>("gamma_rotation") : Real(0));

    setRotation(alpha, beta, gamma);
  }
  else if (up_direction.isValid())
    setUpDirection(Direction(static_cast<unsigned int>(int(up_direction))));

  //
  // Scale
  //
  if (params.isParamValid("length_units_per_meter"))
    setLengthUnitsPerMeter(params.get<Real>("length_units_per_meter"));
}

Point
MooseCoordTransform::operator()(const Point & point) const
{
  Point ret(point);
  if (_rotate)
    ret = (*_rotate) * ret;
  if (_scale)
    ret = (*_scale) * ret;

  // If this shows up in profiling we can make _translation a pointer
  ret += _translation;

  // Finally, coordinate system conversions
  if (_coord_type == Moose::COORD_XYZ && _destination_coord_type == Moose::COORD_RZ)
  {
    Real r_squared = 0;
    for (unsigned int i = 0; i < LIBMESH_DIM; ++i)
      if (i != _destination_z_axis)
        r_squared += ret(i) * ret(i);

    const auto r = std::sqrt(r_squared);
    const auto z = ret(_destination_z_axis);
    ret = 0;
    ret(_destination_r_axis) = r;
    ret(_destination_z_axis) = z;
  }
  else if (_coord_type == Moose::COORD_XYZ && _destination_coord_type == Moose::COORD_RSPHERICAL)
  {
    Real r_squared = 0;
    for (unsigned int i = 0; i < LIBMESH_DIM; ++i)
      r_squared += ret(i) * ret(i);

    const auto r = std::sqrt(r_squared);
    ret = 0;
    ret(_destination_r_axis) = r;
  }
  else if (_coord_type == Moose::COORD_RZ && _destination_coord_type == Moose::COORD_RSPHERICAL)
  {
    Real r_squared = 0;
    for (unsigned int i = 0; i < LIBMESH_DIM; ++i)
    {
      mooseAssert(
          i == _r_axis || i == _z_axis || MooseUtils::absoluteFuzzyEqual(ret(i), 0),
          "Our point should be 0 if we are evaluating at an index that is neither our r or z-axis");
      r_squared += ret(i) * ret(i);
    }

    const auto r = std::sqrt(r_squared);
    ret = 0;
    ret(_destination_r_axis) = r;
  }

  return ret;
}

void
MooseCoordTransform::setTranslationVector(const Point & translation)
{
  _translation = translation;
}

void
MooseCoordTransform::setDestinationCoordinateSystem(
    const MooseCoordTransform & destination_coord_transform)
{
  _destination_coord_type = destination_coord_transform._coord_type;
  _destination_r_axis = destination_coord_transform._r_axis;
  _destination_z_axis = destination_coord_transform._z_axis;

  if (destination_coord_transform._has_different_coord_sys &&
      (_has_different_coord_sys || _coord_type != Moose::COORD_RSPHERICAL))
    mooseError(
        "The destination coordinate system has different coordinate systems and we have coordinate "
        "system(s) that could require coordinate collapsing when transforming from our coordinate "
        "system to the destination coordinate system. Because our transform method only takes a "
        "point argument, and not subdomain arguments, the transform is ambiguous");

  if ((_destination_coord_type == Moose::COORD_RZ ||
       _destination_coord_type == Moose::COORD_RSPHERICAL) &&
      _has_different_coord_sys)
    mooseError("When the destination coordinate system is RZ or RSPHERICAL, we have to perform "
               "coordinate collapsing based on *our* coordinate system. However, we have multiple "
               "coordinate systems, and since when evaluating transformations, we are only "
               "called with a Point argument, we do not know what subdomain we are on and "
               "consequently we do not know what coordinate collapse to apply.");
}
<|endoftext|>


<commit_before>/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
 *
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * Copyright IBM Corporation 2009.
 * Copyright 2009 by Sun Microsystems, Inc.
 *
 * OpenOffice.org - a multi-platform office productivity suite
 *
 * $RCSfile: dpglobal.hxx,v $
 * $Revision: 1.0 $
 *
 * This file is part of OpenOffice.org.
 *
 * OpenOffice.org is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License version 3
 * only, as published by the Free Software Foundation.
 *
 * OpenOffice.org is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License version 3 for more details
 * (a copy is included in the LICENSE file that accompanied this code).
 *
 * You should have received a copy of the GNU Lesser General Public License
 * version 3 along with OpenOffice.org.  If not, see
 * <http://www.openoffice.org/license.html>
 * for a copy of the LGPLv3 License.
 *
 ************************************************************************/

#ifndef _SC_DPGLOBAL_HXX
#define _SC_DPGLOBAL_HXX

#include <algorithm>
#include <list>
#include <tools/gen.hxx>
#include <tools/debug.hxx>
#include <global.hxx>

#include <com/sun/star/container/XNamed.hpp>
#include <com/sun/star/sheet/XDimensionsSupplier.hpp>

#include <com/sun/star/sheet/DataPilotFieldFilter.hpp>
#include <com/sun/star/sheet/DataPilotFieldOrientation.hpp>
#include <com/sun/star/sheet/DataPilotTableHeaderData.hpp>
#include <com/sun/star/sheet/DataPilotTablePositionData.hpp>
#include <com/sun/star/sheet/DataPilotTablePositionType.hpp>
#include <com/sun/star/sheet/DataPilotTableResultData.hpp>
#include <com/sun/star/sheet/DataResultFlags.hpp>
#include <com/sun/star/sheet/GeneralFunction.hpp>
#include <com/sun/star/sheet/MemberResultFlags.hpp>
#include <com/sun/star/sheet/TableFilterField.hpp>
#include <com/sun/star/sheet/XDataPilotMemberResults.hpp>
#include <com/sun/star/sheet/XDataPilotResults.hpp>
#include <com/sun/star/sheet/XHierarchiesSupplier.hpp>
#include <com/sun/star/sheet/XLevelsSupplier.hpp>

// moved from fieldwnd.hxx, see also SC_DAPI_MAXFIELDS
#define MAX_LABELS  256

#define     PIVOT_MAXFUNC           11
#define     PIVOT_FUNC_NONE         0x0000
#define     PIVOT_FUNC_SUM          0x0001
#define     PIVOT_FUNC_COUNT        0x0002
#define     PIVOT_FUNC_AVERAGE      0x0004
#define     PIVOT_FUNC_MAX          0x0008
#define     PIVOT_FUNC_MIN          0x0010
#define     PIVOT_FUNC_PRODUCT      0x0020
#define     PIVOT_FUNC_COUNT_NUM    0x0040
#define     PIVOT_FUNC_STD_DEV      0x0080
#define     PIVOT_FUNC_STD_DEVP     0x0100
#define     PIVOT_FUNC_STD_VAR      0x0200
#define     PIVOT_FUNC_STD_VARP     0x0400
#define     PIVOT_FUNC_AUTO         0x1000

#define DATA_RENAME_SEPARATOR       "_"
#define __MAX_NUM_LEN 64
#define __DECIMALPLACE  18

#define DP_PROP_COLUMNGRAND         "ColumnGrand"
#define DP_PROP_FUNCTION            "Function"
#define DP_PROP_IGNOREEMPTY         "IgnoreEmptyRows"
#define DP_PROP_ISDATALAYOUT        "IsDataLayoutDimension"
#define DP_PROP_ISVISIBLE           "IsVisible"
#define DP_PROP_ORIENTATION         "Orientation"
#define DP_PROP_REPEATIFEMPTY       "RepeatIfEmpty"
#define DP_PROP_ROWGRAND            "RowGrand"
#define DP_PROP_SHOWDETAILS         "ShowDetails"
#define DP_PROP_SHOWEMPTY           "ShowEmpty"
#define DP_PROP_SUBTOTALS           "SubTotals"
#define DP_PROP_USEDHIERARCHY       "UsedHierarchy"
#define DP_PROP_FILTER              "Filter"
#define DP_PROP_POSITION            "Position"

#define DBG_TRACESTR( x )  \
    {\
        ByteString aTemp( x , RTL_TEXTENCODING_UTF8 ); \
        DBG_TRACE( aTemp.GetBuffer() );\
    }

class TypedStrData;
class ScDPObject;
class ScDPInfoWnd;
class ScDocShell;
class ScTabViewShell;

class SC_DLLPUBLIC ScDPItemData
{
public:
    enum { MK_VAL = 0x01, MK_DATA = MK_VAL<<1, MK_ERR = MK_DATA<<1, MK_DATE = MK_ERR<<1, MK_DATEPART = MK_DATE<<1 };
private:
    union
    {
        ULONG   nNumFormat;
        sal_Int32 mnDatePart;
    };

    String  aString;
    double  fValue;
    BYTE    mbFlag;
    //bool  bHasValue: 1 ;
    //bool  bHasData: 1;
    //bool  bErr: 1;

    friend class ScDPTableDataCache;
public:
    ScDPItemData() : nNumFormat( 0 ), fValue(0.0), mbFlag( 0 ){}
    ScDPItemData( ULONG nNF, const String & rS, double fV, BYTE bF ):nNumFormat(nNF), aString(rS), fValue(fV), mbFlag( bF ){}
    ScDPItemData( const String& rS, double fV = 0.0, bool bHV = FALSE, const ULONG nNumFormat = 0 , bool bData = TRUE) ;
    ScDPItemData( ScDocument* pDoc, SCROW nRow, USHORT nCol, USHORT nDocTab );

    void        SetString( const String& rS ) { aString = rS; mbFlag &= ~(MK_VAL|MK_DATE); nNumFormat = 0; mbFlag |= MK_DATA; }
//  void        SetValue ( double value , ULONG nNumFormat = 0 ) { bHasValue = TRUE; nNumFormat = 0;bHasData = TRUE; bDate = FALSE; fValue = value ;}
    bool        IsCaseInsEqual( const ScDPItemData& r ) const;

    size_t      Hash() const;

    // exact equality
    bool        operator==( const ScDPItemData& r ) const;
    // case insensitive equality
    static sal_Int32    Compare( const ScDPItemData& rA, const ScDPItemData& rB );

#ifdef DEBUG
    void    dump() const;
#endif

public:
    bool IsHasData() const ;
    bool IsHasErr() const ;
    bool IsValue() const;
    String  GetString() const ;
    double  GetValue() const ;
    ULONG    GetNumFormat() const ;
    bool HasStringData() const ;
    bool IsDate() const;
    bool HasDatePart() const;
    void SetDate( bool b ) ;

    TypedStrData*  CreateTypeString( );
    sal_uInt8    GetType() const;
    BYTE & GetFlag() throw() { return mbFlag; }
    const BYTE & GetFlag() const throw() { return const_cast<ScDPItemData*>(this)->GetFlag(); }
};

class SC_DLLPUBLIC ScDPItemDataPool
{
public:
    ScDPItemDataPool();
    ScDPItemDataPool(const ScDPItemDataPool& r);

    virtual ~ScDPItemDataPool();
    virtual const ScDPItemData* getData( sal_Int32 nId  );
    virtual sal_Int32 getDataId( const ScDPItemData& aData );
    virtual sal_Int32 insertData( const ScDPItemData& aData );
protected:
    struct DataHashFunc : public std::unary_function< const ScDPItemData &, size_t >
    {
        size_t operator() (const ScDPItemData &rData) const { return rData.Hash(); }
    };

    typedef ::std::hash_multimap< ScDPItemData, sal_Int32, DataHashFunc > DataHash;

    ::std::vector< ScDPItemData > maItems;
    DataHash  maItemIds;
};

namespace ScDPGlobal
{
// used for core data
    String GetFieldFuncString( const String& rSourceName, USHORT &rFuncMask, bool bIsValue );
    com::sun::star::uno::Reference<com::sun::star::container::XNameAccess> DP_GetMembers( const com::sun::star::uno::Reference<
                                                                                com::sun::star::sheet::XDimensionsSupplier>&rSrc, long nField );
// common operation
    String operator + ( const String & rL, const String &rR );
    Rectangle operator *( const Rectangle &rLeft, const std::pair<double,double> & rRight );
// used for  DataPilot Panel
    ScDPInfoWnd* GetDPInfoWnd( ScTabViewShell *pViewShell );

}
#endif

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
<commit_msg>declared but not defined<commit_after>/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
 *
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * Copyright IBM Corporation 2009.
 * Copyright 2009 by Sun Microsystems, Inc.
 *
 * OpenOffice.org - a multi-platform office productivity suite
 *
 * $RCSfile: dpglobal.hxx,v $
 * $Revision: 1.0 $
 *
 * This file is part of OpenOffice.org.
 *
 * OpenOffice.org is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License version 3
 * only, as published by the Free Software Foundation.
 *
 * OpenOffice.org is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License version 3 for more details
 * (a copy is included in the LICENSE file that accompanied this code).
 *
 * You should have received a copy of the GNU Lesser General Public License
 * version 3 along with OpenOffice.org.  If not, see
 * <http://www.openoffice.org/license.html>
 * for a copy of the LGPLv3 License.
 *
 ************************************************************************/

#ifndef _SC_DPGLOBAL_HXX
#define _SC_DPGLOBAL_HXX

#include <algorithm>
#include <list>
#include <tools/gen.hxx>
#include <tools/debug.hxx>
#include <global.hxx>

#include <com/sun/star/container/XNamed.hpp>
#include <com/sun/star/sheet/XDimensionsSupplier.hpp>

#include <com/sun/star/sheet/DataPilotFieldFilter.hpp>
#include <com/sun/star/sheet/DataPilotFieldOrientation.hpp>
#include <com/sun/star/sheet/DataPilotTableHeaderData.hpp>
#include <com/sun/star/sheet/DataPilotTablePositionData.hpp>
#include <com/sun/star/sheet/DataPilotTablePositionType.hpp>
#include <com/sun/star/sheet/DataPilotTableResultData.hpp>
#include <com/sun/star/sheet/DataResultFlags.hpp>
#include <com/sun/star/sheet/GeneralFunction.hpp>
#include <com/sun/star/sheet/MemberResultFlags.hpp>
#include <com/sun/star/sheet/TableFilterField.hpp>
#include <com/sun/star/sheet/XDataPilotMemberResults.hpp>
#include <com/sun/star/sheet/XDataPilotResults.hpp>
#include <com/sun/star/sheet/XHierarchiesSupplier.hpp>
#include <com/sun/star/sheet/XLevelsSupplier.hpp>

// moved from fieldwnd.hxx, see also SC_DAPI_MAXFIELDS
#define MAX_LABELS  256

#define     PIVOT_MAXFUNC           11
#define     PIVOT_FUNC_NONE         0x0000
#define     PIVOT_FUNC_SUM          0x0001
#define     PIVOT_FUNC_COUNT        0x0002
#define     PIVOT_FUNC_AVERAGE      0x0004
#define     PIVOT_FUNC_MAX          0x0008
#define     PIVOT_FUNC_MIN          0x0010
#define     PIVOT_FUNC_PRODUCT      0x0020
#define     PIVOT_FUNC_COUNT_NUM    0x0040
#define     PIVOT_FUNC_STD_DEV      0x0080
#define     PIVOT_FUNC_STD_DEVP     0x0100
#define     PIVOT_FUNC_STD_VAR      0x0200
#define     PIVOT_FUNC_STD_VARP     0x0400
#define     PIVOT_FUNC_AUTO         0x1000

#define DATA_RENAME_SEPARATOR       "_"
#define __MAX_NUM_LEN 64
#define __DECIMALPLACE  18

#define DP_PROP_COLUMNGRAND         "ColumnGrand"
#define DP_PROP_FUNCTION            "Function"
#define DP_PROP_IGNOREEMPTY         "IgnoreEmptyRows"
#define DP_PROP_ISDATALAYOUT        "IsDataLayoutDimension"
#define DP_PROP_ISVISIBLE           "IsVisible"
#define DP_PROP_ORIENTATION         "Orientation"
#define DP_PROP_REPEATIFEMPTY       "RepeatIfEmpty"
#define DP_PROP_ROWGRAND            "RowGrand"
#define DP_PROP_SHOWDETAILS         "ShowDetails"
#define DP_PROP_SHOWEMPTY           "ShowEmpty"
#define DP_PROP_SUBTOTALS           "SubTotals"
#define DP_PROP_USEDHIERARCHY       "UsedHierarchy"
#define DP_PROP_FILTER              "Filter"
#define DP_PROP_POSITION            "Position"

#define DBG_TRACESTR( x )  \
    {\
        ByteString aTemp( x , RTL_TEXTENCODING_UTF8 ); \
        DBG_TRACE( aTemp.GetBuffer() );\
    }

class TypedStrData;
class ScDPObject;
class ScDPInfoWnd;
class ScDocShell;
class ScTabViewShell;

class SC_DLLPUBLIC ScDPItemData
{
public:
    enum { MK_VAL = 0x01, MK_DATA = MK_VAL<<1, MK_ERR = MK_DATA<<1, MK_DATE = MK_ERR<<1, MK_DATEPART = MK_DATE<<1 };
private:
    union
    {
        ULONG   nNumFormat;
        sal_Int32 mnDatePart;
    };

    String  aString;
    double  fValue;
    BYTE    mbFlag;
    //bool  bHasValue: 1 ;
    //bool  bHasData: 1;
    //bool  bErr: 1;

    friend class ScDPTableDataCache;
public:
    ScDPItemData() : nNumFormat( 0 ), fValue(0.0), mbFlag( 0 ){}
    ScDPItemData( ULONG nNF, const String & rS, double fV, BYTE bF ):nNumFormat(nNF), aString(rS), fValue(fV), mbFlag( bF ){}
    ScDPItemData( const String& rS, double fV = 0.0, bool bHV = FALSE, const ULONG nNumFormat = 0 , bool bData = TRUE) ;
    ScDPItemData( ScDocument* pDoc, SCROW nRow, USHORT nCol, USHORT nDocTab );

    void        SetString( const String& rS ) { aString = rS; mbFlag &= ~(MK_VAL|MK_DATE); nNumFormat = 0; mbFlag |= MK_DATA; }
//  void        SetValue ( double value , ULONG nNumFormat = 0 ) { bHasValue = TRUE; nNumFormat = 0;bHasData = TRUE; bDate = FALSE; fValue = value ;}
    bool        IsCaseInsEqual( const ScDPItemData& r ) const;

    size_t      Hash() const;

    // exact equality
    bool        operator==( const ScDPItemData& r ) const;
    // case insensitive equality
    static sal_Int32    Compare( const ScDPItemData& rA, const ScDPItemData& rB );

#ifdef DEBUG
    void    dump() const;
#endif

public:
    bool IsHasData() const ;
    bool IsHasErr() const ;
    bool IsValue() const;
    String  GetString() const ;
    double  GetValue() const ;
    ULONG    GetNumFormat() const ;
    bool HasStringData() const ;
    bool IsDate() const;
    bool HasDatePart() const;
    void SetDate( bool b ) ;

    TypedStrData*  CreateTypeString( );
    sal_uInt8    GetType() const;
    BYTE & GetFlag() throw() { return mbFlag; }
    const BYTE & GetFlag() const throw() { return const_cast<ScDPItemData*>(this)->GetFlag(); }
};

class SC_DLLPUBLIC ScDPItemDataPool
{
public:
    ScDPItemDataPool();
    ScDPItemDataPool(const ScDPItemDataPool& r);

    virtual ~ScDPItemDataPool();
    virtual const ScDPItemData* getData( sal_Int32 nId  );
    virtual sal_Int32 getDataId( const ScDPItemData& aData );
    virtual sal_Int32 insertData( const ScDPItemData& aData );
protected:
    struct DataHashFunc : public std::unary_function< const ScDPItemData &, size_t >
    {
        size_t operator() (const ScDPItemData &rData) const { return rData.Hash(); }
    };

    typedef ::std::hash_multimap< ScDPItemData, sal_Int32, DataHashFunc > DataHash;

    ::std::vector< ScDPItemData > maItems;
    DataHash  maItemIds;
};

namespace ScDPGlobal
{
// common operation
    String operator + ( const String & rL, const String &rR );
    Rectangle operator *( const Rectangle &rLeft, const std::pair<double,double> & rRight );
}
#endif

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
<|endoftext|>


<commit_before>/*************************************************************************
 *
 *  $RCSfile: progress.hxx,v $
 *
 *  $Revision: 1.1.1.1 $
 *
 *  last change: $Author: hr $ $Date: 2000-09-18 16:44:49 $
 *
 *  The Contents of this file are made available subject to the terms of
 *  either of the following licenses
 *
 *         - GNU Lesser General Public License Version 2.1
 *         - Sun Industry Standards Source License Version 1.1
 *
 *  Sun Microsystems Inc., October, 2000
 *
 *  GNU Lesser General Public License Version 2.1
 *  =============================================
 *  Copyright 2000 by Sun Microsystems, Inc.
 *  901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License version 2.1, as published by the Free Software Foundation.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *  MA  02111-1307  USA
 *
 *
 *  Sun Industry Standards Source License Version 1.1
 *  =================================================
 *  The contents of this file are subject to the Sun Industry Standards
 *  Source License Version 1.1 (the "License"); You may not use this file
 *  except in compliance with the License. You may obtain a copy of the
 *  License at http://www.openoffice.org/license.html.
 *
 *  Software provided under this License is provided on an "AS IS" basis,
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 *  See the License for the specific provisions governing your rights and
 *  obligations concerning the Software.
 *
 *  The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 *
 *  Copyright: 2000 by Sun Microsystems, Inc.
 *
 *  All Rights Reserved.
 *
 *  Contributor(s): _______________________________________
 *
 *
 ************************************************************************/

#ifndef SC_PROGRESS_HXX
#define SC_PROGRESS_HXX

#ifndef _SFX_PROGRESS_HXX //autogen
#include <sfx2/progress.hxx>
#endif

class ScDocument;

class ScProgress
{
private:
    static  SfxProgress*    pGlobalProgress;
    static  ULONG           nGlobalRange;
    static  ULONG           nGlobalPercent;
    static  BOOL            bGlobalNoUserBreak;
    static  ScProgress*     pInterpretProgress;
    static  ScProgress*     pOldInterpretProgress;
    static  ULONG           nInterpretProgress;
    static  BOOL            bAllowInterpretProgress;
    static  ScDocument*     pInterpretDoc;
    static  BOOL            bIdleWasDisabled;

            SfxProgress*    pProgress;

                            // not implemented
                            ScProgress( const ScProgress& );
            ScProgress&     operator=( const ScProgress& );

    static  void            CalcGlobalPercent( ULONG nVal )
                                {
                                    nGlobalPercent = nGlobalRange ?
                                        nVal * 100 / nGlobalRange : 0;
                                }

public:
    static  SfxProgress*    GetGlobalSfxProgress() { return pGlobalProgress; }
    static  BOOL            IsUserBreak() { return !bGlobalNoUserBreak; }
    static  void            CreateInterpretProgress( ScDocument* pDoc,
                                                    BOOL bWait = TRUE );
    static  ScProgress*     GetInterpretProgress() { return pInterpretProgress; }
    static  void            DeleteInterpretProgress();
    static  void            SetAllowInterpret( BOOL bVal );
    static  BOOL            GetAllowInterpret() { return bAllowInterpretProgress; }
    static  ULONG           GetInterpretCount() { return nInterpretProgress; }
    static  ULONG           GetGlobalRange()    { return nGlobalRange; }
    static  ULONG           GetGlobalPercent()  { return nGlobalPercent; }

                            ScProgress( SfxObjectShell* pObjSh,
                                         const String& rText,
                                         ULONG nRange, BOOL bAllDocs = FALSE,
                                         BOOL bWait = TRUE );
                            ~ScProgress();

#ifdef SC_PROGRESS_CXX
                            // nur fuer DummyInterpret, sonst nie benutzen!!!
                            ScProgress();
#endif
                            // kann NULL sein!
            SfxProgress*    GetSfxProgress() const { return pProgress; }

            BOOL            SetStateText( ULONG nVal, const String &rVal, ULONG nNewRange = 0 )
                                {
                                    if ( pProgress )
                                    {
                                        if ( nNewRange )
                                            nGlobalRange = nNewRange;
                                        CalcGlobalPercent( nVal );
                                        if ( !pProgress->SetStateText( nVal, rVal, nNewRange ) )
                                            bGlobalNoUserBreak = FALSE;
                                        return bGlobalNoUserBreak;
                                    }
                                    return TRUE;
                                }
            BOOL            SetState( ULONG nVal, ULONG nNewRange = 0 )
                                {
                                    if ( pProgress )
                                    {
                                        if ( nNewRange )
                                            nGlobalRange = nNewRange;
                                        CalcGlobalPercent( nVal );
                                        if ( !pProgress->SetState( nVal, nNewRange ) )
                                            bGlobalNoUserBreak = FALSE;
                                        return bGlobalNoUserBreak;
                                    }
                                    return TRUE;
                                }
            BOOL            SetStateCountDown( ULONG nVal )
                                {
                                    if ( pProgress )
                                    {
                                        CalcGlobalPercent( nGlobalRange - nVal );
                                        if ( !pProgress->SetState( nGlobalRange - nVal ) )
                                            bGlobalNoUserBreak = FALSE;
                                        return bGlobalNoUserBreak;
                                    }
                                    return TRUE;
                                }
            BOOL            SetStateOnPercent( ULONG nVal )
                                {   // nur wenn Prozent mehr als vorher
                                    if ( nGlobalRange && (nVal * 100 /
                                            nGlobalRange) > nGlobalPercent )
                                        return SetState( nVal );
                                    return TRUE;
                                }
            BOOL            SetStateCountDownOnPercent( ULONG nVal )
                                {   // nur wenn Prozent mehr als vorher
                                    if ( nGlobalRange &&
                                            ((nGlobalRange - nVal) * 100 /
                                            nGlobalRange) > nGlobalPercent )
                                        return SetStateCountDown( nVal );
                                    return TRUE;
                                }
            ULONG           GetState()
                                {
                                    if ( pProgress )
                                        return pProgress->GetState();
                                    return 0;
                                }
};

#endif

<commit_msg>INTEGRATION: CWS ooo19126 (1.1.1.1.942); FILE MERGED 2005/09/05 15:00:54 rt 1.1.1.1.942.1: #i54170# Change license header: remove SISSL<commit_after>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: progress.hxx,v $
 *
 *  $Revision: 1.2 $
 *
 *  last change: $Author: rt $ $Date: 2005-09-08 17:49:35 $
 *
 *  The Contents of this file are made available subject to
 *  the terms of GNU Lesser General Public License Version 2.1.
 *
 *
 *    GNU Lesser General Public License Version 2.1
 *    =============================================
 *    Copyright 2005 by Sun Microsystems, Inc.
 *    901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License version 2.1, as published by the Free Software Foundation.
 *
 *    This library is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *    Lesser General Public License for more details.
 *
 *    You should have received a copy of the GNU Lesser General Public
 *    License along with this library; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *    MA  02111-1307  USA
 *
 ************************************************************************/

#ifndef SC_PROGRESS_HXX
#define SC_PROGRESS_HXX

#ifndef _SFX_PROGRESS_HXX //autogen
#include <sfx2/progress.hxx>
#endif

class ScDocument;

class ScProgress
{
private:
    static  SfxProgress*    pGlobalProgress;
    static  ULONG           nGlobalRange;
    static  ULONG           nGlobalPercent;
    static  BOOL            bGlobalNoUserBreak;
    static  ScProgress*     pInterpretProgress;
    static  ScProgress*     pOldInterpretProgress;
    static  ULONG           nInterpretProgress;
    static  BOOL            bAllowInterpretProgress;
    static  ScDocument*     pInterpretDoc;
    static  BOOL            bIdleWasDisabled;

            SfxProgress*    pProgress;

                            // not implemented
                            ScProgress( const ScProgress& );
            ScProgress&     operator=( const ScProgress& );

    static  void            CalcGlobalPercent( ULONG nVal )
                                {
                                    nGlobalPercent = nGlobalRange ?
                                        nVal * 100 / nGlobalRange : 0;
                                }

public:
    static  SfxProgress*    GetGlobalSfxProgress() { return pGlobalProgress; }
    static  BOOL            IsUserBreak() { return !bGlobalNoUserBreak; }
    static  void            CreateInterpretProgress( ScDocument* pDoc,
                                                    BOOL bWait = TRUE );
    static  ScProgress*     GetInterpretProgress() { return pInterpretProgress; }
    static  void            DeleteInterpretProgress();
    static  void            SetAllowInterpret( BOOL bVal );
    static  BOOL            GetAllowInterpret() { return bAllowInterpretProgress; }
    static  ULONG           GetInterpretCount() { return nInterpretProgress; }
    static  ULONG           GetGlobalRange()    { return nGlobalRange; }
    static  ULONG           GetGlobalPercent()  { return nGlobalPercent; }

                            ScProgress( SfxObjectShell* pObjSh,
                                         const String& rText,
                                         ULONG nRange, BOOL bAllDocs = FALSE,
                                         BOOL bWait = TRUE );
                            ~ScProgress();

#ifdef SC_PROGRESS_CXX
                            // nur fuer DummyInterpret, sonst nie benutzen!!!
                            ScProgress();
#endif
                            // kann NULL sein!
            SfxProgress*    GetSfxProgress() const { return pProgress; }

            BOOL            SetStateText( ULONG nVal, const String &rVal, ULONG nNewRange = 0 )
                                {
                                    if ( pProgress )
                                    {
                                        if ( nNewRange )
                                            nGlobalRange = nNewRange;
                                        CalcGlobalPercent( nVal );
                                        if ( !pProgress->SetStateText( nVal, rVal, nNewRange ) )
                                            bGlobalNoUserBreak = FALSE;
                                        return bGlobalNoUserBreak;
                                    }
                                    return TRUE;
                                }
            BOOL            SetState( ULONG nVal, ULONG nNewRange = 0 )
                                {
                                    if ( pProgress )
                                    {
                                        if ( nNewRange )
                                            nGlobalRange = nNewRange;
                                        CalcGlobalPercent( nVal );
                                        if ( !pProgress->SetState( nVal, nNewRange ) )
                                            bGlobalNoUserBreak = FALSE;
                                        return bGlobalNoUserBreak;
                                    }
                                    return TRUE;
                                }
            BOOL            SetStateCountDown( ULONG nVal )
                                {
                                    if ( pProgress )
                                    {
                                        CalcGlobalPercent( nGlobalRange - nVal );
                                        if ( !pProgress->SetState( nGlobalRange - nVal ) )
                                            bGlobalNoUserBreak = FALSE;
                                        return bGlobalNoUserBreak;
                                    }
                                    return TRUE;
                                }
            BOOL            SetStateOnPercent( ULONG nVal )
                                {   // nur wenn Prozent mehr als vorher
                                    if ( nGlobalRange && (nVal * 100 /
                                            nGlobalRange) > nGlobalPercent )
                                        return SetState( nVal );
                                    return TRUE;
                                }
            BOOL            SetStateCountDownOnPercent( ULONG nVal )
                                {   // nur wenn Prozent mehr als vorher
                                    if ( nGlobalRange &&
                                            ((nGlobalRange - nVal) * 100 /
                                            nGlobalRange) > nGlobalPercent )
                                        return SetStateCountDown( nVal );
                                    return TRUE;
                                }
            ULONG           GetState()
                                {
                                    if ( pProgress )
                                        return pProgress->GetState();
                                    return 0;
                                }
};

#endif

<|endoftext|>


<commit_before>/*************************************************************************
 *
 *  $RCSfile: viewopti.hxx,v $
 *
 *  $Revision: 1.1.1.1 $
 *
 *  last change: $Author: hr $ $Date: 2000-09-18 16:44:50 $
 *
 *  The Contents of this file are made available subject to the terms of
 *  either of the following licenses
 *
 *         - GNU Lesser General Public License Version 2.1
 *         - Sun Industry Standards Source License Version 1.1
 *
 *  Sun Microsystems Inc., October, 2000
 *
 *  GNU Lesser General Public License Version 2.1
 *  =============================================
 *  Copyright 2000 by Sun Microsystems, Inc.
 *  901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License version 2.1, as published by the Free Software Foundation.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *  MA  02111-1307  USA
 *
 *
 *  Sun Industry Standards Source License Version 1.1
 *  =================================================
 *  The contents of this file are subject to the Sun Industry Standards
 *  Source License Version 1.1 (the "License"); You may not use this file
 *  except in compliance with the License. You may obtain a copy of the
 *  License at http://www.openoffice.org/license.html.
 *
 *  Software provided under this License is provided on an "AS IS" basis,
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 *  See the License for the specific provisions governing your rights and
 *  obligations concerning the Software.
 *
 *  The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 *
 *  Copyright: 2000 by Sun Microsystems, Inc.
 *
 *  All Rights Reserved.
 *
 *  Contributor(s): _______________________________________
 *
 *
 ************************************************************************/

#ifndef SC_VIEWOPTI_HXX
#define SC_VIEWOPTI_HXX

#ifndef _SVX_OPTGRID_HXX //autogen
#include <svx/optgrid.hxx>
#endif

#ifndef _SVX_SVXIDS_HRC //autogen
#include <svx/svxids.hrc>
#endif

#ifndef _UTL_CONFIGITEM_HXX_
#include <unotools/configitem.hxx>
#endif

#ifndef SC_SCGLOB_HXX
#include "global.hxx"
#endif

//==================================================================
// View-Optionen
//==================================================================

enum ScViewOption
{
    VOPT_FORMULAS = 0,
    VOPT_NULLVALS,
    VOPT_SYNTAX,
    VOPT_NOTES,
    VOPT_VSCROLL,
    VOPT_HSCROLL,
    VOPT_TABCONTROLS,
    VOPT_OUTLINER,
    VOPT_HEADER,
    VOPT_GRID,
    VOPT_HELPLINES,
    VOPT_ANCHOR,
    VOPT_PAGEBREAKS,
    VOPT_SOLIDHANDLES,
    VOPT_CLIPMARKS,
    VOPT_BIGHANDLES
};

enum ScVObjType
{
    VOBJ_TYPE_OLE = 0,
    VOBJ_TYPE_CHART,
    VOBJ_TYPE_DRAW
};

#define MAX_OPT     (USHORT)VOPT_BIGHANDLES+1
#define MAX_TYPE    (USHORT)VOBJ_TYPE_DRAW+1

//==================================================================
// SvxGrid-Optionen mit Standard-Operatoren
//==================================================================

class ScGridOptions : public SvxOptionsGrid
{
public:
                ScGridOptions() : SvxOptionsGrid() {}
                ScGridOptions( const SvxOptionsGrid& rOpt ) : SvxOptionsGrid( rOpt ) {}

    void                    SetDefaults();
    const ScGridOptions&    operator=  ( const ScGridOptions& rCpy );
    int                     operator== ( const ScGridOptions& rOpt ) const;
    int                     operator!= ( const ScGridOptions& rOpt ) const { return !(operator==(rOpt)); }

    friend SvStream&        operator>> ( SvStream& rStream, ScGridOptions& rOpt );
    friend SvStream&        operator<< ( SvStream& rStream, const ScGridOptions& rOpt );
};

//==================================================================
// Einstellungen - Ansicht
//==================================================================

class ScViewOptions
{
public:
                ScViewOptions();
                ScViewOptions( const ScViewOptions& rCpy );
                ~ScViewOptions();

    void                    SetDefaults();

    void                    SetOption( ScViewOption eOpt, BOOL bNew = TRUE )    { aOptArr[eOpt] = bNew; }
    BOOL                    GetOption( ScViewOption eOpt ) const                { return aOptArr[eOpt]; }

    void                    SetObjMode( ScVObjType eObj, ScVObjMode eMode ) { aModeArr[eObj] = eMode; }
    ScVObjMode              GetObjMode( ScVObjType eObj ) const             { return aModeArr[eObj]; }

    void                    SetGridColor( const Color& rCol, const String& rName ) { aGridCol = rCol; aGridColName = rName;}
    Color                   GetGridColor( String* pStrName = NULL ) const;

    const ScGridOptions&    GetGridOptions() const                      { return aGridOpt; }
    void                    SetGridOptions( const ScGridOptions& rNew ) { aGridOpt = rNew; }
    SvxGridItem*            CreateGridItem( USHORT nId = SID_ATTR_GRID_OPTIONS ) const;

    BOOL                    IsHideAutoSpell() const             { return bHideAutoSpell; }
    void                    SetHideAutoSpell( BOOL bSet )       { bHideAutoSpell = bSet; }

    const ScViewOptions&    operator=  ( const ScViewOptions& rCpy );
    int                     operator== ( const ScViewOptions& rOpt ) const;
    int                     operator!= ( const ScViewOptions& rOpt ) const { return !(operator==(rOpt)); }

    friend SvStream&        operator>> ( SvStream& rStream, ScViewOptions& rOpt );

    void                    Save(SvStream& rStream, BOOL bConfig = FALSE) const;

private:
    BOOL            aOptArr     [MAX_OPT];
    ScVObjMode      aModeArr    [MAX_TYPE];
    Color           aGridCol;
    String          aGridColName;
    ScGridOptions   aGridOpt;
    BOOL            bHideAutoSpell;
};

inline SvStream& operator<<( SvStream& rStream, const ScViewOptions& rOpt )
{
    rOpt.Save( rStream, FALSE );
    return rStream;
}

//==================================================================
// Item fuer Einstellungsdialog - Ansicht
//==================================================================

class ScTpViewItem : public SfxPoolItem
{
public:
                TYPEINFO();
                ScTpViewItem( USHORT nWhich );
                ScTpViewItem( USHORT nWhich, const ScViewOptions& rOpt );
                ScTpViewItem( const ScTpViewItem&  rItem );
                ~ScTpViewItem();

    virtual String          GetValueText() const;
    virtual int             operator==( const SfxPoolItem& ) const;
    virtual SfxPoolItem*    Clone( SfxItemPool *pPool = 0 ) const;

    const ScViewOptions&    GetViewOptions() const { return theOptions; }

private:
    ScViewOptions   theOptions;
};

//  ConfigItem for classes that use items from several sub trees
//! move to separate header file

class ScLinkConfigItem : public utl::ConfigItem
{
    Link    aCommitLink;

public:
            ScLinkConfigItem( const rtl::OUString rSubTree );
    void    SetCommitLink( const Link& rLink );

    virtual void    Notify( const com::sun::star::uno::Sequence<rtl::OUString>& aPropertyNames );
    virtual void    Commit();

    ConfigItem::GetProperties;
    ConfigItem::EnableNotification;
    ConfigItem::PutProperties;
    ConfigItem::SetModified;
};

//==================================================================
// CfgItem fuer View-Optionen
//==================================================================

class ScViewCfg : public ScViewOptions
{
    ScLinkConfigItem    aLayoutItem;
    ScLinkConfigItem    aDisplayItem;
    ScLinkConfigItem    aGridItem;

    DECL_LINK( LayoutCommitHdl, void* );
    DECL_LINK( DisplayCommitHdl, void* );
    DECL_LINK( GridCommitHdl, void* );

    com::sun::star::uno::Sequence<rtl::OUString> GetLayoutPropertyNames();
    com::sun::star::uno::Sequence<rtl::OUString> GetDisplayPropertyNames();
    com::sun::star::uno::Sequence<rtl::OUString> GetGridPropertyNames();

public:
            ScViewCfg();

    void            SetOptions( const ScViewOptions& rNew );
};

#endif

<commit_msg>ScLinkConfigItem: parent methods reimplemented<commit_after>/*************************************************************************
 *
 *  $RCSfile: viewopti.hxx,v $
 *
 *  $Revision: 1.2 $
 *
 *  last change: $Author: nn $ $Date: 2000-09-19 17:56:04 $
 *
 *  The Contents of this file are made available subject to the terms of
 *  either of the following licenses
 *
 *         - GNU Lesser General Public License Version 2.1
 *         - Sun Industry Standards Source License Version 1.1
 *
 *  Sun Microsystems Inc., October, 2000
 *
 *  GNU Lesser General Public License Version 2.1
 *  =============================================
 *  Copyright 2000 by Sun Microsystems, Inc.
 *  901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License version 2.1, as published by the Free Software Foundation.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *  MA  02111-1307  USA
 *
 *
 *  Sun Industry Standards Source License Version 1.1
 *  =================================================
 *  The contents of this file are subject to the Sun Industry Standards
 *  Source License Version 1.1 (the "License"); You may not use this file
 *  except in compliance with the License. You may obtain a copy of the
 *  License at http://www.openoffice.org/license.html.
 *
 *  Software provided under this License is provided on an "AS IS" basis,
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 *  See the License for the specific provisions governing your rights and
 *  obligations concerning the Software.
 *
 *  The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 *
 *  Copyright: 2000 by Sun Microsystems, Inc.
 *
 *  All Rights Reserved.
 *
 *  Contributor(s): _______________________________________
 *
 *
 ************************************************************************/

#ifndef SC_VIEWOPTI_HXX
#define SC_VIEWOPTI_HXX

#ifndef _SVX_OPTGRID_HXX //autogen
#include <svx/optgrid.hxx>
#endif

#ifndef _SVX_SVXIDS_HRC //autogen
#include <svx/svxids.hrc>
#endif

#ifndef _UTL_CONFIGITEM_HXX_
#include <unotools/configitem.hxx>
#endif

#ifndef SC_SCGLOB_HXX
#include "global.hxx"
#endif

//==================================================================
// View-Optionen
//==================================================================

enum ScViewOption
{
    VOPT_FORMULAS = 0,
    VOPT_NULLVALS,
    VOPT_SYNTAX,
    VOPT_NOTES,
    VOPT_VSCROLL,
    VOPT_HSCROLL,
    VOPT_TABCONTROLS,
    VOPT_OUTLINER,
    VOPT_HEADER,
    VOPT_GRID,
    VOPT_HELPLINES,
    VOPT_ANCHOR,
    VOPT_PAGEBREAKS,
    VOPT_SOLIDHANDLES,
    VOPT_CLIPMARKS,
    VOPT_BIGHANDLES
};

enum ScVObjType
{
    VOBJ_TYPE_OLE = 0,
    VOBJ_TYPE_CHART,
    VOBJ_TYPE_DRAW
};

#define MAX_OPT     (USHORT)VOPT_BIGHANDLES+1
#define MAX_TYPE    (USHORT)VOBJ_TYPE_DRAW+1

//==================================================================
// SvxGrid-Optionen mit Standard-Operatoren
//==================================================================

class ScGridOptions : public SvxOptionsGrid
{
public:
                ScGridOptions() : SvxOptionsGrid() {}
                ScGridOptions( const SvxOptionsGrid& rOpt ) : SvxOptionsGrid( rOpt ) {}

    void                    SetDefaults();
    const ScGridOptions&    operator=  ( const ScGridOptions& rCpy );
    int                     operator== ( const ScGridOptions& rOpt ) const;
    int                     operator!= ( const ScGridOptions& rOpt ) const { return !(operator==(rOpt)); }

    friend SvStream&        operator>> ( SvStream& rStream, ScGridOptions& rOpt );
    friend SvStream&        operator<< ( SvStream& rStream, const ScGridOptions& rOpt );
};

//==================================================================
// Einstellungen - Ansicht
//==================================================================

class ScViewOptions
{
public:
                ScViewOptions();
                ScViewOptions( const ScViewOptions& rCpy );
                ~ScViewOptions();

    void                    SetDefaults();

    void                    SetOption( ScViewOption eOpt, BOOL bNew = TRUE )    { aOptArr[eOpt] = bNew; }
    BOOL                    GetOption( ScViewOption eOpt ) const                { return aOptArr[eOpt]; }

    void                    SetObjMode( ScVObjType eObj, ScVObjMode eMode ) { aModeArr[eObj] = eMode; }
    ScVObjMode              GetObjMode( ScVObjType eObj ) const             { return aModeArr[eObj]; }

    void                    SetGridColor( const Color& rCol, const String& rName ) { aGridCol = rCol; aGridColName = rName;}
    Color                   GetGridColor( String* pStrName = NULL ) const;

    const ScGridOptions&    GetGridOptions() const                      { return aGridOpt; }
    void                    SetGridOptions( const ScGridOptions& rNew ) { aGridOpt = rNew; }
    SvxGridItem*            CreateGridItem( USHORT nId = SID_ATTR_GRID_OPTIONS ) const;

    BOOL                    IsHideAutoSpell() const             { return bHideAutoSpell; }
    void                    SetHideAutoSpell( BOOL bSet )       { bHideAutoSpell = bSet; }

    const ScViewOptions&    operator=  ( const ScViewOptions& rCpy );
    int                     operator== ( const ScViewOptions& rOpt ) const;
    int                     operator!= ( const ScViewOptions& rOpt ) const { return !(operator==(rOpt)); }

    friend SvStream&        operator>> ( SvStream& rStream, ScViewOptions& rOpt );

    void                    Save(SvStream& rStream, BOOL bConfig = FALSE) const;

private:
    BOOL            aOptArr     [MAX_OPT];
    ScVObjMode      aModeArr    [MAX_TYPE];
    Color           aGridCol;
    String          aGridColName;
    ScGridOptions   aGridOpt;
    BOOL            bHideAutoSpell;
};

inline SvStream& operator<<( SvStream& rStream, const ScViewOptions& rOpt )
{
    rOpt.Save( rStream, FALSE );
    return rStream;
}

//==================================================================
// Item fuer Einstellungsdialog - Ansicht
//==================================================================

class ScTpViewItem : public SfxPoolItem
{
public:
                TYPEINFO();
                ScTpViewItem( USHORT nWhich );
                ScTpViewItem( USHORT nWhich, const ScViewOptions& rOpt );
                ScTpViewItem( const ScTpViewItem&  rItem );
                ~ScTpViewItem();

    virtual String          GetValueText() const;
    virtual int             operator==( const SfxPoolItem& ) const;
    virtual SfxPoolItem*    Clone( SfxItemPool *pPool = 0 ) const;

    const ScViewOptions&    GetViewOptions() const { return theOptions; }

private:
    ScViewOptions   theOptions;
};

//  ConfigItem for classes that use items from several sub trees
//! move to separate header file

class ScLinkConfigItem : public utl::ConfigItem
{
    Link    aCommitLink;

public:
            ScLinkConfigItem( const rtl::OUString rSubTree );
    void    SetCommitLink( const Link& rLink );

    virtual void    Notify( const com::sun::star::uno::Sequence<rtl::OUString>& aPropertyNames );
    virtual void    Commit();

    void    SetModified()   { ConfigItem::SetModified(); }
    com::sun::star::uno::Sequence< com::sun::star::uno::Any>
            GetProperties(const com::sun::star::uno::Sequence< rtl::OUString >& rNames)
                            { return ConfigItem::GetProperties( rNames ); }
    sal_Bool PutProperties( const com::sun::star::uno::Sequence< rtl::OUString >& rNames,
                            const com::sun::star::uno::Sequence< com::sun::star::uno::Any>& rValues)
                            { return ConfigItem::PutProperties( rNames, rValues ); }
    sal_Bool EnableNotification(com::sun::star::uno::Sequence< rtl::OUString >& rNames)
                            { return ConfigItem::EnableNotification( rNames ); }
};

//==================================================================
// CfgItem fuer View-Optionen
//==================================================================

class ScViewCfg : public ScViewOptions
{
    ScLinkConfigItem    aLayoutItem;
    ScLinkConfigItem    aDisplayItem;
    ScLinkConfigItem    aGridItem;

    DECL_LINK( LayoutCommitHdl, void* );
    DECL_LINK( DisplayCommitHdl, void* );
    DECL_LINK( GridCommitHdl, void* );

    com::sun::star::uno::Sequence<rtl::OUString> GetLayoutPropertyNames();
    com::sun::star::uno::Sequence<rtl::OUString> GetDisplayPropertyNames();
    com::sun::star::uno::Sequence<rtl::OUString> GetGridPropertyNames();

public:
            ScViewCfg();

    void            SetOptions( const ScViewOptions& rNew );
};

#endif

<|endoftext|>


<commit_before>/*************************************************************************
 *
 *  $RCSfile: reffld.hxx,v $
 *
 *  $Revision: 1.3 $
 *
 *  last change: $Author: os $ $Date: 2002-01-11 13:59:20 $
 *
 *  The Contents of this file are made available subject to the terms of
 *  either of the following licenses
 *
 *         - GNU Lesser General Public License Version 2.1
 *         - Sun Industry Standards Source License Version 1.1
 *
 *  Sun Microsystems Inc., October, 2000
 *
 *  GNU Lesser General Public License Version 2.1
 *  =============================================
 *  Copyright 2000 by Sun Microsystems, Inc.
 *  901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License version 2.1, as published by the Free Software Foundation.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *  MA  02111-1307  USA
 *
 *
 *  Sun Industry Standards Source License Version 1.1
 *  =================================================
 *  The contents of this file are subject to the Sun Industry Standards
 *  Source License Version 1.1 (the "License"); You may not use this file
 *  except in compliance with the License. You may obtain a copy of the
 *  License at http://www.openoffice.org/license.html.
 *
 *  Software provided under this License is provided on an "AS IS" basis,
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 *  See the License for the specific provisions governing your rights and
 *  obligations concerning the Software.
 *
 *  The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 *
 *  Copyright: 2000 by Sun Microsystems, Inc.
 *
 *  All Rights Reserved.
 *
 *  Contributor(s): _______________________________________
 *
 *
 ************************************************************************/
#ifndef _REFFLD_HXX
#define _REFFLD_HXX

#ifndef _FLDBAS_HXX
#include <fldbas.hxx>
#endif

class SfxPoolItem;
class SwDoc;
class SwTxtAttr;
class SwTxtNode;

enum REFERENCESUBTYPE
{
    REF_SETREFATTR = 0,
    REF_SEQUENCEFLD,
    REF_BOOKMARK,
    REF_OUTLINE,
    REF_FOOTNOTE,
    REF_ENDNOTE
};

enum REFERENCEMARK
{
    REF_BEGIN,
    REF_PAGE = REF_BEGIN,
    REF_CHAPTER,
    REF_CONTENT,
    REF_UPDOWN,
    REF_PAGE_PGDESC,
    REF_ONLYNUMBER,
    REF_ONLYCAPTION,
    REF_ONLYSEQNO,
    REF_END
};

/*--------------------------------------------------------------------
    Beschreibung: Referenz holen
 --------------------------------------------------------------------*/

class SwGetRefFieldType : public SwFieldType
{
    SwDoc* pDoc;
public:
    SwGetRefFieldType(SwDoc* pDoc );
    virtual SwFieldType*    Copy() const;

    SwDoc*                  GetDoc() const { return pDoc; }
    // ueberlagert, um alle Ref-Felder zu updaten
    virtual void Modify( SfxPoolItem *, SfxPoolItem * );

    void MergeWithOtherDoc( SwDoc& rDestDoc );

    static SwTxtNode* FindAnchor( SwDoc* pDoc, const String& rRefMark,
                                        USHORT nSubType, USHORT nSeqNo,
                                        USHORT* pStt, USHORT* pEnd = 0 );
};

/*--------------------------------------------------------------------
    Beschreibung: Referenzfeld
 --------------------------------------------------------------------*/

class SwGetRefField : public SwField
{
    String sSetRefName;
    String sTxt;
    USHORT nSubType;
    USHORT nSeqNo;
public:
    SwGetRefField( SwGetRefFieldType*, const String& rSetRef,
                    USHORT nSubType, USHORT nSeqNo, ULONG nFmt );

    virtual String      GetCntnt(BOOL bName = FALSE) const;
    virtual String      Expand() const;
    virtual SwField*    Copy() const;

    const String&       GetSetRefName() const { return sSetRefName; }

    void                UpdateField();
    void                SetExpand( const String& rStr ) { sTxt = rStr; }

    // SubType erfragen/setzen
    virtual USHORT      GetSubType() const;
    virtual void        SetSubType( USHORT n );

    // SequenceNo erfragen/setzen (nur fuer REF_SEQUENCEFLD interressant)
    USHORT              GetSeqNo() const        { return nSeqNo; }
    void                SetSeqNo( USHORT n )    { nSeqNo = n; }

    // Name der Referenz
    virtual const String& GetPar1() const;
    virtual void        SetPar1(const String& rStr);

    virtual String      GetPar2() const;
    virtual BOOL        QueryValue( com::sun::star::uno::Any& rVal, BYTE nMId ) const;
    virtual BOOL        PutValue( const com::sun::star::uno::Any& rVal, BYTE nMId );

    void                ConvertProgrammaticToUIName();
};

#endif // _REFFLD_HXX

<commit_msg>INTEGRATION: CWS swundo03 (1.3.728); FILE MERGED 2004/07/07 16:42:52 hbrinkm 1.3.728.1: #115575# GetDescription<commit_after>/*************************************************************************
 *
 *  $RCSfile: reffld.hxx,v $
 *
 *  $Revision: 1.4 $
 *
 *  last change: $Author: hr $ $Date: 2004-09-08 14:51:18 $
 *
 *  The Contents of this file are made available subject to the terms of
 *  either of the following licenses
 *
 *         - GNU Lesser General Public License Version 2.1
 *         - Sun Industry Standards Source License Version 1.1
 *
 *  Sun Microsystems Inc., October, 2000
 *
 *  GNU Lesser General Public License Version 2.1
 *  =============================================
 *  Copyright 2000 by Sun Microsystems, Inc.
 *  901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License version 2.1, as published by the Free Software Foundation.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *  MA  02111-1307  USA
 *
 *
 *  Sun Industry Standards Source License Version 1.1
 *  =================================================
 *  The contents of this file are subject to the Sun Industry Standards
 *  Source License Version 1.1 (the "License"); You may not use this file
 *  except in compliance with the License. You may obtain a copy of the
 *  License at http://www.openoffice.org/license.html.
 *
 *  Software provided under this License is provided on an "AS IS" basis,
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 *  See the License for the specific provisions governing your rights and
 *  obligations concerning the Software.
 *
 *  The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 *
 *  Copyright: 2000 by Sun Microsystems, Inc.
 *
 *  All Rights Reserved.
 *
 *  Contributor(s): _______________________________________
 *
 *
 ************************************************************************/
#ifndef _REFFLD_HXX
#define _REFFLD_HXX

#ifndef _FLDBAS_HXX
#include <fldbas.hxx>
#endif

class SfxPoolItem;
class SwDoc;
class SwTxtAttr;
class SwTxtNode;

enum REFERENCESUBTYPE
{
    REF_SETREFATTR = 0,
    REF_SEQUENCEFLD,
    REF_BOOKMARK,
    REF_OUTLINE,
    REF_FOOTNOTE,
    REF_ENDNOTE
};

enum REFERENCEMARK
{
    REF_BEGIN,
    REF_PAGE = REF_BEGIN,
    REF_CHAPTER,
    REF_CONTENT,
    REF_UPDOWN,
    REF_PAGE_PGDESC,
    REF_ONLYNUMBER,
    REF_ONLYCAPTION,
    REF_ONLYSEQNO,
    REF_END
};

/*--------------------------------------------------------------------
    Beschreibung: Referenz holen
 --------------------------------------------------------------------*/

class SwGetRefFieldType : public SwFieldType
{
    SwDoc* pDoc;
public:
    SwGetRefFieldType(SwDoc* pDoc );
    virtual SwFieldType*    Copy() const;

    SwDoc*                  GetDoc() const { return pDoc; }
    // ueberlagert, um alle Ref-Felder zu updaten
    virtual void Modify( SfxPoolItem *, SfxPoolItem * );

    void MergeWithOtherDoc( SwDoc& rDestDoc );

    static SwTxtNode* FindAnchor( SwDoc* pDoc, const String& rRefMark,
                                        USHORT nSubType, USHORT nSeqNo,
                                        USHORT* pStt, USHORT* pEnd = 0 );
};

/*--------------------------------------------------------------------
    Beschreibung: Referenzfeld
 --------------------------------------------------------------------*/

class SwGetRefField : public SwField
{
    String sSetRefName;
    String sTxt;
    USHORT nSubType;
    USHORT nSeqNo;
public:
    SwGetRefField( SwGetRefFieldType*, const String& rSetRef,
                    USHORT nSubType, USHORT nSeqNo, ULONG nFmt );

    virtual String      GetCntnt(BOOL bName = FALSE) const;
    virtual String      Expand() const;
    virtual SwField*    Copy() const;

    const String&       GetSetRefName() const { return sSetRefName; }

    void                UpdateField();
    void                SetExpand( const String& rStr ) { sTxt = rStr; }

    // SubType erfragen/setzen
    virtual USHORT      GetSubType() const;
    virtual void        SetSubType( USHORT n );

    // SequenceNo erfragen/setzen (nur fuer REF_SEQUENCEFLD interressant)
    USHORT              GetSeqNo() const        { return nSeqNo; }
    void                SetSeqNo( USHORT n )    { nSeqNo = n; }

    // Name der Referenz
    virtual const String& GetPar1() const;
    virtual void        SetPar1(const String& rStr);

    virtual String      GetPar2() const;
    virtual BOOL        QueryValue( com::sun::star::uno::Any& rVal, BYTE nMId ) const;
    virtual BOOL        PutValue( const com::sun::star::uno::Any& rVal, BYTE nMId );

    void                ConvertProgrammaticToUIName();

    virtual String GetDescription() const;
};

#endif // _REFFLD_HXX

<|endoftext|>


<commit_before>// $Id$
//
// Test Suite for geos::operation::overlay::snap::GeometrySnapper class.

// tut
#include <tut.hpp>
// geos
#include <geos/operation/overlay/snap/GeometrySnapper.h>
#include <geos/geom/Geometry.h>
#include <geos/geom/GeometryFactory.h>
#include <geos/io/WKTReader.h>
// std
#include <memory>
#include <string>
#include <vector>

namespace tut
{
    //
    // Test Group
    //

    // Common data used by tests
    struct test_geometrysnapper_data
    {
        typedef std::auto_ptr<geos::geom::Geometry> GeomAutoPtr;

        geos::geom::GeometryFactory factory;

        geos::io::WKTReader reader;

        GeomAutoPtr src;

        geos::operation::overlay::snap::GeometrySnapper snapper;

        test_geometrysnapper_data()
                :
                factory(), // initialize before use!
                reader(&factory),
                src(reader.read(
                        "POLYGON ((0 0, 0 100, 100 100, 100 0, 0 0))"
                )),
                snapper( *(src.get()) )

        {
        }
    };

    typedef test_group<test_geometrysnapper_data> group;
    typedef group::object object;

    group test_geometrysnapper_group("geos::operation::overlay::snap::GeometrySnapper");

    //
    // Test Cases
    //

    // Test vertices snapping
    template<>
    template<>
    void object::test<1>()
    {
        GeomAutoPtr snap(reader.read(
                "MULTIPOINT ((0 0), (0 100.0000001), (100 100), (100 0))"
        ));

        GeomAutoPtr expected(reader.read(
                "POLYGON ((0 0, 0 100.0000001, 100 100, 100 0, 0 0))"
        ));

        GeomAutoPtr ret(snapper.snapTo( *(snap.get()), 0.000001 ));

        ensure( ret->equalsExact(expected.get(),0) );

    }

    // Test vertices snapping
    template<>
    template<>
    void object::test<2>()
    {
        GeomAutoPtr snap(reader.read(
                "MULTIPOINT ((0.0000001 50))"
        ));

        GeomAutoPtr expected(reader.read(
                "POLYGON ((0 0, 0.0000001 50, 0 100, 100 100, 100 0, 0 0))"
        ));

        GeomAutoPtr ret(snapper.snapTo( *(snap.get()), 0.000001 ));

        ensure( ret->equalsExact(expected.get(),0) );
    }

} // namespace tut
<commit_msg>Allow testing snapping something different from a single polygon..<commit_after>// $Id$
//
// Test Suite for geos::operation::overlay::snap::GeometrySnapper class.

// tut
#include <tut.hpp>
// geos
#include <geos/operation/overlay/snap/GeometrySnapper.h>
#include <geos/geom/Geometry.h>
#include <geos/geom/GeometryFactory.h>
#include <geos/io/WKTReader.h>
// std
#include <memory>
#include <string>
#include <vector>

namespace tut
{
    //
    // Test Group
    //

    // Common data used by tests
    struct test_geometrysnapper_data
    {
        typedef std::auto_ptr<geos::geom::Geometry> GeomAutoPtr;

        geos::geom::GeometryFactory factory;

        geos::io::WKTReader reader;

        typedef geos::operation::overlay::snap::GeometrySnapper GeometrySnapper;

        test_geometrysnapper_data()
                :
                factory(), // initialize before use!
                reader(&factory)
        {
        }
    };

    typedef test_group<test_geometrysnapper_data> group;
    typedef group::object object;

    group test_geometrysnapper_group("geos::operation::overlay::snap::GeometrySnapper");

    //
    // Test Cases
    //

    // Test vertices snapping
    template<>
    template<>
    void object::test<1>()
    {
        GeomAutoPtr src(reader.read(
                "POLYGON ((0 0, 0 100, 100 100, 100 0, 0 0))"
        ));

        GeometrySnapper snapper( *(src.get()) );

        GeomAutoPtr snap(reader.read(
                "MULTIPOINT ((0 0), (0 100.0000001), (100 100), (100 0))"
        ));

        GeomAutoPtr expected(reader.read(
                "POLYGON ((0 0, 0 100.0000001, 100 100, 100 0, 0 0))"
        ));

        GeomAutoPtr ret(snapper.snapTo( *(snap.get()), 0.000001 ));

        ensure( ret->equalsExact(expected.get(),0) );

    }

    // Test vertices snapping
    template<>
    template<>
    void object::test<2>()
    {
        GeomAutoPtr src(reader.read(
                "POLYGON ((0 0, 0 100, 100 100, 100 0, 0 0))"
        ));

        GeometrySnapper snapper( *(src.get()) );

        GeomAutoPtr snap(reader.read(
                "MULTIPOINT ((0.0000001 50))"
        ));

        GeomAutoPtr expected(reader.read(
                "POLYGON ((0 0, 0.0000001 50, 0 100, 100 100, 100 0, 0 0))"
        ));

        GeomAutoPtr ret(snapper.snapTo( *(snap.get()), 0.000001 ));

        ensure( ret->equalsExact(expected.get(),0) );
    }

} // namespace tut
<|endoftext|>


<commit_before>/***********************************************
 * Author: Jun Jiang - jiangjun4@sina.com
 * Create: 2017-07-27 14:48
 * Last modified : 2017-07-27 17:14
 * Filename      : MatrixHelper.cpp
 * Description   :
 **********************************************/

#include "algebra/MatrixHelper.h"
#include "utils/ParallelOperator.h"
#include <cmath>
#include <string.h>

namespace abcdl{
namespace algebra{

template<class T>
void MatrixHelper<T>::dot(Matrix<T>& mat,
						  const Matrix<T>& mat_a,
						  const Matrix<T>& mat_b){
}

template<class T>
void MatrixHelper<T>::outer(Matrix<T>& mat,
							const Matrix<T>& mat_a,
							const Matrix<T>& mat_b){
}

template<class T>
void MatrixHelper<T>::pow(Matrix<T>& mat,
						  const Matrix<T>& mat_a,
						  const T& exponent){
    auto lamda = [](T* a, const T& b, const T& c){*a = std::pow(b, c);};
    po.parallel_mul2one_copy<T>(mat_a.data(), mat_a.get_size(), exponent, mat.data(), lamda);
}

template<class T>
void MatrixHelper<T>::log(Matrix<T>& mat, const Matrix<T>& mat_a){
    auto lamda = [](T* a, const T& b){ *a = std::log(b);};
    po.parallel_mul2one_copy<T>(mat_a.data(), mat_a.get_size(), mat.data(), lamda);
}

template<class T>
void MatrixHelper<T>::exp(Matrix<T>& mat, const Matrix<T>& mat_a){
    auto lamda = [](T* a, const T& b){ *a = std::exp(std::min(b, (T)EXP_MAX));};
    po.parallel_mul2one_copy<T>(mat_a.data(), mat_a.get_size(), mat.data(), lamda);
}

template<class T>
void MatrixHelper<T>::sigmoid(Matrix<T>& mat, const Matrix<T>& mat_a){
    auto lamda = [](T* a, const T& b){ *a = 1 / (1 + std::exp(-(std::min((T)SIGMOID_MAX, std::max(b, (T)SIGMOID_MIN)))));};
    po.parallel_mul2one_copy<T>(mat_a.data(), mat_a.get_size(), mat.data(), lamda);
}

template<class T>
void MatrixHelper<T>::softmax(Matrix<T>& mat, const Matrix<T>& mat_a){
//    auto lamda = [](T* a){ *a = std::log(*a);};
//    po.parallel_mul2one<T>(_data, get_size(), lamda);
}

template<class T>
void MatrixHelper<T>::tanh(Matrix<T>& mat, const Matrix<T>& mat_a){
    auto lamda = [](T* a, const T& b){ *a = 2.0 /(1.0 + std::exp(std::min((T)EXP_MAX, -2 * b))) - 1.0;};
    po.parallel_mul2one_copy<T>(mat_a.data(), mat_a.get_size(), mat.data(), lamda);
}

template<class T>
void MatrixHelper<T>::relu(Matrix<T>& mat, const Matrix<T>& mat_a){
    auto lamda = [](T* a, const T& b){ if(b < 0) {*a = 0;} else { *a = b;}};
    po.parallel_mul2one_copy<T>(mat_a.data(), mat_a.get_size(), mat.data(), lamda);
}

template<class T>
void MatrixHelper<T>::zero_like(Matrix<T>& mat, const Matrix<T>& mat_a){
	mat.set_data(mat_a.data(), mat_a.rows(), mat_a.cols());
}

template<class T>
void transpose(Matrix<T>& mat, const Matrix<T>& mat_a){
	if(&mat != &mat_a){
		mat.set_data(mat_a.data(), mat_a.rows(), mat_a.cols());
	}

	std::size_t rows = mat.rows();
	std::size_t cols = mat.cols();
	if(mat.rows() == 1 || mat.cols() == 1){
		mat.reshape(cols, rows);
	}else{

	}
}

template class MatrixHelper<int>;
template class MatrixHelper<real>;

}//namespace algebra
}//namespace abcdl
<commit_msg>initialized<commit_after>/***********************************************
 * Author: Jun Jiang - jiangjun4@sina.com
 * Create: 2017-07-27 14:48
 * Last modified : 2017-07-27 17:14
 * Filename      : MatrixHelper.cpp
 * Description   :
 **********************************************/

#include "algebra/MatrixHelper.h"
#include "utils/ParallelOperator.h"
#include <cmath>
#include <string.h>

namespace abcdl{
namespace algebra{

template<class T>
void MatrixHelper<T>::dot(Matrix<T>& mat,
						  const Matrix<T>& mat_a,
						  const Matrix<T>& mat_b){
}

template<class T>
void MatrixHelper<T>::outer(Matrix<T>& mat,
							const Matrix<T>& mat_a,
							const Matrix<T>& mat_b){
}

template<class T>
void MatrixHelper<T>::pow(Matrix<T>& mat,
						  const Matrix<T>& mat_a,
						  const T& exponent){
    auto lamda = [](T* a, const T& b, const T& c){*a = std::pow(b, c);};
    po.parallel_mul2one_copy<T>(mat_a.data(), mat_a.get_size(), exponent, mat.data(), lamda);
}

template<class T>
void MatrixHelper<T>::log(Matrix<T>& mat, const Matrix<T>& mat_a){
    auto lamda = [](T* a, const T& b){ *a = std::log(b);};
    po.parallel_mul2one_copy<T>(mat_a.data(), mat_a.get_size(), mat.data(), lamda);
}

template<class T>
void MatrixHelper<T>::exp(Matrix<T>& mat, const Matrix<T>& mat_a){
    auto lamda = [](T* a, const T& b){ *a = std::exp(std::min(b, (T)EXP_MAX));};
    //auto lamda = [](T* a, const T& b){ *a = utils::TypeDef::exp<T>(b);};
    po.parallel_mul2one_copy<T>(mat_a.data(), mat_a.get_size(), mat.data(), lamda);
}

template<class T>
void MatrixHelper<T>::sigmoid(Matrix<T>& mat, const Matrix<T>& mat_a){
    auto lamda = [](T* a, const T& b){ *a = 1 / (1 + std::exp(-(std::min((T)SIGMOID_MAX, std::max(b, (T)SIGMOID_MIN)))));};
    po.parallel_mul2one_copy<T>(mat_a.data(), mat_a.get_size(), mat.data(), lamda);
}

template<class T>
void MatrixHelper<T>::softmax(Matrix<T>& mat, const Matrix<T>& mat_a){
//    auto lamda = [](T* a){ *a = std::log(*a);};
//    po.parallel_mul2one<T>(_data, get_size(), lamda);
}

template<class T>
void MatrixHelper<T>::tanh(Matrix<T>& mat, const Matrix<T>& mat_a){
    auto lamda = [](T* a, const T& b){ *a = 2.0 /(1.0 + std::exp(std::min((T)EXP_MAX, -2 * b))) - 1.0;};
    po.parallel_mul2one_copy<T>(mat_a.data(), mat_a.get_size(), mat.data(), lamda);
}

template<class T>
void MatrixHelper<T>::relu(Matrix<T>& mat, const Matrix<T>& mat_a){
    auto lamda = [](T* a, const T& b){ if(b < 0) {*a = 0;} else { *a = b;}};
    po.parallel_mul2one_copy<T>(mat_a.data(), mat_a.get_size(), mat.data(), lamda);
}

template<class T>
void MatrixHelper<T>::zero_like(Matrix<T>& mat, const Matrix<T>& mat_a){
	mat.set_data(mat_a.data(), mat_a.rows(), mat_a.cols());
}

template<class T>
void transpose(Matrix<T>& mat, const Matrix<T>& mat_a){
	if(&mat != &mat_a){
		mat.set_data(mat_a.data(), mat_a.rows(), mat_a.cols());
	}

	std::size_t rows = mat.rows();
	std::size_t cols = mat.cols();
	if(mat.rows() == 1 || mat.cols() == 1){
		mat.reshape(cols, rows);
	}else{

	}
}

template class MatrixHelper<int>;
template class MatrixHelper<real>;

}//namespace algebra
}//namespace abcdl
<|endoftext|>