void Orientation_Widget::paintEvent(QPaintEvent * event)
{
	(void)event;

	QPainter painter(this);

	// Draw the border and fill the background
	painter.setRenderHint(QPainter::Antialiasing, false);

	painter.setBrush( painter.background() );
	painter.setPen( Qt::NoPen );

	painter.drawRect( 0, 0, width(), height() );

	painter.setBrush( Qt::NoBrush );
	painter.setPen( QPen( QColor::fromRgb(0,0,0)) );

	painter.setRenderHint(QPainter::Antialiasing, true);

	CenterX = (float)(width() / 2);
	CenterY = (float)(height() / 2);
	DrawScale = ViewScale * ((float)width()/ 560.0f);

	if(bQuat2Valid) {
		DrawShape( painter, mat2, QColor::fromRgb(192,192,192), QuadPt, QuadLine );
	}
	DrawShape( painter, mat, QColor::fromRgb(0,0,0), QuadPt, QuadLine );
}
void DoMouseMove(HWND hWnd,LONG lParam)
{
    HDC hdc;

    if (mouseDown)
    {
	hdc = GetDC(hWnd);
	/*
	 * Erase the old shape.
	 */
	SaveROP = SetROP2(hdc,R2_NOTXORPEN);
	DrawShape(hdc, thisShape[CurrentPoint].Points.left,
		  thisShape[CurrentPoint].Points.top, oldx, oldy,
		  thisShape[CurrentPoint].theShape,
		  thisShape[CurrentPoint].PenWidth,
		  thisShape[CurrentPoint].PenColor, 1);
	/*
	 * At this point, the slope must be positive because
	 * the coordinates could not have been switched.
	 * The next step is to draw the new shape.
	 */

	oldx = LOWORD(lParam);
	oldy = HIWORD(lParam);
	DrawShape(hdc, thisShape[CurrentPoint].Points.left,
		  thisShape[CurrentPoint].Points.top, oldx, oldy,
		  thisShape[CurrentPoint].theShape,
		  thisShape[CurrentPoint].PenWidth,
		  thisShape[CurrentPoint].PenColor, 1);
	SetROP2(hdc,SaveROP);
	ReleaseDC(hWnd,hdc);
    }

}
示例#3
0
static void ProcessFace(
    CImage&      cimg,      // io: color version of image
    const float* landmarks, // in
    int          nfaces,    // in
    const char*  imgpath)   // in
{
    Shape shape(LandmarksAsShape(landmarks));
    shape = ConvertShape(shape, nlandmarks_g);
    if (shape.rows == 0)
        Err("Cannot convert to a %d point shape", nlandmarks_g);
    if (writeimgs_g)
        DrawShape(cimg, shape);
    if (multiface_g)
    {
        logprintf("face %d\n", nfaces);
        double xmin, xmax, ymin, ymax; // needed to position face nbr
        ShapeMinMax(xmin, xmax, ymin, ymax, shape);
        ImgPrintf(cimg,
                  (xmin + xmax)/2, ymin - (ymax-ymin)/50., 0xff0000, 1,
                 "%d", nfaces);
    }
    if (csv_g)
        LogShapeAsCsv(shape, imgpath);
    else
        LogShape(shape, imgpath);
}
示例#4
0
文件: swas.cpp 项目: avtomaton/stasm
static void WriteLandmarkedImg(
    const Image& img,         // in: the image
    const char*  newpath,     // in: the image path
    const Shape& shape,       // in: the shape
    const Shape& cropshape,   // in: crop image to this shape (typically the ref shape)
    unsigned     color=C_RED, // in: rrggbb e.g. 0xff0000 is red
    int          iworst=-1)   // in: index of worst fitting point, -1 for none
{
    CImage cimg; cvtColor(img, cimg, CV_GRAY2BGR); // color image

    if (iworst >= 0) // draw circle at worst fitting point?
        cv::circle(cimg,
                   cv::Point(cvRound(shape(iworst, IX)),
                             cvRound(shape(iworst, IY))),
                   MAX(2, cvRound(ShapeWidth(shape) / 40)),
                   cv::Scalar(255, 255, 0), 2); // cyan

    DrawShape(cimg, shape, color);

    if (crop_g)
        CropCimgToShapeWithMargin(cimg, cropshape);

    if (!cv::imwrite(newpath, cimg))
        Err("Cannot write %s", newpath);
}
void DrawNode(R3Scene *scene, R3Node *node)
{
  // Push transformation onto stack
  glPushMatrix();
  LoadMatrix(&node->transformation);

  // Load material
  if (node->material) LoadMaterial(node->material);

  // Draw shape
  if (node->shape) DrawShape(node->shape);

  // Draw children nodes
  for (int i = 0; i < (int) node->children.size(); i++) 
    DrawNode(scene, node->children[i]);

  // Restore previous transformation
  glPopMatrix();

  // Show bounding box
  if (show_bboxes) {
    GLboolean lighting = glIsEnabled(GL_LIGHTING);
    glDisable(GL_LIGHTING);
    node->bbox.Outline();
    if (lighting) glEnable(GL_LIGHTING);
  }
}
void DrawParticleSinks(R3Scene *scene)
{
  // Check if should draw particle sinks
  if (!show_particle_sources_and_sinks) return;

  // Setup
  GLboolean lighting = glIsEnabled(GL_LIGHTING);
  glEnable(GL_LIGHTING);

  // Define sink material
  static R3Material sink_material;
  if (sink_material.id != 33) {
    sink_material.ka.Reset(0.2,0.2,0.2,1);
    sink_material.kd.Reset(1,0,0,1);
    sink_material.ks.Reset(1,0,0,1);
    sink_material.kt.Reset(0,0,0,1);
    sink_material.emission.Reset(0,0,0,1);
    sink_material.shininess = 1;
    sink_material.indexofrefraction = 1;
    sink_material.texture = NULL;
    sink_material.texture_index = -1;
    sink_material.id = 33;
  }

  // Draw all particle sinks
  glEnable(GL_LIGHTING);
  LoadMaterial(&sink_material);
  for (int i = 0; i < scene->NParticleSinks(); i++) {
    R3ParticleSink *sink = scene->ParticleSink(i);
    DrawShape(sink->shape);
  }

  // Clean up
  if (!lighting) glDisable(GL_LIGHTING);
}
示例#7
0
void DrawLanders()
{
	// draw the landers in 2 colors
	NxU32 nbActors = gScene->getNbActors();
	NxActor** actors = gScene->getActors();
	while (nbActors--)
	{
		NxActor* actor = *actors++;
		const char *name=actor->getName();
		if (strcmp(name,"~lander")==0) {
			NxShape*const* shapes;
			shapes = actor->getShapes();
			NxU32 nShapes = actor->getNbShapes();
			//glDisable(GL_LIGHTING);
			char sname[256]="";
			while (nShapes--)
			{
				sprintf(sname,"%s",shapes[nShapes]->getName());
				if      (strcmp(sname,"upside")==0)
					glColor4f(0.0f,1.0f,0.0f,1.0f);
				else if (strcmp(sname,"downside")==0)
					glColor4f(1.0f,0.0f,0.0f,1.0f);
				else if (strcmp(sname,"U1")==0)
					glColor4f(1.0f,0.0f,0.0f,1.0f);
				else if (strcmp(sname,"U2")==0)
					glColor4f(0.0f,1.0f,0.0f,1.0f);
				else if (strcmp(sname,"U3")==0)
					glColor4f(0.0f,0.0f,1.0f,1.0f);
				DrawShape(shapes[nShapes], false);
			}
			//glEnable(GL_LIGHTING);
		}
	}
}
示例#8
0
void DrawActor(NxActor* actor, NxActor* gSelectedActor)
{
	NxShape*const* shapes = actor->getShapes();
	NxU32 nShapes = actor->getNbShapes();
	if (actor == gSelectedActor) 
	{
		while (nShapes--)
		{
			DrawWireShape(shapes[nShapes], NxVec3(1,1,1));
		}
	}

	NxVec3 defaultColor = NxVec3(0.65f, 0.67f, 0.63f);
	NxVec3 dynamicActiveColor = NxVec3(0.82f, 0.77f, 0.73f);
	NxVec3 dynamicSleepingColor = NxVec3(0.6f, 0.6f, 0.6f);
	NxVec3 kinematicColor = NxVec3(0.73f, 0.77f, 0.82f);

	nShapes = actor->getNbShapes();
	while (nShapes--)
	{
		NxVec3 color = defaultColor;
		if (actor->isDynamic())
		{
			if (actor->readBodyFlag(NX_BF_KINEMATIC))
				color = kinematicColor;
			else
				if (actor->isSleeping())
					color = dynamicSleepingColor;
				else
					color = dynamicActiveColor;
		}
		DrawShape(shapes[nShapes], color);
	}
}
/**
Starts test step
@return TVerdict pass / fail
*/
enum TVerdict CT_WServGenericpluginStepLoad::doTestStepL()
	{
	__UHEAP_MARK;
	RWindow win;
	CleanupClosePushL(win);
	CreateRWindowL(iWinGroup, win, KWinPos, KRgbBlue, KWinSize);
	DrawShape(win);
	
	RWindow win1;
	CleanupClosePushL(win1);
	if(iScreen1)
		{
		CreateRWindowL(iWinGroup1, win1, KWinPos, KRgbBlue, KWinSize);
		DrawShape(win1);
		}
	
	switch( iTestId )
		{
		case 1:
			INFO_PRINTF1(_L("Testing Control of CWsPlugin loading from WSINI.INI..."));
			GraphicsWservGenericpluginLoad1L();
			break;
		case 2:	
			INFO_PRINTF1(_L("Testing that plugins can be specified on a per-screen basis through WSINI.INI file..."));
			GraphicsWservGenericpluginLoad2L();
			break;
		case 3:	
			INFO_PRINTF1(_L("Testing Integer and string attributes in WSINI.INI file can be read from CWsPlugin..."));
			GraphicsWservGenericpluginLoad3L();
			break;
		case 4:
			INFO_PRINTF1(_L("Testing CWsPlugin can gain information about closing windows using MWsWindow interface..."));
			GraphicsWservGenericpluginLoad4L();
			break;
		case 5:	
			INFO_PRINTF1(_L("Testing CWsPlugin can obtain instance of another CWPlugin..."));
			GraphicsWservGenericpluginLoad5L();
			break;
		default:
			break;	
		}
	CleanupStack::PopAndDestroy(2,&win);

	__UHEAP_MARKEND;
	return TestStepResult();
	}
