当前位置: 首页>>代码示例>>C++>>正文


C++ Recti类代码示例

本文整理汇总了C++中Recti的典型用法代码示例。如果您正苦于以下问题:C++ Recti类的具体用法?C++ Recti怎么用?C++ Recti使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Recti类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: calculateOverlayItemLayout

//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void Rendering::renderOverlayItems(OpenGLContext* oglContext, bool useSoftwareRendering)
{
    OverlayItemRectMap itemRectMap;
    calculateOverlayItemLayout(&itemRectMap);
    
    // Must setup a scissor to limit the overlay items to the current viewport, as they might setup a local viewport (e.g. navigation cube)
    GLboolean scissorWasOn = glIsEnabled(GL_SCISSOR_TEST);
    int scissorBox[4] = {0, 0, -1, -1};
    glGetIntegerv(GL_SCISSOR_BOX, scissorBox);
    glScissor(static_cast<GLsizei>(m_camera->viewport()->x()), static_cast<GLsizei>(m_camera->viewport()->y()), static_cast<GLsizei>(m_camera->viewport()->width()), static_cast<GLsizei>(m_camera->viewport()->height()));
    glEnable(GL_SCISSOR_TEST);

    OverlayItemRectMap::iterator it;
    for (it = itemRectMap.begin(); it != itemRectMap.end(); ++it)
    {
        OverlayItem* item = it->first;
        Recti rect = it->second;

        if (useSoftwareRendering)
        {
            item->renderSoftware(oglContext, rect.min(), Vec2ui(static_cast<cvf::uint>(rect.width()), static_cast<cvf::uint>(rect.height())));
        }
        else
        {
            item->render(oglContext, rect.min(),  Vec2ui(static_cast<cvf::uint>(rect.width()), static_cast<cvf::uint>(rect.height())));
        }
    }

    // Restore scissor settings
    if (!scissorWasOn) glDisable(GL_SCISSOR_TEST);
    glScissor(scissorBox[0], scissorBox[1], scissorBox[2], scissorBox[3]); 
}
开发者ID:magnesj,项目名称:CustomVisualizationCore,代码行数:35,代码来源:cvfRendering.cpp

示例2: mousePressEvent

	void Moveable::mousePressEvent( MousePressEvent& event )
	{
		int gx, gy;
		Recti rcorner;


		raise();
		event.position( _lx, _ly );
		size( rcorner.x, rcorner.y );
		rcorner.x -= 18;
		rcorner.y -= 18;
		rcorner.setSize( 18, 18 );
		if( rcorner.contains( _lx, _ly  ) && !_togglebutton.state() ) {
			_activeMode = 2;
		} else {
			event.position( gx, gy );
			mapGlobal( gx, gy );
			_activeWidget = childAt( gx, gy );
			if( _activeWidget ) {
				mapGlobal( event.x, event.y );
				_activeWidget->mapLocal( event.x, event.y );
				_activeWidget->mousePressEvent( event );
			} else {
				_activeMode = 1;
			}
		}
	}
开发者ID:MajorBreakfast,项目名称:cvt,代码行数:27,代码来源:Moveable.cpp

示例3: paintChild

	void Widget::paintChild( Widget* w, GFX& gfx, const Recti& rect ) const
	{
		if( w->parent() != this )
			return;

		/* get current cliprect and translation */
		Recti cliprect = gfx.clipRect();
		Vector2i gtransold;
		gfx.getTranslationGlobal( gtransold );
		/* get child rectangle in global coords */
		Recti newcliprect = w->rect();
		Recti childrect = newcliprect;

		newcliprect.intersect( cliprect );

		/* set new clipping  */
		gfx.setClipRect( newcliprect );
		/* do painting with default GFX, only paint currently visible part */
		newcliprect.intersect( rect );
		PaintEvent pe( newcliprect );
		gfx.setTranslationGlobal( Vector2i( childrect.x, childrect.y ) );
		gfx.setDefault();
		w->paintEvent( pe, gfx );
		/* restore old viewport */
		gfx.setTranslationGlobal( gtransold );
		gfx.setDefault();
		gfx.setClipRect( cliprect );
	}
