FEDRA emulsion software from the OPERA Collaboration
Edb3DView Class Reference

#include <EdbDisplayBase.h>

Inheritance diagram for Edb3DView:
Collaboration diagram for Edb3DView:

Public Member Functions

 Edb3DView ()
 
virtual void ExecuteRotateView (Int_t event, Int_t px, Int_t py)
 
virtual const char * GetName () const
 
virtual char * GetObjectInfo (int px, int py) const
 
virtual const char * GetTitle () const
 
virtual void SetRotateMode (bool Mode=true)
 
 ~Edb3DView ()
 

Protected Attributes

bool fRotateMode
 

Constructor & Destructor Documentation

◆ Edb3DView()

Edb3DView::Edb3DView ( )
inline
54 : TView3D() { fRotateMode = false; }
bool fRotateMode
Definition: EdbDisplayBase.h:50

◆ ~Edb3DView()

Edb3DView::~Edb3DView ( )
inline
60 {};

Member Function Documentation

◆ ExecuteRotateView()

void Edb3DView::ExecuteRotateView ( Int_t  event,
Int_t  px,
Int_t  py 
)
virtual
1240 {
1241 //*-*-*-*-*-*-*-*-*Execute action corresponding to one event*-*-*-*-*-*-*-*-*-*
1242 //*-* ========================================= *
1243 //*-* This member function is called when a object is clicked with the locator *
1244 //*-* *
1245 //*-* If Left button clicked in the object area, while the button is kept down *
1246 //*-* the cube representing the surrounding frame for the corresponding *
1247 //*-* new latitude and longitude position is drawn. *
1248 //*-* *
1249 //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
1250  static Int_t system, framewasdrawn;
1251  static Double_t xrange, yrange, xmin, ymin, longitude1, latitude1, longitude2, latitude2;
1252  static Double_t newlatitude, newlongitude, oldlatitude, oldlongitude;
1253  Double_t dlatitude, dlongitude, x, y;
1254  Int_t irep = 0;
1255  Double_t psideg;
1256 
1257  // all coordinate transformation are from absolute to relative
1258 
1259  if (!fRotateMode)
1260  {
1261  gPad->SetCursor(kPointer);
1262  return;
1263  }
1264  if (!gPad->IsEditable()) return;
1265  gPad->AbsCoordinates(kTRUE);
1266 
1267  switch (event) {
1268 
1269  case kKeyPress :
1270  fChanged = kTRUE;
1271  MoveViewCommand(Char_t(px), py);
1272  break;
1273  case kMouseMotion:
1274  gPad->SetCursor(kRotate);
1275  break;
1276 
1277  case kButton1Down:
1278 
1279  // remember position of the cube
1280  xmin = gPad->GetX1();
1281  ymin = gPad->GetY1();
1282  xrange = gPad->GetX2() - xmin;
1283  yrange = gPad->GetY2() - ymin;
1284  x = gPad->PixeltoX(px);
1285  y = gPad->PixeltoY(py);
1286  system = GetSystem();
1287  framewasdrawn = 0;
1288  if (system == kCARTESIAN || system == kPOLAR || IsPerspective()) {
1289  longitude1 = 180*(x-xmin)/xrange;
1290  latitude1 = 90*(y-ymin)/yrange;
1291  } else {
1292  latitude1 = 90*(x-xmin)/xrange;
1293  longitude1 = 180*(y-ymin)/yrange;
1294  }
1295  newlongitude = oldlongitude = -90 - gPad->GetPhi();
1296  newlatitude = oldlatitude = 90 - gPad->GetTheta();
1297  psideg = GetPsi();
1298 
1299  // if outline isn't set, make it look like a cube
1300  if(!fOutline)
1301  SetOutlineToCube();
1302  break;
1303 
1304  case kButton1Motion:
1305  {
1306  // draw the surrounding frame for the current mouse position
1307  // first: Erase old frame
1308  fChanged = kTRUE;
1309  if (framewasdrawn) fOutline->Paint();
1310  framewasdrawn = 1;
1311  x = gPad->PixeltoX(px);
1312  y = gPad->PixeltoY(py);
1313  if (system == kCARTESIAN || system == kPOLAR || IsPerspective()) {
1314  longitude2 = 180*(x-xmin)/xrange;
1315  latitude2 = 90*(y-ymin)/yrange;
1316  } else {
1317  latitude2 = 90*(x-xmin)/xrange;
1318  longitude2 = 180*(y-ymin)/yrange;
1319  }
1320  dlongitude = longitude2 - longitude1;
1321  dlatitude = latitude2 - latitude1;
1322  newlatitude = oldlatitude + dlatitude;
1323  newlongitude = oldlongitude - dlongitude;
1324  psideg = GetPsi();
1325  ResetView(newlongitude, newlatitude, psideg, irep);
1326  fOutline->Paint();
1327 
1328  break;
1329  }
1330  case kButton1Up:
1331 
1332  // Temporary fix for 2D drawing problems on pad. fOutline contains
1333  // a TPolyLine3D object for the rotation box. This will be painted
1334  // through a newly created TViewer3DPad instance, which is left
1335  // behind on pad. This remaining creates 2D drawing problems.
1336  //
1337  // This is a TEMPORARY fix - will be removed when proper multiple viewers
1338  // on pad problems are resolved.
1339 //Doesn't work in old versions of ROOT
1340 // if (gPad) {
1341 // TVirtualViewer3D *viewer = gPad->GetViewer3D();
1342 // if (viewer && !strcmp(viewer->IsA()->GetName(),"TViewer3DPad")) {
1343 // gPad->ReleaseViewer3D();
1344 // delete viewer;
1345 // }
1346 // }
1347  // End fix
1348 
1349  // Recompute new view matrix and redraw
1350  psideg = GetPsi();
1351  SetView(newlongitude, newlatitude, psideg, irep);
1352  gPad->SetPhi(-90-newlongitude);
1353  gPad->SetTheta(90-newlatitude);
1354  gPad->Modified(kTRUE);
1355 
1356  // Set line color, style and width
1357  gVirtualX->SetLineColor(-1);
1358  gVirtualX->SetLineStyle(-1);
1359  gVirtualX->SetLineWidth(-1);
1360  break;
1361  }
1362 
1363  // set back to default transformation mode
1364  gPad->AbsCoordinates(kFALSE);
1365 }
const Int_t kCARTESIAN
Definition: EdbDisplayBase.cxx:22
const Int_t kPOLAR
Definition: EdbDisplayBase.cxx:23
float xmin
Definition: emthickness.cpp:61
float ymin
Definition: emthickness.cpp:63
int event
Definition: shower_tr.C:25