示例#10
0
void nuiDrawContext::DrawPoint(float x, float y)
{
  nuiShape shp;
  shp.AddCircle(x, y, mCurrentState.mLineWidth);
  nuiColor col(mCurrentState.mFillColor);
  SetFillColor(mCurrentState.mStrokeColor);
  DrawShape(&shp, eFillShape);
  SetFillColor(col);
}
示例#11
0
void slowdown(){
    Touch();
    //if(Touch_ret)
    asm("lda %b",Touch_ret);
    asm("beq %g",else1);
        TouchDo();
        asm("rts");
    else1:
        //PosY--;
        asm("dec %b",PosY);
        DrawShape();
}
示例#12
0
void DrawPxShapes::DrawActor( PxRigidActor* actor )
{
	PxU32 nShapes = actor->getNbShapes();
	PxShape** shapes = new PxShape*[ nShapes ];
	actor->getShapes( shapes, nShapes );
	while ( nShapes-- )
	{
		DrawShape( shapes[ nShapes ] );
	}

	delete [] shapes;
}
示例#13
0
文件: UIShape.cpp 项目: Darkttd/Bibim
    void UIShape::OnDraw(UIDrawingContext& context)
    {
        UIVisual::OnDraw(context);

        const RectF clippedBounds = context.GetCurrentClippedBounds();
        const RectF bounds = context.GetCurrentBounds();

        if (fillColor.A > 0)
            FillShape(context, clippedBounds, bounds, fillColor);
        if (lineColor.A > 0)
            DrawShape(context, clippedBounds, bounds, lineColor);
    }
示例#14
0
void rotate(){
    //NowDirectionNo=(NowDirectionNo+4+rotate_n)&3;
    asm("lda %b",NowDirectionNo);
    asm("clc");
    asm("adc #$04");
    asm("adc %b",rotate_n);
    asm("and #$03");
    asm("sta %b",NowDirectionNo);
    
    getNowLeft();
    //if(PosX+getBlock_ret>10)
    asm("lda %b",getBlock_ret);
    asm("clc");
    asm("adc %b",PosX);
    asm("cmp #$0A");
    asm("bmi %g",else1);
    asm("beq %g",else1);
        //rotate_tempPosX=PosX;
        asm("lda %b",PosX);
        asm("sta %b",rotate_tempPosX);
        //PosX=10-getBlock_ret;
        asm("lda #$0A");
        asm("sec");
        asm("sbc %b",getBlock_ret);
        asm("sta %b",PosX);
        AnyTouch();
        
        //if(0==AnyTouch_ret)jmp jp2
        asm("lda %b",AnyTouch_ret);
        asm("beq %g",jp2);
        
        //PosX=rotate_tempPosX;
        asm("lda %b",rotate_tempPosX);
        asm("sta %b",PosX);
        asm("jmp %g",jp1);
    else1:
    AnyTouch();
    //if(AnyTouch_ret)asm("jmp %g",jp1);
    asm("lda %b",AnyTouch_ret);
    asm("beq %g",jp2);
    jp1:
    //NowDirectionNo=(NowDirectionNo+4-rotate_n)&3;
    asm("lda %b",NowDirectionNo);
    asm("clc");
    asm("adc #$04");
    asm("sec");
    asm("sbc %b",rotate_n);
    asm("and #$03");
    asm("sta %b",NowDirectionNo);
    jp2:
    DrawShape();
}
示例#15
0
void
AirspacePreviewRenderer::Draw(Canvas &canvas, const AbstractAirspace &airspace,
                              const RasterPoint pt, unsigned radius,
                              const AirspaceRendererSettings &settings,
                              const AirspaceLook &look)
{
  AbstractAirspace::Shape shape = airspace.GetShape();
  AirspaceClass type = airspace.GetType();

  // Container for storing the points of a polygon airspace
  std::vector<RasterPoint> pts;
  if (shape == AbstractAirspace::Shape::POLYGON && !IsAncientHardware())
    GetPolygonPoints(pts, (const AirspacePolygon &)airspace, pt, radius);

  if (PrepareFill(canvas, type, look, settings)) {
    DrawShape(canvas, shape, pt, radius, pts);
    UnprepareFill(canvas);
  }

  if (PrepareOutline(canvas, type, look, settings))
    DrawShape(canvas, shape, pt, radius, pts);
}
示例#16
0
	void Render::DrawBodies(list<Body*> bodies) {

		list<Body*>::iterator bIter;
		for (bIter = bodies.begin(); bIter != bodies.end(); ++bIter) {
			Body* b = *bIter;
			const b2Transform& xf = b->getBody()->GetTransform();
			list<Fixture*> fixtures = b->getFixtureList();
			list<Fixture*>::iterator fIter;
			for (fIter = fixtures.begin(); fIter != fixtures.end(); ++fIter) {
				Fixture* f = *fIter;
				DrawShape(f->getFixture(), xf, f->getColor());
			}
		}
	}