开发者ID:MajorBreakfast,项目名称:cvt,代码行数:28,代码来源:Widget.cpp

示例4: contains

bool Recti::contains(const Recti &rect) const
{
	return getLeft() < rect.getRight() &&
		getRight() > rect.getLeft() &&
		getTop() < rect.getTop() &&
		getBottom() > rect.getBottom();
}
开发者ID:hkbruvold,项目名称:x2D-Game-Engine,代码行数:7,代码来源:rect.cpp

示例5: TYPED_TEST

 TYPED_TEST(BufferTest, ShouldReturnRect) {
   Buffer<TypeParam> buffer(50, 50);
   Recti rect = buffer.rect();
   ASSERT_EQ(0, rect.x());
   ASSERT_EQ(0, rect.y());
   ASSERT_EQ(50, rect.width());
   ASSERT_EQ(50, rect.height());
 }
开发者ID:tkadauke,项目名称:raytracer,代码行数:8,代码来源:BufferTest.cpp

示例6: CORRADE_VERIFY

void RangeTest::subclassTypes() {
    const Vector2i a;
    CORRADE_VERIFY((std::is_same<decltype(Recti::fromSize(a, a)), Recti>::value));

    const Recti r;
    CORRADE_VERIFY((std::is_same<decltype(r.translated(a)), Recti>::value));
    CORRADE_VERIFY((std::is_same<decltype(r.padded(a)), Recti>::value));
    CORRADE_VERIFY((std::is_same<decltype(r.scaled(a)), Recti>::value));
}
开发者ID:ArEnSc,项目名称:magnum,代码行数:9,代码来源:RangeTest.cpp

示例7: calculateOverlayItemLayout

//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void Rendering::renderOverlayItems(OpenGLContext* oglContext, bool useSoftwareRendering)
{
    OverlayItemRectMap itemRectMap;
    calculateOverlayItemLayout(&itemRectMap);
    
    // Must setup a scissor to limit the overlay items to the current viewport, as they might setup a local viewport (e.g. navigation cube)
    GLboolean scissorWasOn = glIsEnabled(GL_SCISSOR_TEST);
    int scissorBox[4] = {0, 0, -1, -1};
    glGetIntegerv(GL_SCISSOR_BOX, scissorBox);
    glScissor(static_cast<GLsizei>(m_camera->viewport()->x()), static_cast<GLsizei>(m_camera->viewport()->y()), static_cast<GLsizei>(m_camera->viewport()->width()), static_cast<GLsizei>(m_camera->viewport()->height()));
    glEnable(GL_SCISSOR_TEST);


    const size_t numOverlayItems = m_overlayItems.size();
    for (size_t i = 0; i < numOverlayItems; i++)
    {
        OverlayItem* item = m_overlayItems.at(i);

        Vec2i pos(0, 0);
        Vec2ui size(0, 0);

        if (item->layoutScheme() == OverlayItem::FIXED_POSITION)
        {
            pos = item->fixedPosition();
            size = item->sizeHint();
        }
        else
        {
            // Item should be laid out already - grab its pos/size from the layout map
            OverlayItemRectMap::iterator it = itemRectMap.find(item);
            if (it != itemRectMap.end())
            {
                Recti rect = it->second;
                pos = rect.min();
                size.set(static_cast<uint>(rect.width()), static_cast<uint>(rect.height()));
            }
        }

        if (!size.isZero())
        {
            if (useSoftwareRendering)
            {
                item->renderSoftware(oglContext, pos, size);
            }
            else
            {
                item->render(oglContext, pos, size);
            }
        }
    }


    // Restore scissor settings
    if (!scissorWasOn) glDisable(GL_SCISSOR_TEST);
    glScissor(scissorBox[0], scissorBox[1], scissorBox[2], scissorBox[3]); 
}
开发者ID:JacobStoren,项目名称:ResInsight,代码行数:59,代码来源:cvfRendering.cpp

