Ejemplo n.º 1
1
void wxHtmlContainerCell::Draw(wxDC& dc, int x, int y, int view_y1, int view_y2,
                               wxHtmlRenderingInfo& info)
{
#if 0 // useful for debugging
    dc.SetPen(*wxRED_PEN);
    dc.DrawRectangle(x+m_PosX,y+m_PosY,m_Width,m_Height);
#endif

    int xlocal = x + m_PosX;
    int ylocal = y + m_PosY;

    if (m_UseBkColour)
    {
        wxBrush myb = wxBrush(m_BkColour, wxBRUSHSTYLE_SOLID);

        int real_y1 = mMax(ylocal, view_y1);
        int real_y2 = mMin(ylocal + m_Height - 1, view_y2);

        dc.SetBrush(myb);
        dc.SetPen(*wxTRANSPARENT_PEN);
        dc.DrawRectangle(xlocal, real_y1, m_Width, real_y2 - real_y1 + 1);
    }

    if (m_Border == 1)
    {
        // draw thin border using lines
        wxPen mypen1(m_BorderColour1, 1, wxPENSTYLE_SOLID);
        wxPen mypen2(m_BorderColour2, 1, wxPENSTYLE_SOLID);

        dc.SetPen(mypen1);
        dc.DrawLine(xlocal, ylocal, xlocal, ylocal + m_Height - 1);
        dc.DrawLine(xlocal, ylocal, xlocal + m_Width, ylocal);
        dc.SetPen(mypen2);
        dc.DrawLine(xlocal + m_Width - 1, ylocal, xlocal +  m_Width - 1, ylocal + m_Height - 1);
        dc.DrawLine(xlocal, ylocal + m_Height - 1, xlocal + m_Width, ylocal + m_Height - 1);
    }
    else if (m_Border> 0)
    {
        wxBrush mybrush1(m_BorderColour1, wxBRUSHSTYLE_SOLID);
        wxBrush mybrush2(m_BorderColour2, wxBRUSHSTYLE_SOLID);

        // draw upper left corner
        // 0---------------5
        // |              /
        // | 3-----------4
        // | |
        // | 2
        // |/
        // 1

        wxPoint poly[6];
        poly[0].x =m_PosX;
        poly[0].y = m_PosY ;
        poly[1].x =m_PosX;
        poly[1].y = m_PosY + m_Height;
        poly[2].x =m_PosX + m_Border;
        poly[2].y = poly[1].y - m_Border;
        poly[3].x =poly[2].x ;
        poly[3].y = m_PosY + m_Border;
        poly[4].x =m_PosX + m_Width - m_Border;
        poly[4].y = poly[3].y;
        poly[5].x =m_PosX + m_Width;
        poly[5].y = m_PosY;

        dc.SetBrush(mybrush1);
        dc.SetPen(*wxTRANSPARENT_PEN);
        dc.DrawPolygon(6, poly, x, y);

        // draw lower right corner reusing point 1,2,4 and 5
        //                 5
        //                /|
        //               4 |
        //               | |
        //   2-----------3 |
        //  /              |
        // 1---------------0
        dc.SetBrush(mybrush2);
        poly[0].x = poly[5].x;
        poly[0].y = poly[1].y;
        poly[3].x = poly[4].x;
        poly[3].y = poly[2].y;
        dc.DrawPolygon(6, poly, x, y);

        // smooth color transition like firefox
        wxColour borderMediumColour(
            (m_BorderColour1.Red() + m_BorderColour2.Red()) /2 ,
            (m_BorderColour1.Green() + m_BorderColour2.Green()) /2 ,
            (m_BorderColour1.Blue() + m_BorderColour2.Blue()) /2
        );
        wxPen mypen3(borderMediumColour, 1, wxPENSTYLE_SOLID);
        dc.SetPen(mypen3);
        dc.DrawLines(2, &poly[1], x, y - 1); // between 1 and 2
        dc.DrawLines(2, &poly[4], x, y - 1); // between 4 and 5
    }
    if (m_Cells)
    {
        // draw container's contents:
        for (wxHtmlCell *cell = m_Cells; cell; cell = cell->GetNext())
        {

            // optimize drawing: don't render off-screen content:
            if ((ylocal + cell->GetPosY() <= view_y2) &&
                    (ylocal + cell->GetPosY() + cell->GetHeight() > view_y1))
            {
                // the cell is visible, draw it:
                UpdateRenderingStatePre(info, cell);
                cell->Draw(dc,
                           xlocal, ylocal, view_y1, view_y2,
                           info);
                UpdateRenderingStatePost(info, cell);
            }
            else
            {
                // the cell is off-screen, proceed with font+color+etc.
                // changes only:
                cell->DrawInvisible(dc, xlocal, ylocal, info);
            }
        }
    }
}
Ejemplo n.º 2
0
SpBasis::SpBasis(double _omega, int _nMax, int _lMax) :
  Basis(std::string("SpBasis"),
        std::vector<std::string>(
{
  "n", "l", "m", "s"
})),
omega(_omega),
      nMax(_nMax),
      lMax(_nMax + 1),
      mMax(_nMax + 1, _lMax + 1)
{
  //Defining maximum numbers and determining basis size
  size = 0;

  for (int n = 0; n <= nMax; n++)
  {
    // Here to specify lMax dependency on n
    lMax(n) = _lMax;

    for (int l = 0; l <= lMax(n); l++)
    {
      mMax(n, l) = l;
      size += 2 * l + 1;
    }
  }

  //Considering spin
  size *= 2;
  //Filling the quantum numbers for each state
  qNumbers = arma::imat(size, qNumSize);
  int i = 0;

  for (int s = -1; s <= 1; s += 2)
    for (int n = 0; n <= nMax; n++)
      for (int l = 0; l <= lMax(n); l++)
        for (int m = -mMax(n, l); m <= mMax(n, l); m++)
        {
          qNumbers(i, 0) = n;
          qNumbers(i, 1) = l;
          qNumbers(i, 2) = m;
          qNumbers(i, 3) = s;
          i++;
        }

  //Calculating N normalization coefficients
  nu = NUCLEON_MASS * omega / 2 / HBAR;
  N = arma::zeros<arma::vec>(size);
  calcN();
}
Ejemplo n.º 3
0
/**
 * Performs ray/box intersection. Returns true if the ray
 * intersects the box, and the hit time for the entry/exit
 * in tmin/tmax respectively.
 */
