コード例 #1
0
ファイル: print.cpp プロジェクト: frenchjl/stan
int calculate_column_width(const Eigen::VectorXd& x,
                           const std::string& name,
                           const int sig_figs,
                           std::ios_base::fmtflags& format) {

  int padding = 2;
  
  // Fixed Precision
  size_t fixed_threshold = 8;
  size_t max_fixed_width = 0;
  
  for (int i = 0; i < x.size(); ++i) {
    size_t width = compute_width(x[i], sig_figs);
    max_fixed_width = width > max_fixed_width ? width : max_fixed_width;
  }
  
  if (max_fixed_width + padding < fixed_threshold) {
    format = std::ios_base::fixed;
    max_fixed_width = name.length() > max_fixed_width ? name.length() : max_fixed_width;
    return max_fixed_width + padding;
  }
  
  // Scientific Notation
  size_t scientific_width = sig_figs + 1 + 4; // Decimal place + exponent
  if (x.minCoeff() < 0) ++scientific_width;
  
  scientific_width = name.length() > scientific_width ? name.length() : scientific_width;
  
  format = std::ios_base::scientific;
  return scientific_width + padding;
  
}
コード例 #2
0
ファイル: converting_stage.c プロジェクト: Radugr7/ls
void	edit_based_on_flags(t_mod *data)
{
	if (data->precision == 1 && data->procent == 0)
	{
		if (data->specifier != 's' && data->specifier != 'c')
		{
			stock_precision(data);
			compute_precision(data);
		}
		else
			edit_strings_precision(data);
	}
	if (data->hash_mod == 1)
		case_hash(data);
	if (data->width == 1)
		stock_width(data);
	if (data->zero_mod == 1)
		case_zero(data);
	if (data->plus_mod == 1)
		case_plus(data);
	if (data->dot_mod == 1)
		case_dot(data);
	compute_width(data);
	if (data->space_mod == 1 && data->plus_mod == 0)
		case_space(data);
	edit_wide_flags(data);
	edit_wildcard(data);
}
コード例 #3
0
static void
ChangeManaged (RestraintWidget w)
{
  Widget child = NULL;
  int i;
  /* Find the child, if any. */
  for (i = 0; i < w->composite.num_children; i++)
    if (XtIsManaged (w->composite.children[i]))
      {
	child = w->composite.children[i];
	/* There can only be one! */
	break;
      }

  ON_DEBUG(printf ("Restraint::ChangeManaged: my size = %d x %d\n",
		   w->core.width, w->core.height));
  ON_DEBUG(printf ("  Num children = %d, child = 0x%p\n",
		   w->composite.num_children, child));

  /* If this is our first child, compute initial sizing. */
  /* Tried using !XtIsRealized (w) to do this stuff when were
     are being realized, but this doesn't handle the case of this
     widget being realized before it has a child.  This code will
     handle both cases correctly. */
  ON_DEBUG(printf ("  Checking for width calc\n    child = 0x%p, first = %d\n",
		   child, w->restraint.had_child));
  if (child != NULL && w->restraint.had_child == False)
    {
      compute_width (w, child);
      /* Q: Should this be reset when last child is deleted, so next new
	 child causes another width computation? 14:54 02/03/93 DJB */
      w->restraint.had_child = True;
    }

  /* Force child to take on my width. */
  if (child != NULL)
    {
      compute_height (w, child);
      ON_DEBUG(printf ("Restraint::ChangeManaged: sizing child to %d x %d\n",
		       w->core.width, w->core.height));
      XtResizeWidget (child, w->core.width, w->core.height, 0);
    }

  ON_DEBUG(printf ("----\n"));
  /* Do Motif bookkeeping. */
  _XmNavigChangeManaged ((Widget) w);
}
コード例 #4
0
ファイル: lomse_shape_barline.cpp プロジェクト: gouchi/lenmus
//=======================================================================================
// GmoShapeBarline implementation
//=======================================================================================
GmoShapeBarline::GmoShapeBarline(ImoObj* pCreatorImo, ShapeId idx, int nBarlineType,
                                 LUnits xPos, LUnits yTop,
						         LUnits yBottom, LUnits uThinLineWidth,
                                 LUnits uThickLineWidth, LUnits uSpacing,
                                 LUnits uRadius, Color color, LUnits uMinWidth)
    : GmoSimpleShape(pCreatorImo, GmoObj::k_shape_barline, idx, color)
    , m_nBarlineType(nBarlineType)
    , m_uxLeft(xPos)
    , m_uThinLineWidth(uThinLineWidth)
    , m_uThickLineWidth(uThickLineWidth)
    , m_uSpacing(uSpacing)
    , m_uRadius(uRadius)
{
    m_origin.x = xPos;
    m_origin.y = yTop;
    m_size.height = yBottom - yTop;
    m_size.width = uMinWidth;
    compute_width();
}