ATLAS Offline Software
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
VP1CameraHelper::Imp Class Reference
Collaboration diagram for VP1CameraHelper::Imp:

Public Member Functions

void getCameraCoordinateSystem (SoCamera *cameraarg, SoNode *root, SbMatrix &matrix, SbMatrix &inverse)
 
void updateLastVars ()
 
bool lastParsChanged () const
 
void startSeekTimer (double duration_in_secs)
 
bool instanceInvalid ()
 
bool getCameraParametersForBBox (const SbBox3f &box, SoSFVec3f &position, SoSFFloat &nearDistance, SoSFFloat &farDistance, SoSFFloat &focalDistance, bool &isPerspective, SoSFFloat &height)
 
void actual_animatedZoomToCameraState (const QByteArray &camstate, double duration_in_secs)
 
void actual_animatedZoomToPoint (SbVec3f, double duration_in_secs=1.0)
 
void actual_animatedZoomToPath (SoPath *path, double duration_in_secs=1.0, double slack=1.0, const SbVec3f &lookat=SbVec3f(999, 999, 999), const SbVec3f &upvec=SbVec3f(999, 999, 999))
 
void actual_animatedZoomToBBox (const SbBox3f &box, double duration_in_secs=1.0, double slack=1.0, const SbVec3f &lookat=SbVec3f(999, 999, 999), const SbVec3f &upvec=SbVec3f(999, 999, 999))
 
void actual_animatedZoomToSubTree (SoNode *subtreeroot, double duration_in_secs=1.0, double slack=1.0, const SbVec3f &lookat=SbVec3f(999, 999, 999), const SbVec3f &upvec=SbVec3f(999, 999, 999))
 
void die (bool abnormal=true)
 

Static Public Member Functions

static void seeksensorCB (void *data, SoSensor *)
 
static SbRotation cameraOrientation (SbVec3f dir, SbVec3f up)
 

Public Attributes

VP1CameraHelpertheclass
 
SoCamera * camera
 
SoGroup * sceneroot
 
QByteArray targetCamState
 
bool forceCircular
 
SoTimerSensor * seeksensor
 
float seekperiod
 
SbBool inseekmode
 
SbBool seektopoint
 
float seekdistance
 
SbBool seekdistanceabs
 
SbVec3f camerastartposition
 
SbVec3f cameraendposition
 
SbRotation camerastartorient
 
SbRotation cameraendorient
 
SoSFFloat camerastart_nearDistance
 
SoSFFloat cameraend_nearDistance
 
SoSFFloat camerastart_farDistance
 
SoSFFloat cameraend_farDistance
 
SoSFFloat camerastart_focalDistance
 
SoSFFloat cameraend_focalDistance
 
bool camera_isperspective
 
SoSFFloat camerastart_ortho_height
 
SoSFFloat cameraend_ortho_height
 
bool varySpeed
 
double clipVol_startPercentage
 
double clipVol_percentage
 
double clipVol_endPercentage
 
VP1ExaminerViewerrenderArea
 
QString outputdir
 
QString prefix
 
double fps
 
int ntotframes
 
int iframe
 
int width
 
int height
 
SbRotation last_cameraorient
 
SbVec3f last_cameraposition
 
SoSFFloat last_camera_ortho_height
 
double clipVol_lastPercentage
 
SoSearchAction * searchaction
 
SoGetMatrixAction * matrixaction
 
int32_t camera_ref
 
bool instance_invalid
 

Static Public Attributes

static std::map< SoCamera *, VP1CameraHelper * > helpers
 

Detailed Description

Definition at line 42 of file VP1CameraHelper.cxx.

Member Function Documentation

◆ actual_animatedZoomToBBox()

void VP1CameraHelper::Imp::actual_animatedZoomToBBox ( const SbBox3f &  box,
double  duration_in_secs = 1.0,
double  slack = 1.0,
const SbVec3f &  lookat = SbVec3f(999,999,999),
const SbVec3f &  upvec = SbVec3f(999,999,999) 
)

Definition at line 474 of file VP1CameraHelper.cxx.