◆ GetName()

const char * Edb3DView::GetName ( ) const
virtual
1210 {
1211  static char name[] = "3-D View";
1212  return name;
1213 }
const char * name
Definition: merge_Energy_SytematicSources_Electron.C:24

◆ GetObjectInfo()

char * Edb3DView::GetObjectInfo ( int  px,
int  py 
) const
virtual
1216 {
1217  static char rcoordinates[]="Rotated coordinates";
1218  static char coordinates[80];
1219  if (!gPad) return rcoordinates;
1220  float nxyz[3] = {gPad->AbsPixeltoX(px), gPad->AbsPixeltoY(py), 0.}, wxyz[3] = {0., 0., 0.};
1221  ((TView *)this)->NDCtoWC(nxyz, wxyz);
1222  if (((TView *)this)->GetLatitude() == 90.)
1223  {
1224  if (((TView *)this)->GetLongitude() == 180.)
1225  sprintf(coordinates, "Y = %.1f, Z = %.1f", wxyz[1], wxyz[2]);
1226  else if (((TView *)this)->GetLongitude() == 90.)
1227  sprintf(coordinates, "X = %.1f, Z = %.1f", wxyz[0], wxyz[2]);
1228  else
1229  return rcoordinates;
1230  }
1231  else if (((TView *)this)->GetLatitude() == 0.)
1232  sprintf(coordinates, "X = %.1f, Y = %.1f", wxyz[0], wxyz[1]);
1233  else
1234  return rcoordinates;
1235  return coordinates;
1236 }

◆ GetTitle()

const char * Edb3DView::GetTitle ( ) const
virtual
1202 {
1203  static char title[80];
1204  sprintf(title, "%s", "FEDRA Event Display");
1205  return title;
1206 }

◆ SetRotateMode()

void Edb3DView::SetRotateMode ( bool  Mode = true)
virtual
1368 {
1369  //
1370  // Set or unset 3-D View Rotate Mode
1371  //
1372  fRotateMode = mode;
1373 }

Member Data Documentation

◆ fRotateMode

bool Edb3DView::fRotateMode
protected

The documentation for this class was generated from the following files: