34 #include "DGtal/io/viewers/windows/GL/glext.h"
37 #include "DGtal/io/viewers/Viewer3D.h"
43 using namespace qglviewer;
88 for (
unsigned int i=0; i<myVoxelSetList.size(); i++ )
90 glCallList ( myListToAff+i );
92 for (
unsigned int i=0; i<myLineSetList.size(); i++ )
94 glCallList ( GLuint ( myListToAff+myVoxelSetList.size() +i ) );
97 for (
unsigned int i=0; i<myPointSetList.size(); i++ )
99 glCallList ( GLuint ( myListToAff+myVoxelSetList.size() +myLineSetList.size() +i ) );
108 glMultMatrixd ( manipulatedFrame()->matrix() );
111 glScalef(myScaleX, myScaleY, myScaleZ);
113 for (
unsigned int i =0; i< myClippingPlaneList.size(); i++ )
121 glEnable ( GL_CLIP_PLANE0+i );
122 glClipPlane ( GL_CLIP_PLANE0+i, eq );
126 Vec centerS = sceneCenter();
127 Vec posCam = camera()->position();
128 double distCam =sqrt ( ( posCam.x-centerS.x ) * ( posCam.x-centerS.x ) +
129 ( posCam.y-centerS.y ) * ( posCam.y-centerS.y ) +
130 ( posCam.z-centerS.z ) * ( posCam.z-centerS.z ) );
133 for (
unsigned int i=0; i<myPointSetList.size(); i++ )
135 if ( myPointSetList.at ( i ).size() !=0 )
137 glPointSize ( ( myPointSetList.at ( i ).at ( 0 ).size ) /distCam );
139 glCallList ( GLuint ( myListToAff+myVoxelSetList.size() +myLineSetList.size() +i+1 ) );
142 for (
unsigned int i=0; i<myLineSetList.size(); i++ )
144 if ( myLineSetList.at ( i ).size() !=0 )
146 glLineWidth ( ( myLineSetList.at ( i ).at ( 0 ).width ) );
148 glCallList ( GLuint ( myListToAff+myVoxelSetList.size() +1+i ) );
151 glCallList ( GLuint ( myListToAff+myVoxelSetList.size() ) );
152 for (
unsigned int i=0; i<myVoxelSetList.size(); i++ )
154 glCallList ( myListToAff+i );
160 unsigned int nbListOfPrimitives = myLineSetList.size() +myVoxelSetList.size() + myPointSetList.size();
161 glLineWidth ( myMeshDefaultLineWidth /distCam );
162 glDisable(GL_CULL_FACE);
163 glCallList ( GLuint ( myListToAff+nbListOfPrimitives+1 ) );
165 glLineWidth ( myMeshDefaultLineWidth /distCam );
166 glCallList ( GLuint ( myListToAff+nbListOfPrimitives+2 ) );
169 glDisable(GL_CULL_FACE);
170 glCallList ( GLuint ( myListToAff+nbListOfPrimitives+3 ) );
173 glLineWidth ( myMeshDefaultLineWidth /distCam );
174 glCallList ( GLuint ( myListToAff+nbListOfPrimitives+4 ) );
178 glDisable(GL_CULL_FACE);
179 glCallList ( GLuint ( myListToAff+nbListOfPrimitives+5 ) );
181 glLineWidth ( myMeshDefaultLineWidth /distCam );
182 glCallList ( GLuint ( myListToAff+nbListOfPrimitives+6 ) );
193 for (
unsigned int i=0; i< myKSPointelList.size(); i++ )
195 glDrawGLPointel ( myKSPointelList.at ( i ) );
197 for (
unsigned int i=0; i< myKSLinelList.size(); i++ )
199 glDrawGLLinel ( myKSLinelList.at ( i ) );
208 for (
unsigned int i=0; i< myKSPointelList.size(); i++ )
210 glDrawGLPointel ( myKSPointelList.at ( i ) );
212 for (
unsigned int i=0; i< myKSLinelList.size(); i++ )
214 glDrawGLLinel ( myKSLinelList.at ( i ) );
223 for (
unsigned int i=0; i< myKSPointelList.size(); i++ )
225 glDrawGLPointel ( myKSPointelList.at ( i ) );
227 for (
unsigned int i=0; i< myKSLinelList.size(); i++ )
229 glDrawGLLinel ( myKSLinelList.at ( i ) );
239 #define _HAS_MSVC_MAX_ true
244 #define _HAS_MSVC_MIN_ true
250 myMeshDefaultLineWidth=10.0;
253 createNewVoxelList (
true );
254 vector<lineD3D> listeLine;
255 myLineSetList.push_back ( listeLine );
256 vector<pointD3D> listePoint;
257 myPointSetList.push_back ( listePoint );
258 myCurrentFillColor =
Color ( 220, 220, 220 );
259 myCurrentLineColor =
Color ( 22, 22, 222, 50 );
260 myDefaultBackgroundColor =
Color ( backgroundColor().red(), backgroundColor().green(),
261 backgroundColor().blue() );
262 myIsBackgroundDefault=
true;
263 myBoundingPtLow[0]=numeric_limits<double>::max( );
264 myBoundingPtLow[1]=numeric_limits<double>::max( );
265 myBoundingPtLow[2]=numeric_limits<double>::max( );
267 myBoundingPtUp[0]=numeric_limits<double>::min( );
268 myBoundingPtUp[1]=numeric_limits<double>::min( );
269 myBoundingPtUp[2]=numeric_limits<double>::min( );
270 createNewVoxelList (
true );
271 std::vector<voxelD3D> aKSVoxelList;
273 myCurrentfShiftVisuKSSurfels=0.0;
274 myDefaultColor=
Color ( 255, 255, 255 );
275 camera()->showEntireScene();
276 setKeyDescription ( Qt::Key_E,
"Export the current display into OFF file (just Voxel, surfel and KSSurfel for now)." );
277 setKeyDescription ( Qt::Key_W,
"Switch display with and without wired view of triangle and quad faces." );
278 setKeyDescription ( Qt::Key_T,
"Sort elements for display improvements." );
279 setKeyDescription ( Qt::Key_L,
"Load last visualisation settings." );
280 setKeyDescription ( Qt::Key_B,
"Switch background color with White/Black colors." );
281 setKeyDescription ( Qt::Key_C,
"Show camera informations." );
282 setKeyDescription ( Qt::Key_R,
"Reset default scale for 3 axes to 1.0f." );
285 setMouseBindingDescription ( Qt::ShiftModifier+Qt::RightButton,
"Delete the mouse selected list." );
286 setManipulatedFrame (
new ManipulatedFrame() );
290 #if defined( _HAS_MSVC_MAX_ )
291 #define max(A,B) ((A)>(B)?(A):(B))
294 #if defined( _HAS_MSVC_MIN_ )
295 #define min(A,B) ((A)<(B)?(A):(B))
302 comp.
posCam= camera()->position();
303 for (
unsigned int i=0; i<myVoxelSetList.size(); i++ )
305 sort ( myVoxelSetList.at ( i ).begin(), myVoxelSetList.at ( i ).end(), comp );
308 DGtal::trace.
info() <<
"sort surfel size" << myKSSurfelList.size() << std::endl;
309 sort ( myKSSurfelList.begin(), myKSSurfelList.end(), compSurf );
318 comp.
posCam= camera()->position();
320 DGtal::trace.
info() <<
"sort triangle size" << myTriangleList.size() << std::endl;
321 sort ( myTriangleList.begin(), myTriangleList.end(), comp );
332 comp.
posCam= camera()->position();
334 DGtal::trace.
info() <<
"sort quad size" << myTriangleList.size() << std::endl;
335 sort ( myQuadList.begin(), myQuadList.end(), comp );
345 comp.
posCam= camera()->position();
347 DGtal::trace.
info() <<
"sort polygon size" << myPolygonList.size() << std::endl;
348 sort ( myPolygonList.begin(), myPolygonList.end(), comp );
359 camera()->convertClickToLine ( point, myOrig, myDir );
361 this->myPosSelector= point;
362 mySelectedPoint = camera()->pointUnderPixel ( point, found );
365 DGtal::trace.
info() <<
"Element of liste= " << selectedName() <<
"selected" << endl;
366 if ( selectedName() !=-1 )
368 unsigned int id =
abs ( selectedName()-1 );
369 if (
id< myVoxelSetList.size() )
372 myVoxelSetList.erase ( myVoxelSetList.begin() +id );
373 updateList (
false );
375 else if (
id< myVoxelSetList.size() +myLineSetList.size() )
377 myLineSetList.erase ( myLineSetList.begin() + (
id-myVoxelSetList.size() ) );
378 updateList (
false );
380 else if (
id< myPointSetList.size() +myLineSetList.size() +myVoxelSetList.size() )
382 myPointSetList.erase ( myPointSetList.begin() + (
id-myVoxelSetList.size()-myLineSetList.size() ) );
383 updateList (
false );
399 unsigned int nbList= (
unsigned int ) ( myVoxelSetList.size() + myLineSetList.size() + myPointSetList.size() +6 );
400 glDeleteLists ( myListToAff, myNbListe );
401 myListToAff = glGenLists ( nbList );
403 unsigned int listeID=0;
404 glEnable ( GL_BLEND );
405 glEnable ( GL_MULTISAMPLE_ARB );
406 glEnable ( GL_SAMPLE_ALPHA_TO_COVERAGE_ARB );
407 glBlendFunc ( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
410 for (
unsigned int i=0; i<myVoxelSetList.size(); i++ )
412 glNewList ( myListToAff+i, GL_COMPILE );
413 if ( myListVoxelDepthTest.at ( i ) )
415 glEnable ( GL_DEPTH_TEST );
419 glDisable ( GL_DEPTH_TEST );
422 glPushName ( myNbListe );
423 glBegin ( GL_QUADS );
424 for ( std::vector<voxelD3D>::iterator s_it = myVoxelSetList.at ( i ).begin();
425 s_it != myVoxelSetList.at ( i ).end();
429 glColor4ub ( ( *s_it ).R, ( *s_it ).G, ( *s_it ).B, ( *s_it ).T );
430 double _width= ( *s_it ).width;
433 glNormal3f ( 0.0, 0.0, 1.0 );
434 glVertex3f ( ( *s_it ).x-_width, ( *s_it ).y+_width, ( *s_it ).z+_width );
435 glVertex3f ( ( *s_it ).x+_width, ( *s_it ).y+_width, ( *s_it ).z+_width );
436 glVertex3f ( ( *s_it ).x+_width, ( *s_it ).y-_width, ( *s_it ).z+_width );
437 glVertex3f ( ( *s_it ).x-_width, ( *s_it ).y-_width, ( *s_it ).z+_width );
439 glNormal3f ( 0.0, 0.0, -1.0 );
440 glVertex3f ( ( *s_it ).x-_width, ( *s_it ).y+_width, ( *s_it ).z-_width );
441 glVertex3f ( ( *s_it ).x+_width, ( *s_it ).y+_width, ( *s_it ).z-_width );
442 glVertex3f ( ( *s_it ).x+_width, ( *s_it ).y-_width, ( *s_it ).z-_width );
443 glVertex3f ( ( *s_it ).x-_width, ( *s_it ).y-_width, ( *s_it ).z-_width );
445 glNormal3f ( 1.0, 0.0, 0.0 );
446 glVertex3f ( ( *s_it ).x+_width, ( *s_it ).y-_width, ( *s_it ).z+_width );
447 glVertex3f ( ( *s_it ).x+_width, ( *s_it ).y+_width, ( *s_it ).z+_width );
448 glVertex3f ( ( *s_it ).x+_width, ( *s_it ).y+_width, ( *s_it ).z-_width );
449 glVertex3f ( ( *s_it ).x+_width, ( *s_it ).y-_width, ( *s_it ).z-_width );
451 glNormal3f ( -1.0, 0.0, 0.0 );
452 glVertex3f ( ( *s_it ).x-_width, ( *s_it ).y-_width, ( *s_it ).z+_width );
453 glVertex3f ( ( *s_it ).x-_width, ( *s_it ).y+_width, ( *s_it ).z+_width );
454 glVertex3f ( ( *s_it ).x-_width, ( *s_it ).y+_width, ( *s_it ).z-_width );
455 glVertex3f ( ( *s_it ).x-_width, ( *s_it ).y-_width, ( *s_it ).z-_width );
457 glNormal3f ( 0.0, 1.0, 0.0 );
458 glVertex3f ( ( *s_it ).x-_width, ( *s_it ).y+_width, ( *s_it ).z+_width );
459 glVertex3f ( ( *s_it ).x+_width, ( *s_it ).y+_width, ( *s_it ).z+_width );
460 glVertex3f ( ( *s_it ).x+_width, ( *s_it ).y+_width, ( *s_it ).z-_width );
461 glVertex3f ( ( *s_it ).x-_width, ( *s_it ).y+_width, ( *s_it ).z-_width );
463 glNormal3f ( 0.0, -1.0, 0.0 );
464 glVertex3f ( ( *s_it ).x-_width, ( *s_it ).y-_width, ( *s_it ).z+_width );
465 glVertex3f ( ( *s_it ).x+_width, ( *s_it ).y-_width, ( *s_it ).z+_width );
466 glVertex3f ( ( *s_it ).x+_width, ( *s_it ).y-_width, ( *s_it ).z-_width );
467 glVertex3f ( ( *s_it ).x-_width, ( *s_it ).y-_width, ( *s_it ).z-_width );
472 glNewList ( GLuint ( myListToAff+myVoxelSetList.size() ), GL_COMPILE );
474 glPushName ( myNbListe );
475 glEnable ( GL_DEPTH_TEST );
476 glEnable ( GL_BLEND );
477 glEnable ( GL_MULTISAMPLE_ARB );
478 glEnable ( GL_SAMPLE_ALPHA_TO_COVERAGE_ARB );
479 glBlendFunc ( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
481 glBegin ( GL_QUADS );
482 glEnable ( GL_DEPTH_TEST );
483 for ( std::vector<quadD3D>::iterator s_it = myKSSurfelList.begin();
484 s_it != myKSSurfelList.end();
487 glColor4ub ( ( *s_it ).R, ( *s_it ).G, ( *s_it ).B, ( *s_it ).T );
488 glNormal3f ( ( *s_it ).nx, ( *s_it ).ny, ( *s_it ).nz );
489 glVertex3f ( ( *s_it ).x1, ( *s_it ).y1 , ( *s_it ).z1 );
490 glVertex3f ( ( *s_it ).x2, ( *s_it ).y2 , ( *s_it ).z2 );
491 glVertex3f ( ( *s_it ).x3, ( *s_it ).y3 , ( *s_it ).z3 );
492 glVertex3f ( ( *s_it ).x4, ( *s_it ).y4 , ( *s_it ).z4 );
499 for (
unsigned int i=0; i<myLineSetList.size(); i++ )
502 glNewList ( GLuint ( myListToAff+myVoxelSetList.size() +i+1 ), GL_COMPILE );
504 glDisable ( GL_LIGHTING );
505 glPushName ( myNbListe );
506 glBegin ( GL_LINES );
507 for ( std::vector<lineD3D>::iterator s_it = myLineSetList.at ( i ).begin();
508 s_it != myLineSetList.at ( i ).end();
511 glColor4ub ( ( *s_it ).R, ( *s_it ).G, ( *s_it ).B, ( *s_it ).T );
512 glVertex3f ( ( *s_it ).x1, ( *s_it ).y1, ( *s_it ).z1 );
513 glVertex3f ( ( *s_it ).x2, ( *s_it ).y2, ( *s_it ).z2 );
517 glEnable ( GL_LIGHTING );
523 for (
unsigned int i=0; i<myPointSetList.size(); i++ )
525 glNewList ( GLuint ( myListToAff+myLineSetList.size() +myVoxelSetList.size() +i+1 ), GL_COMPILE );
527 glDepthMask ( GL_TRUE );
528 glDisable ( GL_TEXTURE_2D );
529 glDisable ( GL_POINT_SMOOTH );
530 glDisable ( GL_LIGHTING );
532 glPushName ( myNbListe );
533 glBegin ( GL_POINTS );
534 for ( std::vector<pointD3D>::iterator s_it = myPointSetList.at ( i ).begin();
535 s_it != myPointSetList.at ( i ).end();
539 glColor4ub ( ( *s_it ).R, ( *s_it ).G, ( *s_it ).B, ( *s_it ).T );
540 glVertex3f ( ( *s_it ).x, ( *s_it ).y, ( *s_it ).z );
543 glEnable ( GL_LIGHTING );
561 unsigned int nbListOfPrimitives = myLineSetList.size() +myVoxelSetList.size() + myPointSetList.size();
564 glNewList ( GLuint ( myListToAff +nbListOfPrimitives + 1 ), GL_COMPILE );
566 glPushName ( myNbListe );
568 glEnable ( GL_LIGHTING );
569 glBegin ( GL_QUADS );
571 for (
unsigned int i=0; i<myQuadList.size(); i++ )
573 glColor4ub ( myQuadList.at ( i ).R, myQuadList.at ( i ).G, myQuadList.at ( i ).B, myQuadList.at ( i ).T );
574 glNormal3f ( -myQuadList.at ( i ).nx, -myQuadList.at ( i ).ny ,-myQuadList.at ( i ).nz );
575 glVertex3f ( myQuadList.at ( i ).x1, myQuadList.at ( i ).y1, myQuadList.at ( i ).z1 );
576 glVertex3f ( myQuadList.at ( i ).x2, myQuadList.at ( i ).y2, myQuadList.at ( i ).z2 );
577 glVertex3f ( myQuadList.at ( i ).x3, myQuadList.at ( i ).y3, myQuadList.at ( i ).z3 );
578 glVertex3f ( myQuadList.at ( i ).x4, myQuadList.at ( i ).y4, myQuadList.at ( i ).z4 );
585 glNewList ( GLuint ( myListToAff +nbListOfPrimitives + 2 ), GL_COMPILE );
587 glPushName ( myNbListe );
588 glDisable ( GL_LIGHTING );
589 glBegin ( GL_LINES );
590 for (
unsigned int i=0; i<myQuadList.size(); i++ )
592 glColor4ub ( 150.0,150.0,150.0,255.0 );
593 glColor4ub ( myCurrentLineColor.red(), myCurrentLineColor.green(), myCurrentLineColor.blue() , myCurrentLineColor.alpha() );
594 glVertex3f ( myQuadList.at ( i ).x1, myQuadList.at ( i ).y1, myQuadList.at ( i ).z1 );
595 glVertex3f ( myQuadList.at ( i ).x2, myQuadList.at ( i ).y2, myQuadList.at ( i ).z2 );
596 glVertex3f ( myQuadList.at ( i ).x2, myQuadList.at ( i ).y2, myQuadList.at ( i ).z2 );
597 glColor4ub ( myCurrentLineColor.red(), myCurrentLineColor.green(), myCurrentLineColor.blue() , myCurrentLineColor.alpha() );
598 glVertex3f ( myQuadList.at ( i ).x3, myQuadList.at ( i ).y3, myQuadList.at ( i ).z3 );
599 glVertex3f ( myQuadList.at ( i ).x3, myQuadList.at ( i ).y3, myQuadList.at ( i ).z3 );
600 glVertex3f ( myQuadList.at ( i ).x4, myQuadList.at ( i ).y4, myQuadList.at ( i ).z4 );
601 glColor4ub ( myCurrentLineColor.red(), myCurrentLineColor.green(), myCurrentLineColor.blue() , myCurrentLineColor.alpha() );
602 glVertex3f ( myQuadList.at ( i ).x4, myQuadList.at ( i ).y4, myQuadList.at ( i ).z4 );
603 glVertex3f ( myQuadList.at ( i ).x1, myQuadList.at ( i ).y1, myQuadList.at ( i ).z1 );
606 glEnable ( GL_LIGHTING );
611 glNewList ( GLuint (myListToAff +nbListOfPrimitives + 3 ), GL_COMPILE );
613 glPushName ( myNbListe );
614 glEnable ( GL_LIGHTING );
615 glBegin ( GL_TRIANGLES );
616 for (
unsigned int i=0; i<myTriangleList.size(); i++ )
618 glColor4ub ( myTriangleList.at ( i ).R, myTriangleList.at ( i ).G, myTriangleList.at ( i ).B, myTriangleList.at ( i ).T );
619 glNormal3f ( -myTriangleList.at ( i ).nx, -myTriangleList.at ( i ).ny ,-myTriangleList.at ( i ).nz );
620 glVertex3f ( myTriangleList.at ( i ).x1, myTriangleList.at ( i ).y1, myTriangleList.at ( i ).z1 );
621 glVertex3f ( myTriangleList.at ( i ).x2, myTriangleList.at ( i ).y2, myTriangleList.at ( i ).z2 );
622 glVertex3f ( myTriangleList.at ( i ).x3, myTriangleList.at ( i ).y3, myTriangleList.at ( i ).z3 );
629 glNewList ( GLuint ( myListToAff + nbListOfPrimitives +4), GL_COMPILE );
631 glPushName ( myNbListe );
633 glDisable ( GL_LIGHTING );
634 glBegin ( GL_LINES );
635 for (
unsigned int i=0; i<myTriangleList.size(); i++ )
637 glColor4ub ( myCurrentLineColor.red(), myCurrentLineColor.green(), myCurrentLineColor.blue() , myCurrentLineColor.alpha() );
638 glVertex3f ( myTriangleList.at ( i ).x1, myTriangleList.at ( i ).y1, myTriangleList.at ( i ).z1 );
639 glVertex3f ( myTriangleList.at ( i ).x2, myTriangleList.at ( i ).y2, myTriangleList.at ( i ).z2 );
640 glVertex3f ( myTriangleList.at ( i ).x2, myTriangleList.at ( i ).y2, myTriangleList.at ( i ).z2 );
641 glVertex3f ( myTriangleList.at ( i ).x3, myTriangleList.at ( i ).y3, myTriangleList.at ( i ).z3 );
642 glVertex3f ( myTriangleList.at ( i ).x3, myTriangleList.at ( i ).y3, myTriangleList.at ( i ).z3 );
643 glVertex3f ( myTriangleList.at ( i ).x1, myTriangleList.at ( i ).y1, myTriangleList.at ( i ).z1 );
647 glEnable ( GL_LIGHTING );
651 glNewList ( GLuint (myListToAff + nbListOfPrimitives +5 ), GL_COMPILE );
653 glPushName ( myNbListe );
654 glEnable ( GL_LIGHTING );
655 for (
unsigned int i=0; i<myPolygonList.size(); i++ )
657 glBegin ( GL_POLYGON );
658 glColor4ub ( myPolygonList.at ( i ).R, myPolygonList.at ( i ).G, myPolygonList.at ( i ).B, myPolygonList.at ( i ).T );
659 glNormal3f ( -myPolygonList.at ( i ).nx, -myPolygonList.at ( i ).ny ,-myPolygonList.at ( i ).nz );
660 vector<pointD3D> vectVertex = myPolygonList.at ( i ).vectPoints;
661 for(
unsigned int j=0;j < vectVertex.size();j++){
662 glVertex3f ( vectVertex.at(j).x, vectVertex.at(j).y, vectVertex.at ( j ).z );
670 glNewList ( GLuint (myListToAff + nbListOfPrimitives +6 ), GL_COMPILE );
672 glPushName ( myNbListe );
673 glDisable ( GL_LIGHTING );
674 glBegin ( GL_LINES );
675 for (
unsigned int i=0; i<myPolygonList.size(); i++ )
677 glColor4ub ( myCurrentLineColor.red(), myCurrentLineColor.green(), myCurrentLineColor.blue() , myCurrentLineColor.alpha() );
678 vector<pointD3D> vectVertex = myPolygonList.at ( i ).vectPoints;
679 for(
unsigned int j=0;j < vectVertex.size();j++){
680 glVertex3f ( vectVertex.at(j).x, vectVertex.at(j).y, vectVertex.at ( j ).z );
681 glVertex3f ( vectVertex.at((j+1)%vectVertex.size()).x, vectVertex.at((j+1)%vectVertex.size()).y, vectVertex.at ( (j+1)%vectVertex.size() ).z );
688 if ( needToUpdateBoundingBox )
690 setSceneBoundingBox ( qglviewer::Vec ( myBoundingPtLow[0],myBoundingPtLow[1],myBoundingPtLow[2] ),
691 qglviewer::Vec ( myBoundingPtUp[0], myBoundingPtUp[1], myBoundingPtUp[2] ) );
706 glTranslatef ( aLinel.
x1, aLinel.
y1, aLinel.
z1 );
707 Vec dir ( aLinel.
x2-aLinel.
x1, aLinel.
y2-aLinel.
y1, aLinel.
z2-aLinel.
z1 );
708 glMultMatrixd ( Quaternion ( Vec ( 0,0,1 ), dir ).matrix() );
709 GLUquadric* quadric = gluNewQuadric();
710 glColor4ub ( aLinel.
R, aLinel.
G, aLinel.
B, aLinel.
T );
729 glTranslatef ( pointel.
x, pointel.
y, pointel.
z );
730 GLUquadric* quadric = gluNewQuadric();
731 glColor4ub ( pointel.
R, pointel.
G, pointel.
B, pointel.
T );
732 gluSphere ( quadric, pointel.
size, 10, 10 );
741 glTranslatef ( pointel.
x-0.07, pointel.
y-0.07, pointel.
z );
742 Vec dir ( 0.14, 0.14, 0 );
743 glMultMatrixd ( Quaternion ( Vec ( 0,0,1 ), dir ).matrix() );
744 GLUquadric* quadric = gluNewQuadric();
745 glColor4ub ( pointel.
R, pointel.
G, pointel.
B, pointel.
T );
746 gluCylinder ( quadric, pointel.
size/3.0 , pointel.
size/3.0,
750 glTranslatef ( pointel.
x-0.07, pointel.
y+0.07, pointel.
z );
751 dir=Vec ( 0.14, -0.14, 0 );
752 glMultMatrixd ( Quaternion ( Vec ( 0,0,1 ), dir ).matrix() );
753 quadric = gluNewQuadric();
754 glColor4ub ( pointel.
R, pointel.
G, pointel.
B, pointel.
T );
755 gluCylinder ( quadric, pointel.
size/3.0 , pointel.
size/3.0,
762 glTranslatef ( pointel.
x, pointel.
y+0.07, pointel.
z-0.07 );
763 Vec dir ( 0.0, -0.14, 0.14 );
764 glMultMatrixd ( Quaternion ( Vec ( 0,0,1 ), dir ).matrix() );
765 GLUquadric* quadric = gluNewQuadric();
766 glColor4ub ( pointel.
R, pointel.
G, pointel.
B, pointel.
T );
767 gluCylinder ( quadric, pointel.
size/4.0 , pointel.
size/4.0,
781 bool handled =
false;
783 if( e->key() == Qt::Key_E){
785 (*this) >>
"exportedMesh.off";
790 if ( ( e->key() ==Qt::Key_W ) )
792 myViewWire=!myViewWire;
797 if ( ( e->key() ==Qt::Key_R ) )
806 if ( ( e->key() ==Qt::Key_T ) )
810 sortSurfelFromCamera();
811 sortTriangleFromCamera();
812 sortQuadFromCamera();
813 sortPolygonFromCamera();
818 if ( ( e->key() ==Qt::Key_B ) )
821 myIsBackgroundDefault=!myIsBackgroundDefault;
822 if ( !myIsBackgroundDefault )
824 setBackgroundColor ( QColor ( 255, 255,255 ) );
828 setBackgroundColor ( QColor ( 51, 51, 51 ) );
832 if ( ( e->key() ==Qt::Key_L ) )
834 restoreStateFromFile();
837 if ( ( e->key() ==Qt::Key_C ) )
841 GLdouble Projection[16], Modelview[16];
846 glGetIntegerv ( GL_VIEWPORT , Viewport );
847 glGetDoublev ( GL_MODELVIEW_MATRIX , Modelview );
848 glGetDoublev ( GL_PROJECTION_MATRIX, Projection );
850 for (
unsigned short m=0; m<4; ++m )
852 for (
unsigned short l=0; l<4; ++l )
855 for (
unsigned short k=0; k<4; ++k )
856 sum += Projection[l+4*k]*Modelview[k+4*m];
864 for (
unsigned short l=0; l<4; ++l )
868 Vec cp = camera()->position();
869 Vec cd = camera()->viewDirection();
870 Vec cup = camera()->upVector();
873 for (
unsigned short l=0; l<3; ++l )
878 for (
unsigned short l=0; l<3; ++l )
883 for (
unsigned short l=0; l<3; ++l )
887 DGtal::trace.
info() <<
"zNear: " << camera()->zNear() <<
" - zFar: " << camera()->zFar() << std::endl;
894 QGLViewer::keyPressEvent ( e );
907 QString text (
"<h2> Viewer3D</h2>" );
908 text +=
"Use the mouse to move the camera around the object. ";
909 text +=
"You can respectively revolve around, zoom and translate with the three mouse buttons. ";
910 text +=
"Left and middle buttons pressed together rotate around the camera view direction axis<br><br>";
911 text +=
"Pressing <b>Alt</b> and one of the function keys (<b>F1</b>..<b>F12</b>) defines a camera keyFrame. ";
912 text +=
"Simply press the function key again to restore it. Several keyFrames define a ";
913 text +=
"camera path. Paths are saved when you quit the application and restored at next start.<br><br>";
914 text +=
"Press <b>F</b> to display the frame rate, <b>A</b> for the world axis, ";
915 text +=
"<b>Alt+Return</b> for full screen mode and <b>Control+S</b> to save a snapshot. ";
916 text +=
"See the <b>Keyboard</b> tab in this window for a complete shortcut list.<br><br>";
917 text +=
"Double clicks automates single click actions: A left button double click aligns the closer axis with the camera (if close enough). ";
918 text +=
"A middle button double click fits the zoom of the camera and the right button re-centers the scene.<br><br>";
919 text +=
"A left button double click while holding right button pressed defines the camera <i>Revolve Around Point</i>. ";
920 text +=
"See the <b>Mouse</b> tab and the documentation web pages for details.<br><br>";
921 text +=
"Press <b>Escape</b> to exit the viewer.";