476 {
477  if (instanceInvalid()) {
478  die();
479  return;
480  }
481 
482  if (slack<=0.0||duration_in_secs<0.0) {
483  die();
484  return;
485  }
486 
487  if (instanceInvalid()) {
488  die();
489  return;
490  }
491 
492  if (box.isEmpty()) {
493  die();
494  return;
495  }
496  SbBox3f actualbbox = box;
497  if (slack!=1.0) {
498  float minx, miny, minz, maxx, maxy, maxz;
499  actualbbox.getBounds (minx, miny, minz, maxx, maxy, maxz);
500  float dx(maxx-minx), cx(0.5*(maxx+minx));
501  float dy(maxy-miny), cy(0.5*(maxy+miny));
502  float dz(maxz-minz), cz(0.5*(maxz+minz));
503  actualbbox.setBounds (cx-0.5*slack*dx, cy-0.5*slack*dy, cz-0.5*slack*dz,
504  cx+0.5*slack*dx, cy+0.5*slack*dy, cz+0.5*slack*dz);
505  }
506 
507 
508 
509  SoSFVec3f target_position;
510  SoSFFloat target_nearDistance;
511  SoSFFloat target_farDistance;
512  SoSFFloat target_focalDistance;
513  bool currentcamera_isperspective;
514  SoSFFloat target_ortho_height;
515 
516  camerastartorient = camera->orientation.getValue();
517 
518  bool changeorient(false);
519  if (lookat==SbVec3f(999,999,999)&&upvec==SbVec3f(999,999,999)) {
520  cameraendorient = camerastartorient;//Same orientation
521  } else {
522  changeorient=true;
523  //At least one of view direction and upwards direction is set by user
524  SbVec3f actual_lookat(lookat);
525  if (lookat==SbVec3f(999,999,999)) {
526  //Use present view direction of camera
527  SbRotation camrot = camera->orientation.getValue();
528  actual_lookat = SbVec3f(0.0f, 0.0f, -1.0f); // init to default view direction vector
529  camrot.multVec(actual_lookat, actual_lookat);
530  }
531  SbVec3f actual_upvec(upvec);
532  if (upvec==SbVec3f(999,999,999)) {
533  //Use present upwards direction of camera
534  SbRotation camrot = camera->orientation.getValue();
535  actual_upvec = SbVec3f(0.0f, 1.0f, 0.0f); // init to default up vector
536  camrot.multVec(actual_upvec, actual_upvec);
537  // { float x,y,z; actual_upvec.getValue(x,y,z);
538  // //std::cout<<"USE PRESENT CAMERA UPVEC ( "<<x<<", "<<y<<", "<<z<<" )"<<std::endl;
539  // }
540  }
541  //Use actual_lookat and actual_upvec to construct an orientation
542  //of the camera (refer to the SoCamera doc. for how it should be
543  //defined):
544  cameraendorient = Imp::cameraOrientation(actual_lookat,actual_upvec);
545  }
546 
547 
548  if (changeorient)
549  camera->orientation.setValue(cameraendorient);
550  if (!getCameraParametersForBBox( actualbbox,
551  target_position, target_nearDistance,
552  target_farDistance, target_focalDistance,
553  currentcamera_isperspective,target_ortho_height)) {
554  die();
555  return;
556  }
557  camerastartposition = camera->position.getValue();
558  cameraendposition = target_position.getValue();
559 
560  camerastart_nearDistance = camera->nearDistance.getValue();
561  cameraend_nearDistance = target_nearDistance;
562  camerastart_farDistance = camera->farDistance.getValue();
563  cameraend_farDistance = target_farDistance;
564  camerastart_focalDistance = camera->focalDistance.getValue();
565  cameraend_focalDistance = target_focalDistance;
566  camera_isperspective = currentcamera_isperspective;
567  if (camera_isperspective) {
568  camerastart_ortho_height = 1.0f;//Irrelevant value since not needed (we could cast to orthographic camera and get the real value).
570  } else {
571  SoOrthographicCamera * orthocam =static_cast<SoOrthographicCamera*>(camera);
572  if (!orthocam) {
573  if (changeorient)
574  camera->orientation.setValue(camerastartorient);
575  die();
576  return;
577  }
578  camerastart_ortho_height = orthocam->height.getValue();
579  cameraend_ortho_height = target_ortho_height;
580  }
581  if (changeorient)
582  camera->orientation.setValue(camerastartorient);
583 
584  //Start seek:
585 
586  startSeekTimer(duration_in_secs);
587 }

◆ actual_animatedZoomToCameraState()

void VP1CameraHelper::Imp::actual_animatedZoomToCameraState ( const QByteArray &  camstate,
double  duration_in_secs 
)

Definition at line 320 of file VP1CameraHelper.cxx.

322 {
323  if (!camera||camstate==QByteArray()||duration_in_secs<0.0) {
324  die();
325  return;
326  }
327 
328  if (instanceInvalid()) {
329  if (seeksensor->isScheduled())
330  seeksensor->unschedule();
331  die();
332  return;
333  }
334 
335  targetCamState = camstate;
336 
337  const bool perspective(camera->getTypeId().isDerivedFrom(SoPerspectiveCamera::getClassTypeId()));
338  SoCamera * targetcam = perspective ? static_cast<SoCamera*>(new SoPerspectiveCamera)
339  : static_cast<SoCamera*>(new SoOrthographicCamera);
340  targetcam->ref();
341  QByteArray ba = camstate;
342  if (!VP1QtInventorUtils::deserializeSoCameraParameters( ba, *targetcam )) {
343  targetcam->unref();
344  die();
345  return;
346  }
347 
348  camera_isperspective = perspective;
349  camerastartposition = camera->position.getValue();
350  camerastartorient = camera->orientation.getValue();
351  camerastart_nearDistance = camera->nearDistance.getValue();
352  camerastart_farDistance = camera->farDistance.getValue();
353  camerastart_focalDistance = camera->focalDistance.getValue();
354  cameraendposition = targetcam->position.getValue();
355  cameraendorient = targetcam->orientation.getValue();
356  cameraend_nearDistance = targetcam->nearDistance.getValue();
357  cameraend_farDistance = targetcam->farDistance.getValue();
358  cameraend_focalDistance = targetcam->focalDistance.getValue();
359  if (!perspective) {
360  camerastart_ortho_height = static_cast<SoOrthographicCamera*>(camera)->height.getValue();
361  cameraend_ortho_height = static_cast<SoOrthographicCamera*>(targetcam)->height.getValue();
362  }
363  targetcam->unref();
364 
365  startSeekTimer( duration_in_secs );
366 }

◆ actual_animatedZoomToPath()

void VP1CameraHelper::Imp::actual_animatedZoomToPath ( SoPath *  path,
double  duration_in_secs = 1.0,
double  slack = 1.0,
const SbVec3f &  lookat = SbVec3f(999,999,999),
const SbVec3f &  upvec = SbVec3f(999,999,999) 
)

Definition at line 384 of file VP1CameraHelper.cxx.

386 {
387  if (!path||instanceInvalid()) {
388  die();
389  return;
390  }
391 
392  if (slack<=0.0||duration_in_secs<0.0) {
393  die();
394  return;
395  }
396 
397  if (instanceInvalid()) {
398  if (seeksensor->isScheduled())
399  seeksensor->unschedule();
400  die();
401  return;
402  }
403  SbViewportRegion dummyvp;
404  SoGetBoundingBoxAction mybboxaction(dummyvp);
405  mybboxaction.apply(path);
406  SbBox3f box = mybboxaction.getBoundingBox();
407 
408  actual_animatedZoomToBBox(box, duration_in_secs, slack, lookat,upvec);
409 }

◆ actual_animatedZoomToPoint()

void VP1CameraHelper::Imp::actual_animatedZoomToPoint ( SbVec3f  targetpoint,
double  duration_in_secs = 1.0 
)

