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


C++ TView::SetRange方法代码示例

本文整理汇总了C++中TView::SetRange方法的典型用法代码示例。如果您正苦于以下问题:C++ TView::SetRange方法的具体用法?C++ TView::SetRange怎么用?C++ TView::SetRange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TView的用法示例。


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

示例1: MakeFourView

//_______________________________________________________________________________________
void MakeFourView(TVirtualPad *pad=0)
{
//  Creates 4 pads view of the pad (or qPad)
//   ------------------------------
//   |              |             |
//   |              |             |
//   |              |             |
//   |    Front     |   Top       |
//   |    view      |   view      |
//   |              |             |
//   |              |             |
//   |              |             |
//   ---------------+-------------
//   |              |             |
//   |              |             |
//   |              |             |
//   |    Side      |  Spacial    |
//   |    view      |   view      |
//   |              |             |
//   |              |             |
//   |              |             |
//   ------------------------------
// begin_html  <P ALIGN=CENTER> <IMG SRC="gif/FourStarView.gif" ></P> end_html
//
  TVirtualPad *thisPad = pad;
  if (!thisPad) thisPad = qPad();
  TView *view = 0; 
  TList *thisPrimitives = 0; 
  if (thisPad && (thisPrimitives = thisPad->GetListOfPrimitives()) && (view =  thisPad->GetView()) ) 
  {
    Double_t min[3],max[3];
    view->GetRange(min,max);
    Int_t system = view->GetSystem();
    TCanvas *c = new TCanvas(" 4 views", thisPad->GetTitle(),600,600);
    c->Divide(2,2);
    TIter *next=  new TIter(thisPrimitives);
    for (int i =1; i <= 4; i++) {
      c->cd(i);
      TList *newPrimitives = qPad()->GetListOfPrimitives();
      TObject *obj = 0;
      while (obj = next->Next()) newPrimitives->Add(obj);
      TView *newView = new TView(system);
      newView->SetRange(min,max);
      next->Reset();
   }
   delete next;
   // set separate view;
   // Fron view
    Int_t j = 1;
    c->cd(j++); FrontView();
    c->cd(j++); TopView();
    c->cd(j++); SideView();
    c->cd(j++); RotateView(-30.0,60.0,0);
    c->Modified();
    c->Update();
  }
}
开发者ID:star-bnl,项目名称:star-macros,代码行数:58,代码来源:PadControlPanel.C

示例2: TCanvas

 void pl3() {
      TCanvas *c1 = new TCanvas("c1");
      TView *view = TView::CreateView(1);
      view->SetRange(0,0,0,2,2,2);
      const Int_t n = 100;
      TPolyLine3D *l = new TPolyLine3D(n);
      for (Int_t i=0;i<n;i++) {
         Double_t x = 2*gRandom->Rndm();
         Double_t y = 2*gRandom->Rndm();
         Double_t z = 2*gRandom->Rndm();
         l->SetPoint(i,x,y,z);
      }
      l->Draw();
   }
开发者ID:camsonne,项目名称:g4sbsDDVCS,代码行数:14,代码来源:pl3.C

示例3: drawing_pion_decay

void drawing_pion_decay(){

	double Pi_lifetime = 0.26033e-6; //s
	double c = 3e8;//m/s
	TCanvas *c1 = new TCanvas("test", "test");
	TRandom *r = new TRandom();
	

	TView *view = TView::CreateView(1, 0, 0);
	view->ShowAxis();
	view->SetRange(-5, -5, 0, 5, 5, 10);
	
	

	for (int i = 0; i < 100; ++i)
	{
		double px = 0.3;
		double py = 0.3;
		double pz = -1; // GeV
		double energy = sqrt(px*px+py*py+pz*pz+M_pion*M_pion);
		
		//life time
		double t = r->Exp(Pi_lifetime);
		//decay length
		double gamma = energy/M_pion;
		double length = c*t*gamma/1e3;
		// decay position
		double vx = 0;
		double vy = 0;
		double vz = 10 - length;

		TLorentzVector pion(px, py, pz, energy);

		double decay_particle_mass[2] = {M_muon, M_neu};
		TGenPhaseSpace event;
		event.SetDecay(pion, 2, decay_particle_mass);
		event.Generate();

		TLorentzVector Muon = *(event.GetDecay(0));
		TLorentzVector Neu = *(event.GetDecay(1));
		
		plot_particle(Muon, vx, vy, vz, 2);
		plot_particle(Neu, vx, vy, vz, 4);


	}


}
开发者ID:TuringTW,项目名称:ntu_2015_fall,代码行数:49,代码来源:drawing_pion_decay.C