示例#17
0
void nuiDrawContext::DrawLine(float x1, float y1, float x2, float y2)
{
  if (x1 == x2 && y1 == y2)
  {
    DrawPoint(x1, y1);
  }
  else
  {
    nuiShape shp;
    shp.LineTo(nuiPoint(x1, y1));
    shp.LineTo(nuiPoint(x2, y2));
    DrawShape(&shp, eStrokeShape);
  }
}
void BulletOpenGLApplication::RenderScene() {
	// create an array of 16 floats (representing a 4x4 matrix)
	btScalar transform[16];

	// iterate through all of the objects in our world
	for(GameObjects::iterator i = m_objects.begin(); i != m_objects.end(); ++i) {
		// get the object from the iterator
		GameObject* pObj = *i;

		// read the transform
		pObj->GetTransform(transform);

		// get data from the object and draw it
		DrawShape(transform, pObj->GetShape(), pObj->GetColor());
	}
}
示例#19
0
bool nuiGLDrawContext::AddClipShape(nuiShape& rShape, bool Invert)
{
  EnableStencilTest(true);
  glColorMask(GL_FALSE,GL_FALSE,GL_FALSE,GL_FALSE);
  glStencilMask(~0);

  // Now draw the shape in the stencil buffer:
  GLenum value = Invert? 0: mClipShapeValue;
  glStencilFunc(GL_ALWAYS, value, 255);
  glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE);
  DrawShape(&rShape, eFillShape);

  // Now lets get back to the mode we were in before the stencill fun:
  glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE);
  glStencilMask(0);
  glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
  glStencilFunc(GL_EQUAL, mClipShapeValue, 255);
  return true;
}
示例#20
0
void movelr(){
    //PosX+=movelr_n;
    asm("lda %b",PosX);
    asm("clc");
    asm("adc %b",movelr_n);
    asm("sta %b",PosX);
    AnyTouch();
    
    //if(AnyTouch_ret)
    asm("lda %b",AnyTouch_ret);
    asm("beq %g",else1);
        //PosX-=movelr_n;
        asm("lda %b",PosX);
        asm("sec");
        asm("sbc %b",movelr_n);
        asm("sta %b",PosX);
    else1:
    DrawShape();
}
示例#21
0
//simvan kata to opio afinoume to click tou pontikiou
void __fastcall TForm1::Image1MouseUp(TObject *Sender, TMouseButton Button,
      TShiftState Shift, int X, int Y)
{
        redo = new TImage(this);
        redo->Picture = Image1->Picture;

    if (Button != mbLeft)
        return;

    if ((Form1->FillButton->Down) || (Form1->PencilButton->Down))
        return;

    if (Form1->EraseButton->Down)
    {
        Image1->Canvas->Pen->Width = 1;
        return;
    }
    DrawShape(X, Y);
    delete TmpImage;
}
void BulletOpenGLApplication::RenderScene() {
	// create an array of 16 floats (representing a 4x4 matrix)
	btScalar transform[16];

	// iterate through all of the objects in our world
	for(GameObjects::iterator i = m_objects.begin(); i != m_objects.end(); ++i) {
		// get the object from the iterator
		GameObject* pObj = *i;

		// read the transform
		pObj->GetTransform(transform);

		// get data from the object and draw it
		DrawShape(transform, pObj->GetShape(), pObj->GetColor());
	}

	// after rendering all game objects, perform debug rendering
	// Bullet will figure out what needs to be drawn then call to
	// our DebugDrawer class to do the rendering for us
	m_pWorld->debugDrawWorld();
}
示例#23
0
//simvan to opoio pragmatopoieite kata to sirsimo tou pontikiou eno exi patimeno to click
void __fastcall TForm1::Image1MouseMove(TObject *Sender, TShiftState Shift,
      int X, int Y)
{
    if (!Shift.Contains(ssLeft))
        return;

    if (Form1->FillButton->Down)
        return;

    if (Form1->PencilButton->Down) //zografizi analogos to antikimeno pou xrisimopoioume
    {
        Image1->Canvas->LineTo(X,Y);  //X,Y oi sintetagmenes tou kersora pano sto image1
        return;
    }

    if (Form1->EraseButton->Down)
    {
        Image1->Canvas->LineTo(X,Y);
        return;
    }
    DrawShape(X, Y);
}
示例#24
0
void b2World::DrawDebugData()
{
	if (m_debugDraw == NULL)
	{
		return;
	}

	uint32 flags = m_debugDraw->GetFlags();

	if (flags & b2DebugDraw::e_shapeBit)
	{
		bool core = (flags & b2DebugDraw::e_coreShapeBit) == b2DebugDraw::e_coreShapeBit;

		for (b2Body* b = m_bodyList; b; b = b->GetNext())
		{
			const b2XForm& xf = b->GetXForm();
			for (b2Shape* s = b->GetShapeList(); s; s = s->GetNext())
			{
				if (b->IsStatic())
				{
					DrawShape(s, xf, b2Color(0.5f, 0.9f, 0.5f), core);
				}
				else if (b->IsSleeping())
				{
					DrawShape(s, xf, b2Color(0.5f, 0.5f, 0.9f), core);
				}
				else
				{
					DrawShape(s, xf, b2Color(0.9f, 0.9f, 0.9f), core);
				}
			}
		}
	}

	if (flags & b2DebugDraw::e_jointBit)
	{
		for (b2Joint* j = m_jointList; j; j = j->GetNext())
		{
			if (j->GetType() != e_mouseJoint)
			{
				DrawJoint(j);
			}
		}
	}

	if (flags & b2DebugDraw::e_controllerBit)
	{
		for (b2Controller* c = m_controllerList; c; c= c->GetNext())
		{
			c->Draw(m_debugDraw);
		}
	}

	if (flags & b2DebugDraw::e_pairBit)
	{
		b2BroadPhase* bp = m_broadPhase;
		b2Vec2 invQ;
		invQ.Set(1.0f / bp->m_quantizationFactor.x, 1.0f / bp->m_quantizationFactor.y);
		b2Color color(0.9f, 0.9f, 0.3f);

		for (int32 i = 0; i < b2_tableCapacity; ++i)
		{
			uint16 index = bp->m_pairManager.m_hashTable[i];
			while (index != b2_nullPair)
			{
				b2Pair* pair = bp->m_pairManager.m_pairs + index;
				b2Proxy* p1 = bp->m_proxyPool + pair->proxyId1;
				b2Proxy* p2 = bp->m_proxyPool + pair->proxyId2;

				b2AABB b1, b2;
				b1.lowerBound.x = bp->m_worldAABB.lowerBound.x + invQ.x * bp->m_bounds[0][p1->lowerBounds[0]].value;
				b1.lowerBound.y = bp->m_worldAABB.lowerBound.y + invQ.y * bp->m_bounds[1][p1->lowerBounds[1]].value;
				b1.upperBound.x = bp->m_worldAABB.lowerBound.x + invQ.x * bp->m_bounds[0][p1->upperBounds[0]].value;
				b1.upperBound.y = bp->m_worldAABB.lowerBound.y + invQ.y * bp->m_bounds[1][p1->upperBounds[1]].value;
				b2.lowerBound.x = bp->m_worldAABB.lowerBound.x + invQ.x * bp->m_bounds[0][p2->lowerBounds[0]].value;
				b2.lowerBound.y = bp->m_worldAABB.lowerBound.y + invQ.y * bp->m_bounds[1][p2->lowerBounds[1]].value;
				b2.upperBound.x = bp->m_worldAABB.lowerBound.x + invQ.x * bp->m_bounds[0][p2->upperBounds[0]].value;
				b2.upperBound.y = bp->m_worldAABB.lowerBound.y + invQ.y * bp->m_bounds[1][p2->upperBounds[1]].value;

				b2Vec2 x1 = 0.5f * (b1.lowerBound + b1.upperBound);
				b2Vec2 x2 = 0.5f * (b2.lowerBound + b2.upperBound);

				m_debugDraw->DrawSegment(x1, x2, color);

				index = pair->next;
			}
		}
	}

	if (flags & b2DebugDraw::e_aabbBit)
	{
		b2BroadPhase* bp = m_broadPhase;
		b2Vec2 worldLower = bp->m_worldAABB.lowerBound;
		b2Vec2 worldUpper = bp->m_worldAABB.upperBound;

		b2Vec2 invQ;
		invQ.Set(1.0f / bp->m_quantizationFactor.x, 1.0f / bp->m_quantizationFactor.y);
		b2Color color(0.9f, 0.3f, 0.9f);
		for (int32 i = 0; i < b2_maxProxies; ++i)
		{
			b2Proxy* p = bp->m_proxyPool + i;
			if (p->IsValid() == false)
			{
				continue;
			}

			b2AABB b;
			b.lowerBound.x = worldLower.x + invQ.x * bp->m_bounds[0][p->lowerBounds[0]].value;
			b.lowerBound.y = worldLower.y + invQ.y * bp->m_bounds[1][p->lowerBounds[1]].value;
			b.upperBound.x = worldLower.x + invQ.x * bp->m_bounds[0][p->upperBounds[0]].value;
			b.upperBound.y = worldLower.y + invQ.y * bp->m_bounds[1][p->upperBounds[1]].value;

			b2Vec2 vs[4];
			vs[0].Set(b.lowerBound.x, b.lowerBound.y);
			vs[1].Set(b.upperBound.x, b.lowerBound.y);
			vs[2].Set(b.upperBound.x, b.upperBound.y);
			vs[3].Set(b.lowerBound.x, b.upperBound.y);

			m_debugDraw->DrawPolygon(vs, 4, color);
		}

		b2Vec2 vs[4];
		vs[0].Set(worldLower.x, worldLower.y);
		vs[1].Set(worldUpper.x, worldLower.y);
		vs[2].Set(worldUpper.x, worldUpper.y);
		vs[3].Set(worldLower.x, worldUpper.y);
		m_debugDraw->DrawPolygon(vs, 4, b2Color(0.3f, 0.9f, 0.9f));
	}

	if (flags & b2DebugDraw::e_obbBit)
	{
		b2Color color(0.5f, 0.3f, 0.5f);

		for (b2Body* b = m_bodyList; b; b = b->GetNext())
		{
			const b2XForm& xf = b->GetXForm();
			for (b2Shape* s = b->GetShapeList(); s; s = s->GetNext())
			{
				if (s->GetType() != e_polygonShape)
				{
					continue;
				}

				b2PolygonShape* poly = (b2PolygonShape*)s;
				const b2OBB& obb = poly->GetOBB();
				b2Vec2 h = obb.extents;
				b2Vec2 vs[4];
				vs[0].Set(-h.x, -h.y);
				vs[1].Set( h.x, -h.y);
				vs[2].Set( h.x,  h.y);
				vs[3].Set(-h.x,  h.y);

				for (int32 i = 0; i < 4; ++i)
				{
					vs[i] = obb.center + b2Mul(obb.R, vs[i]);
					vs[i] = b2Mul(xf, vs[i]);
				}

				m_debugDraw->DrawPolygon(vs, 4, color);
			}
		}
	}

	if (flags & b2DebugDraw::e_centerOfMassBit)
	{
		for (b2Body* b = m_bodyList; b; b = b->GetNext())
		{
			b2XForm xf = b->GetXForm();
			xf.position = b->GetWorldCenter();
			m_debugDraw->DrawXForm(xf);
		}
	}
}
/**
@SYMTestCaseID			graphics-wserv-1841-0005
@SYMPREQ				1841
@SYMTestCaseDesc		CWsPlugin can gain information about closing windows using MWsWindow interface.
@SYMTestActions			Create modified WSINI.INI file which specifies a test renderer to be loaded.
						Register CWsPLugin as eventhandler receiving EWindowClosing events.
@SYMTestStatus			Implemented
@SYMTestPriority		2
@SYMTestExpectedResults	Plugin can access information about closing windows through MWsWindow interface.
						Windows with different size and position are created and closed in screen 0.
@SYMTestType			CT
*/	
void CT_WServGenericpluginStepLoad::GraphicsWservGenericpluginLoad4L()
	{
	const TUint32 KWin1WsHandle = 0xFFFFFFFC;
	const TUint32 KWin2WsHandle = 0xFFFFFFFD;
	const TUint32 KWin3WsHandle = 0xFFFFFFFE;
	TPoint w1Point(50,240);
	TPoint w2Point(580,100);
	TPoint w3Point(25,100);
	TSize w1Size(10,10);
	TSize w2Size(150,70);
	TSize w3Size(50,140);
		
	//Draw windows with different origins and sizes	
	RWindow win;	
	CleanupClosePushL(win);
	CreateRWindowL(iWinGroup, win, w1Point, KRgbBlue, w1Size, KWin1WsHandle);
	DrawShape(win);
	CleanupStack::PopAndDestroy(&win);
	
	CleanupClosePushL(win);
	CreateRWindowL(iWinGroup, win, w2Point, KRgbBlue, w2Size, KWin2WsHandle);
	DrawShape(win);
	CleanupStack::PopAndDestroy(&win);
	
	CleanupClosePushL(win);
	CreateRWindowL(iWinGroup, win, w3Point, KRgbBlue, w3Size, KWin3WsHandle);
	DrawShape(win);
	CleanupStack::PopAndDestroy(&win);
	
	CleanupClosePushL(win); //create dummy 4th window to ensure window3 closing event has time to log info
	CreateRWindowL(iWinGroup, win, w2Point, KRgbBlue, w2Size, KWin2WsHandle);
	DrawShape(win);
	CleanupStack::PopAndDestroy(&win);
	
	//Calculate AbsRect values
	TSize absRect1;
	TSize absRect2;
	TSize absRect3;
	CalcAbsRect(absRect1, w1Point, w1Size);	
	CalcAbsRect(absRect2, w2Point, w2Size);	
	CalcAbsRect(absRect3, w3Point, w3Size);
	
	TBuf8<255> msg;
	//check log for window1 info
	msg.Format(_L8("Closing Window Handle %d - Origin: %d, %d"), KWin1WsHandle, w1Point.iX, w1Point.iY);
	TEST(CheckLogL(msg) == EMsgFound);
	msg.Format(_L8("Closing Window Handle %d - AbsRec: Height %d, Width %d"), KWin1WsHandle, absRect1.iHeight, absRect1.iWidth);
	TEST(CheckLogL(msg) == EMsgFound);
	msg.Format(_L8("Closing Window Handle %d - Size: Height %d, Width %d"), KWin1WsHandle, w1Size.iHeight, w1Size.iWidth);
	TEST(CheckLogL(msg) == EMsgFound);
	//check log for window2 info
	msg.Format(_L8("Closing Window Handle %d - Origin: %d, %d"), KWin2WsHandle, w2Point.iX, w2Point.iY);
	TEST(CheckLogL(msg) == EMsgFound);
	msg.Format(_L8("Closing Window Handle %d - AbsRec: Height %d, Width %d"), KWin2WsHandle, absRect2.iHeight, absRect2.iWidth);
	TEST(CheckLogL(msg) == EMsgFound);
	msg.Format(_L8("Closing Window Handle %d - Size: Height %d, Width %d"), KWin2WsHandle, w2Size.iHeight, w2Size.iWidth);
	TEST(CheckLogL(msg) == EMsgFound);
	//check log for window3 info
	msg.Format(_L8("Closing Window Handle %d - Origin: %d, %d"), KWin3WsHandle, w3Point.iX, w3Point.iY);
	TEST(CheckLogL(msg) == EMsgFound);
	msg.Format(_L8("Closing Window Handle %d - AbsRec: Height %d, Width %d"), KWin3WsHandle, absRect3.iHeight, absRect3.iWidth);
	TEST(CheckLogL(msg) == EMsgFound);
	msg.Format(_L8("Closing Window Handle %d - Size: Height %d, Width %d"), KWin3WsHandle, w3Size.iHeight, w3Size.iWidth);
	TEST(CheckLogL(msg) == EMsgFound);
	}