Definition at line 619 of file VP1CameraHelper.cxx.

620 {
621  if (instanceInvalid()) {
622  die();
623  return;
624  }
625 
626  if (duration_in_secs<0.0) {
627  die();
628  return;
629  }
630 
631  if (instanceInvalid()) {
632  die();
633  return;
634  }
635 
636  camerastartposition = camera->position.getValue();
637  camerastartorient = camera->orientation.getValue();
638 
639  //The following variables are not needed in seekToPoint mode, so
640  //give them values indicating they should not be updated:
641 
642  camerastart_nearDistance = camera->nearDistance.getValue();
644  camerastart_farDistance = camera->farDistance.getValue();
646  camerastart_focalDistance = camera->focalDistance.getValue();
648  //It actually doesnt matter if we set this one:
649  camera_isperspective=!(camera->getTypeId() == SoOrthographicCamera::getClassTypeId());
650  camerastart_ortho_height = 1.0f;//Irrelevant value since not needed (we could cast to orthographic camera and get the real value).
652 
653  // move point to the camera coordinate system, consider
654  // transformations before camera in the scene graph
655  SbMatrix cameramatrix, camerainverse;
657  sceneroot,
658  cameramatrix,
659  camerainverse);
660  camerainverse.multVecMatrix(targetpoint, targetpoint);
661  float fd = seekdistance;
662  if (!seekdistanceabs)
663  fd *= (targetpoint - camera->position.getValue()).length()/100.0f;
664  camera->focalDistance = fd;
665 
666  SbVec3f dir = targetpoint - camerastartposition;
667  dir.normalize();
668 
669  // find a rotation that rotates current camera direction into new
670  // camera direction.
671  SbVec3f olddir;
672  camera->orientation.getValue().multVec(SbVec3f(0, 0, -1), olddir);
673  SbRotation diffrot(olddir, dir);
674  cameraendposition = targetpoint - fd * dir;
675  cameraendorient = camera->orientation.getValue() * diffrot;
676 
677  startSeekTimer(duration_in_secs);
678 }

◆ actual_animatedZoomToSubTree()

void VP1CameraHelper::Imp::actual_animatedZoomToSubTree ( SoNode *  subtreeroot,
double  duration_in_secs = 1.0,
double  slack = 1.0,
const SbVec3f &  lookat = SbVec3f(999,999,999),
const SbVec3f &  upvec = SbVec3f(999,999,999) 
)

Definition at line 426 of file VP1CameraHelper.cxx.

428 {
429  if (!subtreeroot||instanceInvalid()) {
430  die();
431  return;
432  }
433 
434  if (slack<=0.0||duration_in_secs<0.0) {
435  die();
436  return;
437  }
438 
439  if (instanceInvalid()) {
440  die();
441  return;
442  }
443 
444  SoSearchAction mysearchaction;
445  mysearchaction.setNode(subtreeroot);
446  mysearchaction.apply(sceneroot);
447  SoPath * mypath = mysearchaction.getPath();
448  if (!mypath) {
449  VP1Msg::messageDebug("VP1CameraHelper WARNING: Cancelled operation due to failure to locate path to node.");
450  return;
451  }
452  mypath->ref();
453  actual_animatedZoomToPath( mypath, duration_in_secs, slack, lookat,upvec );
454  mypath->unref();
455  mysearchaction.reset();
456 }

◆ cameraOrientation()

SbRotation VP1CameraHelper::Imp::cameraOrientation ( SbVec3f  dir,
SbVec3f  up 
)
static

Definition at line 927 of file VP1CameraHelper.cxx.

928 {
929  const float epsilon = 0.00001f;
930 
931  //Input vectors must be non-zero:
932  if (dir.sqrLength()==0.0f||up.sqrLength()==0.0f) {
933  VP1Msg::messageDebug("VP1CameraHelper Warning: Asked to determine camera orientation from "
934  "view and up direction vectors that are not both non-zero");
935  return SbRotation(SbVec3f(0.0f, 0.0f, 1.0f), 0.0f);//Default rotation (as in SoCamera.cpp)
936  }
937 
938  //Normalize input:
939  dir.normalize();
940  up.normalize();
941 
942  //Direction and upvector corresponding to identity rotation:
943  SbVec3f dir0(0.0f, 0.0f, -1.0f), up0(0.0f, 1.0f, 0.0f);
944 
945  //First we construct the rotation which takes dir0 into dir:
946  SbRotation rot(dir0,dir);
947 
948  //dir and up should not be parallel:
949  if (fabs(dir.dot(up))>1.0f-epsilon) {
950  VP1Msg::messageDebug("VP1CameraHelper Warning: Asked to determine camera orientation from "
951  "view and up direction vectors that are essentially parallel."
952  " Choosing new arbitrary up direction.");
953  up = dir.cross(SbVec3f(1.0f,1.0f,0.0f));
954  up.normalize();
955  if (fabs(dir.dot(up))>1.0f-epsilon) {
956  up = dir.cross(SbVec3f(1.0f,0.0f,1.0f));
957  up.normalize();
958  if (fabs(dir.dot(up))>1.0f-epsilon) {
959  VP1Msg::messageDebug("VP1CameraHelper Warning: Unable to find useful up-vector.");
960  return rot;
961  }
962  }
963  }
964 
965  //The second rotation should rotate around dir (to leave it
966  //unchanged), and should take, in the plane orthogonal to dir, (the
967  //projection of) rot*up0 into (the projection of) up. This is achieved
968  //by first putting the two up vectors into the plane orthogonal to
969  //dir, and then simply finding the rotation which brings up0 into
970  //up:
971 
972  //Put up vectors into plane orthogonal to dir.
973  up = up - dir*(dir.dot(up));
974  if (up.length()<epsilon) {
975  //up and dir are parallel?
976  VP1Msg::messageDebug("VP1CameraHelper Warning: Can't determine correct up direction (1).");
977  return rot;
978  }
979  up.normalize();
980 
981  rot.multVec(up0,up0);
982  up0 = up0 - dir*(dir.dot(up0));
983  if (up0.length()<epsilon) {
984  //up0 and dir are parallel?
985  VP1Msg::messageDebug("VP1CameraHelper Warning: Can't determine correct up direction (2).");
986  return rot;
987  }
988  up0.normalize();
989 
990  //Done:
991  return rot*SbRotation(up0,up);
992 }

