Пример #1
0
void CDisplay::drawMode(QPainter *p)
{
    QRect size = this->geometry();
    int left = size.width()/4;
    int right = size.width()*3/4;
    int top = size.height()*2.3/3;
    QColor cyan(Qt::cyan);
    QBrush brush(cyan);
    QFont font("Times", 8, QFont::Bold);
    QFontMetrics    fm(font);
    QRect           r = fm.boundingRect(QString("%1").arg(Mode1));
    QPen pen(Qt::cyan, 2.0, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    r.moveCenter(QPoint(left,top));
    p->setBrush(brush);
    p->setFont(font);
    p->drawRoundRect(QRectF(left - 20.0, top - 10.0, 40.0, 20.0));
    pen.setColor(QColor(Qt::black));
    p->setPen(pen);
    p->drawText(r, QString("%1").arg(Mode1));
    pen.setColor(QColor(Qt::cyan));

    r = fm.boundingRect(QString("%1").arg(Mode2));
    r.moveCenter(QPoint(right,top));
    p->setBrush(brush);
    p->setFont(font);
    p->drawRoundRect(QRectF(right - 20.0, top - 10.0, 40.0, 20.0));
    pen.setColor(QColor(Qt::black));
    p->setPen(pen);
    p->drawText(r, QString("%1k").arg(Mode2));
    pen.setColor(QColor(Qt::cyan));

}
Пример #2
0
osgToy::OctoStrip::OctoStrip()
{
    osg::Vec3Array* vAry = dynamic_cast<osg::Vec3Array*>( getVertexArray() );

    osg::Vec3Array* nAry = dynamic_cast<osg::Vec3Array*>( getNormalArray() );
    setNormalBinding( osg::Geometry::BIND_PER_VERTEX );

    osg::Vec4Array* cAry = dynamic_cast<osg::Vec4Array*>( getColorArray() );
    setColorBinding( osg::Geometry::BIND_PER_VERTEX );

    osg::Vec3 xp( 1, 0, 0);   osg::Vec4 red(1,0,0,1);
    osg::Vec3 xn(-1, 0, 0);   osg::Vec4 cyan(0,1,1,1);
    osg::Vec3 yp( 0, 1, 0);   osg::Vec4 green(0,1,0,1);
    osg::Vec3 yn( 0,-1, 0);   osg::Vec4 magenta(1,0,1,1);
    osg::Vec3 zp( 0, 0, 1);   osg::Vec4 blue(0,0,1,1);
    osg::Vec3 zn( 0, 0,-1);   osg::Vec4 yellow(1,1,0,1);

    vAry->push_back(zp); nAry->push_back(zp); cAry->push_back(blue);
    vAry->push_back(yp); nAry->push_back(yp); cAry->push_back(green);
    vAry->push_back(xn); nAry->push_back(xn); cAry->push_back(cyan);
    vAry->push_back(zn); nAry->push_back(zn); cAry->push_back(yellow);
    vAry->push_back(yn); nAry->push_back(yn); cAry->push_back(magenta);
    vAry->push_back(xp); nAry->push_back(xp); cAry->push_back(red);
    vAry->push_back(zp); nAry->push_back(zp); cAry->push_back(blue);
    vAry->push_back(yp); nAry->push_back(yp); cAry->push_back(green);

    addPrimitiveSet( new osg::DrawArrays( GL_TRIANGLE_STRIP, 0, vAry->size() ) );
}
Пример #3
0
void Component::showEllipse(Mat nbrhd, float radius_ir, Point2f ctr_ir) {
	if (size()<=5) return;
	Scalar cyan(255,255,0); Scalar black(0,0,0); Scalar yellow(0,255,255);
	Scalar white(255,255,255);
	float f_diff=0;
	
	stringstream ss; ss << id%100; 

	Point2f ctr_tmp=ctr;
	ctr_tmp.x=ctr_tmp.x*radius_ir;
	ctr_tmp.y=ctr_tmp.y*radius_ir;
	ctr_tmp=ctr_tmp+ctr_ir;
	Size2f a_b(a,b);
	a_b=a_b*radius_ir;
	ellipse(nbrhd,ctr_tmp,a_b,(phi+f_diff)*(180/M_PI),0,360,black, 3,2);
	ellipse(nbrhd,ctr_tmp,a_b,(phi+f_diff)*(180/M_PI),0,360,white ,1,2);
	RNG rng( 0xFFFFFFFF );
	putText( nbrhd, ss.str().c_str(), ctr_tmp,
	         0, 				// font face
	         0.3,								// font scale
	         white,							// font color
	         2);
	putText( nbrhd, ss.str().c_str(), ctr_tmp,
	         0, 				// font face
	         0.3,								// font scale
	         black,							// font color
	         1);
}
void RouteMapOverlay::RenderIsoRoute(IsoRoute *r, wxColour &grib_color, wxColour &climatology_color,
                                     wrDC &dc, PlugIn_ViewPort &vp)
{
    SkipPosition *s = r->skippoints;
    if(!s)
        return;

    wxColour grib_deficient_color = TransparentColor(grib_color);
    wxColour climatology_deficient_color = TransparentColor(climatology_color);

    Position *p = s->point;
    wxColour *pcolor = &PositionColor(p, grib_color, climatology_color,
                                      grib_deficient_color, climatology_deficient_color);
    if(!dc.GetDC())
        glBegin(GL_LINES);
    do {
        wxColour &ncolor = PositionColor(p->next, grib_color, climatology_color,
                                         grib_deficient_color, climatology_deficient_color);
        if(!p->copied || !p->next->copied)
            DrawLine(p, *pcolor, p->next, ncolor, dc, vp);
        pcolor = &ncolor;
        p = p->next;
    } while(p != s->point);
    if(!dc.GetDC())
        glEnd();

    /* now render any children */
    wxColour cyan(0, 255, 255), magenta(255, 0, 255);
    for(IsoRouteList::iterator it = r->children.begin(); it != r->children.end(); ++it)
        RenderIsoRoute(*it, cyan, magenta, dc, vp);
}
Пример #5
0
void
LineSegment2I::TestDraw( )
{
    Color3B gray( 100, 100, 100 );
    Color3B yellow( 255, 255, 0 );
    Color3B magenta( 255, 0, 255 );
    Color3B cyan( 0, 255, 255 );

    int x = 60;
    int y = 20;
    int dx = 100;
    int dy = 80;
    LineSegment2I ln1( x, y, dx, dy );
    int x1 = 160;
    int y1 = 20;
    int x2 = 60;
    int y2 = 100;
    LineSegment2I ln2( Point2I( x1, y1 ), Point2I( x2, y2 ) );

    Rectangle oldClip = Surface::Current()->ClippingRect();
    ln1.Draw( gray );
    ln2.Draw( gray );
    Surface::Current()->SetClippingRect( Rectangle( 100, 50, 20, 20 ) );
    ln1.Draw( yellow );
    ln2.Draw( yellow );
    Surface::Current()->SetClippingRect( Rectangle( 60, 10, 20, 200 ) );
    ln1.Draw( cyan );
    ln2.Draw( cyan );
    Surface::Current()->SetClippingRect( Rectangle( 140, 10, 20, 200 ) );
    ln1.Draw( magenta );
    ln2.Draw( magenta );
    Surface::Current()->SetClippingRect( oldClip );
}
Пример #6
0
bool TriangleGame::loadContent()
{
	vertexShader.reset(device->createVertexShader("TriangleShader.fx", "VS_Main", "vs_4_0"));

	vector<InputElementDescriptor> inputElements;
	inputElements.push_back(InputElementDescriptor("POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, true, 0));
	inputElements.push_back(InputElementDescriptor("COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 12, true, 0));
	inputLayout.reset(device->createInputLayout(inputElements, vertexShader.get()));

	pixelShader.reset(device->createPixelShader("TriangleShader.fx", "PS_Main", "ps_4_0"));

	float minX = -0.5f;
	float maxX = 0.5f;
	float minY = -1.0f;
	float maxY = 1.0f;
	XMFLOAT4 red(1.0f, 0.0f, 0.0f, 1.0f);
	XMFLOAT4 green(0.0f, 1.0f, 0.0f, 1.0f);
	XMFLOAT4 blue(0.0f, 0.0f, 1.0f, 1.0f);
	XMFLOAT4 yellow(1.0f, 1.0f, 0.0f, 1.0f);
	XMFLOAT4 cyan(0.0f, 1.0f, 1.0f, 1.0f);
	XMFLOAT4 magenta(1.0f, 0.0f, 1.0f, 1.0f);
	XMFLOAT4 white(1.0f, 1.0f, 1.0f, 1.0f);

	vector<Vertex> vertices;
	vertices.push_back(Vertex(XMFLOAT3(minX, maxY, 0.5f), red));
	vertices.push_back(Vertex(XMFLOAT3(maxX, maxY, 0.5f), green));
	vertices.push_back(Vertex(XMFLOAT3(minX, 0.0f, 0.5f), blue));
	vertices.push_back(Vertex(XMFLOAT3(maxX, 0.0f, 0.5f), yellow));
	vertices.push_back(Vertex(XMFLOAT3(minX, minY, 0.5f), cyan));
	vertices.push_back(Vertex(XMFLOAT3(maxX, minY, 0.5f), magenta));
	vertexBuffer.reset(device->createVertexBuffer(vertices.size() * sizeof(Vertex), &vertices[0]));

	return true;
}
Пример #7
0
/* Envoie le handshake au pair donné. */
void send_handshake(const struct proto_peer *peer, const struct proto_client_handshake *hs) {
    cyan() ;
    printf("Send handshake to %d\n",peer->peerId) ;
    normal() ;
    write(peer->sockfd,&hs->version,sizeof(hs->version)) ;
    write(peer->sockfd,&hs->filehash,sizeof(hs->filehash)) ;
    write(peer->sockfd,&hs->peerId,sizeof(hs->peerId)) ;

}
Пример #8
0
/// <summary>
/// Cuboid constructor, takes size in 3 axes and creates cuboid at origin.
/// New cuboid constructor code based on a mesh object.
/// <summary>
/// <param name="SX">Size of cuboid in X direction</param>
/// <param name="SY">Size of cuboid in Y direction</param>
/// <param name="SZ">Size of cuboid in Z direction</param>
Cuboid::Cuboid(double SX, double SY, double SZ) {
	float hSX=(float)SX/2, hSY=(float)SY/2, hSZ=(float)SZ/2; //half sizes

	//create a unit cube using the mesh helpers
	glm::vec3 p[] = {
		//front face
		glm::vec3( hSX, -hSY,  hSZ), //0
		glm::vec3( hSX,  hSY,  hSZ), //1
		glm::vec3(-hSX,  hSY,  hSZ), //2
		glm::vec3(-hSX, -hSY,  hSZ), //3
		//back face
		glm::vec3( hSX, -hSY, -hSZ), //4
		glm::vec3( hSX,  hSY, -hSZ), //5
		glm::vec3(-hSX,  hSY, -hSZ), //6
		glm::vec3(-hSX, -hSY, -hSZ)  //7
	};

	//add faces one at a time here
	glm::vec3 red(1.0,0.0,0.0);
	glm::vec3 green(0.0,1.0,0.0);
	glm::vec3 blue(0.0,0.0,1.0);
	glm::vec3 yellow(1.0,1.0,0.0);
	glm::vec3 cyan(0.0,1.0,1.0);
	glm::vec3 magenta(1.0,0.0,1.0);
	AddFace(p[0],p[1],p[2],red,red,red); //front
	AddFace(p[0],p[2],p[3],red,red,red);
	AddFace(p[4],p[5],p[1],blue,blue,blue); //right
	AddFace(p[4],p[1],p[0],blue,blue,blue);
	AddFace(p[1],p[5],p[6],green,green,green); //top
	AddFace(p[1],p[6],p[2],green,green,green);
	AddFace(p[3],p[2],p[6],cyan,cyan,cyan); //left
	AddFace(p[3],p[6],p[7],cyan,cyan,cyan);
	AddFace(p[4],p[0],p[3],magenta,magenta,magenta); //bottom
	AddFace(p[4],p[3],p[7],magenta,magenta,magenta);
	AddFace(p[7],p[6],p[5],yellow,yellow,yellow); //back
	AddFace(p[7],p[5],p[4],yellow,yellow,yellow);

	CreateBuffers();
}
Пример #9
0
osgToy::TetraStrip::TetraStrip()
{
    osg::Vec3Array* vAry = dynamic_cast<osg::Vec3Array*>( getVertexArray() );

    osg::Vec3Array* nAry = dynamic_cast<osg::Vec3Array*>( getNormalArray() );
    setNormalBinding( osg::Geometry::BIND_PER_VERTEX );

    osg::Vec4Array* cAry = dynamic_cast<osg::Vec4Array*>( getColorArray() );
    setColorBinding( osg::Geometry::BIND_PER_VERTEX );

    osg::Vec3 ppp(  1,  1,  1);   osg::Vec4 white(1,1,1,1);
    osg::Vec3 nnp( -1, -1,  1);   osg::Vec4 blue(0,0,1,1);
    osg::Vec3 pnn(  1, -1, -1);   osg::Vec4 red(1,0,0,1);
    osg::Vec3 npn( -1,  1, -1);   osg::Vec4 green(0,1,0,1);
    osg::Vec3 ppn(  1,  1, -1);   osg::Vec4 yellow(1,1,0,1);
    osg::Vec3 pnp(  1, -1,  1);   osg::Vec4 magenta(1,0,1,1);
    osg::Vec3 nnn( -1, -1, -1);   osg::Vec4 black(0,0,0,1);
    osg::Vec3 npp( -1,  1,  1);   osg::Vec4 cyan(0,1,1,1);

#if 1
    vAry->push_back(ppp); nAry->push_back(ppp); cAry->push_back(white);
    vAry->push_back(nnp); nAry->push_back(nnp); cAry->push_back(blue);
    vAry->push_back(pnn); nAry->push_back(pnn); cAry->push_back(red);
    vAry->push_back(npn); nAry->push_back(npn); cAry->push_back(green);
    vAry->push_back(ppp); nAry->push_back(ppp); cAry->push_back(white);
    vAry->push_back(nnp); nAry->push_back(nnp); cAry->push_back(blue);
#else
    vAry->push_back(ppn); nAry->push_back(ppn); cAry->push_back(yellow);
    vAry->push_back(pnp); nAry->push_back(pnp); cAry->push_back(magenta);
    vAry->push_back(nnn); nAry->push_back(nnn); cAry->push_back(black);
    vAry->push_back(npp); nAry->push_back(npp); cAry->push_back(cyan);
    vAry->push_back(ppn); nAry->push_back(ppn); cAry->push_back(yellow);
    vAry->push_back(pnp); nAry->push_back(pnp); cAry->push_back(magenta);
#endif

    addPrimitiveSet( new osg::DrawArrays( GL_TRIANGLE_STRIP, 0, vAry->size() ) );
}
Пример #10
0
//------------------------------------------------------------------------------
// serialize() -- print the value of this object to the output stream sout.
//------------------------------------------------------------------------------
std::ostream& Cmy::serialize(std::ostream& sout, const int i, const bool slotsOnly) const
{
    int j = 0;
    if ( !slotsOnly ) {
        sout << "( " << getFactoryName() << std::endl;
        j = 4;
    }

    indent(sout,i+j);
    sout << "cyan:    " << cyan() << std::endl;

    indent(sout,i+j);
    sout << "magenta: " << magenta() << std::endl;

    indent(sout,i+j);
    sout << "yellow:  " << yellow() << std::endl;

    if ( !slotsOnly ) {
        indent(sout,i);
        sout << ")" << std::endl;
    }

    return sout;
}
Пример #11
0
/* Create a new backing pixmap of the appropriate size */
int PopulationDrawingArea::configure_event_impl (GdkEventConfigure * /* event */)
  {

    Gdk_Font font ( "-*-courier-bold-*-*-*-*-120-*-*-*-*-*-*");
    list<Generation_viz*>::iterator curgen;
    Generation_viz *lastgen=0;
    list<Species_viz*>::iterator curspec;
    list<Species_viz*>::iterator curspec2;
    Species_viz *samespec=0;
    Gdk_Color red("red");
    Gdk_Color white("white");
    Gdk_Color black("black");
    Gdk_Color blue("blue");
    Gdk_Color cyan("cyan");
    Gdk_Color yellow("yellow");
    Gdk_Color green("green");
    Gdk_Color orange("orange");
    Gdk_Color purple("purple");
    GdkPoint points[4];  //The polygonal area to fill

    get_colormap().alloc(black);
    get_colormap().alloc(white);
    get_colormap().alloc(red);
    get_colormap().alloc(blue);
    get_colormap().alloc(cyan);
    get_colormap().alloc(yellow);
    get_colormap().alloc(green);
    get_colormap().alloc(orange);
    get_colormap().alloc(purple);
    int ypos=3;
    int xpos=3;
    double ypixels=height()-6;
    double xpixels=width()-6;
    int ystep;
    int xstep;
    int num_gens=stop_gen-start_gen+1;  //Total number of generations
    int gen_count;
    int print_number_every=(int) num_gens/10;
    bool y_for_gens;  //Flag for deciding on which axis is which


    //Markers for points where the color should change with fitness
    //Mark 3 is the MEAN
    //Mark 1 and 2 are 2 and 1 std. away respectively, going down
    //Mark 4 and 5 are 1 and 2 std. away respectively, going up
    double mark1,mark2,mark3,mark4,mark5;

    if (num_gens<10) print_number_every=1;
    
    if (width()>height())
      y_for_gens=false;
    else y_for_gens=true;

    mark3=pop->mean_fitness;
    mark2=mark3-(pop->standard_deviation);
    mark1=mark2-(pop->standard_deviation);
    mark4=mark3+(pop->standard_deviation);
    mark5=mark4+(pop->standard_deviation);

    //cout<<"blue "<<mark1<<" cyan "<<mark2<<" green "<<mark3<<" orange "<<mark4<<" purple "<<mark5<<" red"<<endl;

    cout<<"blue "<<mark3<<" black "<<mark5<<" red"<<endl;

    //Computer the step
    if (y_for_gens)
      ystep=(int) floor(ypixels/((double) num_gens));
    else xstep=(int) floor(xpixels/((double) num_gens));

    char text[20];

    win = get_window();
    visual = win.get_visual();

    if (pixmap)
      pixmap.release();
    
    pixmap.create(get_window(),  width(), height());

    if (!gc)
      {
        gc = Gdk_GC(pixmap);
	gc.set_foreground(white);
      }
    //gc = get_style()->get_white_gc();
    gc.set_foreground(white);
    pixmap.draw_rectangle (gc,
			TRUE,
			0, 0,
			width(),
			height());

    //Set the current generation to the start gen
    curgen=(pop->generation_snapshots).begin();
    for(gen_count=1;gen_count<start_gen;gen_count++)
      ++curgen;

    //DRAW THE POPULATION HERE
    for(gen_count=start_gen;gen_count<=stop_gen;gen_count++) {

      //Print the gen_num in the left or bottom column space every few gens
      if ((gen_count%print_number_every)==0) {
	gc.set_foreground(black);
	itoa(gen_count,text);
	if (y_for_gens) 
	  pixmap.draw_text      (font,
				 gc,
				 1,
				 ypos+5,
				 text,
				 strlen(text));
	else pixmap.draw_text      (font,
				    gc,
				    xpos-5,
				    height()-10,
				    text,
				    strlen(text));
      }

      //Draw each Species in the current generation
      for(curspec=((*curgen)->species_list).begin();curspec!=((*curgen)->species_list).end();++curspec) {
	
	//Determine the line color for this species
	if (((*curspec)->max_fitness)<mark1) {
	    gc.set_foreground(blue);
	    //gc.set_line_width(1);
	}
	else if (((*curspec)->max_fitness)<mark2) {
	    gc.set_foreground(blue);
	    //gc.set_line_width(1);
	}
	else if (((*curspec)->max_fitness)<mark3) {
	    gc.set_foreground(blue);
	    //gc.set_line_width(2);
	}
	else if (((*curspec)->max_fitness)<mark4) {
	    gc.set_foreground(black);
	    //gc.set_line_width(2);
	}
	else if (((*curspec)->max_fitness)<mark5) {
	    gc.set_foreground(black);
	    //gc.set_line_width(3);
	}
	else {
	    gc.set_foreground(red);
	    //gc.set_line_width(3);
	}

	//If this is the first gen, then everything is a straight line
	if (gen_count==start_gen) {
	  //gc.set_foreground(black);
	  //gc.set_line_width(floor(fabs(2*((*curlink)->weight))));
	  if (y_for_gens)
	    pixmap.draw_line(gc,
			     (*curspec)->startx,
			     ypos,
			     (*curspec)->endx, 
			     ypos);
	  else pixmap.draw_line(gc,
				xpos,
				(*curspec)->starty,
				xpos, 
				(*curspec)->endy);
	}
	else {
	  //Check the previous generation for this same Species
	  curspec2=(lastgen->species_list).begin();
	  while ((curspec2!=(lastgen->species_list).end())&&
		 (((*curspec2)->id)!=((*curspec)->id)))
	    ++curspec2;

	  //If it is not found, just draw a horizontal line
	  if (curspec2==(lastgen->species_list).end()) {
	    if (y_for_gens)
	      pixmap.draw_line(gc,
			       (*curspec)->startx,
			       ypos,
			       (*curspec)->endx, 
			       ypos);
	    else pixmap.draw_line(gc,
				  xpos,
				  (*curspec)->starty,
				  xpos, 
				  (*curspec)->endy);

	  }

	  //Otherwise, if it existed before, connect the 2 endpoint pairs
	  else {
 
	    //Instead of just linking lines, draw a filled polygon
	    //contained by them
	    if (y_for_gens) {
	      points[0].x=(*curspec)->startx;
	      points[0].y=ypos;
	      points[1].x=(*curspec)->endx;
	      points[1].y=ypos;
	      points[2].x=(*curspec2)->endx;
	      points[2].y=ypos-ystep;
	      points[3].x=(*curspec2)->startx;
	      points[3].y=ypos-ystep;
	    }
	    else {
	      points[0].x=xpos;
	      points[0].y=(*curspec)->starty;
	      points[1].x=xpos;
	      points[1].y=(*curspec)->endy;;
	      points[2].x=xpos-xstep;
	      points[2].y=(*curspec2)->endy;
	      points[3].x=xpos-xstep;
	      points[3].y=(*curspec2)->starty;
	    }

	    pixmap.draw_polygon    (gc,
				    TRUE,
				    points,
				    4);

    
	    //Make white borders
	    gc.set_foreground(white);
	    gc.set_line_width(1);
	    if (y_for_gens) {
	      pixmap.draw_line(gc,
			       (*curspec)->startx,
			       ypos,
			       (*curspec2)->startx, 
			       ypos-ystep);
	      pixmap.draw_line(gc,
			       (*curspec)->endx,
			       ypos,
			       (*curspec2)->endx, 
			       ypos-ystep);
	    }
	    else {
	      pixmap.draw_line(gc,
			       xpos,
			       (*curspec)->starty,
			       xpos-xstep, 
			       (*curspec2)->starty);
	      pixmap.draw_line(gc,
			       xpos,
			       (*curspec)->endy,
			       xpos-xstep, 
			       (*curspec2)->endy);
	    }


	  }

	  //Print the Species' id for high fitness
	  if ((*curspec)->max_fitness>mark5) {
	    gc.set_foreground(black);
	    itoa((*curspec)->id,text);
	    if (y_for_gens)
	      pixmap.draw_text      (font,
				     gc,
				     (int) ((((*curspec)->endx)+((*curspec)->startx))/2.0),
				     ypos,
				     text,
				     strlen(text));
	    else pixmap.draw_text      (font,
					gc,
					xpos-5,
					(int) ((((*curspec)->endy)+((*curspec)->starty))/2.0)+5.0,
					text,
					strlen(text));
	  }
	    
	  

	}

      }  //End for on curspec

      //Increment pos
      ypos+=ystep;
      xpos+=xstep;
      
      //Remember the last generation
      lastgen=(*curgen);

      ++curgen;

    } //End for on curgen


    //Print labels in a separate loop so they don't get painted over    
    
    //Set the current generation to the start gen
    curgen=(pop->generation_snapshots).begin();
    for(gen_count=1;gen_count<start_gen;gen_count++)
      ++curgen;
    ypos=3;
    xpos=3;
    for(gen_count=start_gen;gen_count<=stop_gen;gen_count++) {
      
      //Draw each Species in the current generation
      for(curspec=((*curgen)->species_list).begin();curspec!=((*curgen)->species_list).end();++curspec) {
	
	if ((*curspec)->max_fitness>mark5) {
	  gc.set_foreground(black);
	  itoa((*curspec)->id,text);
	  if (y_for_gens)
	    pixmap.draw_text      (font,
				   gc,
				   (int) ((((*curspec)->endx)+((*curspec)->startx))/2.0),
				   ypos,
				   text,
				   strlen(text));
	  else pixmap.draw_text      (font,
				      gc,
				      xpos-7,
				      (int) ((((*curspec)->endy)+((*curspec)->starty))/2.0)+5.0,
				      text,
				      strlen(text));
	}
	
      }
      
      //Increment pos
      ypos+=ystep;
      xpos+=xstep;
      
      //Remember the last generation
      lastgen=(*curgen);
      
      ++curgen;
      
    }
    
    return TRUE;
    
  }
Пример #12
0
void
My_TestGLDrawing::InitTest()
{
    _renderIndex = HdRenderIndex::New(&_renderDelegate);
    TF_VERIFY(_renderIndex != nullptr);
    _delegate = new Hdx_UnitTestDelegate(_renderIndex);

    _delegate->SetRefineLevel(_refineLevel);

    // prepare render task
    SdfPath renderSetupTask("/renderSetupTask");
    SdfPath renderTask("/renderTask");
    _delegate->AddRenderSetupTask(renderSetupTask);
    _delegate->AddRenderTask(renderTask);

    // render task parameters.
    HdxRenderTaskParams param
        = _delegate->GetTaskParam(
            renderSetupTask, HdTokens->params).Get<HdxRenderTaskParams>();
    param.enableLighting = true; // use default lighting
    _delegate->SetTaskParam(renderSetupTask, HdTokens->params, VtValue(param));
    _delegate->SetTaskParam(renderTask, HdTokens->collection,
                           VtValue(HdRprimCollection(HdTokens->geometry,
                                   _reprName)));

    // prepare scene
    // To ensure that the non-aggregated element index returned via picking, 
    // we need to have at least two cubes with uniform colors.
    GfVec4f red(1,0,0,1), green(0,1,0,1), blue(0,0,1,1),
            yellow(1,1,0,1), magenta(1,0,1,1), cyan(0,1,1,1),
            white(1,1,1,1), black(0,0,0,1);

    GfVec4f faceColors[] = { red, green, blue, yellow, magenta, cyan};
    VtValue faceColor = VtValue(_BuildArray(&faceColors[0],
                                 sizeof(faceColors)/sizeof(faceColors[0])));

    GfVec4f vertColors[] = { white, blue, green, yellow,
                             black, blue, magenta, red};
    VtValue vertColor = VtValue(_BuildArray(&vertColors[0],
                                 sizeof(vertColors)/sizeof(vertColors[0])));

    _delegate->AddCube(SdfPath("/cube0"), _GetTranslate( 5, 0, 5),
                       /*guide=*/false, /*instancerId=*/SdfPath(),
                       /*scheme=*/PxOsdOpenSubdivTokens->catmark,
                       /*color=*/faceColor,
                       /*colorInterpolation=*/Hdx_UnitTestDelegate::UNIFORM);
    _delegate->AddCube(SdfPath("/cube1"), _GetTranslate(-5, 0, 5),
                       /*guide=*/false, /*instancerId=*/SdfPath(),
                       /*scheme=*/PxOsdOpenSubdivTokens->catmark,
                       /*color=*/faceColor,
                       /*colorInterpolation=*/Hdx_UnitTestDelegate::UNIFORM);
    _delegate->AddCube(SdfPath("/cube2"), _GetTranslate(-5, 0,-5));
    _delegate->AddCube(SdfPath("/cube3"), _GetTranslate( 5, 0,-5),
                        /*guide=*/false, /*instancerId=*/SdfPath(),
                       /*scheme=*/PxOsdOpenSubdivTokens->catmark,
                       /*color=*/vertColor,
                       /*colorInterpolation=*/Hdx_UnitTestDelegate::VERTEX);

    {
        _delegate->AddInstancer(SdfPath("/instancerTop"));
        _delegate->AddCube(SdfPath("/protoTop"),
                         GfMatrix4d(1), false, SdfPath("/instancerTop"));

        std::vector<SdfPath> prototypes;
        prototypes.push_back(SdfPath("/protoTop"));

        VtVec3fArray scale(3);
        VtVec4fArray rotate(3);
        VtVec3fArray translate(3);
        VtIntArray prototypeIndex(3);

        scale[0] = GfVec3f(1);
        rotate[0] = GfVec4f(0);
        translate[0] = GfVec3f(3, 0, 2);
        prototypeIndex[0] = 0;

        scale[1] = GfVec3f(1);
        rotate[1] = GfVec4f(0);
        translate[1] = GfVec3f(0, 0, 2);
        prototypeIndex[1] = 0;

        scale[2] = GfVec3f(1);
        rotate[2] = GfVec4f(0);
        translate[2] = GfVec3f(-3, 0, 2);
        prototypeIndex[2] = 0;

        _delegate->SetInstancerProperties(SdfPath("/instancerTop"),
                                        prototypeIndex,
                                        scale, rotate, translate);
    }

    {
        _delegate->AddInstancer(SdfPath("/instancerBottom"));
        _delegate->AddCube(SdfPath("/protoBottom"),
                         GfMatrix4d(1), false, SdfPath("/instancerBottom"));

        std::vector<SdfPath> prototypes;
        prototypes.push_back(SdfPath("/protoBottom"));

        VtVec3fArray scale(3);
        VtVec4fArray rotate(3);
        VtVec3fArray translate(3);
        VtIntArray prototypeIndex(3);

        scale[0] = GfVec3f(1);
        rotate[0] = GfVec4f(0);
        translate[0] = GfVec3f(3, 0, -2);
        prototypeIndex[0] = 0;

        scale[1] = GfVec3f(1);
        rotate[1] = GfVec4f(0);
        translate[1] = GfVec3f(0, 0, -2);
        prototypeIndex[1] = 0;

        scale[2] = GfVec3f(1);
        rotate[2] = GfVec4f(0);
        translate[2] = GfVec3f(-3, 0, -2);
        prototypeIndex[2] = 0;

        _delegate->SetInstancerProperties(SdfPath("/instancerBottom"),
                                        prototypeIndex,
                                        scale, rotate, translate);
    }

    SetCameraTranslate(GfVec3f(0, 0, -20));

    // XXX: Setup a VAO, the current drawing engine will not yet do this.
    glGenVertexArrays(1, &vao);
    glBindVertexArray(vao);
    glBindVertexArray(0);
}
Пример #13
0
void CDisplay::drawFilter(QPainter *p)
{
    QRect size = this->geometry();
    int grid = 4;
    QPen penaxis(Qt::white, 1.0, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    QPen pen(Qt::cyan, 2.0, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    // Draw axis 1
    qreal axisx1 = (size.width()*1.75/grid);
    qreal axisx2 = (size.width()*1.25/grid);
    qreal axiswidth = axisx1 - axisx2;
    qreal axisy1 = size.height()*2/3;
    qreal axisy2 = size.height()*2.5/3 ;
    qreal axisheight = axisy2 -axisy1;
    qreal axismid = axisx1 + (axisx2 - axisx1)/2.0;
    qreal pos = 128*axiswidth/255.0;
    // Draw center axis
    p->setPen(penaxis);
    //draw bottom axis
    p->drawLine(QPointF(axisx1,axisy2), QPointF(axisx2,axisy2));
    penaxis.setStyle(Qt::DashLine);
    p->drawLine(QPointF(axismid, axisy1 ), QPointF(axismid,axisy2));
    penaxis.setStyle(Qt::SolidLine);

    // Draw Filter1 band
    p->setPen(pen);
    //top
    p->drawLine(QPointF(axisx2 + pos + (Filter1*axiswidth/460000.0) , axisy1 + axisheight * 2 /8), QPointF(axisx2 + pos - (Filter1*axiswidth/460000.0), axisy1 + axisheight * 2 /8));
    //left
    p->drawLine(QPointF(axisx2 + pos + (Filter1*axiswidth/460000.0) , axisy1 + axisheight * 2 /8), QPointF(axisx2 + pos + (Filter1*axiswidth/460000.0) + axiswidth/16.0 , axisy2));
    //right
    p->drawLine(QPointF(axisx2 + pos - (Filter1*axiswidth/460000.0) , axisy1 + axisheight * 2 /8), QPointF(axisx2 + pos - (Filter1*axiswidth/460000.0) - axiswidth/16.0 , axisy2));

    // Selection
    QColor cyan(Qt::cyan);
    QBrush brush(cyan);
    p->setBrush(brush);

    pen.setWidth(1.0);
    QFont font("Times", 8, QFont::Bold);
    QFontMetrics    fm(font);
    QRect           r = fm.boundingRect(QString("%1k").arg(Filter1/1000.0));
    r.moveCenter(QPoint(axismid,axisy2 +13.0));
    p->setFont(font);
    p->drawRoundRect(QRectF(axismid - axiswidth/4.0, axisy2 +8.0, axiswidth * 2 / 4, 10.0));
    pen.setColor(QColor(Qt::black));
    p->setPen(pen);
    p->drawText(r, QString("%1k").arg(Filter1/1000));
    pen.setColor(QColor(Qt::cyan));
    pen.setWidth(2.0);
    p->setPen(pen);

    // Draw axis 2
    axisx1 = (size.width()*3.75/grid);
    axisx2 = (size.width()*3.25/grid);
    axismid = axisx1 + (axisx2 - axisx1)/2.0;
    pos = 128*axiswidth/255.0;
    p->setPen(penaxis);
    //draw bottom axis
    p->drawLine(QPointF(axisx1,axisy2), QPointF(axisx2,axisy2));
    penaxis.setStyle(Qt::DashLine);
    p->drawLine(QPointF(axismid, axisy1 ), QPointF(axismid,axisy2));
    penaxis.setStyle(Qt::SolidLine);

    // Draw Filter2 band
    p->setPen(pen);
    // top
    p->drawLine(QPointF(axisx2 + pos - (Filter2*axiswidth/460000.0) , axisy1 + axisheight * 2 /8), QPointF(axisx2 + pos +  (Filter2*axiswidth/460000.0), axisy1 + axisheight * 2 /8));
    //left
    p->drawLine(QPointF(axisx2 + pos - (Filter2*axiswidth/460000.0) , axisy1 + axisheight * 2 /8), QPointF(axisx2 + pos - (Filter2*axiswidth/460000.0) - axiswidth/16.0 , axisy2));
    //right
    p->drawLine(QPointF(axisx2 + pos + (Filter2*axiswidth/460000.0) , axisy1 + axisheight * 2 /8), QPointF(axisx2 + pos + (Filter2*axiswidth/460000.0) + axiswidth/16.0 , axisy2));

    // Selection
    pen.setWidth(1.0);
    p->setPen(pen);
    r = fm.boundingRect(QString("%1k").arg(Filter2/1000.0));
    r.moveCenter(QPoint(axismid,axisy2 +13.0));
    p->setFont(font);
    p->drawRoundRect(QRectF(axismid - axiswidth/4.0, axisy2 +8.0, axiswidth * 2 / 4, 10.0));
    pen.setColor(QColor(Qt::black));
    p->setPen(pen);
    p->drawText(r, QString("%1k").arg(Filter2/1000));
    pen.setColor(QColor(Qt::cyan));

}