示例4: qPad

//_______________________________________________________________________________________
static void Inscrease3DScale()
{
  TVirtualPad *thisPad = qPad();
  if (thisPad) {
    TView *view = thisPad->GetView(); 
    if (!view) return;
    Double_t min[3],max[3];
    view->GetRange(min,max);
    int i;
    for (i=0;i<3; i++) {max[i] *= 0.8; min[i]=max[i]*0.1;}
    view->SetRange(min,max);
    thisPad->Modified();
    thisPad->Update();
  }
}
开发者ID:star-bnl,项目名称:star-macros,代码行数:16,代码来源:PadControlPanel.C

示例5: AdjustScales

//_______________________________________________________________________________________
static void AdjustScales()
{
  TVirtualPad *thisPad = qPad();
  if (thisPad) {
    TView *view = thisPad->GetView(); 
    if (!view) return;
    Double_t min[3],max[3];
    view->GetRange(min,max);
    int i;
    Double_t maxSide = 0;
    // Find the largest side
    for (i=0;i<3; i++) maxSide = TMath::Max(maxSide,max[i]-min[i]);
    //Adjust scales:
    for (i=0;i<3; i++) max[i] += maxSide - (max[i]-min[i]);
    view->SetRange(min,max);
    thisPad->Modified();
    thisPad->Update();
 }
}
开发者ID:star-bnl,项目名称:star-macros,代码行数:20,代码来源:PadControlPanel.C

示例6: spheres

void spheres(Int_t nspheres=20, Int_t npoints=100000) {
   // generate random points uniformly distributed over the surface
   // of spheres generated at random positions.

   TCanvas *c1 = new TCanvas("c1","spheres",600,600);
   c1->SetFillColor(kBlack);
   TView *view = new TView(1);
   Double_t k=0.8;
   view->SetRange( -k, -k, -k, k, k, k);
   
   //generate sphere coordinates and radius
   TRandom r;
   if (nspheres <=0) nspheres = 10;
   Double_t *xs = new Double_t[nspheres];
   Double_t *ys = new Double_t[nspheres];
   Double_t *zs = new Double_t[nspheres];
   Double_t *rs = new Double_t[nspheres];
   Int_t i;
   for (i=0;i<nspheres;i++) {
      xs[i] = r.Uniform(-1,1);
      ys[i] = r.Uniform(-1,1);
      zs[i] = r.Uniform(-1,1);
      rs[i] = r.Uniform(0.05,0.25);
   }

   //generate points
   TPolyMarker3D *pm = new TPolyMarker3D(npoints);
   pm->SetMarkerColor(kRed);
   Double_t x,y,z;
   for (Int_t j=0;j<npoints;j++) {
       i = (Int_t)r.Uniform(0,nspheres);  //choose sphere
       r.Sphere(x,y,z,rs[i]);
       pm->SetPoint(j,xs[i]+x, ys[i]+y,zs[i]+z);
   }
   
   delete [] xs;
   delete [] ys;
   delete [] zs;
   delete [] rs;
    
   pm->Draw();
}
开发者ID:alcap-org,项目名称:AlcapDAQ,代码行数:42,代码来源:spheres.C

示例7: setCanvas