◆ die()

void VP1CameraHelper::Imp::die ( bool  abnormal = true)
inline

Definition at line 135 of file VP1CameraHelper.cxx.

136  {
137  VP1Msg::messageVerbose("VP1CameraHelper::Imp::die(abnormal="+VP1Msg::str(abnormal)+")");
138  if (seeksensor&&seeksensor->isScheduled())
139  seeksensor->unschedule();
140  if (abnormal)
142  else
144  theclass->deleteLater();
145  }

◆ getCameraCoordinateSystem()

void VP1CameraHelper::Imp::getCameraCoordinateSystem ( SoCamera *  cameraarg,
SoNode *  root,
SbMatrix &  matrix,
SbMatrix &  inverse 
)

Definition at line 830 of file VP1CameraHelper.cxx.

834 {
835  searchaction->reset();
836  searchaction->setSearchingAll(TRUE);
837  searchaction->setInterest(SoSearchAction::FIRST);
838  searchaction->setNode(cameraarg);
839  searchaction->apply(root);
840 
841  matrix = inverse = SbMatrix::identity();
842  if (searchaction->getPath()) {
843  matrixaction->apply(searchaction->getPath());
844  matrix = matrixaction->getMatrix();
845  inverse = matrixaction->getInverse();
846  }
847  searchaction->reset();
848 }

◆ getCameraParametersForBBox()

bool VP1CameraHelper::Imp::getCameraParametersForBBox ( const SbBox3f &  box,
SoSFVec3f &  position,
SoSFFloat &  nearDistance,
SoSFFloat &  farDistance,
SoSFFloat &  focalDistance,
bool &  isPerspective,
SoSFFloat &  height 
)

Definition at line 851 of file VP1CameraHelper.cxx.

856 {
857  float aspect = camera->aspectRatio.getValue();
858 
859  if (box.isEmpty())
860  return false;
861  if (camera->getTypeId() == SoPerspectiveCamera::getClassTypeId()) {
862  isPerspective=true;
863  } else if (camera->getTypeId() == SoOrthographicCamera::getClassTypeId()) {
864  isPerspective=false;
865  } else {
866  VP1Msg::messageDebug("VP1CameraHelper WARNING: Unknown camera type. Animation aborted.");
867  return false;
868  }
869 
870  SbVec3f cameradirection;
871  camera->orientation.getValue().multVec(SbVec3f(0, 0, -1), cameradirection);
872  position.setValue(box.getCenter() + -cameradirection);
873 
874  // Get the radius of the bounding sphere.
875  SbSphere bs;
876  bs.circumscribe(box);
877  float radius = bs.getRadius();
878 
879  if (isPerspective) {
880  // Make sure that everything will still be inside the viewing volume
881  // even if the aspect ratio "favorizes" width over height.
882  float aspectradius = radius / (aspect < 1.0f ? aspect : 1.0f);
883 
884  SoPerspectiveCamera * perspcam =static_cast<SoPerspectiveCamera*>(camera);
885  if (!perspcam)
886  return false;
887  // Move the camera to the edge of the bounding sphere, while still
888  // pointing at the scene.
889  SbVec3f direction = position.getValue() - box.getCenter();
890  (void) direction.normalize(); // we know this is not a null vector
891  float movelength =
892  aspectradius + (aspectradius/float(atan(perspcam->heightAngle.getValue())));
893  position.setValue(box.getCenter() + direction * movelength);
894  } else {
895  // Make sure that everything will still be inside the viewing volume
896  // even if the aspect ratio "favorizes" width over height.
897  if (aspect < 1.0f)
898  height = 2 * radius / aspect;
899  else
900  height = 2 * radius;
901 
902  // Move the camera to the edge of the bounding sphere, while still
903  // pointing at the scene.
904  SbVec3f direction = position.getValue() - box.getCenter();
905  (void) direction.normalize(); // we know this is not a null vector
906  position.setValue(box.getCenter() + direction * radius);
907  }
908 
909  // Set up the clipping planes according to the slack value (a value
910  // of 1.0 will yield clipping planes that are tangent to the
911  // bounding sphere of the scene).
912  float distance_to_midpoint = (position.getValue() - box.getCenter()).length();
913  nearDistance = distance_to_midpoint - radius;
914  farDistance = distance_to_midpoint + radius;
915 
916 
917  // The focal distance is simply the distance from the camera to the
918  // scene midpoint. This field is not used in rendering, its just
919  // provided to make it easier for the user to do calculations based
920  // on the distance between the camera and the scene.
921  focalDistance = distance_to_midpoint;
922 
923  return true;
924 }

◆ instanceInvalid()

bool VP1CameraHelper::Imp::instanceInvalid ( )

Definition at line 811 of file VP1CameraHelper.cxx.

812 {
813  if (instance_invalid)
814  return true;
815  if (!camera||camera_ref!=camera->getRefCount()) {
816  instance_invalid=true;
817  VP1Msg::messageDebug("VP1CameraHelper WARNING: Cancelled operation due to invalid camera.");
818  return true;
819  }
820  if (sceneroot->getRefCount()<=1) {
821  instance_invalid=true;
822  VP1Msg::messageDebug("VP1CameraHelper WARNING: Cancelled operation due to sceneroot being unref'ed.");
823  return true;
824  }
825 
826  return false;
827 }

◆ lastParsChanged()

bool VP1CameraHelper::Imp::lastParsChanged ( ) const

Definition at line 288 of file VP1CameraHelper.cxx.

289 {
290  if (camera->position.getValue()!=last_cameraposition
291  ||camera->orientation.getValue()!=last_cameraorient)
292  return true;
294  &&static_cast<SoOrthographicCamera*>(camera)->height!=last_camera_ortho_height)
295  return true;
296  return false;
297 }