示例#26
0
void D_PAD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDraw_mode,
                  const wxPoint& aOffset )
{
    wxSize mask_margin;   // margin (clearance) used for some non copper layers

#ifdef SHOW_PADMASK_REAL_SIZE_AND_COLOR
    int    showActualMaskSize = 0;  /* Layer number if the actual pad size on mask layer can
                                     * be displayed i.e. if only one layer is shown for this pad
                                     * and this layer is a mask (solder mask or solder paste
                                     */
#endif

    if( m_Flags & DO_NOT_DRAW )
        return;

    PAD_DRAWINFO drawInfo;

    drawInfo.m_Offset = aOffset;

    /* We can show/hide pads from the layer manager.
     * options are show/hide pads on front and/or back side of the board
     * For through pads, we hide them only if both sides are hidden.
     * smd pads on back are hidden for all layers (copper and technical layers)
     * on back side of the board
     * smd pads on front are hidden for all layers (copper and technical layers)
     * on front side of the board
     * ECO, edge and Draw layers and not considered
     */

    BOARD* brd = GetBoard();
    bool   frontVisible = brd->IsElementVisible( PCB_VISIBLE( PAD_FR_VISIBLE ) );
    bool   backVisible  = brd->IsElementVisible( PCB_VISIBLE( PAD_BK_VISIBLE ) );

    if( !frontVisible && !backVisible )
        return;

    // If pad is only on front side (no layer on back side)
    // and if hide front side pads is enabled, do not draw
    if( !frontVisible && !( m_layerMask & LSET::BackMask() ).any() )
        return;

    // If pad is only on back side (no layer on front side)
    // and if hide back side pads is enabled, do not draw
    if( !backVisible && !( m_layerMask & LSET::FrontMask() ).any() )
        return;

    PCB_BASE_FRAME* frame  = (PCB_BASE_FRAME*) aPanel->GetParent();

    wxCHECK_RET( frame != NULL, wxT( "Panel has no parent frame window." ) );

    DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)frame->GetDisplayOptions();
    PCB_SCREEN*     screen = frame->GetScreen();

    if( displ_opts && displ_opts->m_DisplayPadFill == SKETCH )
        drawInfo.m_ShowPadFilled = false;
    else
        drawInfo.m_ShowPadFilled = true;

    EDA_COLOR_T color = BLACK;

    if( m_layerMask[F_Cu] )
    {
        color = brd->GetVisibleElementColor( PAD_FR_VISIBLE );
    }

    if( m_layerMask[B_Cu] )
    {
        color = ColorMix( color, brd->GetVisibleElementColor( PAD_BK_VISIBLE ) );
    }

    if( color == BLACK ) // Not on a visible copper layer (i.e. still nothing to show)
    {
        // If the pad is on only one tech layer, use the layer color else use DARKGRAY
        LSET mask_non_copper_layers = m_layerMask & ~LSET::AllCuMask();

#ifdef SHOW_PADMASK_REAL_SIZE_AND_COLOR
        mask_non_copper_layers &= brd->GetVisibleLayers();
#endif
        LAYER_ID pad_layer = mask_non_copper_layers.ExtractLayer();

        switch( (int) pad_layer )
        {
        case UNDEFINED_LAYER:   // More than one layer
            color = DARKGRAY;
            break;

        case UNSELECTED_LAYER:  // Shouldn't really happen...
            break;

        default:
            color = brd->GetLayerColor( pad_layer );
#ifdef SHOW_PADMASK_REAL_SIZE_AND_COLOR
            showActualMaskSize = pad_layer;
#endif
        }
    }

    // if SMD or connector pad and high contrast mode
    if( ( aDraw_mode & GR_ALLOW_HIGHCONTRAST ) &&
        ( GetAttribute() == PAD_SMD || GetAttribute() == PAD_CONN ) &&
        displ_opts && displ_opts->m_ContrastModeDisplay )
    {
        // when routing tracks
        if( frame->GetToolId() == ID_TRACK_BUTT )
        {
            LAYER_ID routeTop = screen->m_Route_Layer_TOP;
            LAYER_ID routeBot = screen->m_Route_Layer_BOTTOM;

            // if routing between copper and component layers,
            // or the current layer is one of said 2 external copper layers,
            // then highlight only the current layer.
            if( ( screen->m_Active_Layer == F_Cu || screen->m_Active_Layer == B_Cu ) ||
                ( routeTop==F_Cu && routeBot==B_Cu ) ||
                ( routeTop==B_Cu && routeBot==F_Cu )
                )
            {
                if( !IsOnLayer( screen->m_Active_Layer ) )
                    ColorTurnToDarkDarkGray( &color );
            }
            // else routing between an internal signal layer and some other
            // layer.  Grey out all PAD_SMD pads not on current or the single
            // selected external layer.
            else if( !IsOnLayer( screen->m_Active_Layer )
                    && !IsOnLayer( routeTop )
                    && !IsOnLayer( routeBot ) )
            {
                ColorTurnToDarkDarkGray( &color );
            }
        }
        // when not edting tracks, show PAD_SMD components not on active layer
        // as greyed out
        else
        {
            if( !IsOnLayer( screen->m_Active_Layer ) )
                ColorTurnToDarkDarkGray( &color );
        }
    }