示例8: plot

void Camera::plot(Buffer<unsigned int>& buffer, const Recti& rect, const ViewPlane::Iterator& pixel, const Colord& color) const {
  auto avergageColor = color / viewPlane()->sampler()->numSamples();
  unsigned int rgb = avergageColor.rgb();
  
  int size = pixel.pixelSize();
  if (size == 1) {
    buffer[pixel.row()][pixel.column()] = rgb;
  } else {
    for (int x = pixel.column(); x != pixel.column() + size && x < rect.right(); ++x)
      for (int y = pixel.row(); y != pixel.row() + size && y < rect.bottom(); ++y)
        buffer[y][x] = rgb;
  }
}
开发者ID:,项目名称:,代码行数:13,代码来源:

示例9: clipBy

bool Recti::clipBy(const Recti& other)
{
  int minX, minY, maxX, maxY;
  getBounds(minX, minY, maxX, maxY);

  int otherMinX, otherMinY, otherMaxX, otherMaxY;
  other.getBounds(otherMinX, otherMinY, otherMaxX, otherMaxY);

  if (minX > otherMaxX || maxX < otherMinX)
    return false;

  if (minY > otherMaxY || maxY < otherMinY)
    return false;

  if (minX < otherMinX)
    minX = otherMinX;
  if (minY < otherMinY)
    minY = otherMinY;
  if (maxX > otherMaxX)
    maxX = otherMaxX;
  if (maxY > otherMaxY)
    maxY = otherMaxY;

  setBounds(minX, minY, maxX, maxY);
  return true;
}
开发者ID:r-lyeh-forks,项目名称:Wendy,代码行数:26,代码来源:Rect.cpp

示例10: setBounds

	void Viewport::setBounds(Recti bounds)
	{
		sprite->setBounds(bounds);
		if (target.isValid())
		{
			target->setSize(bounds.getSize());
		}
	}
开发者ID:fiddleplum,项目名称:ve,代码行数:8,代码来源:viewport.cpp

示例11: calculateOverlayItemLayout

//--------------------------------------------------------------------------------------------------
/// Get the the overlay item (if any) at the given cursor position
//--------------------------------------------------------------------------------------------------
OverlayItem* Rendering::overlayItemFromWindowCoordinates(int x, int y)
{
    OverlayItemRectMap itemRectMap;
    calculateOverlayItemLayout(&itemRectMap);

    OverlayItemRectMap::iterator it;
    for (it = itemRectMap.begin(); it != itemRectMap.end(); ++it)
    {
        OverlayItem* item = it->first;
        Recti rect = it->second;

        if (item->pick(x, y, rect.min(), Vec2ui(static_cast<cvf::uint>(rect.width()), static_cast<cvf::uint>(rect.height()))))
        {
            return item;
        }
    }

    return NULL;
}
开发者ID:joelmheim,项目名称:ResInsight,代码行数:22,代码来源:cvfRendering.cpp

示例12: Draw

 void ContainerClip::Draw(Graphics &g) const {
     const Transform2d& tr = g.GetTransform();
     Recti clip = g.GetClipRect();
     Recti nclip = m_rect;
     Vector2f lt = tr.transform(nclip.GetTopLeft());
     Vector2f rb = tr.transform(nclip.GetBottomRight());
     nclip.x = std::max(0.0f,std::min(lt.x, rb.x));
     nclip.y = std::max(0.0f,std::min(lt.y, rb.y));
     nclip.w = std::max(lt.x, rb.x) - nclip.x;
     nclip.h = std::max(lt.y, rb.y) - nclip.y;
     if (nclip.w > 0 && nclip.h > 0) {
         nclip = nclip.GetIntersect(clip);
         if (nclip.w > 0 && nclip.h > 0) {
             g.SetClipRect(nclip);
             Container::Draw(g);
             g.SetClipRect(clip);
         }
     }
 }