◆ seeksensorCB()

void VP1CameraHelper::Imp::seeksensorCB ( void *  data,
SoSensor *  s 
)
static

Definition at line 682 of file VP1CameraHelper.cxx.

683 {
684  VP1Msg::messageVerbose("VP1CameraHelper::Imp::seeksensorCB()");
685 
687  if (!d||!s)
688  return;
689  if (d->instanceInvalid() || d->lastParsChanged()) {
690  d->die();
691  return;
692  }
693 
694  SoTimerSensor * sensor = (SoTimerSensor *)s;
695 
696  float t(0);
697 
698  if (d->fps>0) {
699  //fixed number of frames and output
700  if (d->ntotframes<0) {
701  //first time: figure out total number of frames
702  d->ntotframes = std::max(1,static_cast<int>((d->fps)*(d->seekperiod)+0.5));
703  d->iframe = 0;
704  }
705  //Example: 5 total frames should give times 0.2, 0.4, 0.6, 0.8,
706  //1.0. We should _not_ include 0.0 here. Otherwise chained zooms
707  //will get a frame at both the old 1.0 and the new 0.0.
708  t = ( (d->iframe+1==d->ntotframes) ? 1.0f : static_cast<float>((d->iframe+1)*1.0/(d->ntotframes*1.0)) );
709  ++(d->iframe);
710  } else {
711  //normal animation:
712  SbTime currenttime = SbTime::getTimeOfDay();
713  t = float((currenttime - sensor->getBaseTime()).getValue()) / d->seekperiod;
714  }
715 
716  if ((t > 1.0f) || (d->fps<=0&&(t + sensor->getInterval().getValue()/d->seekperiod > 1.0f))) t = 1.0f;
717 
718  d->clipVol_percentage = d->clipVol_startPercentage+(d->clipVol_endPercentage - d->clipVol_startPercentage)*t;
719  emit d->theclass->clipVolumePercentageOfATLAS(d->clipVol_percentage);
720 
721  bool end = (t == 1.0f);
722 
723  if (d->varySpeed)
724  t = (float) ((1.0 - cos(M_PI*t)) * 0.5);//Map t to slow down motion in the beginning and end of the animation.
725 
726  if (d->camera->position.getValue()!=d->cameraendposition) {
727  double rBegin=d->camerastartposition.length();
728  double rEnd=d->cameraendposition.length();
729  double lengthRatio = rEnd/rBegin;
730  SbVec3f u = d->camerastartposition; u.normalize();
731  SbVec3f v = d->cameraendposition; v.normalize();
732  double angle = acos(u.dot(v));
733  if (d->forceCircular||(lengthRatio>0.99 && lengthRatio<1.01 && angle<0.95*M_PI && angle>0.05*M_PI)) {
734  double r = rBegin + (rEnd-rBegin)*t;
735  SbVec3f w = u.cross(v);
736  SbRotation R(w,t*angle);
737  SbVec3f z;
738  R.multVec(u,z);
739  z*=r;
740  d->camera->position=z;
741  } else {
742  d->camera->position = d->camerastartposition + (d->cameraendposition - d->camerastartposition) * t;
743  }
744  }
745  if (d->camera->orientation.getValue()!=d->cameraendorient)
746  d->camera->orientation = SbRotation::slerp(d->camerastartorient,d->cameraendorient,t);
747  //TKTEST: Comment out the next lines to fix camera??>
748  //Other thing to try: Something about disable notify while setting multiple pars??
749 
750  //TEST if (d->camera->nearDistance!=d->cameraend_nearDistance)
751  //TEST d->camera->nearDistance.setValue(d->camerastart_nearDistance.getValue()*(1-t) + d->cameraend_nearDistance.getValue()*t);
752  //TEST if (d->camera->farDistance!=d->cameraend_farDistance)
753  //TEST d->camera->farDistance.setValue(d->camerastart_farDistance.getValue()*(1-t) + d->cameraend_farDistance.getValue()*t);
754  if (d->camera->focalDistance!=d->cameraend_focalDistance)
755  d->camera->focalDistance.setValue(d->camerastart_focalDistance.getValue()*(1-t) + d->cameraend_focalDistance.getValue()*t);
756  if (!d->camera_isperspective) {
757  SoOrthographicCamera * orthocam =static_cast<SoOrthographicCamera*>(d->camera);
758  if (orthocam&&orthocam->height!=d->cameraend_ortho_height)
759  orthocam->height.setValue(d->camerastart_ortho_height.getValue()*(1-t) + d->cameraend_ortho_height.getValue()*t);
760  }
761 
762  d->updateLastVars();
763 
764  if (d->ntotframes>0) {
765  QString dummy, filename;
767  if (d->seekperiod>0.0) {
768  VP1Msg::messageVerbose("VP1CameraHelper: Attempting to create image "+filename);
769  QPixmap pm = VP1QtInventorUtils::renderToPixmap(d->renderArea,
770  d->width,d->height,false);
771  if (pm.isNull()) {
772  VP1Msg::messageDebug("VP1CameraHelper ERROR: Could not create image");
773  } else {
774  if (!pm.save(filename))
775  VP1Msg::messageDebug("VP1CameraHelper ERROR: Could not save image file "+filename);
776  }
777  }
778  }
779 
780  if (end) {
781  if (d->targetCamState!=QByteArray()) {
782  if (!VP1QtInventorUtils::deserializeSoCameraParameters( d->targetCamState, *(d->camera) )) {
783  d->die();
784  return;
785  }
786  }
787  d->die(false/*non-abnormal end!*/);
788  }
789 
790 }

◆ startSeekTimer()

void VP1CameraHelper::Imp::startSeekTimer ( double  duration_in_secs)

Definition at line 604 of file VP1CameraHelper.cxx.