void RootWImage::setCanvas(TCanvas* myCanvas) {
  if (myCanvas_) delete myCanvas_;
  myCanvas_ = (TCanvas*)myCanvas->DrawClone();
  std::ostringstream canvasName("");
  //int myNumber = imageNameCounter_[name_]++; //##########
  canvasName << "canvas" << setfill('0') << setw(3) << imageCounter_;
  myCanvas_->SetName(canvasName.str().c_str());
  TView* myView = myCanvas->GetView();
  if (myView) {
    TView* newView = myCanvas_->GetView();
    if (newView) {
      double min[3], max[3];
      Int_t irep;
      newView->SetView(myView->GetLongitude(),
		       myView->GetLatitude(),
		       myView->GetPsi(), irep);
      myView->GetRange(min, max);
      newView->SetRange(min, max);
    }
  }
}
开发者ID:Deepali-Garg,项目名称:Ph2_ACF,代码行数:21,代码来源:rootweb.cpp

示例8: sphere

void sphere()
{
   /********************/
   /*Mpi initialization*/
   /********************/
   ROOT::Mpi::TEnvironment env(gApplication->Argc(), gApplication->Argv());
   ROOT::Mpi::TIntraCommunicator world;

   /*********************************/
   /*Error control, need 4 processes*/
   /*********************************/   
   if(world.Size()!=4)
   {
      std::cout<<"Error: You need run with 4 processes exactly, the sphere was spplitted in four regions. \nExample: mpirun -np 4 root -l  sphere.C\n";
      std::cout.flush();
      world.Abort(ROOT::Mpi::ERR_SIZE);  
   }
   
   /*********************************************************************/
   /*Section to calculate volume with parallel multimensional integrator*/
   /*********************************************************************/   
   //integrator creation root's style
   ROOT::Math::Functor1D function(&sphere_function);

   ROOT::Math::Integrator integrator;
   integrator.SetFunction(function);

   //Mpi's integrator wrapper, integrator from ROOT in one dimension
   ROOT::Mpi::Math::TIntegratorWrapper MpiIntegrator(&integrator);

   //integrate in parallel and send the result to rank zero, intervar [0,radius]
   MpiIntegrator.Integrate(0, 0, radius);

   
   /*****************************************************************************************/
   /*this is the root process,calculate the surface z=+qsrt(1−(x2+b2)) for x∈[−1,0],y∈[−1,1]*/
   /*and recv the other surface regions in TPolyMarker3D object from others ranks           */
   /*****************************************************************************************/
   if (world.Rank() == 0) {
      gBenchmark->Start("sphere");
      // create and open a canvas
      TCanvas *canvas = new TCanvas("sphere", "sphere", 300, 10, 700, 500);
      canvas->SetFillColor(14);
      // creating view
      TView *view = TView::CreateView(1, 0, 0);
      view->RotateView(90,-10);
      view->SetRange(-radius*2, -radius*2, -2*radius, 2*radius, 2*radius, 2*radius);
      // create a PolyMarker3D for region/segment 1 calculate in rank 0(this rank)
      TPolyMarker3D *surfaceSeg13d = new TPolyMarker3D();
      
      for (theta = 0; theta <0.5*M_PI ; theta+= delta) {
         for (phi = 0; phi <M_PI; phi += delta) {
	   
	   x=radius*cos(theta)*sin(phi);
	   y=radius*sin(theta)*sin(phi);
	   z=radius*cos(phi);
            // set points
            surfaceSeg13d->SetPoint(point, x, y, z);
            point++;
         }
      }
      // set marker size, color & style
      surfaceSeg13d->SetMarkerSize(1);
      surfaceSeg13d->SetMarkerColor(world.Rank() + world.Size());
      surfaceSeg13d->SetMarkerStyle(1);
      //drawing region 1
      surfaceSeg13d->Draw();

      //getting region 2 from rank 1
      TPolyMarker3D *surfaceSeg23d = new TPolyMarker3D;
      world.RecvObject(1, 1, *surfaceSeg23d);
      surfaceSeg23d->Draw();

      //getting region 3 from rank 2
      TPolyMarker3D *surfaceSeg33d = new TPolyMarker3D;
      world.RecvObject(2, 1, *surfaceSeg33d);
      surfaceSeg33d->Draw();

      //getting region 4 from rank 3
      TPolyMarker3D *surfaceSeg43d = new TPolyMarker3D;
      world.RecvObject(3, 1, *surfaceSeg43d);
      surfaceSeg43d->Draw();

      Char_t timeStr[60];
      Char_t pointsStr[100];
      Char_t radiusStr[100];
      Char_t deltaStr[100];
      gBenchmark->Show("sphere");

      Float_t ct = gBenchmark->GetCpuTime("sphere");
      sprintf(timeStr, "Execution time: %g sec.", ct);
      sprintf(radiusStr, "Radius : %g", radius);
      sprintf(deltaStr, "Delta : %g", delta);
      sprintf(pointsStr, "Total surface points : %g", point*4);
      
      TPaveText *text = new TPaveText(0.1, 0.6, 0.9, 0.99);
      text->SetFillColor(42);
      text->AddText("ROOTMpi example: sphere.C");
      text->AddText(timeStr);
      text->AddText(radiusStr);
//.........这里部分代码省略.........
开发者ID:omazapa,项目名称:RootMpi,代码行数:101,代码来源:sphere.C

示例9: printf

//_____________________________________________________________________________
Int_t AliTRDdisplayDigits3D(Int_t event = 0, Int_t thresh = 4
                          , Bool_t sdigits = kFALSE) 
{
  //  
  //  TRD digits display
  //
  //  Input parameter:
  //    <event>   : Event number 
  //    <thresh>  : Threshold to suppress the noise
  //    <sdigits> : If kTRUE it will display summable digits, normal digits otherwise.
  //                The signal event is displayed in yellow.
  //

  Char_t *inputFile = "galice.root";

  // Define the objects
  AliTRDv1       *trd;
  AliTRDgeometry *geo;

  TString       evfoldname = AliConfig::GetDefaultEventFolderName();
  AliRunLoader *runLoader  = AliRunLoader::GetRunLoader(evfoldname);
  if (!runLoader) {
    runLoader = AliRunLoader::Open(inputFile
                                  ,AliConfig::GetDefaultEventFolderName()
                                  ,"UPDATE");
  }
  if (!runLoader) {
    printf("Can not open session for file %s.",inputFile);
    return kFALSE;
  }
   
  if (!runLoader->GetAliRun()) {
    runLoader->LoadgAlice();
  }
  gAlice = runLoader->GetAliRun();  
  if (!gAlice) {
    printf("Could not find AliRun object.\n");
    return kFALSE;
  }

  runLoader->GetEvent(event);
  
  AliLoader *loader = runLoader->GetLoader("TRDLoader");
  if (!loader) {
    printf("Can not get TRD loader from Run Loader");
  }
  loader->LoadDigits();
  
  // Get the pointer to the detector object
  trd = (AliTRDv1*) gAlice->GetDetector("TRD");

  // Get the pointer to the geometry object
  if (trd) {
    geo = trd->GetGeometry();
  }
  else {
    printf("Cannot find the geometry\n");
    return 1;
  }

  AliCDBManager *cdbManager  = AliCDBManager::Instance();
  cdbManager->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
  AliTRDcalibDB *calibration = AliTRDcalibDB::Instance();
  calibration->SetRun(0);

  TCanvas *c1 = new TCanvas("digits","TRD digits display",0,0,700,730);
  TView   *v  = new TView(1);
  v->SetRange(-430,-560,-430,430,560,1710);
  v->SetParallel();
  c1->Clear();
  c1->SetFillColor(1);
  c1->SetTheta(90.0);
  c1->SetPhi(0.0);

  Int_t markerColorSignal = 2;
  Int_t markerColorBgnd   = 7;
  Int_t markerColorMerged = 5;
  Int_t mask              = 10000000;

  // Create the digits manager
  AliTRDdigitsManager *digitsManager = new AliTRDdigitsManager();
  digitsManager->SetSDigits(sdigits);

  // Read the digits from the file
  if (sdigits) {
    digitsManager->ReadDigits(loader->TreeS());
  }
  else {
    if (!loader->TreeD()) {
      printf("mist\n");
      return kFALSE;
    }
    digitsManager->ReadDigits(loader->TreeD());
  }

  Int_t totalsignal = 0;
  Int_t totalbgnd   = 0;
  Int_t totalmerged = 0;
  Int_t timeMax     = calibration->GetNumberOfTimeBins();
//.........这里部分代码省略.........
开发者ID:alisw,项目名称:AliRoot,代码行数:101,代码来源:AliTRDdisplayDigits3D.C

示例10: tornado

void tornado() {
//Show 3-d polymarkers
// To see the output of this macro, click begin_html <a href="gif/tornado.gif" >here</a> end_html
//Author: Rene Brun
   
    gBenchmark->Start("tornado");

    double PI = 3.141592653;
    int d = 16;
    int numberOfPoints=200;
    int numberOfCircles=40;

    // create and open a canvas
    TCanvas *sky = new TCanvas( "sky", "Tornado", 300, 10, 700, 500 );
    sky->SetFillColor(14);

    // creating view
    TView *view = TView::CreateView(1,0,0);
    float range = numberOfCircles*d;
    view->SetRange( 0, 0, 0, 4.0*range, 2.0*range, range );

    for( int j = d; j < numberOfCircles*d; j += d ) {

        // create a PolyMarker3D
        TPolyMarker3D *pm3d = new TPolyMarker3D( numberOfPoints );

        float x, y, z;

        // set points
        for( int i = 1; i < numberOfPoints; i++ ) {
            float csin = sin(2*PI / (double)numberOfPoints  * (double)i) + 1;
            float ccos = cos(2*PI / (double)numberOfPoints  * (double)i) + 1;
            float esin = sin(2*PI / (double)(numberOfCircles*d) * (double)j) + 1;
            x = j * ( csin + esin );
            y = j * ccos;
            z = j;
            pm3d->SetPoint( i, x, y, z );
        }

        // set marker size, color & style
        pm3d->SetMarkerSize( 1 );
        pm3d->SetMarkerColor( 2 + ( d == ( j & d ) ) );
        pm3d->SetMarkerStyle( 3 );

        //draw
        pm3d->Draw();
    }

    char timeStr[60];
    gBenchmark->Show("tornado");

    Float_t ct = gBenchmark->GetCpuTime("tornado");
    sprintf( timeStr, "Execution time: %g sec.", ct);

    TPaveText *text = new TPaveText( 0.1, 0.81, 0.9, 0.97 );
    text->SetFillColor( 42 );
    text->AddText("ROOT example: tornado.C");
    text->AddText(timeStr);
    text->Draw();
    sky->Update();
}
开发者ID:My-Source,项目名称:root,代码行数:61,代码来源:tornado.C

示例11: xtruSamples


//.........这里部分代码省略.........
  worldnode->cd();

// Canonical shape ... gets further modified by scale factors
// to create convex (and malformed) versions
  Float_t x[] = { -0.50, -1.20,  1.20,  0.50,  0.50,  1.20, -1.20, -0.50 };
  Float_t y[] = { -0.75, -2.00, -2.00, -0.75,  0.75,  2.00,  2.00,  0.75 };
  Float_t z[] = { -0.50, -1.50, -1.50,  1.50,  1.50,  0.50 };
  Float_t s[] = {  0.50,  1.00,  1.50,  1.50,  1.00,  0.50 };
  Int_t   nxy = sizeof(x)/sizeof(Float_t);
  Float_t convexscale[] = { 7.0, -1.0, 1.5 };

  Int_t icolor[] = { 1, 2, 3, 2, 2, 2, 4, 2, 6 };

// xycase and zcase:  0=convex, 1=malformed, 2=concave
// this will either create a 2x2 matrix of shapes
// or a 3x3 array (if displaying malformed versions)
  for (Int_t zcase = 0; zcase<3; zcase++) {
     if (zcase == 1 && !domalformed) continue;
     for (Int_t xycase = 0; xycase<3; xycase++) {
        if (xycase == 1 && !domalformed) continue;

        Char_t *name = "txtruXYZ";
        sprintf(name,"txtru%1d%1d%1d",xycase,zcase,zseg);
        TXTRU* mytxtru = new TXTRU(name,name,"void",8,2);

        Int_t i, j;
        Float_t xsign = (makecw) ? -1 : 1;
        Float_t zsign = (reversez) ? -1 : 1;

        // set the vertex points
        for (i=0; i<nxy; i++) {
           Float_t xtmp = x[i]*xsign;
           Float_t ytmp = y[i];
           if (i==0||i==3||i==4||i==7) xtmp *= convexscale[xycase];
           if (xycase==2) xtmp *=2;
           mytxtru->DefineVertex(i,xtmp,ytmp);
        }
        // set the z segment positions and scales
        for (i=0, j=0; i<zseg; i++) {
           Float_t ztmp = z[i]*zsign;
           if (i==0||i==5) ztmp *= convexscale[zcase];
           if (zcase==2) ztmp *= 2.5;
           if (zseg>2 && zcase!=2 && (i==1||i==4)) continue;
           mytxtru->DefineSection(j,ztmp,s[i]);
           j++;
        }

        TNode* txtrunode = new TNode(name,name,mytxtru);
        txtrunode->SetLineColor(icolor[3*zcase+xycase]);
        Float_t pos_scale = (domalformed) ? 10 : 6;
        Float_t xpos = (xycase-1)*pos_scale*unit;
        Float_t ypos = (zcase-1)*pos_scale*unit;
        txtrunode->SetPosition(xpos,ypos,0.);
     }
  }


// Some extra shapes to show the direction of "z"
  Float_t zhalf = 0.5*bigdim;
  Float_t rmax = 0.03*bigdim;
  TCONE* zcone = new TCONE("zcone","zcone","void",zhalf,0.,rmax,0.,0.);
  zcone->SetVisibility(extravis);
  TNode* zconenode = new TNode("zconenode","zconenode",zcone);
  zconenode->SetLineColor(3);

  Float_t dzstub = 2*rmax; 
  TBRIK* zbrik = new TBRIK("zbrik","zbrik","void",rmax,rmax,dzstub);
  zbrik->SetVisibility(extravis);
  TNode* zbriknode = new TNode("zbriknode","zbriknode",zbrik);
  zbriknode->SetPosition(0.,0.,zhalf+dzstub);
  zbriknode->SetLineColor(3);

//  geom->ls();

  geom->Draw();

// Tweak the pad so that it displays the entire geometry undistorted
  TVirtualPad *thisPad = gPad;
  if (thisPad) {
    TView *view = thisPad->GetView(); 
    if (!view) return;
    Double_t min[3],max[3],center[3];
    view->GetRange(min,max);
    int i;
    // Find the boxed center
    for (i=0;i<3; i++) center[i] = 0.5*(max[i]+min[i]);
    Double_t maxSide = 0;
    // Find the largest side
    for (i=0;i<3; i++) maxSide = TMath::Max(maxSide,max[i]-center[i]);
    file://Adjust scales:
    for (i=0;i<3; i++) {
       max[i] = center[i] + maxSide;
       min[i] = center[i] - maxSide;
    }
    view->SetRange(min,max);
    thisPad->Modified();
    thisPad->Update();
  }

}
开发者ID:My-Source,项目名称:root,代码行数:101,代码来源:xtruSamples.C


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