bool AABB::intersect(const Ray& ray, float& tmin, float& tmax) const
{
	float t0 = ray.minT;
	float t1 = ray.maxT;

	// Loop over the three axes and compute the hit time for the
	// two axis-aligned bounding box planes in each, decreasing the
	// parametric range of the ray until start>end time, which means
	// the ray missed the box, or until we finish which means there
	// is an intersection.
	for (int i = 0; i < 3; i++) {
		float invDir = 1.0f / ray.dir(i);
		float tNear = (mMin(i) - ray.orig(i)) * invDir;
		float tFar  = (mMax(i) - ray.orig(i)) * invDir;
		
		if (tNear > tFar) swap(tNear,tFar);
		
		if (tNear > t0) t0 = tNear;
		if (tFar < t1) t1 = tFar;
		if (t0 > t1) return false;
	}
	
	tmin = t0;
	tmax = t1;
	return true;
}
Ejemplo n.º 4
0
	/**
	 * Expands the capacity of the array so that it automatically has
	 * enough space. It is 1.5x size growth
	 */
	void expand()
	{
		mAllocSize = mCeil(mMax(1, mAllocSize) * 1.5f);

		mArray = reinterpret_cast<T*>(realloc(mArray, mAllocSize * sizeof(T)));
		
		// we could potentially be allocating a LOT of memory. Check to make sure
		// the allocation was successful.
		if (mArray == nullptr)
		{
			// TODO: Implement some message box in here to say we are out of
			// memory.
			exit(-1);
		}
	}
Ejemplo n.º 5
0
void wxHtmlContainerCell::Draw(wxDC& dc, int x, int y, int view_y1, int view_y2,
                               wxHtmlRenderingInfo& info)
{
#if 0 // useful for debugging
    dc.SetPen(*wxRED_PEN);
    dc.DrawRectangle(x+m_PosX,y+m_PosY,m_Width,m_Height);
#endif

    int xlocal = x + m_PosX;
    int ylocal = y + m_PosY;

    if (m_UseBkColour)
    {
        wxBrush myb = wxBrush(m_BkColour, wxSOLID);

        int real_y1 = mMax(ylocal, view_y1);
        int real_y2 = mMin(ylocal + m_Height - 1, view_y2);

        dc.SetBrush(myb);
        dc.SetPen(*wxTRANSPARENT_PEN);
        dc.DrawRectangle(xlocal, real_y1, m_Width, real_y2 - real_y1 + 1);
    }

    if (m_UseBorder)
    {
        wxPen mypen1(m_BorderColour1, 1, wxSOLID);
        wxPen mypen2(m_BorderColour2, 1, wxSOLID);

        dc.SetPen(mypen1);
        dc.DrawLine(xlocal, ylocal, xlocal, ylocal + m_Height - 1);
        dc.DrawLine(xlocal, ylocal, xlocal + m_Width, ylocal);
        dc.SetPen(mypen2);
        dc.DrawLine(xlocal + m_Width - 1, ylocal, xlocal +  m_Width - 1, ylocal + m_Height - 1);
        dc.DrawLine(xlocal, ylocal + m_Height - 1, xlocal + m_Width, ylocal + m_Height - 1);
    }

    if (m_Cells)
    {
        // draw container's contents:
        for (wxHtmlCell *cell = m_Cells; cell; cell = cell->GetNext())
        {

            // optimize drawing: don't render off-screen content:
            if ((ylocal + cell->GetPosY() <= view_y2) &&
                    (ylocal + cell->GetPosY() + cell->GetHeight() > view_y1))
            {
                // the cell is visible, draw it:
                UpdateRenderingStatePre(info, cell);
                cell->Draw(dc,
                           xlocal, ylocal, view_y1, view_y2,
                           info);
                UpdateRenderingStatePost(info, cell);
            }
            else
            {
                // the cell is off-screen, proceed with font+color+etc.
                // changes only:
                cell->DrawInvisible(dc, xlocal, ylocal, info);
            }
        }
    }
}