605 {
606  seekperiod = static_cast<float>(duration_in_secs);
607 
608  if (seeksensor->isScheduled())
609  seeksensor->unschedule();
610 
611  seeksensor->setBaseTime(SbTime::getTimeOfDay());
612  seeksensor->schedule();
613 
614  updateLastVars();
615 
616 }

◆ updateLastVars()

void VP1CameraHelper::Imp::updateLastVars ( )

Definition at line 278 of file VP1CameraHelper.cxx.

279 {
280  last_cameraposition=camera->position.getValue();
281  last_cameraorient = camera->orientation.getValue();
283  last_camera_ortho_height=static_cast<SoOrthographicCamera*>(camera)->height;
285 }

Member Data Documentation

◆ camera

SoCamera* VP1CameraHelper::Imp::camera

Definition at line 45 of file VP1CameraHelper.cxx.

◆ camera_isperspective

bool VP1CameraHelper::Imp::camera_isperspective

Definition at line 67 of file VP1CameraHelper.cxx.

◆ camera_ref

int32_t VP1CameraHelper::Imp::camera_ref

Definition at line 100 of file VP1CameraHelper.cxx.

◆ cameraend_farDistance

SoSFFloat VP1CameraHelper::Imp::cameraend_farDistance

Definition at line 65 of file VP1CameraHelper.cxx.

◆ cameraend_focalDistance

SoSFFloat VP1CameraHelper::Imp::cameraend_focalDistance

Definition at line 66 of file VP1CameraHelper.cxx.

◆ cameraend_nearDistance

SoSFFloat VP1CameraHelper::Imp::cameraend_nearDistance

Definition at line 64 of file VP1CameraHelper.cxx.

◆ cameraend_ortho_height

SoSFFloat VP1CameraHelper::Imp::cameraend_ortho_height

Definition at line 68 of file VP1CameraHelper.cxx.

◆ cameraendorient

SbRotation VP1CameraHelper::Imp::cameraendorient

Definition at line 62 of file VP1CameraHelper.cxx.

◆ cameraendposition

SbVec3f VP1CameraHelper::Imp::cameraendposition

Definition at line 61 of file VP1CameraHelper.cxx.

◆ camerastart_farDistance

SoSFFloat VP1CameraHelper::Imp::camerastart_farDistance

Definition at line 65 of file VP1CameraHelper.cxx.

◆ camerastart_focalDistance

SoSFFloat VP1CameraHelper::Imp::camerastart_focalDistance

Definition at line 66 of file VP1CameraHelper.cxx.

◆ camerastart_nearDistance

SoSFFloat VP1CameraHelper::Imp::camerastart_nearDistance

Definition at line 64 of file VP1CameraHelper.cxx.

◆ camerastart_ortho_height

SoSFFloat VP1CameraHelper::Imp::camerastart_ortho_height

Definition at line 68 of file VP1CameraHelper.cxx.

◆ camerastartorient

SbRotation VP1CameraHelper::Imp::camerastartorient

Definition at line 62 of file VP1CameraHelper.cxx.

◆ camerastartposition

SbVec3f VP1CameraHelper::Imp::camerastartposition

Definition at line 61 of file VP1CameraHelper.cxx.

◆ clipVol_endPercentage

double VP1CameraHelper::Imp::clipVol_endPercentage

Definition at line 71 of file VP1CameraHelper.cxx.

◆ clipVol_lastPercentage

double VP1CameraHelper::Imp::clipVol_lastPercentage

Definition at line 89 of file VP1CameraHelper.cxx.

◆ clipVol_percentage

double VP1CameraHelper::Imp::clipVol_percentage

Definition at line 71 of file VP1CameraHelper.cxx.

◆ clipVol_startPercentage

double VP1CameraHelper::Imp::clipVol_startPercentage

Definition at line 71 of file VP1CameraHelper.cxx.

◆ forceCircular

bool VP1CameraHelper::Imp::forceCircular

Definition at line 48 of file VP1CameraHelper.cxx.

◆ fps

double VP1CameraHelper::Imp::fps

Definition at line 78 of file VP1CameraHelper.cxx.

◆ height

int VP1CameraHelper::Imp::height

Definition at line 82 of file VP1CameraHelper.cxx.

◆ helpers

std::map< SoCamera *, VP1CameraHelper * > VP1CameraHelper::Imp::helpers
static

Definition at line 114 of file VP1CameraHelper.cxx.

◆ iframe

int VP1CameraHelper::Imp::iframe

Definition at line 80 of file VP1CameraHelper.cxx.

◆ inseekmode

SbBool VP1CameraHelper::Imp::inseekmode

Definition at line 56 of file VP1CameraHelper.cxx.

◆ instance_invalid

bool VP1CameraHelper::Imp::instance_invalid

Definition at line 101 of file VP1CameraHelper.cxx.

◆ last_camera_ortho_height

SoSFFloat VP1CameraHelper::Imp::last_camera_ortho_height

Definition at line 88 of file VP1CameraHelper.cxx.

◆ last_cameraorient

SbRotation VP1CameraHelper::Imp::last_cameraorient

Definition at line 86 of file VP1CameraHelper.cxx.

◆ last_cameraposition

SbVec3f VP1CameraHelper::Imp::last_cameraposition

Definition at line 87 of file VP1CameraHelper.cxx.

◆ matrixaction

SoGetMatrixAction* VP1CameraHelper::Imp::matrixaction

Definition at line 97 of file VP1CameraHelper.cxx.

◆ ntotframes

int VP1CameraHelper::Imp::ntotframes

Definition at line 79 of file VP1CameraHelper.cxx.

◆ outputdir

QString VP1CameraHelper::Imp::outputdir

Definition at line 76 of file VP1CameraHelper.cxx.

◆ prefix

QString VP1CameraHelper::Imp::prefix

Definition at line 77 of file VP1CameraHelper.cxx.

◆ renderArea

VP1ExaminerViewer* VP1CameraHelper::Imp::renderArea

Definition at line 75 of file VP1CameraHelper.cxx.

◆ sceneroot