#ifdef SHOW_PADMASK_REAL_SIZE_AND_COLOR
    if( showActualMaskSize )
    {
        switch( showActualMaskSize )
        {
        case B_Mask:
        case F_Mask:
            mask_margin.x = mask_margin.y = GetSolderMaskMargin();
            break;

        case B_Paste:
        case F_Paste:
            mask_margin = GetSolderPasteMargin();
            break;

        default:
            // Another layer which has no margin to handle
            break;
        }
    }
#endif

    // if Contrast mode is ON and a technical layer active, show pads on this
    // layer so we can see pads on paste or solder layer and the size of the
    // mask
    if( ( aDraw_mode & GR_ALLOW_HIGHCONTRAST ) &&
        displ_opts && displ_opts->m_ContrastModeDisplay && !IsCopperLayer( screen->m_Active_Layer ) )
    {
        if( IsOnLayer( screen->m_Active_Layer ) )
        {
            color = brd->GetLayerColor( screen->m_Active_Layer );

            // In high contrast mode, and if the active layer is the mask
            // layer shows the pad size with the mask clearance
            switch( screen->m_Active_Layer )
            {
            case B_Mask:
            case F_Mask:
                mask_margin.x = mask_margin.y = GetSolderMaskMargin();
                break;

            case B_Paste:
            case F_Paste:
                mask_margin = GetSolderPasteMargin();
                break;

            default:
                break;
            }
        }
        else
            color = DARKDARKGRAY;
    }


    if( aDraw_mode & GR_HIGHLIGHT )
        ColorChangeHighlightFlag( &color, !(aDraw_mode & GR_AND) );

    ColorApplyHighlightFlag( &color );

    bool DisplayIsol = displ_opts && displ_opts->m_DisplayPadIsol;

    if( !( m_layerMask & LSET::AllCuMask() ).any() )
        DisplayIsol = false;

    if( ( GetAttribute() == PAD_HOLE_NOT_PLATED ) &&
        brd->IsElementVisible( NON_PLATED_VISIBLE ) )
    {
        drawInfo.m_ShowNotPlatedHole = true;
        drawInfo.m_NPHoleColor = brd->GetVisibleElementColor( NON_PLATED_VISIBLE );
    }

    drawInfo.m_DrawMode    = aDraw_mode;
    drawInfo.m_Color       = color;
    drawInfo.m_DrawPanel   = aPanel;
    drawInfo.m_Mask_margin = mask_margin;
    drawInfo.m_ShowNCMark  = brd->IsElementVisible( PCB_VISIBLE( NO_CONNECTS_VISIBLE ) );
    drawInfo.m_IsPrinting  = screen->m_IsPrinting;
    SetAlpha( &color, 170 );

    /* Get the pad clearance. This has a meaning only for Pcbnew.
     *  for CvPcb GetClearance() creates debug errors because
     *  there is no net classes so a call to GetClearance() is made only when
     *   needed (never needed in CvPcb)
     */
    drawInfo.m_PadClearance = DisplayIsol ? GetClearance() : 0;

    // Draw the pad number
    if( displ_opts && !displ_opts->m_DisplayPadNum )
        drawInfo.m_Display_padnum = false;

    if( displ_opts &&
        (( displ_opts ->m_DisplayNetNamesMode == 0 ) || ( displ_opts->m_DisplayNetNamesMode == 2 )) )
        drawInfo.m_Display_netname = false;

    // Display net names is restricted to pads that are on the active layer
    // in high contrast mode display
    if( ( aDraw_mode & GR_ALLOW_HIGHCONTRAST ) &&
        !IsOnLayer( screen->m_Active_Layer ) && displ_opts && displ_opts->m_ContrastModeDisplay )
        drawInfo.m_Display_netname = false;

    DrawShape( aPanel->GetClipBox(), aDC, drawInfo );
}
示例#27
0
void D_PAD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDraw_mode, const wxPoint& aOffset )
{
    int    color = 0;
    wxSize mask_margin;   // margin (clearance) used for some non copper layers

#ifdef SHOW_PADMASK_REAL_SIZE_AND_COLOR
    int    showActualMaskSize = 0;  /* Layer number if the actual pad size on mask layer can
                                     * be displayed i.e. if only one layer is shown for this pad
                                     * and this layer is a mask (solder mask or sloder paste
                                     */
#endif

    if( m_Flags & DO_NOT_DRAW )
        return;

    PAD_DRAWINFO drawInfo;

    drawInfo.m_Offset = aOffset;

    /* We can show/hide pads from the layer manager.
     * options are show/hide pads on front and/or back side of the board
     * For through pads, we hide them only if both sides are hidden.
     * smd pads on back are hidden for all layers (copper and technical layers)
     * on back side of the board
     * smd pads on front are hidden for all layers (copper and technical layers)
     * on front side of the board
     * ECO, edge and Draw layers and not considered
     */

    // Mask layers for Back side of board
    #define BACK_SIDE_LAYERS \
    (LAYER_BACK | ADHESIVE_LAYER_BACK | SOLDERPASTE_LAYER_BACK \
     | SILKSCREEN_LAYER_BACK | SOLDERMASK_LAYER_BACK)

    // Mask layers for Front side of board
    #define FRONT_SIDE_LAYERS \
    (LAYER_FRONT | ADHESIVE_LAYER_FRONT | SOLDERPASTE_LAYER_FRONT \
     | SILKSCREEN_LAYER_FRONT | SOLDERMASK_LAYER_FRONT)

    BOARD* brd = GetBoard();
    bool   frontVisible = brd->IsElementVisible( PCB_VISIBLE( PAD_FR_VISIBLE ) );
    bool   backVisible  = brd->IsElementVisible( PCB_VISIBLE( PAD_BK_VISIBLE ) );

    if( !frontVisible && !backVisible )
        return;

    /* If pad are only on front side (no layer on back side)
     * and if hide front side pads is enabled, do not draw
     */
    if( !frontVisible && ( (m_layerMask & BACK_SIDE_LAYERS) == 0 ) )
        return;

    /* If pad are only on back side (no layer on front side)
     * and if hide back side pads is enabled, do not draw
     */
    if( !backVisible && ( (m_layerMask & FRONT_SIDE_LAYERS) == 0 ) )
        return;


    PCB_BASE_FRAME* frame  = (PCB_BASE_FRAME*) aPanel->GetParent();
    PCB_SCREEN*     screen = frame->GetScreen();

    if( frame->m_DisplayPadFill == FILLED )
        drawInfo.m_ShowPadFilled = true;
    else
        drawInfo.m_ShowPadFilled = false;

    if( m_layerMask & LAYER_FRONT )
    {
        color = brd->GetVisibleElementColor( PAD_FR_VISIBLE );
    }

    if( m_layerMask & LAYER_BACK )
    {
        color |= brd->GetVisibleElementColor( PAD_BK_VISIBLE );
    }

    if( color == 0 ) /* Not on copper layer */
    {
        // If the pad in on only one tech layer, use the layer color else use DARKGRAY
        int mask_non_copper_layers = m_layerMask & ~ALL_CU_LAYERS;
#ifdef SHOW_PADMASK_REAL_SIZE_AND_COLOR
        mask_non_copper_layers &= brd->GetVisibleLayers();
#endif
        switch( mask_non_copper_layers )
        {
        case 0:
            break;

        case ADHESIVE_LAYER_BACK:
            color = brd->GetLayerColor( ADHESIVE_N_BACK );
            break;

        case ADHESIVE_LAYER_FRONT:
            color = brd->GetLayerColor( ADHESIVE_N_FRONT );
            break;

        case SOLDERPASTE_LAYER_BACK:
            color = brd->GetLayerColor( SOLDERPASTE_N_BACK );
#ifdef SHOW_PADMASK_REAL_SIZE_AND_COLOR
            showActualMaskSize = SOLDERPASTE_N_BACK;
#endif
            break;

        case SOLDERPASTE_LAYER_FRONT:
            color = brd->GetLayerColor( SOLDERPASTE_N_FRONT );
#ifdef SHOW_PADMASK_REAL_SIZE_AND_COLOR
            showActualMaskSize = SOLDERPASTE_N_FRONT;
#endif
            break;

        case SILKSCREEN_LAYER_BACK:
            color = brd->GetLayerColor( SILKSCREEN_N_BACK );
            break;

        case SILKSCREEN_LAYER_FRONT:
            color = brd->GetLayerColor( SILKSCREEN_N_FRONT );
            break;

        case SOLDERMASK_LAYER_BACK:
            color = brd->GetLayerColor( SOLDERMASK_N_BACK );
#ifdef SHOW_PADMASK_REAL_SIZE_AND_COLOR
            showActualMaskSize = SOLDERMASK_N_BACK;
#endif
            break;

        case SOLDERMASK_LAYER_FRONT:
            color = brd->GetLayerColor( SOLDERMASK_N_FRONT );
#ifdef SHOW_PADMASK_REAL_SIZE_AND_COLOR
            showActualMaskSize = SOLDERMASK_N_FRONT;
#endif
            break;

        case DRAW_LAYER:
            color = brd->GetLayerColor( DRAW_N );
            break;

        case COMMENT_LAYER:
            color = brd->GetLayerColor( COMMENT_N );
            break;

        case ECO1_LAYER:
            color = brd->GetLayerColor( ECO1_N );
            break;

        case ECO2_LAYER:
            color = brd->GetLayerColor( ECO2_N );
            break;

        case EDGE_LAYER:
            color = brd->GetLayerColor( EDGE_N );
            break;

        default:
            color = DARKGRAY;
            break;
        }
    }

    // if PAD_SMD pad and high contrast mode
    if( ( aDraw_mode & GR_ALLOW_HIGHCONTRAST ) && 
        ( GetAttribute() == PAD_SMD || GetAttribute() == PAD_CONN ) && 
        DisplayOpt.ContrastModeDisplay )
    {
        // when routing tracks
        if( frame && frame->GetToolId() == ID_TRACK_BUTT )
        {
            int routeTop = screen->m_Route_Layer_TOP;
            int routeBot = screen->m_Route_Layer_BOTTOM;

            // if routing between copper and component layers,
            // or the current layer is one of said 2 external copper layers,
            // then highlight only the current layer.
            if( ( ( 1 << routeTop ) | ( 1 << routeBot ) ) == ( LAYER_BACK | LAYER_FRONT )
               || ( ( 1 << screen->m_Active_Layer ) & ( LAYER_BACK | LAYER_FRONT ) ) )
            {
                if( !IsOnLayer( screen->m_Active_Layer ) )
                {
                    color &= ~MASKCOLOR;
                    color |= DARKDARKGRAY;
                }
            }
            // else routing between an internal signal layer and some other
            // layer.  Grey out all PAD_SMD pads not on current or the single
            // selected external layer.
            else if( !IsOnLayer( screen->m_Active_Layer )
                    && !IsOnLayer( routeTop )
                    && !IsOnLayer( routeBot ) )
            {
                color &= ~MASKCOLOR;
                color |= DARKDARKGRAY;
            }
        }
        // when not edting tracks, show PAD_SMD components not on active layer
        // as greyed out
        else
        {
            if( !IsOnLayer( screen->m_Active_Layer ) )
            {
                color &= ~MASKCOLOR;
                color |= DARKDARKGRAY;
            }
        }
    }

#ifdef SHOW_PADMASK_REAL_SIZE_AND_COLOR
    if( showActualMaskSize )
    {
        switch( showActualMaskSize )
        {
        case SOLDERMASK_N_BACK:
        case SOLDERMASK_N_FRONT:
            mask_margin.x = mask_margin.y = GetSolderMaskMargin();
            break;

        case SOLDERPASTE_N_BACK:
        case SOLDERPASTE_N_FRONT:
            mask_margin = GetSolderPasteMargin();
            break;

        default:
            break;
        }
    }
#endif

    // if Contrast mode is ON and a technical layer active, show pads on this
    // layer so we can see pads on paste or solder layer and the size of the
    // mask
    if( ( aDraw_mode & GR_ALLOW_HIGHCONTRAST ) && 
        DisplayOpt.ContrastModeDisplay && screen->m_Active_Layer > LAST_COPPER_LAYER )
    {
        if( IsOnLayer( screen->m_Active_Layer ) )
        {
            color = brd->GetLayerColor( screen->m_Active_Layer );

            // In hight contrast mode, and if the active layer is the mask
            // layer shows the pad size with the mask clearance
            switch( screen->m_Active_Layer )
            {
            case SOLDERMASK_N_BACK:
            case SOLDERMASK_N_FRONT:
                mask_margin.x = mask_margin.y = GetSolderMaskMargin();
                break;

            case SOLDERPASTE_N_BACK:
            case SOLDERPASTE_N_FRONT:
                mask_margin = GetSolderPasteMargin();
                break;

            default:
                break;
            }
        }
        else
            color = DARKDARKGRAY;
    }


    if( aDraw_mode & GR_HIGHLIGHT )
    {
        if( aDraw_mode & GR_AND )
            color &= ~HIGHLIGHT_FLAG;
        else
            color |= HIGHLIGHT_FLAG;
    }

    if( color & HIGHLIGHT_FLAG )
        color = ColorRefs[color & MASKCOLOR].m_LightColor;

    bool DisplayIsol = DisplayOpt.DisplayPadIsol;

    if( ( m_layerMask & ALL_CU_LAYERS ) == 0 )
        DisplayIsol = false;

    if( GetAttribute() == PAD_HOLE_NOT_PLATED )
        drawInfo.m_ShowNotPlatedHole = true;

    drawInfo.m_DrawMode    = aDraw_mode;
    drawInfo.m_Color       = color;
    drawInfo.m_DrawPanel   = aPanel;
    drawInfo.m_Mask_margin = mask_margin;
    drawInfo.m_ShowNCMark  = brd->IsElementVisible( PCB_VISIBLE( NO_CONNECTS_VISIBLE ) );
    drawInfo.m_IsPrinting  = screen->m_IsPrinting;
    SetAlpha( &color, 170 );

    /* Get the pad clearance. This has a meaning only for Pcbnew.
     *  for CvPcb (and GerbView) GetClearance() creates debug errors because
     *  there is no net classes so a call to GetClearance() is made only when
     *   needed (never needed in CvPcb nor in GerbView)
     */
    drawInfo.m_PadClearance = DisplayIsol ? GetClearance() : 0;

    /* Draw the pad number */
    if( frame && !frame->m_DisplayPadNum )
        drawInfo.m_Display_padnum = false;

    if( ( DisplayOpt.DisplayNetNamesMode == 0 ) || ( DisplayOpt.DisplayNetNamesMode == 2 ) )
        drawInfo.m_Display_netname = false;

    // Display net names is restricted to pads that are on the active layer
    // in hight contrast mode display
    if( ( aDraw_mode & GR_ALLOW_HIGHCONTRAST ) && 
        !IsOnLayer( screen->m_Active_Layer ) && DisplayOpt.ContrastModeDisplay )
        drawInfo.m_Display_netname = false;

    DrawShape( aPanel->GetClipBox(), aDC, drawInfo );
}
示例#28
0
void b2World::DrawDebugData()
{
	if (m_debugDraw == NULL)
	{
		return;
	}

	uint32 flags = m_debugDraw->GetFlags();

	if (flags & b2Draw::e_shapeBit)
	{
		for (b2Body* b = m_bodyList; b; b = b->GetNext())
		{
			const b2Transform& xf = b->GetTransform();
			for (b2Fixture* f = b->GetFixtureList(); f; f = f->GetNext())
			{
				if (b->IsActive() == false)
				{
					DrawShape(f, xf, b2Color(0.5f, 0.5f, 0.3f));
				}
				else if (b->GetType() == b2_staticBody)
				{
					DrawShape(f, xf, b2Color(0.5f, 0.9f, 0.5f));
				}
				else if (b->GetType() == b2_kinematicBody)
				{
					DrawShape(f, xf, b2Color(0.5f, 0.5f, 0.9f));
				}
				else if (b->IsAwake() == false)
				{
					DrawShape(f, xf, b2Color(0.6f, 0.6f, 0.6f));
				}
				else
				{
					DrawShape(f, xf, b2Color(0.9f, 0.7f, 0.7f));
				}
			}
		}
	}

	if (flags & b2Draw::e_jointBit)
	{
		for (b2Joint* j = m_jointList; j; j = j->GetNext())
		{
			DrawJoint(j);
		}
	}

	if (flags & b2Draw::e_pairBit)
	{
		b2Color color(0.3f, 0.9f, 0.9f);
		for (b2Contact* c = m_contactManager.m_contactList; c; c = c->GetNext())
		{
			//b2Fixture* fixtureA = c->GetFixtureA();
			//b2Fixture* fixtureB = c->GetFixtureB();

			//b2Vec2 cA = fixtureA->GetAABB().GetCenter();
			//b2Vec2 cB = fixtureB->GetAABB().GetCenter();

			//m_debugDraw->DrawSegment(cA, cB, color);
		}
	}

	if (flags & b2Draw::e_aabbBit)
	{
		b2Color color(0.9f, 0.3f, 0.9f);
		b2BroadPhase* bp = &m_contactManager.m_broadPhase;

		for (b2Body* b = m_bodyList; b; b = b->GetNext())
		{
			if (b->IsActive() == false)
			{
				continue;
			}

			for (b2Fixture* f = b->GetFixtureList(); f; f = f->GetNext())
			{
				for (int32 i = 0; i < f->m_proxyCount; ++i)
				{
					b2FixtureProxy* proxy = f->m_proxies + i;
					b2AABB aabb = bp->GetFatAABB(proxy->proxyId);
					b2Vec2 vs[4];
					vs[0].Set(aabb.lowerBound.x, aabb.lowerBound.y);
					vs[1].Set(aabb.upperBound.x, aabb.lowerBound.y);
					vs[2].Set(aabb.upperBound.x, aabb.upperBound.y);
					vs[3].Set(aabb.lowerBound.x, aabb.upperBound.y);

					m_debugDraw->DrawPolygon(vs, 4, color);
				}
			}
		}
	}

	if (flags & b2Draw::e_centerOfMassBit)
	{
		for (b2Body* b = m_bodyList; b; b = b->GetNext())
		{
			b2Transform xf = b->GetTransform();
			xf.p = b->GetWorldCenter();
			m_debugDraw->DrawTransform(xf);
		}
	}
}
示例#29
0
void b2World::DrawDebugData()
{
	if (m_debugDraw == NULL)
	{
		return;
	}

	uint32 flags = m_debugDraw->GetFlags();

	if (flags & b2DebugDraw::e_shapeBit)
	{
		for (b2Body* b = m_bodyList; b; b = b->GetNext())
		{
			const b2Transform& xf = b->GetTransform();
			for (b2Fixture* f = b->GetFixtureList(); f; f = f->GetNext())
			{
				if (b->IsStatic())
				{
					DrawShape(f, xf, b2Color(0.5f, 0.9f, 0.5f));
				}
				else if (b->IsSleeping())
				{
					DrawShape(f, xf, b2Color(0.5f, 0.5f, 0.9f));
				}
				else
				{
					DrawShape(f, xf, b2Color(0.9f, 0.9f, 0.9f));
				}
			}
		}
	}

	if (flags & b2DebugDraw::e_jointBit)
	{
		for (b2Joint* j = m_jointList; j; j = j->GetNext())
		{
			if (j->GetType() != e_mouseJoint)
			{
				DrawJoint(j);
			}
		}
	}

	if (flags & b2DebugDraw::e_pairBit)
	{
		// TODO_ERIN
	}

	if (flags & b2DebugDraw::e_aabbBit)
	{
		b2Color color(0.9f, 0.3f, 0.9f);
		b2BroadPhase* bp = &m_contactManager.m_broadPhase;

		for (b2Body* b = m_bodyList; b; b = b->GetNext())
		{
			for (b2Fixture* f = b->GetFixtureList(); f; f = f->GetNext())
			{
				b2AABB aabb = bp->GetFatAABB(f->m_proxyId);
				b2Vec2 vs[4];
				vs[0].Set(aabb.lowerBound.x, aabb.lowerBound.y);
				vs[1].Set(aabb.upperBound.x, aabb.lowerBound.y);
				vs[2].Set(aabb.upperBound.x, aabb.upperBound.y);
				vs[3].Set(aabb.lowerBound.x, aabb.upperBound.y);

				m_debugDraw->DrawPolygon(vs, 4, color);
			}
		}
	}

	if (flags & b2DebugDraw::e_centerOfMassBit)
	{
		for (b2Body* b = m_bodyList; b; b = b->GetNext())
		{
			b2Transform xf = b->GetTransform();
			xf.position = b->GetWorldCenter();
			m_debugDraw->DrawXForm(xf);
		}
	}
}
void DoPaint(HWND hWnd)
{
    int         i;

    HDC		hdc,
		hMemDC;

    RECT	theRect,
		destRect;

    HBITMAP	theBitmap;
    PAINTSTRUCT	ps;

    if (CurrentPoint >= 0)
    {
	hdc = BeginPaint(hWnd,&ps);
	/*
	 * Determine which rectangle on the window is invalid.
	 * If no rectangle is marked invalid, it will be a full
	 * window repaint.
	 */
	GetUpdateRect(hWnd,&theRect,0);
	if (IsRectEmpty(&theRect))
	    GetClientRect(hWnd,&theRect);

	/*
	 * Create a memory DC and bitmap the same
	 * size as the update rectangle.
	 */
	hMemDC = CreateCompatibleDC(hdc);
	theBitmap = CreateCompatibleBitmap(hdc,
					   theRect.right-theRect.left,
					   theRect.bottom-theRect.top);
	SelectObject(hMemDC,theBitmap);

	/*
	 * Erase the memBitmap.
	 */
	BitBlt(hMemDC, 0, 0,
	       theRect.right-theRect.left,
	       theRect.bottom-theRect.top,
	       hdc, 0, 0, SRCCOPY);

	/*
	 * Draw only those shapes that lie
	 * within the update rectangle.
	 */
	for (i = 0; i <= CurrentPoint; ++i)
	{
	    IntersectRect(&destRect, &thisShape[i].Points, &theRect);
	    if (!IsRectEmpty(&destRect))
		DrawShape(hMemDC,
			  thisShape[i].Points.left-theRect.left,
			  thisShape[i].Points.top-theRect.top,
			  thisShape[i].Points.right-theRect.left,
			  thisShape[i].Points.bottom-theRect.top,
			  thisShape[i].theShape,thisShape[i].PenWidth,
			  thisShape[i].PenColor,thisShape[i].Slope);
		/*
		 * Note that when drawing the shape, the shape's
		 * position was transformed so that the origin was
		 * at the upper-left corner of the update rectangle.
		 * This is the point (0,0) on the bitmap that will
		 * map onto (theRect.left,theRect.right).
		 */
	}

	/*
	 * Finally, copy the bitmap onto the update rectangle.
	 */
	BitBlt(hdc, theRect.left, theRect.top,
	       theRect.right-theRect.left,
	       theRect.bottom-theRect.top,
	       hMemDC, 0, 0, SRCCOPY);

	DeleteDC(hMemDC);
	DeleteObject(theBitmap);
	EndPaint(hWnd,&ps);
     }

}