开发者ID:andryblack,项目名称:sandbox,代码行数:19,代码来源:sb_container_clip.cpp

示例13: generate_cave

void generate_cave(Location origin, const Recti& area) {
  set<Vec2i> dug;
  set<Vec2i> edge;

  Vec2i pos = area.min() + area.dim() / 2;
  const float floor_fraction = 0.5;
  size_t n = area.volume() * floor_fraction;

  dig(origin + pos);
  dug.insert(pos);
  for (auto a : hex_dirs) {
    if (dug.find(pos + a) == dug.end()) {
      edge.insert(pos + a);
    }
  }

  while (dug.size() < n && edge.size() > 0) {
    auto pick = rand_choice(edge);
    pos = *pick;

    int n_floor = 0;
    for (auto a : hex_dirs)
      if (dug.find(pos + a) != dug.end())
        n_floor++;

    // Decide whether to dig here. Prefer to dig in closed quarters and
    // destroy singleton pillars.
    if (n_floor < 6 && rand_int(n_floor * n_floor) > 1)
      continue;

    edge.erase(pick);

    dig(origin + pos);
    dug.insert(pos);
    for (auto a : hex_dirs) {
      if (dug.find(pos + a) == dug.end() && area.contains(pos + a)) {
        edge.insert(pos + a);
      }
    }
  }
}
开发者ID:rsaarelm,项目名称:telos,代码行数:41,代码来源:cavegen.cpp

示例14: oglRect

//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
bool OverlayScalarMapperLegend::pick(int oglXCoord, int oglYCoord, const Vec2i& position, const Vec2ui& size)
{
    Recti oglRect(position, size.x(), size.y());

    OverlayColorLegendLayoutInfo layoutInViewPortCoords(oglRect.min(), Vec2ui(oglRect.width(), oglRect.height()));
    layoutInfo(&layoutInViewPortCoords);

    Vec2i legendBarOrigin = oglRect.min();
    legendBarOrigin.x() += static_cast<uint>(layoutInViewPortCoords.legendRect.min().x());
    legendBarOrigin.y() += static_cast<uint>(layoutInViewPortCoords.legendRect.min().y());

    Recti legendBarRect = Recti(legendBarOrigin, static_cast<uint>(layoutInViewPortCoords.legendRect.width()), static_cast<uint>(layoutInViewPortCoords.legendRect.height()));

    if ((oglXCoord > legendBarRect.min().x()) && (oglXCoord < legendBarRect.max().x()) &&
        (oglYCoord > legendBarRect.min().y()) && (oglYCoord < legendBarRect.max().y()))
    {
        return true;
    }

    return false;
}
开发者ID:PETECLAM,项目名称:ResInsight,代码行数:24,代码来源:cvfOverlayScalarMapperLegend.cpp

示例15: calculateOverlayItemLayout

//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void Rendering::renderOverlayItems(OpenGLContext* oglContext, bool useSoftwareRendering)
{
    OverlayItemRectMap itemRectMap;
    calculateOverlayItemLayout(&itemRectMap);
    
    OverlayItemRectMap::iterator it;
    for (it = itemRectMap.begin(); it != itemRectMap.end(); ++it)
    {
        OverlayItem* item = it->first;
        Recti rect = it->second;

        if (useSoftwareRendering)
        {
            item->renderSoftware(oglContext, rect.min(), Vec2ui(static_cast<cvf::uint>(rect.width()), static_cast<cvf::uint>(rect.height())));
        }
        else
        {
            item->render(oglContext, rect.min(),  Vec2ui(static_cast<cvf::uint>(rect.width()), static_cast<cvf::uint>(rect.height())));
        }
    }
}
开发者ID:akva2,项目名称:ResInsight,代码行数:24,代码来源:cvfRendering.cpp


注:本文中的Recti类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。