SoGroup* VP1CameraHelper::Imp::sceneroot

Definition at line 46 of file VP1CameraHelper.cxx.

◆ searchaction

SoSearchAction* VP1CameraHelper::Imp::searchaction

Definition at line 96 of file VP1CameraHelper.cxx.

◆ seekdistance

float VP1CameraHelper::Imp::seekdistance

Definition at line 58 of file VP1CameraHelper.cxx.

◆ seekdistanceabs

SbBool VP1CameraHelper::Imp::seekdistanceabs

Definition at line 59 of file VP1CameraHelper.cxx.

◆ seekperiod

float VP1CameraHelper::Imp::seekperiod

Definition at line 55 of file VP1CameraHelper.cxx.

◆ seeksensor

SoTimerSensor* VP1CameraHelper::Imp::seeksensor

Definition at line 54 of file VP1CameraHelper.cxx.

◆ seektopoint

SbBool VP1CameraHelper::Imp::seektopoint

Definition at line 57 of file VP1CameraHelper.cxx.

◆ targetCamState

QByteArray VP1CameraHelper::Imp::targetCamState

Definition at line 47 of file VP1CameraHelper.cxx.

◆ theclass

VP1CameraHelper* VP1CameraHelper::Imp::theclass

Definition at line 44 of file VP1CameraHelper.cxx.

◆ varySpeed

bool VP1CameraHelper::Imp::varySpeed

Definition at line 70 of file VP1CameraHelper.cxx.

◆ width

int VP1CameraHelper::Imp::width

Definition at line 81 of file VP1CameraHelper.cxx.


