33#ifdef G4VIS_BUILD_OPENGL_DRIVER
58G4int G4OpenGLViewer::fPrintSizeX = -1;
59G4int G4OpenGLViewer::fPrintSizeY = -1;
60G4String G4OpenGLViewer::fPrintFilename =
"G4OpenGL";
61int G4OpenGLViewer::fPrintFilenameIndex = 0;
63G4OpenGLViewer::G4OpenGLViewer (G4OpenGLSceneHandler& scene):
67fOpenGLSceneHandler(scene),
69transparency_enabled (true),
70antialiasing_enabled (false),
71haloing_enabled (false),
75fDisplayHeadTime(false),
76fDisplayHeadTimeX(-0.9),
77fDisplayHeadTimeY(-0.9),
78fDisplayHeadTimeSize(24.),
79fDisplayHeadTimeRed(0.),
80fDisplayHeadTimeGreen(1.),
81fDisplayHeadTimeBlue(1.),
82fDisplayLightFront(false),
83fDisplayLightFrontX(0.),
84fDisplayLightFrontY(0.),
85fDisplayLightFrontZ(0.),
86fDisplayLightFrontT(0.),
87fDisplayLightFrontRed(0.),
88fDisplayLightFrontGreen(1.),
89fDisplayLightFrontBlue(0.),
96fGl2psDefaultLineWith(1),
97fGl2psDefaultPointSize(2)
100 printf(
"G4OpenGLViewer:: Creation\n");
103 fVP.SetAutoRefresh(
true);
104 fDefaultVP.SetAutoRefresh(
true);
116G4OpenGLViewer::~G4OpenGLViewer ()
121void G4OpenGLViewer::InitializeGLView ()
123#ifdef G4DEBUG_VIS_OGL
124 printf(
"G4OpenGLViewer::InitializeGLView\n");
127 fWinSize_x = fVP.GetWindowSizeHintX();
128 fWinSize_y = fVP.GetWindowSizeHintY();
130 glClearColor (0.0, 0.0, 0.0, 0.0);
132 glDisable (GL_LINE_SMOOTH);
133 glDisable (GL_POLYGON_SMOOTH);
139 glDepthFunc (GL_LEQUAL);
140 glDepthMask (GL_TRUE);
143 glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
145#ifdef G4DEBUG_VIS_OGL
146 printf(
"G4OpenGLViewer::InitializeGLView END\n");
150void G4OpenGLViewer::ClearView () {
151#ifdef G4DEBUG_VIS_OGL
152 printf(
"G4OpenGLViewer::ClearView\n");
154 glClearColor (background.GetRed(),
155 background.GetGreen(),
156 background.GetBlue(),
161 glClear (GL_COLOR_BUFFER_BIT);
162 glClear (GL_DEPTH_BUFFER_BIT);
163 glClear (GL_STENCIL_BUFFER_BIT);
164#ifdef G4DEBUG_VIS_OGL
165 printf(
"G4OpenGLViewer::ClearView flush\n");
171void G4OpenGLViewer::ResizeWindow(
unsigned int aWidth,
unsigned int aHeight) {
172 if ((fWinSize_x != aWidth) || (fWinSize_y != aHeight)) {
174 fWinSize_y = aHeight;
175 fSizeHasChanged =
true;
177 fSizeHasChanged =
false;
187void G4OpenGLViewer::ResizeGLView()
189#ifdef G4DEBUG_VIS_OGL
190 printf(
"G4OpenGLViewer::ResizeGLView %d %d %#lx\n",fWinSize_x,fWinSize_y,(
unsigned long)
this);
197 glGetIntegerv(GL_MAX_VIEWPORT_DIMS, dims);
199 if ((dims[0] !=0 ) && (dims[1] !=0)) {
201 if (fWinSize_x > (
unsigned)dims[0]) {
202 G4cerr <<
"Try to resize view greater than max X viewport dimension. Desired size "<<fWinSize_x <<
" is resize to "<< dims[0] <<
G4endl;
203 fWinSize_x = dims[0];
205 if (fWinSize_y > (
unsigned)dims[1]) {
206 G4cerr <<
"Try to resize view greater than max Y viewport dimension. Desired size "<<fWinSize_y <<
" is resize to "<< dims[1] <<
G4endl;
207 fWinSize_y = dims[1];
211 glViewport(0, 0, fWinSize_x,fWinSize_y);
217void G4OpenGLViewer::SetView () {
219 if (!fSceneHandler.GetScene()) {
227 GLfloat lightPosition [4];
228 lightPosition [0] = fVP.GetActualLightpointDirection().x();
229 lightPosition [1] = fVP.GetActualLightpointDirection().y();
230 lightPosition [2] = fVP.GetActualLightpointDirection().z();
231 lightPosition [3] = 0.;
233 GLfloat ambient [] = { 0.2, 0.2, 0.2, 1.};
234 GLfloat diffuse [] = { 0.8, 0.8, 0.8, 1.};
235 glEnable (GL_LIGHT0);
236 glLightfv (GL_LIGHT0, GL_AMBIENT, ambient);
237 glLightfv (GL_LIGHT0, GL_DIFFUSE, diffuse);
241 if (fWinSize_y > fWinSize_x) {
244 if (fWinSize_x > fWinSize_y) {
251 = fSceneHandler.GetScene()->GetStandardTargetPoint()
252 + fVP.GetCurrentTargetPoint ();
253 G4double radius = fSceneHandler.GetScene()->GetExtent().GetExtentRadius();
254 if(radius<=0.) radius = 1.;
255 const G4double cameraDistance = fVP.GetCameraDistance (radius);
257 targetPoint + cameraDistance * fVP.GetViewpointDirection().
unit();
258 const GLdouble pnear = fVP.GetNearDistance (cameraDistance, radius);
259 const GLdouble pfar = fVP.GetFarDistance (cameraDistance, pnear, radius);
260 const GLdouble right = fVP.GetFrontHalfHeight (pnear, radius) * ratioY;
261 const GLdouble left = -right;
262 const GLdouble top = fVP.GetFrontHalfHeight (pnear, radius) * ratioX;
263 const GLdouble bottom = -top;
269 glMatrixMode (GL_PROJECTION);
272 const G4Vector3D scaleFactor = fVP.GetScaleFactor();
273 glScaled(scaleFactor.
x(),scaleFactor.
y(),scaleFactor.
z());
275 if (fVP.GetFieldHalfAngle() == 0.) {
276 glOrtho (left, right, bottom, top, pnear, pfar);
279 glFrustum (left, right, bottom, top, pnear, pfar);
282 glMatrixMode (GL_MODELVIEW);
285 const G4Normal3D& upVector = fVP.GetUpVector ();
287 if (cameraDistance > 1.e-6 * radius) {
288 gltarget = targetPoint;
291 gltarget = targetPoint - radius * fVP.GetViewpointDirection().
unit();
294 const G4Point3D& pCamera = cameraPosition;
295 gluLookAt (pCamera.
x(), pCamera.
y(), pCamera.
z(),
296 gltarget.
x(), gltarget.
y(), gltarget.
z(),
297 upVector.
x(), upVector.
y(), upVector.
z());
300 glLightfv (GL_LIGHT0, GL_POSITION, lightPosition);
314 sArray[3] =
sp.d() + radius * 1.e-05;
315 glClipPlane (GL_CLIP_PLANE0, sArray);
316 glEnable (GL_CLIP_PLANE0);
320 sArray[3] = -
sp.d() + radius * 1.e-05;
321 glClipPlane (GL_CLIP_PLANE1, sArray);
322 glEnable (GL_CLIP_PLANE1);
324 glDisable (GL_CLIP_PLANE0);
325 glDisable (GL_CLIP_PLANE1);
332 const G4Planes& cutaways = fVP.GetCutawayPlanes();
333 size_t nPlanes = cutaways.size();
334 if (fVP.IsCutaway() &&
338 a[0] = cutaways[0].a();
339 a[1] = cutaways[0].b();
340 a[2] = cutaways[0].c();
341 a[3] = cutaways[0].d();
342 glClipPlane (GL_CLIP_PLANE2, a);
343 glEnable (GL_CLIP_PLANE2);
345 a[0] = cutaways[1].a();
346 a[1] = cutaways[1].b();
347 a[2] = cutaways[1].c();
348 a[3] = cutaways[1].d();
349 glClipPlane (GL_CLIP_PLANE3, a);
350 glEnable (GL_CLIP_PLANE3);
353 a[0] = cutaways[2].a();
354 a[1] = cutaways[2].b();
355 a[2] = cutaways[2].c();
356 a[3] = cutaways[2].d();
357 glClipPlane (GL_CLIP_PLANE4, a);
358 glEnable (GL_CLIP_PLANE4);
361 glDisable (GL_CLIP_PLANE2);
362 glDisable (GL_CLIP_PLANE3);
363 glDisable (GL_CLIP_PLANE4);
367 background = fVP.GetBackgroundColour ();
373void G4OpenGLViewer::ResetView () {
380void G4OpenGLViewer::HaloingFirstPass () {
390 glColorMask (GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
393 glDepthMask (GL_TRUE);
394 glDepthFunc (GL_LESS);
398 ChangeLineWidth(3.0);
402void G4OpenGLViewer::HaloingSecondPass () {
405 glColorMask (GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
406 glDepthFunc (GL_LEQUAL);
407 ChangeLineWidth(1.0);
411void G4OpenGLViewer::Pick(GLdouble x, GLdouble y)
414 const G4int BUFSIZE = 512;
415 GLuint selectBuffer[BUFSIZE];
416 glSelectBuffer(BUFSIZE, selectBuffer);
417 glRenderMode(GL_SELECT);
420 glMatrixMode(GL_PROJECTION);
421 G4double currentProjectionMatrix[16];
422 glGetDoublev(GL_PROJECTION_MATRIX, currentProjectionMatrix);
426 glGetIntegerv(GL_VIEWPORT, viewport);
428 gluPickMatrix(x, viewport[3] - y, 5., 5., viewport);
429 glMultMatrixd(currentProjectionMatrix);
430 glMatrixMode(GL_MODELVIEW);
432 GLint hits = glRenderMode(GL_RENDER);
434 G4cout <<
"Too many hits. Zoom in to reduce overlaps." <<
G4endl;
437 GLuint* p = selectBuffer;
438 for (GLint i = 0; i < hits; ++i) {
439 GLuint nnames = *p++;
448 for (GLuint j = 0; j < nnames; ++j) {
451 <<
", Sub-hit: " << j
452 <<
", PickName: " << name <<
G4endl;
453 std::map<GLuint, G4AttHolder*>::iterator iter =
454 fOpenGLSceneHandler.fPickMap.find(name);
455 if (iter != fOpenGLSceneHandler.fPickMap.end()) {
457 if(attHolder && attHolder->
GetAttDefs().size()) {
458 for (
size_t iAtt = 0;
459 iAtt < attHolder->
GetAttDefs().size(); ++iAtt) {
469 glMatrixMode(GL_PROJECTION);
471 glMatrixMode(GL_MODELVIEW);
477GLubyte* G4OpenGLViewer::grabPixels (
int inColor,
unsigned int width,
unsigned int height) {
480 GLint swapbytes, lsbfirst, rowlength;
481 GLint skiprows, skippixels, alignment;
487 size = width*height*3;
489 format = GL_LUMINANCE;
490 size = width*height*1;
493 buffer =
new GLubyte[size];
497 glGetIntegerv (GL_UNPACK_SWAP_BYTES, &swapbytes);
498 glGetIntegerv (GL_UNPACK_LSB_FIRST, &lsbfirst);
499 glGetIntegerv (GL_UNPACK_ROW_LENGTH, &rowlength);
501 glGetIntegerv (GL_UNPACK_SKIP_ROWS, &skiprows);
502 glGetIntegerv (GL_UNPACK_SKIP_PIXELS, &skippixels);
503 glGetIntegerv (GL_UNPACK_ALIGNMENT, &alignment);
505 glPixelStorei (GL_UNPACK_SWAP_BYTES, GL_FALSE);
506 glPixelStorei (GL_UNPACK_LSB_FIRST, GL_FALSE);
507 glPixelStorei (GL_UNPACK_ROW_LENGTH, 0);
509 glPixelStorei (GL_UNPACK_SKIP_ROWS, 0);
510 glPixelStorei (GL_UNPACK_SKIP_PIXELS, 0);
511 glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
513 glReadBuffer(GL_FRONT);
514 glReadPixels (0, 0, (GLsizei)width, (GLsizei)height, format, GL_UNSIGNED_BYTE, (GLvoid*)
buffer);
516 glPixelStorei (GL_UNPACK_SWAP_BYTES, swapbytes);
517 glPixelStorei (GL_UNPACK_LSB_FIRST, lsbfirst);
518 glPixelStorei (GL_UNPACK_ROW_LENGTH, rowlength);
520 glPixelStorei (GL_UNPACK_SKIP_ROWS, skiprows);
521 glPixelStorei (GL_UNPACK_SKIP_PIXELS, skippixels);
522 glPixelStorei (GL_UNPACK_ALIGNMENT, alignment);
527void G4OpenGLViewer::printEPS() {
529#ifdef G4DEBUG_VIS_OGL
530 printf(
"G4OpenGLViewer::printEPS file:%s Vec:%d Name:%s\n",getRealPrintFilename().c_str(),fVectoredPs,GetName().c_str());
535 size_t len = strlen(setlocale(LC_NUMERIC,NULL));
536 char* oldLocale = (
char*)(malloc(len+1));
537 if(oldLocale!=NULL) strncpy(oldLocale,setlocale(LC_NUMERIC,NULL),len);
538 setlocale(LC_NUMERIC,
"C");
541 res = printVectoredEPS();
543 res = printNonVectoredEPS();
548 setlocale(LC_NUMERIC,oldLocale);
553 G4cerr <<
"Error while saving file... "<<getRealPrintFilename().c_str()<<
G4endl;
555 G4cout <<
"File "<<getRealPrintFilename().c_str()<<
" has been saved " <<
G4endl;
559 if ( fPrintFilenameIndex != -1) {
560 fPrintFilenameIndex++;
563#ifdef G4DEBUG_VIS_OGL
564 printf(
"G4OpenGLViewer::printEPS END\n");
568bool G4OpenGLViewer::printVectoredEPS() {
572bool G4OpenGLViewer::printNonVectoredEPS () {
574 int width = getRealPrintSizeX();
575 int height = getRealPrintSizeY();
577#ifdef G4DEBUG_VIS_OGL
578 printf(
"G4OpenGLViewer::printNonVectoredEPS file:%s Vec:%d X:%d Y:%d col:%d fWinX:%d fWinY:%d\n",getRealPrintFilename().c_str(),fVectoredPs,width,height,fPrintColour,fWinSize_x,fWinSize_y);
583 int components, pos, i;
585 pixels = grabPixels (fPrintColour, width, height);
587 if (pixels == NULL) {
588 G4cerr <<
"Failed to get pixels from OpenGl viewport" <<
G4endl;
596 std::string name = getRealPrintFilename();
597 fp = fopen (name.c_str(),
"w");
599 G4cerr <<
"Can't open filename " << name.c_str() <<
G4endl;
603 fprintf (fp,
"%%!PS-Adobe-2.0 EPSF-1.2\n");
604 fprintf (fp,
"%%%%Title: %s\n", name.c_str());
605 fprintf (fp,
"%%%%Creator: OpenGL pixmap render output\n");
606 fprintf (fp,
"%%%%BoundingBox: 0 0 %d %d\n", width, height);
607 fprintf (fp,
"%%%%EndComments\n");
608 fprintf (fp,
"gsave\n");
609 fprintf (fp,
"/bwproc {\n");
610 fprintf (fp,
" rgbproc\n");
611 fprintf (fp,
" dup length 3 idiv string 0 3 0 \n");
612 fprintf (fp,
" 5 -1 roll {\n");
613 fprintf (fp,
" add 2 1 roll 1 sub dup 0 eq\n");
614 fprintf (fp,
" { pop 3 idiv 3 -1 roll dup 4 -1 roll dup\n");
615 fprintf (fp,
" 3 1 roll 5 -1 roll } put 1 add 3 0 \n");
616 fprintf (fp,
" { 2 1 roll } ifelse\n");
617 fprintf (fp,
" }forall\n");
618 fprintf (fp,
" pop pop pop\n");
619 fprintf (fp,
"} def\n");
620 fprintf (fp,
"systemdict /colorimage known not {\n");
621 fprintf (fp,
" /colorimage {\n");
622 fprintf (fp,
" pop\n");
623 fprintf (fp,
" pop\n");
624 fprintf (fp,
" /rgbproc exch def\n");
625 fprintf (fp,
" { bwproc } image\n");
626 fprintf (fp,
" } def\n");
627 fprintf (fp,
"} if\n");
628 fprintf (fp,
"/picstr %d string def\n", width * components);
629 fprintf (fp,
"%d %d scale\n", width, height);
630 fprintf (fp,
"%d %d %d\n", width, height, 8);
631 fprintf (fp,
"[%d 0 0 %d 0 0]\n", width, height);
632 fprintf (fp,
"{currentfile picstr readhexstring pop}\n");
633 fprintf (fp,
"false %d\n", components);
634 fprintf (fp,
"colorimage\n");
636 curpix = (GLubyte*) pixels;
638 for (i = width*height*components; i>0; i--) {
639 fprintf (fp,
"%02hx ", (
unsigned short)(*(curpix++)));
648 fprintf (fp,
"grestore\n");
649 fprintf (fp,
"showpage\n");
662bool G4OpenGLViewer::isGl2psWriting() {
664 if (!fGL2PSAction)
return false;
665 if (fGL2PSAction->fileWritingEnabled()) {
674void G4OpenGLViewer::DrawText(
const G4Text& g4text)
677 if (isGl2psWriting()) {
680 G4double size = fSceneHandler.GetMarkerSize(g4text,sizeType);
684 const char* textCString = textString.c_str();
695 gl2psTextOpt(textCString,
"Times-Roman",GLshort(size),align,0);
699 static G4int callCount = 0;
702 if (callCount <= 1) {
704 "G4OpenGLViewer::DrawText: Not implemented for \""
715void G4OpenGLViewer::ChangePointSize(
G4double size) {
717 if (isGl2psWriting()) {
718 fGL2PSAction->setPointSize(
int(size));
727void G4OpenGLViewer::ChangeLineWidth(
G4double width) {
729 if (isGl2psWriting()) {
730 fGL2PSAction->setLineWidth(
int(width));
737bool G4OpenGLViewer::printGl2PS() {
739 int width = getRealPrintSizeX();
740 int height = getRealPrintSizeY();
742 if (!fGL2PSAction)
return false;
744 fGL2PSAction->setFileName(getRealPrintFilename().c_str());
761 bool extendBuffer =
true;
762 bool endWriteAction =
false;
763 bool beginWriteAction =
true;
764 while ((extendBuffer) && (! endWriteAction)) {
766 beginWriteAction = fGL2PSAction->enableFileWriting();
767 if (beginWriteAction) {
772 fGL2PSAction->setLineWidth(fGl2psDefaultLineWith);
774 fGL2PSAction->setPointSize(fGl2psDefaultPointSize);
777 endWriteAction = fGL2PSAction->disableFileWriting();
779 if ((! endWriteAction) || (! beginWriteAction)) {
780 extendBuffer = fGL2PSAction->extendBufferSize();
783 fGL2PSAction->resetBufferSizeParameters();
785 if (!extendBuffer ) {
786 G4cerr <<
"gl2ps buffer size is not big enough to print this geometry. Thy to extend it. No output produced"<<
G4endl;
788 if (!beginWriteAction ) {
789 G4cerr <<
"Error while writing in the file "<<getRealPrintFilename().c_str()<<
". Check read/write access No output produced" <<
G4endl;
791 if (!endWriteAction ) {
804unsigned int G4OpenGLViewer::getWinWidth() {
808unsigned int G4OpenGLViewer::getWinHeight() {
812G4bool G4OpenGLViewer::sizeHasChanged() {
813 return fSizeHasChanged;
816G4int G4OpenGLViewer::getRealPrintSizeX() {
817 if (fPrintSizeX == -1) {
821 glGetIntegerv(GL_MAX_VIEWPORT_DIMS, dims);
824 if ((dims[0] !=0 ) && (dims[1] !=0)) {
825 if (fPrintSizeX > dims[0]){
829 if (fPrintSizeX < -1){
835G4int G4OpenGLViewer::getRealPrintSizeY() {
836 if (fPrintSizeY == -1) {
840 glGetIntegerv(GL_MAX_VIEWPORT_DIMS, dims);
843 if ((dims[0] !=0 ) && (dims[1] !=0)) {
844 if (fPrintSizeY > dims[1]){
848 if (fPrintSizeY < -1){
854void G4OpenGLViewer::setPrintSize(
G4int X,
G4int Y) {
861 fPrintFilename = name;
863 fPrintFilename =
"G4OpenGL";
866 fPrintFilenameIndex=0;
868 fPrintFilenameIndex=-1;
872std::string G4OpenGLViewer::getRealPrintFilename() {
873 std::string temp = fPrintFilename;
874 if (fPrintFilenameIndex != -1) {
875 temp += std::string(
"_");
876 std::ostringstream os;
877 os << fPrintFilenameIndex;
878 std::string nb_str = os.str();
885GLdouble G4OpenGLViewer::getSceneNearWidth()
887 if (!fSceneHandler.GetScene()) {
891 = fSceneHandler.GetScene()->GetStandardTargetPoint()
892 + fVP.GetCurrentTargetPoint ();
893 G4double radius = fSceneHandler.GetScene()->GetExtent().GetExtentRadius();
894 if(radius<=0.) radius = 1.;
895 const G4double cameraDistance = fVP.GetCameraDistance (radius);
896 const GLdouble pnear = fVP.GetNearDistance (cameraDistance, radius);
897 return 2 * fVP.GetFrontHalfHeight (pnear, radius);
900GLdouble G4OpenGLViewer::getSceneFarWidth()
902 if (!fSceneHandler.GetScene()) {
906 = fSceneHandler.GetScene()->GetStandardTargetPoint()
907 + fVP.GetCurrentTargetPoint ();
908 G4double radius = fSceneHandler.GetScene()->GetExtent().GetExtentRadius();
909 if(radius<=0.) radius = 1.;
910 const G4double cameraDistance = fVP.GetCameraDistance (radius);
911 const GLdouble pnear = fVP.GetNearDistance (cameraDistance, radius);
912 const GLdouble pfar = fVP.GetFarDistance (cameraDistance, pnear, radius);
913 return 2 * fVP.GetFrontHalfHeight (pfar, radius);
917GLdouble G4OpenGLViewer::getSceneDepth()
919 if (!fSceneHandler.GetScene()) {
923 = fSceneHandler.GetScene()->GetStandardTargetPoint()
924 + fVP.GetCurrentTargetPoint ();
925 G4double radius = fSceneHandler.GetScene()->GetExtent().GetExtentRadius();
926 if(radius<=0.) radius = 1.;
927 const G4double cameraDistance = fVP.GetCameraDistance (radius);
928 const GLdouble pnear = fVP.GetNearDistance (cameraDistance, radius);
929 return fVP.GetFarDistance (cameraDistance, pnear, radius)- pnear;
937 rotateSceneInViewDirection(dx,dy);
940 rotateSceneThetaPhi(dx,0);
943 rotateSceneThetaPhi(0,dy);
952 rotateSceneInViewDirection(dx,dy);
955 rotateSceneThetaPhi(dx,0);
958 rotateSceneThetaPhi(0,dy);
965 if (!fSceneHandler.GetScene()) {
993 vp = fVP.GetViewpointDirection ().
unit ();
994 up = fVP.GetUpVector ().
unit ();
996 yprime = (up.
cross(vp)).unit();
997 zprime = (vp.
cross(yprime)).unit();
999 if (fVP.GetLightsMoveWithCamera()) {
1000 delta_alpha = dy * fRot_sens;
1001 delta_theta = -dx * fRot_sens;
1003 delta_alpha = -dy * fRot_sens;
1004 delta_theta = dx * fRot_sens;
1010 new_vp = std::cos(delta_alpha) * vp + std::sin(delta_alpha) * zprime;
1015 if (fVP.GetLightsMoveWithCamera()) {
1016 new_up = (new_vp.
cross(yprime)).unit();
1017 if (new_vp.
z()*vp.
z() <0) {
1018 new_up.
set(new_up.
x(),-new_up.
y(),new_up.
z());
1022 if (new_vp.
z()*vp.
z() <0) {
1023 new_up.
set(new_up.
x(),-new_up.
y(),new_up.
z());
1026 fVP.SetUpVector(new_up);
1030 cosalpha = new_up.
dot (new_vp.
unit());
1031 sinalpha = std::sqrt (1. - std::pow (cosalpha, 2));
1032 yprime = (new_up.
cross (new_vp.
unit())).unit ();
1033 xprime = yprime.
cross (new_up);
1035 a1 = sinalpha * xprime;
1037 a2 = sinalpha * (std::cos (delta_theta) * xprime + std::sin (delta_theta) * yprime);
1041 viewPoint = new_vp.
unit() + delta;
1043 fVP.SetViewAndLights (viewPoint);
1049 if (!fSceneHandler.GetScene()) {
1073#ifdef G4DEBUG_VIS_OGL
1074 printf(
"G4OpenGLViewer::rotateScene dx:%f dy:%f delta:%f\n",dx,dy, fRot_sens);
1077 vp = fVP.GetViewpointDirection ().
unit();
1078 up = fVP.GetUpVector ().
unit();
1081 up.
z()*vp.
x()-up.
x()*vp.
z(),
1082 up.
x()*vp.
y()-up.
y()*vp.
x());
1084 viewPoint = vp/fRot_sens + (zPrimeVector*dx - up*dy) ;
1085 new_up =
G4Vector3D(viewPoint.
y()*zPrimeVector.
z()-viewPoint.
z()*zPrimeVector.
y(),
1086 viewPoint.
z()*zPrimeVector.
x()-viewPoint.
x()*zPrimeVector.
z(),
1087 viewPoint.
x()*zPrimeVector.
y()-viewPoint.
y()*zPrimeVector.
x());
1093 fVP.SetUpVector(new_upUnit);
1094 fVP.SetViewAndLights (viewPoint);
HepGeom::Vector3D< G4double > G4Vector3D
std::vector< G4Plane3D > G4Planes
G4DLLIMPORT std::ostream G4cerr
G4DLLIMPORT std::ostream G4cout
const std::vector< const std::vector< G4AttValue > * > & GetAttValues() const
const std::vector< const std::map< G4String, G4AttDef > * > & GetAttDefs() const
G4Point3D GetPosition() const
BasicVector3D< T > cross(const BasicVector3D< T > &v) const
BasicVector3D< T > unit() const
void set(T x1, T y1, T z1)
T dot(const BasicVector3D< T > &v) const