The documentation for this class was generated from the following file:
beamspotman.r
def r
Definition: beamspotman.py:676
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
python.CaloRecoConfig.f
f
Definition: CaloRecoConfig.py:127
VP1CameraHelper::Imp::last_cameraposition
SbVec3f last_cameraposition
Definition: VP1CameraHelper.cxx:87
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
VP1CameraHelper::Imp::seekdistanceabs
SbBool seekdistanceabs
Definition: VP1CameraHelper.cxx:59
athena.path
path
python interpreter configuration --------------------------------------—
Definition: athena.py:126
max
#define max(a, b)
Definition: cfImp.cxx:41
VP1QtInventorUtils::deserializeSoCameraParameters
static bool deserializeSoCameraParameters(QByteArray &, SoCamera &)
Definition: VP1QtInventorUtils.cxx:959
IDTPM::R
float R(const U &p)
Definition: TrackParametersHelper.h:101
VP1CameraHelper::getLastAndNextFrameFileNames
static void getLastAndNextFrameFileNames(QString outputdir, QString prefix, QString &lastOfExistingFiles, QString &nextAvailableFile)
Definition: VP1CameraHelper.cxx:793
VP1CameraHelper::Imp::camera_ref
int32_t camera_ref
Definition: VP1CameraHelper.cxx:100
VP1CameraHelper::Imp::actual_animatedZoomToPath
void actual_animatedZoomToPath(SoPath *path, double duration_in_secs=1.0, double slack=1.0, const SbVec3f &lookat=SbVec3f(999, 999, 999), const SbVec3f &upvec=SbVec3f(999, 999, 999))
Definition: VP1CameraHelper.cxx:384
hist_file_dump.d
d
Definition: hist_file_dump.py:137
VP1CameraHelper::Imp::camerastartorient
SbRotation camerastartorient
Definition: VP1CameraHelper.cxx:62
VP1CameraHelper::Imp::getCameraCoordinateSystem
void getCameraCoordinateSystem(SoCamera *cameraarg, SoNode *root, SbMatrix &matrix, SbMatrix &inverse)
Definition: VP1CameraHelper.cxx:830
VP1CameraHelper::Imp::cameraOrientation
static SbRotation cameraOrientation(SbVec3f dir, SbVec3f up)
Definition: VP1CameraHelper.cxx:927
VP1CameraHelper::Imp::height
int height
Definition: VP1CameraHelper.cxx:82
VP1CameraHelper::Imp::seeksensor
SoTimerSensor * seeksensor
Definition: VP1CameraHelper.cxx:54
M_PI
#define M_PI
Definition: ActiveFraction.h:11
VP1CameraHelper::Imp::cameraendorient
SbRotation cameraendorient
Definition: VP1CameraHelper.cxx:62
VP1CameraHelper::Imp::sceneroot
SoGroup * sceneroot
Definition: VP1CameraHelper.cxx:46
sendEI_SPB.root
root
Definition: sendEI_SPB.py:34
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
drawFromPickle.cos
cos
Definition: drawFromPickle.py:36
VP1String::str
static QString str(const QString &s)
Definition: VP1String.h:49
VP1CameraHelper::animationFinishedAbnormally
void animationFinishedAbnormally()
Trk::u
@ u
Enums for curvilinear frames.
Definition: ParamDefs.h:83
drawFromPickle.atan
atan
Definition: drawFromPickle.py:36
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
VP1CameraHelper::Imp::seekdistance
float seekdistance
Definition: VP1CameraHelper.cxx:58
VP1CameraHelper::Imp::getCameraParametersForBBox
bool getCameraParametersForBBox(const SbBox3f &box, SoSFVec3f &position, SoSFFloat &nearDistance, SoSFFloat &farDistance, SoSFFloat &focalDistance, bool &isPerspective, SoSFFloat &height)
Definition: VP1CameraHelper.cxx:851
VP1CameraHelper::Imp::instanceInvalid
bool instanceInvalid()
Definition: VP1CameraHelper.cxx:811
PlotCalibFromCool.cx
cx
Definition: PlotCalibFromCool.py:666
VP1CameraHelper::Imp::instance_invalid
bool instance_invalid
Definition: VP1CameraHelper.cxx:101
VP1CameraHelper::Imp::cameraend_farDistance
SoSFFloat cameraend_farDistance
Definition: VP1CameraHelper.cxx:65
VP1CameraHelper::Imp::camerastart_nearDistance
SoSFFloat camerastart_nearDistance
Definition: VP1CameraHelper.cxx:64
VP1CameraHelper::Imp::camera
SoCamera * camera
Definition: VP1CameraHelper.cxx:45
z
#define z
VP1CameraHelper::Imp::targetCamState
QByteArray targetCamState
Definition: VP1CameraHelper.cxx:47
VP1CameraHelper::Imp::cameraend_focalDistance
SoSFFloat cameraend_focalDistance
Definition: VP1CameraHelper.cxx:66
angle
double angle(const GeoTrf::Vector2D &a, const GeoTrf::Vector2D &b)
Definition: TRTDetectorFactory_Full.cxx:73
VP1CameraHelper::Imp::startSeekTimer
void startSeekTimer(double duration_in_secs)
Definition: VP1CameraHelper.cxx:604
VP1CameraHelper::Imp::die
void die(bool abnormal=true)
Definition: VP1CameraHelper.cxx:135
CalibCoolCompareRT.up
up
Definition: CalibCoolCompareRT.py:109
python.xAODType.dummy
dummy
Definition: xAODType.py:4
python.Constants.TRUE
bool TRUE
for job options legacy (TODO: get rid of these!) ----------------------—
Definition: Control/AthenaCommon/python/Constants.py:22
VP1CameraHelper::Imp::actual_animatedZoomToBBox
void actual_animatedZoomToBBox(const SbBox3f &box, double duration_in_secs=1.0, double slack=1.0, const SbVec3f &lookat=SbVec3f(999, 999, 999), const SbVec3f &upvec=SbVec3f(999, 999, 999))
Definition: VP1CameraHelper.cxx:474
VP1CameraHelper::Imp::theclass
VP1CameraHelper * theclass
Definition: VP1CameraHelper.cxx:44
VP1CameraHelper::Imp::cameraend_ortho_height
SoSFFloat cameraend_ortho_height
Definition: VP1CameraHelper.cxx:68
python.LArCalib_ToCoolInlineConfig.mypath
mypath
Definition: LArCalib_ToCoolInlineConfig.py:157
RTTAlgmain.currenttime
currenttime
Definition: RTTAlgmain.py:24
beamspotman.dir
string dir
Definition: beamspotman.py:623
VP1CameraHelper::Imp::searchaction
SoSearchAction * searchaction
Definition: VP1CameraHelper.cxx:96
ReadFromCoolCompare.fd
fd
Definition: ReadFromCoolCompare.py:196
VP1Msg::messageVerbose
static void messageVerbose(const QString &)
Definition: VP1Msg.cxx:84
VP1CameraHelper::Imp::updateLastVars
void updateLastVars()
Definition: VP1CameraHelper.cxx:278
VP1CameraHelper::Imp::camerastart_ortho_height
SoSFFloat camerastart_ortho_height
Definition: VP1CameraHelper.cxx:68
VP1CameraHelper::Imp::camerastart_farDistance
SoSFFloat camerastart_farDistance
Definition: VP1CameraHelper.cxx:65
ParticleGun_SamplingFraction.radius
radius
Definition: ParticleGun_SamplingFraction.py:96
VP1CameraHelper::Imp::camerastartposition
SbVec3f camerastartposition
Definition: VP1CameraHelper.cxx:61
VP1CameraHelper::Imp::matrixaction
SoGetMatrixAction * matrixaction
Definition: VP1CameraHelper.cxx:97
python.PyAthena.v
v
Definition: PyAthena.py:157
makeTRTBarrelCans.dy
tuple dy
Definition: makeTRTBarrelCans.py:21
VP1CameraHelper::animationFinished
void animationFinished()
python.testIfMatch.matrix
matrix
Definition: testIfMatch.py:66
VP1CameraHelper::Imp::last_cameraorient
SbRotation last_cameraorient
Definition: VP1CameraHelper.cxx:86
VP1CameraHelper::Imp::camera_isperspective
bool camera_isperspective
Definition: VP1CameraHelper.cxx:67
VP1Msg::messageDebug
static void messageDebug(const QString &)
Definition: VP1Msg.cxx:39
PlotCalibFromCool.cy
cy
Definition: PlotCalibFromCool.py:667
makeTRTBarrelCans.dx
tuple dx
Definition: makeTRTBarrelCans.py:20
VP1CameraHelper::Imp::cameraend_nearDistance
SoSFFloat cameraend_nearDistance
Definition: VP1CameraHelper.cxx:64
CaloCellTimeCorrFiller.filename
filename
Definition: CaloCellTimeCorrFiller.py:24
VP1QtInventorUtils::renderToPixmap
static QPixmap renderToPixmap(VP1ExaminerViewer *ra, int pixels_x, int pixels_y, bool transparent_background=false, double actualRenderedSizeFact=1.0)
Definition: VP1QtInventorUtils.cxx:593
VP1CameraHelper::Imp
Definition: VP1CameraHelper.cxx:42
VP1CameraHelper::Imp::clipVol_lastPercentage
double clipVol_lastPercentage
Definition: VP1CameraHelper.cxx:89
VP1CameraHelper::Imp::seekperiod
float seekperiod
Definition: VP1CameraHelper.cxx:55
python.IoTestsLib.w
def w
Definition: IoTestsLib.py:200
VP1CameraHelper::Imp::clipVol_percentage
double clipVol_percentage
Definition: VP1CameraHelper.cxx:71
length
double length(const pvec &v)
Definition: FPGATrackSimLLPDoubletHoughTransformTool.cxx:26
VP1CameraHelper::Imp::last_camera_ortho_height
SoSFFloat last_camera_ortho_height
Definition: VP1CameraHelper.cxx:88
readCCLHist.float
float
Definition: readCCLHist.py:83
VP1CameraHelper::Imp::cameraendposition
SbVec3f cameraendposition
Definition: VP1CameraHelper.cxx:61
VP1CameraHelper::Imp::camerastart_focalDistance
SoSFFloat camerastart_focalDistance
Definition: VP1CameraHelper.cxx:66