DGtal  1.0.0
Viewer3D.h
1 
17 #pragma once
18 
31 #if defined(Viewer3D_RECURSES)
32 #error Recursive header files inclusion detected in Viewer3D.h
33 #else // defined(Viewer3D_RECURSES)
34 
35 #define Viewer3D_RECURSES
36 
37 #if !defined Viewer3D_h
38 
39 #define Viewer3D_h
40 
42 // Inclusions
43 #include "DGtal/base/Common.h"
44 
45 #include <iostream>
46 #include <vector>
47 #include <algorithm>
48 #ifdef WIN32
49 #include <windows.h>
50 #endif
51 #ifdef APPLE
52 #include <OpenGL/gl.h>
53 #include <OpenGL/glu.h>
54 #else
55 #include <GL/gl.h>
56 #include <GL/glu.h>
57 #endif
58 
59 #ifdef WITH_QT5
60  #include <QApplication>
61 #else
62  #include <QtGui/qapplication.h>
63 #endif
64 
65 #include <QGLViewer/qglviewer.h>
66 #include <QGLWidget>
67 #include <QKeyEvent>
68 
69 #include "DGtal/kernel/SpaceND.h"
70 #include "DGtal/topology/KhalimskySpaceND.h"
71 #include "DGtal/base/CountedPtr.h"
72 #include "DGtal/io/Display3D.h"
73 #include "DGtal/math/BasicMathFunctions.h"
74 
75 #include "DGtal/kernel/CSpace.h"
76 
78 
79 namespace DGtal
80 {
81 
83  // class Viewer3D
130  template <typename TSpace = SpaceND<3>,
131  typename TKSpace = KhalimskySpaceND<3>>
132  class Viewer3D : public QGLViewer, public Display3D<TSpace, TKSpace>
133  {
134 
136 
137  //---------------overwritting some functions of Display3D -------------------
138 
139  // ----------------------- public types ------------------------------
140  public:
141  typedef TSpace Space;
142  typedef TKSpace KSpace;
146  typedef typename Display::RealPoint RealPoint;
148 
150  {
155  };
156 
163  struct Extension
164  {
167 
168  virtual ~Extension() = default;
169 
178  virtual bool keyPressEvent( Viewer & viewer, QKeyEvent * event )
179  {
180  boost::ignore_unused_variable_warning( viewer );
181  boost::ignore_unused_variable_warning( event );
182  return false;
183  }
184 
190  virtual void drawWithNames( Viewer & viewer )
191  {
192  boost::ignore_unused_variable_warning( viewer );
193  }
194 
200  virtual void draw( Viewer & viewer )
201  {
202  boost::ignore_unused_variable_warning( viewer );
203  }
204 
209  virtual void init( Viewer & viewer )
210  {
211  boost::ignore_unused_variable_warning( viewer );
212  }
213 
220  virtual QString helpString( const Viewer & viewer ) const
221  {
222  boost::ignore_unused_variable_warning( viewer );
223  return "";
224  }
225 
235  virtual bool postSelection( const Viewer & viewer, const QPoint & point )
236  {
237  boost::ignore_unused_variable_warning( viewer );
238  boost::ignore_unused_variable_warning( point );
239  return false;
240  }
241 
250  virtual bool mouseMoveEvent( const Viewer & viewer, QMouseEvent * event )
251  {
252  boost::ignore_unused_variable_warning( viewer );
253  boost::ignore_unused_variable_warning( event );
254  return false;
255  }
256 
265  virtual bool mousePressEvent( const Viewer & viewer, QMouseEvent * event )
266  {
267  boost::ignore_unused_variable_warning( viewer );
268  boost::ignore_unused_variable_warning( event );
269  return false;
270  }
271 
281  virtual bool mouseReleaseEvent( const Viewer & viewer, QMouseEvent * event )
282  {
283  boost::ignore_unused_variable_warning( viewer );
284  boost::ignore_unused_variable_warning( event );
285  return false;
286  }
287  };
288 
289  // ----------------------- Standard services ------------------------------
290  public:
291 
295  Viewer3D() : QGLViewer(), Display3D<Space, KSpace>(), myExtension( 0 )
296  {
297  resize( 800, 600 );
298  };
299 
304  Viewer3D( const KSpace & KSEmb )
305  : QGLViewer(), Display3D<Space, KSpace>( KSEmb ), myExtension( 0 )
306  {
307  resize(800,600);
308  }
309 
313  void setExtension( Extension * ext )
314  {
315  if ( myExtension != 0 )
316  delete myExtension;
317  myExtension = ext;
318  }
319 
323  {
324  if ( myExtension != 0 )
325  delete myExtension;
326  myExtension = 0;
327  }
328 
335  void setCameraPosition(double ax, double ay, double az)
336  {
337  camera_position[0] = ax; camera_position[1] = ay; camera_position[2] = az;
338  }
339 
346  void setCameraDirection(double ax, double ay, double az)
347  {
348  camera_direction[0] = ax; camera_direction[1] = ay; camera_direction[2] = az;
349  }
350 
357  void setCameraUpVector(double ax, double ay, double az)
358  {
359  camera_upVector[0] = ax; camera_upVector[1] = ay; camera_upVector[2] = az;
360  }
361 
367  void setNearFar(double _near, double _far)
368  {
369  ZNear = _near; ZFar = _far;
370  }
371 
381  void setGLScale(float sx, float sy, float sz)
382  {
383  myGLScaleFactorX=sx;
384  myGLScaleFactorY=sy;
385  myGLScaleFactorZ=sz;
386  // In order to have the light source rendering the same as wtih the default scale 1.
387  glEnable(GL_NORMALIZE);
388  }
389 
390 
402  void setGLDoubleRenderingMode(bool doubleSidedRendering);
403 
404 
412  void setGLMaterialShininessCoefficient(const GLfloat matShininessCoeff);
413 
414 
423  void setGLLightAmbientCoefficients(const GLfloat lightAmbientCoeffs [4]);
424 
433  void setGLLightDiffuseCoefficients(const GLfloat lightDiffuseCoeffs [4]);
434 
435 
443  void setGLLightSpecularCoefficients(const GLfloat lightSpecularCoeffs [4]);
444 
445 
446 
457  void setUseGLPointForBalls(bool useOpenGLPt);
458 
459 
467  void updateRenderingCoefficients(const RenderingMode aRenderMode, bool displayState=true);
468 
469 
474 
483  double myGLPointMinWidth = 1.5;
484  double myGLLineMinWidth = 1.5;
485  bool myAutoSaveState;
487  // define the default rendering mode of the viewer
489 
495  {
496 
505  unsigned int myDomainWidth;
507  unsigned int myDomainHeight;
511  std::string myMode;
513  std::size_t myLineSetIndex;
514 
524  template<typename TDomain>
525  Image2DDomainD3D( TDomain aDomain, ImageDirection normalDir=zDirection,
526  double xBottomLeft=0.0, double yBottomLeft=0.0, double zBottomLeft=0.0, std::string mode= "BoundingBox")
527  {
529  myMode = mode;
530  myDirection=normalDir;
531  myDomainWidth = (aDomain.upperBound())[0]-(aDomain.lowerBound())[0]+1;
532  myDomainHeight = (aDomain.upperBound())[1]-(aDomain.lowerBound())[1]+1;
533  updateDomainOrientation(normalDir, xBottomLeft, yBottomLeft, zBottomLeft);
534  }
535 
536 
546  void updateDomainOrientation( ImageDirection normalDir,
547  double xBottomLeft, double yBottomLeft, double zBottomLeft);
548 
549 
556  void translateDomain(double xTranslation=0.0,
557  double yTranslation=0.0, double zTranslation=0.0);
558 
559  };
560 
561 
567  {
568 
573 
575 
576  unsigned int myImageWidth;
577  unsigned int myImageHeight;
578  //TODO complete desc attribute
579  unsigned int * myTabImage;
580 
582  unsigned int myIndexDomain;
584 
589  {
590  delete [] myTabImage;
591  };
592 
598  point3(img.point3), point4(img.point4),
601  myTabImage(img.myTabImage),
604  myMode(img.myMode)
605  {
606 
607  if(img.myImageHeight>0 && img.myImageWidth>0)
608  {
609  myTabImage = new unsigned int [img.myImageWidth*img.myImageHeight];
610  for(unsigned int i=0; i<img.myImageWidth*img.myImageHeight; i++)
611  {
612  myTabImage[i] = img.myTabImage[i];
613  }
614  }else
615  {
616  myTabImage=img.myTabImage;
617  }
618  };
619 
620 
621 
641  template <typename TImageType, typename TFunctor>
642 
643  TextureImage( const TImageType & image, const TFunctor &aFunctor,
644  ImageDirection normalDir=zDirection,
645  double xBottomLeft=0.0, double yBottomLeft=0.0, double zBottomLeft=0.0,
646  TextureMode aMode= GrayScaleMode)
647  {
650  myDrawDomain=false;
651  myDirection=normalDir;
652  myImageWidth = (image.domain().upperBound())[0]-(image.domain().lowerBound())[0]+1;
653  myImageHeight = (image.domain().upperBound())[1]-(image.domain().lowerBound())[1]+1;
654  myTabImage = new unsigned int [myImageWidth*myImageHeight];
655  updateImageOrientation(normalDir, xBottomLeft, yBottomLeft, zBottomLeft);
656  myMode=aMode;
657  updateImageDataAndParam(image, aFunctor);
658  }
659 
669  void updateImageOrientation( ImageDirection normalDir,
670  double xBottomLeft, double yBottomLeft, double zBottomLeft);
671 
672 
680  void
682  RealPoint aPoint2,
683  RealPoint aPoint3,
684  RealPoint aPoint4)
685  {
686  point1 = aPoint1; point2 = aPoint2; point3 = aPoint3; point4 = aPoint4;
688  }
689 
690 
706  template <typename TImageType, typename TFunctor>
707  void updateImageDataAndParam(const TImageType & image, const TFunctor &aFunctor, double xTranslation=0.0,
708  double yTranslation=0.0, double zTranslation=0.0)
709  {
712  assert ( (image.domain().upperBound())[0]-(image.domain().lowerBound())[0]+1== static_cast<int>(myImageWidth) &&
713  (image.domain().upperBound())[1]-(image.domain().lowerBound())[1]+1== static_cast<int>(myImageHeight));
714 
715  point1[0] += xTranslation; point1[1] += yTranslation; point1[2] += zTranslation;
716  point2[0] += xTranslation; point2[1] +=yTranslation; point2[2] += zTranslation;
717  point3[0] += xTranslation; point3[1] += yTranslation; point3[2] += zTranslation;
718  point4[0] += xTranslation; point4[1] += yTranslation; point4[2] += zTranslation;
719 
720  unsigned int pos=0;
721  for(typename TImageType::Domain::ConstIterator it = image.domain().begin(), itend=image.domain().end();
722  it!=itend; ++it)
723  {
724  myTabImage[pos]= aFunctor(image(*it));
725  pos++;
726  }
727  }
728 
732  std::string className() const;
733 
734  private:
740  {};
741  };
742 
749 
750 
757 
758 
762  void sortSurfelFromCamera();
763 
767  void sortTriangleFromCamera();
768 
772  void sortQuadFromCamera();
773 
777  void sortPolygonFromCamera();
778 
779 
780 
781  template <typename TDrawableWithViewer3D>
790  Viewer3D<Space, KSpace> & operator<< ( const TDrawableWithViewer3D & object );
791 
792 
793 
794  // ----------------------- Interface --------------------------------------
795  public:
796 
801  void selfDisplay ( std::ostream & out ) const;
802 
807  bool isValid() const;
808 
809 
810 
811  virtual unsigned int getCurrentDomainNumber();
812 
813  virtual unsigned int getCurrentGLImageNumber();
814 
815 
821  virtual void paintGL();
822 
823 
830  virtual void show();
831 
832 
838  void addTextureImage(const TextureImage &image);
839 
840 
853  template <typename TImageType, typename TFunctor>
854 
855  void updateTextureImage(unsigned int imageIndex, const TImageType & image, const TFunctor & aFunctor,
856  double xTranslation=0.0, double yTranslation=0.0, double zTranslation=0.0,
857  double rotationAngle=0.0, ImageDirection rotationDir=zDirection);
858 
859 
860 
861 
871  void updateOrientationTextureImage(unsigned int imageIndex,
872  double xPosition, double yPosition,
873  double zPosition, ImageDirection newDirection);
874 
875 
876 
885  void updateEmbeddingTextureImage(unsigned int anImageIndex,
886  typename Space::Point aPoint1, typename Space::Point aPoint2,
887  typename Space::Point aPoint3, typename Space::Point aPoint4);
888 
889 
890 
897  template<typename TDomain>
898  void addImage2DDomainD3D(const TDomain &anImageDomain, std::string mode,
899  const DGtal::Color &aColor=DGtal::Color::Red );
900 
901 
910  void updateAn2DDomainOrientation(unsigned int imageIndex,
911  double xPosition, double yPosition,
912  double zPosition, ImageDirection newDirection);
913 
921  void translateAn2DDomain(unsigned int domainIndex, double xTranslation,
922  double yTranslation, double zTranslation);
923 
930  std::vector<typename DGtal::Viewer3D< Space , KSpace >::LineD3D>
931  compute2DDomainLineRepresentation( Image2DDomainD3D &anImageDomain, double delta );
932 
938  std::vector<typename DGtal::Viewer3D< Space , KSpace >::LineD3D>
939  compute2DDomainLineRepresentation( Image2DDomainD3D &anImageDomain);
940 
941 
950  template < typename TContainer >
952  double angleRotation, ImageDirection dirRotation);
953 
954 
955 
964  void rotateDomain(Image2DDomainD3D &anDom, double angle, ImageDirection rotationDir);
965 
966 
967 
968 
969 
970 
971  // ------------------------- Protected Datas ------------------------------
972  private:
973 
974 
975 
976  public:
978  void drawSomeLight( GLenum light ) const
979  {
980  QGLViewer::drawLight( light );
981  }
983  void drawSomeLight( GLenum light, float zoom ) const
984  {
985  QGLViewer::drawLight( light, zoom );
986  }
987 
988  // ------------------------- Hidden services ------------------------------
989  // protected:
990 
997  void updateList( bool needToUpdateBoundingBox = true );
998 
1003  void glDrawGLBall( const typename Viewer3D<Space, KSpace>::BallD3D & aBall );
1004 
1022  virtual void keyPressEvent( QKeyEvent * e );
1023 
1029  virtual void mouseMoveEvent( QMouseEvent * e );
1030 
1036  virtual void mousePressEvent( QMouseEvent * e );
1037 
1043  virtual void mouseReleaseEvent( QMouseEvent * e );
1044 
1049  {
1050  qglviewer::Vec posCam;
1052  typename Viewer3D<Space, KSpace>::CubeD3D s2 )
1053  {
1054  double dist1 =
1055  sqrt( ( posCam.x - s1.center[ 0 ] ) * ( posCam.x - s1.center[ 0 ] ) +
1056  ( posCam.y - s1.center[ 1 ] ) * ( posCam.y - s1.center[ 1 ] ) +
1057  ( posCam.z - s1.center[ 2 ] ) * ( posCam.z - s1.center[ 2 ] ) );
1058  double dist2 =
1059  sqrt( ( posCam.x - s2.center[ 0 ] ) * ( posCam.x - s2.center[ 0 ] ) +
1060  ( posCam.y - s2.center[ 1 ] ) * ( posCam.y - s2.center[ 1 ] ) +
1061  ( posCam.z - s2.center[ 2 ] ) * ( posCam.z - s2.center[ 2 ] ) );
1062  return dist1 > dist2;
1063  }
1064  };
1065 
1066 
1071  {
1072  qglviewer::Vec posCam;
1075  {
1076  qglviewer::Vec center1 ( ( t1.point1[0]+t1.point2[0]+t1.point3[0] ) /3.0, ( t1.point1[1]+t1.point2[1]+t1.point3[1] ) /3.0, ( t1.point1[2]+t1.point2[2]+t1.point3[2] ) /3.0 );
1077  qglviewer::Vec center2 ( ( t2.point1[0]+t2.point2[0]+t2.point3[0] ) /3.0, ( t2.point1[1]+t2.point2[1]+t2.point3[1] ) /3.0, ( t2.point1[2]+t2.point2[2]+t2.point3[2] ) /3.0 );
1078  double dist1= sqrt ( ( posCam.x-center1.x ) * ( posCam.x-center1.x ) + ( posCam.y-center1.y ) * ( posCam.y-center1.y ) + ( posCam.z-center1.z ) * ( posCam.z-center1.z ) );
1079  double dist2= sqrt ( ( posCam.x-center2.x ) * ( posCam.x-center2.x ) + ( posCam.y-center2.y ) * ( posCam.y-center2.y ) + ( posCam.z-center2.z ) * ( posCam.z-center2.z ) );
1080 
1081  return dist1>dist2;
1082  }
1083  };
1084 
1089  {
1090  qglviewer::Vec posCam;
1092  typename Viewer3D<Space,KSpace>::QuadD3D q2 )
1093  {
1094 
1095  qglviewer::Vec center1 ( ( q1.point1[0]+q1.point2[0]+q1.point3[0]+q1.point4[0] ) /4.0, ( q1.point1[1]+q1.point2[1]+q1.point3[1]+q1.point4[1] ) /4.0, ( q1.point1[2]+q1.point2[2]+q1.point3[2]+q1.point4[2] ) /4.0 );
1096  qglviewer::Vec center2 ( ( q2.point1[0]+q2.point2[0]+q2.point3[0]+q2.point4[0] ) /4.0, ( q2.point1[1]+q2.point2[1]+q2.point3[1]+q2.point4[1] ) /4.0, ( q2.point1[2]+q2.point2[2]+q2.point3[2]+q2.point4[2] ) /4.0 );
1097 
1098  double dist1= sqrt ( ( posCam.x-center1.x ) * ( posCam.x-center1.x ) + ( posCam.y-center1.y ) * ( posCam.y-center1.y ) + ( posCam.z-center1.z ) * ( posCam.z-center1.z ) );
1099  double dist2= sqrt ( ( posCam.x-center2.x ) * ( posCam.x-center2.x ) + ( posCam.y-center2.y ) * ( posCam.y-center2.y ) + ( posCam.z-center2.z ) * ( posCam.z-center2.z ) );
1100  return dist1>dist2;
1101  }
1102  };
1103 
1108  {
1109  qglviewer::Vec posCam;
1112  {
1113  double c1x=0.0, c1y=0.0, c1z=0.0;
1114  double c2x=0.0, c2y=0.0, c2z=0.0;
1115  for(unsigned int i=0; i< q1.vertices.size(); i++){
1116  c1x+=q1.vertices.at(i)[0];
1117  c1y+=q1.vertices.at(i)[1];
1118  c1z+=q1.vertices.at(i)[2];
1119  }
1120  for(unsigned int i=0; i< q2.vertices.size(); i++){
1121  c2x+=q2.vertices.at(i)[0];
1122  c2y+=q2.vertices.at(i)[1];
1123  c2z+=q2.vertices.at(i)[2];
1124  }
1125 
1126  qglviewer::Vec center1 ( c1x/(double)q1.vertices.size(),c1y/(double)q1.vertices.size(), c1z/(double)q1.vertices.size() );
1127  qglviewer::Vec center2 ( c2x/(double)q2.vertices.size(),c2y/(double)q2.vertices.size(), c2z/(double)q2.vertices.size() );
1128 
1129  double dist1= sqrt ( ( posCam.x-center1.x ) * ( posCam.x-center1.x ) + ( posCam.y-center1.y ) * ( posCam.y-center1.y ) + ( posCam.z-center1.z ) * ( posCam.z-center1.z ) );
1130  double dist2= sqrt ( ( posCam.x-center2.x ) * ( posCam.x-center2.x ) + ( posCam.y-center2.y ) * ( posCam.y-center2.y ) + ( posCam.z-center2.z ) * ( posCam.z-center2.z ) );
1131  return dist1>dist2;
1132  }
1133  };
1134 
1135 
1136 
1140  virtual void drawWithNames();
1141 
1145  virtual void draw();
1146 
1150  virtual void init();
1151 
1155  virtual QString helpString() const;
1156 
1161  virtual void postSelection ( const QPoint& point );
1162 
1163 
1164 
1174  virtual QDomElement domElement(const QString& name, QDomDocument& document) const;
1175 
1176 
1187  virtual void initFromDOMElement(const QDomElement& element);
1188 
1189 
1197  protected: virtual void closeEvent ( QCloseEvent * e );
1198 
1199 
1200 
1201  // ------------------------- Internals ------------------------------------
1202  private:
1203 
1204 
1210  {
1216 
1218  unsigned int myImageWidth;
1219  unsigned int myImageHeight;
1220 
1221  unsigned int myBufferWidth;
1222  unsigned int myBufferHeight;
1225  unsigned char * myTextureImageBufferGS;
1226  unsigned char * myTextureImageBufferRGB;
1227  double vectNormal[3];
1228 
1229 
1230  // By definition in OpenGL the image size of texture should power of 2
1233 
1234 
1235  // Destructor
1237  {
1238  if(myMode== 1)
1239  {
1240  if(myTextureImageBufferGS!=0)
1241  delete [] myTextureImageBufferGS;
1242  }
1244  {
1246  delete [] myTextureImageBufferRGB;
1247  }
1248 
1249  }
1250 
1251  //Copy constructor from a GLTextureImage
1254  myTextureName(aGLImg.myTextureName),
1255  myMode(aGLImg.myMode),
1256  myTextureFitX(aGLImg.myTextureFitX),
1258 
1259  {
1260  point1[0]=aGLImg.point1[0]; point1[1]=aGLImg.point1[1]; point1[2]=aGLImg.point1[2];
1261  point2[0]=aGLImg.point2[0]; point2[1]=aGLImg.point2[1]; point2[2]=aGLImg.point2[2];
1262  point3[0]=aGLImg.point3[0]; point3[1]=aGLImg.point3[1]; point3[2]=aGLImg.point3[2];
1263  point4[0]=aGLImg.point4[0]; point4[1]=aGLImg.point4[1]; point4[2]=aGLImg.point4[2];
1265  myDirection = aGLImg.myDirection;
1266  vectNormal[0]=aGLImg.vectNormal[0];
1267  vectNormal[1]=aGLImg.vectNormal[1];
1268  vectNormal[2]=aGLImg.vectNormal[2];
1269 
1270  if(myMode== 1)
1271  {
1272  myTextureImageBufferGS = new unsigned char [myBufferHeight*myBufferWidth];
1273  for(unsigned int i=0; i<myBufferHeight*myBufferWidth;i++)
1274  {
1276  }
1278  {
1279  myTextureImageBufferRGB = new unsigned char [3*myBufferHeight*myBufferWidth];
1280  for(unsigned int i=0; i<3*myBufferHeight*myBufferWidth;i+=3)
1281  {
1285  }
1286  }
1287  }
1288 
1289 
1290  //Copy constructor from a TextureImage
1292  {
1293  point1[0]=aGSImage.point1[0]; point1[1]=aGSImage.point1[1]; point1[2]=aGSImage.point1[2];
1294  point2[0]=aGSImage.point2[0]; point2[1]=aGSImage.point2[1]; point2[2]=aGSImage.point2[2];
1295  point3[0]=aGSImage.point3[0]; point3[1]=aGSImage.point3[1]; point3[2]=aGSImage.point3[2];
1296  point4[0]=aGSImage.point4[0]; point4[1]=aGSImage.point4[1]; point4[2]=aGSImage.point4[2];
1297  myImageWidth=aGSImage.myImageWidth; myImageHeight=aGSImage.myImageHeight;
1298  myDirection = aGSImage.myDirection;
1299  myMode= aGSImage.myMode;
1304  RealPoint v1 = point2-point1;
1305  RealPoint v2 = point4-point1;
1306  vectNormal[0] = v1[1]*v2[2] - v1[2]*v2[1];
1307  vectNormal[1] = v1[2]*v2[0] - v1[0]*v2[2];
1308  vectNormal[2] = v1[0]*v2[1] - v1[1]*v2[0];
1309  double norm = sqrt(vectNormal[0]*vectNormal[0]+vectNormal[1]*vectNormal[1]+vectNormal[2]*vectNormal[2]);
1310  vectNormal[0] /=norm; vectNormal[1] /=norm; vectNormal[2] /=norm;
1311  }
1312 
1315 
1316  if(myMode== 1)
1317  {
1318  myTextureImageBufferGS = new unsigned char [myBufferHeight*myBufferWidth];
1319  unsigned int pos=0;
1320  for (unsigned int i=0; i<myBufferHeight; i++)
1321  {
1322  for (unsigned int j=0; j<myBufferWidth; j++)
1323  {
1324  if(i<myImageHeight && j< myImageWidth)
1325  {
1326  myTextureImageBufferGS[pos]= aGSImage.myTabImage[i*myImageWidth+j];
1327  }else{
1328  myTextureImageBufferGS[pos]=0;
1329  }
1330  pos++;
1331  }
1332  }
1334  {
1335  myTextureImageBufferRGB = new unsigned char [3*myBufferHeight*myBufferWidth];
1336  unsigned int pos=0;
1337  for (unsigned int i=0; i<myBufferHeight; i++)
1338  {
1339  for (unsigned int j=0; j<myBufferWidth; j++)
1340  {
1341  if(i<myImageHeight && j< myImageWidth)
1342  {
1343  DGtal::Color aCol(aGSImage.myTabImage[i*myImageWidth+j]);
1344  myTextureImageBufferRGB[pos]= aCol.red();
1345  myTextureImageBufferRGB[pos+1]= aCol.green();
1346  myTextureImageBufferRGB[pos+2]= aCol.blue();
1347  }else{
1348  myTextureImageBufferRGB[pos]=0;
1349  myTextureImageBufferRGB[pos+1]=0;
1350  myTextureImageBufferRGB[pos+2]=0;
1351  }
1352  pos+=3;
1353  }
1354  }
1355  }
1356 
1359  }
1360  };
1361 
1362 
1363 
1369  typedef typename std::vector<typename Viewer3D<Space, KSpace>::CubeD3D> VectorCubes;
1370  typedef typename std::vector<typename Viewer3D<Space, KSpace>::QuadD3D> VectorQuad;
1371  typedef typename std::vector<typename Viewer3D<Space, KSpace>::LineD3D> VectorLine;
1372  typedef typename std::vector<typename Viewer3D<Space, KSpace>::BallD3D> VectorBall;
1373  typedef typename std::vector<typename Viewer3D<Space, KSpace>::TriangleD3D> VectorTriangle;
1374  typedef typename std::vector<typename Viewer3D<Space, KSpace>::PolygonD3D> VectorPolygon;
1375  typedef typename std::vector<typename Viewer3D<Space, KSpace>::TextureImage> VectorTextureImage;
1376 
1377 
1378  typedef typename VectorCubes::iterator ItCube;
1379 
1380 
1390  void glCreateListCubesMaps(const typename Display3D<Space, KSpace>::CubesMap &aCubeMap, unsigned int idList);
1391 
1392 
1393 
1399  void glCreateListQuadD3D(const VectorQuad &aVectQuad, unsigned int idList);
1400 
1401 
1407  void glCreateListLines(const VectorLine &aVectLine, unsigned int idList);
1408 
1409 
1415  void glCreateListBalls(const VectorBall &aVectBall, unsigned int idList);
1416 
1417 
1427  void glCreateListQuadMaps(const typename Display3D<Space, KSpace>::QuadsMap &aQuadMap, unsigned int idList);
1428 
1429 
1439  void glCreateListQuadMapsWired(const typename Display3D<Space, KSpace>::QuadsMap &aQuadMap, unsigned int idList);
1440 
1441 
1450  void glCreateListTriangles(const std::vector<VectorTriangle> &aVectTriangle, unsigned int idList);
1451 
1452 
1461  void glCreateListTrianglesWired(const std::vector<VectorTriangle> &aVectTriangle, unsigned int idList);
1462 
1463 
1472  void glCreateListPolygons(const std::vector<VectorPolygon> &aVectPolygon, unsigned int idList);
1473 
1474 
1483  void glCreateListPolygonsWired(const std::vector<VectorPolygon> &aVectPolygon, unsigned int idList);
1484 
1485 
1491  void glUpdateTextureImages(const VectorTextureImage &aVectImage);
1492 
1493 
1500  void glUpdateLightRenderingMode() const;
1501 
1506  void glUpdateBackground() ;
1507 
1515 
1523 
1524 
1525 
1526  public:
1538  template<typename TImageORDomain>
1539  static
1540  void
1541  rotateImageVertex(TImageORDomain &anImageOrDom, double angle, ImageDirection rotationDir){
1542  double xB = (anImageOrDom.point1[0]+anImageOrDom.point2[0]+anImageOrDom.point3[0]+anImageOrDom.point4[0])/4.0;
1543  double yB = (anImageOrDom.point1[1]+anImageOrDom.point2[1]+anImageOrDom.point3[1]+anImageOrDom.point4[1])/4.0;
1544  double zB = (anImageOrDom.point1[2]+anImageOrDom.point2[2]+anImageOrDom.point3[2]+anImageOrDom.point4[2])/4.0;
1545  rotatePoint( anImageOrDom.point1[0], anImageOrDom.point1[1], anImageOrDom.point1[2], xB, yB, zB, angle, rotationDir);
1546  rotatePoint( anImageOrDom.point2[0], anImageOrDom.point2[1], anImageOrDom.point2[2], xB, yB, zB, angle, rotationDir);
1547  rotatePoint( anImageOrDom.point3[0], anImageOrDom.point3[1], anImageOrDom.point3[2], xB, yB, zB, angle, rotationDir);
1548  rotatePoint( anImageOrDom.point4[0], anImageOrDom.point4[1], anImageOrDom.point4[2], xB, yB, zB, angle, rotationDir);
1549 
1550  }
1551 
1565  template <typename TValues>
1566  static
1567  void rotatePoint(TValues &x, TValues &y, TValues &z,
1568  double cx, double cy, double cz,
1569  double rotationAngle, ImageDirection rotationDir);
1570 
1571 
1572 
1573 
1574 
1575  // ------------------------- Private Datas --------------------------------
1576  private:
1577 
1579  //GLuint myListToAff;
1580 
1583 
1586 
1590 
1593 
1596 
1598 
1599  unsigned int myNbListe;
1600  unsigned int myNbLineSetList;
1601  unsigned int myNbBallSetList;
1602  unsigned int myNbPrismSetList;
1603 
1606  unsigned char mySelectionColorShift = 150;
1607 
1613  std::vector<GLTextureImage> myVectTextureImage;
1614 
1616 
1617  double camera_position[3];
1618  double camera_direction[3];
1619  double camera_upVector[3];
1620 
1621  bool myLightPositionFixToCamera = true; // when false the light position is fix according to the scene.
1622  double myLightTheta;
1623  double myLightPhi;
1624  double myLightR;
1625  GLfloat myLightPosition [4] = {0.0f, 0.0f, 1.0f, 1.0f}; // the light position in cartesian coordinate
1626  GLfloat myLightPositionRefCameraDefault [3] = {-100.0f, 100.0f, 0.0f}; // the light default position according to the camera position
1627  GLfloat myLightPositionRefCamera [3] = {0.0f, 0.0f, 0.0f}; // the light position according to the camera position
1628  GLfloat myMaterialShininessCoeff[1] = {50.0f} ; // the material shininess coefficient used in opengl rendering
1629  GLfloat myMaterialSpecularCoeffs[4] = { 1.0f, 1.0f, 1.0f, 1.0f }; // the light specular coefficients used in opengl rendering
1630  GLfloat myLightSpecularCoeffs[4] = { 0.3f, 0.3f, 0.3f, 1.0f }; // the light specular coefficients used in opengl rendering
1631  GLfloat myLightAmbientCoeffs[4] = { 0.0f, 0.0f, 0.0f, 1.0f }; // the material ambient coefficients used in opengl rendering
1632  GLfloat myLightDiffuseCoeffs[4] = { 0.7f, 0.7f, 0.7f, 1.0f }; // the material diffuse coefficients used in opengl rendering
1633 
1634  const GLfloat myDefaultRenderSpec = 0.3f; // default specular coefficients for default mode rendering
1635  const GLfloat myDefaultRenderDiff = 0.7f; // default diffuse coefficients for metallic mode rendering
1636  const GLfloat myLambertRenderSpec = 0.0f; // default specular coefficients for default mode rendering
1637  const GLfloat myLambertRenderDiff = 0.9f; // default diffuse coefficients for metallic mode rendering
1638  const GLfloat myMetallicRenderSpec = 0.5f; // default specular coefficients for metallic mode rendering
1639  const GLfloat myMetallicRenderDiff = 0.5f; // default diffuse coefficients for metallic mode rendering
1640  const GLfloat myPlasticRenderSpec = 0.8f; // default specular coefficients for platic mode rendering
1641  const GLfloat myPlasticRenderDiff = 0.2f; // default diffuse coefficients for platic mode rendering
1642 
1643  bool myUseGLPointsForBalls = false; // to display balls with GL points (instead real ball)
1644 
1645  double ZNear;
1646  double ZFar;
1647 
1648  //the default width of the mesh line
1650 
1651  // To apply openGL ajustment only on visualisation
1652  float myGLScaleFactorX=1.0;
1653  float myGLScaleFactorY=1.0;
1654  float myGLScaleFactorZ=1.0;
1655 
1656  // Used to apply interactive light rotation
1661 
1663  std::vector<TextureImage> myGSImageList;
1665  std::vector<Image2DDomainD3D> myImageDomainList;
1667  Extension * myExtension;
1668 
1669  }; // end of class Viewer3D
1670 
1671  template <typename TSpace, typename TKSpace>
1678  std::ostream & operator<<( std::ostream & out,
1679  const Viewer3D<TSpace, TKSpace> & object );
1680 } // namespace DGtal
1681 
1682 
1684 // Includes inline functions.
1685 #include "DGtal/io/viewers/Viewer3D.ih"
1686 
1687 // //
1689 
1690 #endif // !defined Viewer3D_h
1691 
1692 #undef Viewer3D_RECURSES
1693 #endif // else defined(Viewer3D_RECURSES)
void setGLDoubleRenderingMode(bool doubleSidedRendering)
void glUpdateTextureImages(const VectorTextureImage &aVectImage)
GLfloat myLightDiffuseCoeffs[4]
Definition: Viewer3D.h:1632
void glCreateListCubesMaps(const typename Display3D< Space, KSpace >::CubesMap &aCubeMap, unsigned int idList)
float myGLScaleFactorX
Definition: Viewer3D.h:1652
virtual void drawWithNames(Viewer &viewer)
Definition: Viewer3D.h:190
RealPoint point1
coordinates
Definition: Viewer3D.h:1212
float myGLScaleFactorZ
Definition: Viewer3D.h:1654
double myGLLineMinWidth
to improve the display of gl points
Definition: Viewer3D.h:484
std::vector< typename Viewer3D< Space, KSpace >::TriangleD3D > VectorTriangle
Definition: Viewer3D.h:1373
unsigned int myDomainHeight
the height of the image domain
Definition: Viewer3D.h:507
Image2DDomainD3D(TDomain aDomain, ImageDirection normalDir=zDirection, double xBottomLeft=0.0, double yBottomLeft=0.0, double zBottomLeft=0.0, std::string mode="BoundingBox")
Definition: Viewer3D.h:525
unsigned int myNbLineSetList
Definition: Viewer3D.h:1600
double myLightTheta
Definition: Viewer3D.h:1622
GLuint myQuadsMapWiredId
Definition: Viewer3D.h:1592
ImageDirection myDirection
Definition: Viewer3D.h:574
virtual ~Extension()=default
MyDigitalSurface::ConstIterator ConstIterator
const GLfloat myMetallicRenderDiff
Definition: Viewer3D.h:1639
GLuint myPolygonSetListWiredId
Definition: Viewer3D.h:1585
virtual QString helpString(const Viewer &viewer) const
Definition: Viewer3D.h:220
virtual bool mouseMoveEvent(const Viewer &viewer, QMouseEvent *event)
Definition: Viewer3D.h:250
GLfloat myLightPositionRefCamera[3]
Definition: Viewer3D.h:1627
void rotateLineD3D(typename DGtal::Display3D< Space, KSpace >::LineD3D &aLine, DGtal::PointVector< 3, int, TContainer > pt, double angleRotation, ImageDirection dirRotation)
std::vector< typename Viewer3D< Space, KSpace >::QuadD3D > VectorQuad
Definition: Viewer3D.h:1370
virtual void mouseReleaseEvent(QMouseEvent *e)
bool myAutoSaveState
flag to save automatically or not the Viewer3d state when closing the viewer
Definition: Viewer3D.h:486
unsigned char * myTextureImageBufferGS
Definition: Viewer3D.h:1225
unsigned int myIndexDomain
true if the draw have a domain
Definition: Viewer3D.h:582
int mySelectedElementId
used to displayed selected elements
Definition: Viewer3D.h:1605
void updateRenderingCoefficients(const RenderingMode aRenderMode, bool displayState=true)
GLuint myCubeSetListWiredId
Definition: Viewer3D.h:1595
GLuint myLineSetListId
Definition: Viewer3D.h:1587
virtual bool keyPressEvent(Viewer &viewer, QKeyEvent *event)
Definition: Viewer3D.h:178
bool operator()(typename Viewer3D< Space, KSpace >::PolygonD3D q1, typename Viewer3D< Space, KSpace >::PolygonD3D q2)
Definition: Viewer3D.h:1110
void glCreateListTriangles(const std::vector< VectorTriangle > &aVectTriangle, unsigned int idList)
GLfloat myMaterialShininessCoeff[1]
Definition: Viewer3D.h:1628
Viewer3D< Space, KSpace >::ImageDirection myDirection
Definition: Viewer3D.h:1217
GLTextureImage(const GLTextureImage &aGLImg)
Definition: Viewer3D.h:1252
unsigned char * myTextureImageBufferRGB
Definition: Viewer3D.h:1226
bool myViewWire
objects have shadows which follow the camera if false
Definition: Viewer3D.h:482
qglviewer::Vec myDirSelector
Definition: Viewer3D.h:1609
std::string className() const
std::vector< typename Viewer3D< Space, KSpace >::TextureImage > VectorTextureImage
Definition: Viewer3D.h:1375
virtual QDomElement domElement(const QString &name, QDomDocument &document) const
Overload of the QGLViewer method which returns an XML QDomElement representing the QGLViewer state....
void updateImageOrientation(ImageDirection normalDir, double xBottomLeft, double yBottomLeft, double zBottomLeft)
void glCreateListQuadMaps(const typename Display3D< Space, KSpace >::QuadsMap &aQuadMap, unsigned int idList)
virtual bool mouseReleaseEvent(const Viewer &viewer, QMouseEvent *event)
Definition: Viewer3D.h:281
void glCreateListPolygonsWired(const std::vector< VectorPolygon > &aVectPolygon, unsigned int idList)
std::vector< typename DGtal::Viewer3D< Space, KSpace >::LineD3D > compute2DDomainLineRepresentation(Image2DDomainD3D &anImageDomain, double delta)
void drawSomeLight(GLenum light) const
To call the protected method drawLight.
Definition: Viewer3D.h:978
DGtal::Color color
The image domain color.
Definition: Viewer3D.h:503
double camera_position[3]
camera position
Definition: Viewer3D.h:1617
bool myIsMovingLight
the reference mouse y-position used to determince the light position change (inclination)
Definition: Viewer3D.h:1660
void glCreateListPolygons(const std::vector< VectorPolygon > &aVectPolygon, unsigned int idList)
Viewer3D< Space, KSpace > Viewer
The associated viewer.
Definition: Viewer3D.h:166
const GLfloat myLambertRenderSpec
Definition: Viewer3D.h:1636
const GLfloat myMetallicRenderSpec
Definition: Viewer3D.h:1638
double camera_direction[3]
camera direction
Definition: Viewer3D.h:1618
virtual void init(Viewer &viewer)
Definition: Viewer3D.h:209
void translateAn2DDomain(unsigned int domainIndex, double xTranslation, double yTranslation, double zTranslation)
void setGLMaterialShininessCoefficient(const GLfloat matShininessCoeff)
void updateDomainOrientation(ImageDirection normalDir, double xBottomLeft, double yBottomLeft, double zBottomLeft)
TextureMode myMode
index of the image domain if exist
Definition: Viewer3D.h:583
Aim: Implements basic operations that will be used in Point and Vector classes.
Definition: PointVector.h:165
~TextureImage()
the mode of representation of the image
Definition: Viewer3D.h:588
TextureImage(const TImageType &image, const TFunctor &aFunctor, ImageDirection normalDir=zDirection, double xBottomLeft=0.0, double yBottomLeft=0.0, double zBottomLeft=0.0, TextureMode aMode=GrayScaleMode)
Definition: Viewer3D.h:643
double myLightPhi
the light position (inclination)
Definition: Viewer3D.h:1623
double myGLPointMinWidth
Definition: Viewer3D.h:483
std::map< DGtal::int32_t, std::vector< QuadD3D > > QuadsMap
The type that maps identifier name -> vector of QuadD3D.
Definition: Display3D.h:254
void sortPolygonFromCamera()
unsigned int myImageHeight
the width of the image
Definition: Viewer3D.h:577
Aim: Defines a unary functor, which associates arguments to results.
Definition: CUnaryFunctor.h:89
void drawSomeLight(GLenum light, float zoom) const
To call the protected method drawLight.
Definition: Viewer3D.h:983
Display::RealPoint RealPoint
Definition: Viewer3D.h:146
ImageDirection myDirection
the direction of the domain (x, y or z axe)
Definition: Viewer3D.h:509
bool operator()(typename Viewer3D< Space, KSpace >::QuadD3D q1, typename Viewer3D< Space, KSpace >::QuadD3D q2)
Definition: Viewer3D.h:1091
GLuint myPrismListId
Definition: Viewer3D.h:1589
RenderingMode myRenderingMode
Definition: Viewer3D.h:488
void glCreateListLines(const VectorLine &aVectLine, unsigned int idList)
Extension * myExtension
Stored a possible extension to the viewer (pointer owned).
Definition: Viewer3D.h:1667
const GLfloat myLambertRenderDiff
Definition: Viewer3D.h:1637
unsigned int myImageWidth
direction of the image (x, y or z axe)
Definition: Viewer3D.h:576
int myRefMouseXPos
the angle rotation increment used for interactive light move
Definition: Viewer3D.h:1658
void setGLLightAmbientCoefficients(const GLfloat lightAmbientCoeffs [4])
GLfloat myLightAmbientCoeffs[4]
Definition: Viewer3D.h:1631
virtual void draw(Viewer &viewer)
Definition: Viewer3D.h:200
double ZFar
zfar distance
Definition: Viewer3D.h:1646
void addImage2DDomainD3D(const TDomain &anImageDomain, std::string mode, const DGtal::Color &aColor=DGtal::Color::Red)
std::vector< TextureImage > myGSImageList
flag to display the ligth source when it is moved by the user
Definition: Viewer3D.h:1663
const GLfloat myPlasticRenderSpec
Definition: Viewer3D.h:1640
void setGLLightSpecularCoefficients(const GLfloat lightSpecularCoeffs [4])
virtual void paintGL()
Overload of the QGLViewer method in order to change the order of display (to fix the QGLViewer axis d...
virtual void mouseMoveEvent(QMouseEvent *e)
Aim: This concept represents a digital domain, i.e. a non mutable subset of points of the given digit...
Definition: CDomain.h:129
void setGLLightDiffuseCoefficients(const GLfloat lightDiffuseCoeffs [4])
std::vector< GLTextureImage > myVectTextureImage
list of the images textures in this viewer
Definition: Viewer3D.h:1613
Viewer3D< Space, KSpace >::TextureMode myMode
Definition: Viewer3D.h:1224
double myLightR
the light position (azimuth)
Definition: Viewer3D.h:1624
void setCameraUpVector(double ax, double ay, double az)
Definition: Viewer3D.h:357
virtual unsigned int getCurrentDomainNumber()
void setCameraDirection(double ax, double ay, double az)
Definition: Viewer3D.h:346
qglviewer::Vec mySelectedPoint
Definition: Viewer3D.h:1609
void addTextureImage(const TextureImage &image)
void updateRelativeCameraFromLightPosition()
void rotateDomain(Image2DDomainD3D &anDom, double angle, ImageDirection rotationDir)
std::vector< typename Viewer3D< Space, KSpace >::CubeD3D > VectorCubes
Definition: Viewer3D.h:1369
virtual void draw()
draw
void setExtension(Extension *ext)
Definition: Viewer3D.h:313
DGtal::Color myDefaultBackgroundColor
the default background color of the viewer
Definition: Viewer3D.h:476
std::vector< typename Viewer3D< Space, KSpace >::BallD3D > VectorBall
Definition: Viewer3D.h:1372
unsigned int myNbPrismSetList
Definition: Viewer3D.h:1602
double camera_upVector[3]
camera up-vector
Definition: Viewer3D.h:1619
std::map< DGtal::int32_t, std::vector< CubeD3D > > CubesMap
The type that maps identifier name -> vector of CubeD3D.
Definition: Display3D.h:257
virtual unsigned int getCurrentGLImageNumber()
bool myIsBackgroundDefault
true if the background is default
Definition: Viewer3D.h:480
virtual bool postSelection(const Viewer &viewer, const QPoint &point)
Definition: Viewer3D.h:235
GLTextureImage(const typename Viewer3D< Space, KSpace >::TextureImage &aGSImage)
Definition: Viewer3D.h:1291
Aim: Defines the concept describing a digital space, ie a cartesian product of integer lines.
Definition: CSpace.h:105
GLfloat myLightPosition[4]
the light position (distance)
Definition: Viewer3D.h:1625
std::ostream & operator<<(std::ostream &out, const ClosedIntegerHalfPlane< TSpace > &object)
void glCreateListTrianglesWired(const std::vector< VectorTriangle > &aVectTriangle, unsigned int idList)
void sortSurfelFromCamera()
double myLigthRotationStep
Definition: Viewer3D.h:1657
bool myUseGLPointsForBalls
Definition: Viewer3D.h:1643
int myRefMouseYPos
the reference mouse x-position used to determince the light position change (azimuth)
Definition: Viewer3D.h:1659
virtual QString helpString() const
DGtal::Color myDefaultColor
the default color of the viewer
Definition: Viewer3D.h:478
GLuint myQuadsMapId
Definition: Viewer3D.h:1591
Viewer3D(const KSpace &KSEmb)
Definition: Viewer3D.h:304
VectorCubes::iterator ItCube
Definition: Viewer3D.h:1378
SelectCallbackFct getSelectCallback3D(DGtal::int32_t aName, void *&data) const
bool myLightPositionFixToCamera
Definition: Viewer3D.h:1621
static void rotatePoint(TValues &x, TValues &y, TValues &z, double cx, double cy, double cz, double rotationAngle, ImageDirection rotationDir)
GLuint myBallSetListId
Definition: Viewer3D.h:1588
void glCreateListBalls(const VectorBall &aVectBall, unsigned int idList)
void updateTextureImage(unsigned int imageIndex, const TImageType &image, const TFunctor &aFunctor, double xTranslation=0.0, double yTranslation=0.0, double zTranslation=0.0, double rotationAngle=0.0, ImageDirection rotationDir=zDirection)
float myMeshDefaultLineWidth
Definition: Viewer3D.h:1649
GLuint myTriangleSetListId
lists of the list to draw
Definition: Viewer3D.h:1581
void selfDisplay(std::ostream &out) const
TKSpace KSpace
Definition: Viewer3D.h:142
virtual bool mousePressEvent(const Viewer &viewer, QMouseEvent *event)
Definition: Viewer3D.h:265
DGtal is the top-level namespace which contains all DGtal functions and types.
void updateLightCoordsFromCamera()
int(* SelectCallbackFct)(void *viewer, DGtal::int32_t name, void *data)
Select callback function type.
Definition: Display3D.h:109
std::vector< Image2DDomainD3D > myImageDomainList
Used to store all the domains.
Definition: Viewer3D.h:1665
virtual void drawWithNames()
drawWithNames
void translateDomain(double xTranslation=0.0, double yTranslation=0.0, double zTranslation=0.0)
static void rotateImageVertex(TImageORDomain &anImageOrDom, double angle, ImageDirection rotationDir)
Definition: Viewer3D.h:1541
const GLfloat myPlasticRenderDiff
Definition: Viewer3D.h:1641
virtual void postSelection(const QPoint &point)
postSelection
BOOST_CONCEPT_ASSERT((concepts::CSpace< TSpace >))
virtual void initFromDOMElement(const QDomElement &element)
Overload of the QGLViewer method which restores the viewer state from a QDomDocument element....
qglviewer::Vec myDir
Definition: Viewer3D.h:1609
unsigned int * myTabImage
the height of the image
Definition: Viewer3D.h:579
void removeExtension()
Definition: Viewer3D.h:322
void glCreateListQuadD3D(const VectorQuad &aVectQuad, unsigned int idList)
void setGLScale(float sx, float sy, float sz)
Definition: Viewer3D.h:381
GLuint myPolygonSetListId
Definition: Viewer3D.h:1584
void setNearFar(double _near, double _far)
Definition: Viewer3D.h:367
bool operator()(typename Viewer3D< Space, KSpace >::CubeD3D s1, typename Viewer3D< Space, KSpace >::CubeD3D s2)
Definition: Viewer3D.h:1051
Display3D< Space, KSpace > Display
Definition: Viewer3D.h:144
unsigned int myDomainWidth
the width of the image domain
Definition: Viewer3D.h:505
const GLfloat myDefaultRenderDiff
Definition: Viewer3D.h:1635
TextureImage(const TextureImage &img)
Copy constructor (needed due to myTabImage)
Definition: Viewer3D.h:597
void setUseGLPointForBalls(bool useOpenGLPt)
virtual void mousePressEvent(QMouseEvent *e)
void updateOrientationTextureImage(unsigned int imageIndex, double xPosition, double yPosition, double zPosition, ImageDirection newDirection)
virtual void init()
init
Viewer3D< Space, KSpace > & operator<<(const DGtal::Color &aColor)
T roundToUpperPowerOfTwo(const T &n)
std::vector< typename Viewer3D< Space, KSpace >::PolygonD3D > VectorPolygon
Definition: Viewer3D.h:1374
void updateAn2DDomainOrientation(unsigned int imageIndex, double xPosition, double yPosition, double zPosition, ImageDirection newDirection)
void updateEmbeddingTextureImage(unsigned int anImageIndex, typename Space::Point aPoint1, typename Space::Point aPoint2, typename Space::Point aPoint3, typename Space::Point aPoint4)
QPoint myPosSelector
a point selected with postSelection
Definition: Viewer3D.h:1611
Structure representing an RGB triple with alpha component.
Definition: Color.h:66
virtual void closeEvent(QCloseEvent *e)
Overload the QWidget method to customize the viewer state auto saving. Now it save the viewer state i...
ImageDirection
the 3 possible axes for the image direction
Definition: Viewer3D.h:471
std::vector< typename Viewer3D< Space, KSpace >::LineD3D > VectorLine
Definition: Viewer3D.h:1371
void glUpdateBackground()
void green(const unsigned char aGreenValue)
Viewer3D< Space, KSpace > Self
Definition: Viewer3D.h:143
bool operator()(typename Viewer3D< Space, KSpace >::TriangleD3D t1, typename Viewer3D< Space, KSpace >::TriangleD3D t2)
Definition: Viewer3D.h:1073
unsigned char mySelectionColorShift
Definition: Viewer3D.h:1606
const GLfloat myDefaultRenderSpec
Definition: Viewer3D.h:1634
virtual void show()
Overload QWidget method in order to add a call to updateList() method (to ensure that the lists are w...
static const Color Red
Definition: Color.h:391
TSpace Space
Definition: Viewer3D.h:141
GLfloat myLightPositionRefCameraDefault[3]
Definition: Viewer3D.h:1626
TextureMode
the modes of representation of an image
Definition: Viewer3D.h:473
void sortTriangleFromCamera()
void setCameraPosition(double ax, double ay, double az)
Definition: Viewer3D.h:335
void red(const unsigned char aRedValue)
Aim: Defines the concept describing a read-only image, which is a refinement of CPointFunctor.
Definition: CConstImage.h:94
qglviewer::Vec myOrig
information linked to the navigation in the viewer
Definition: Viewer3D.h:1609
void updateImageDataAndParam(const TImageType &image, const TFunctor &aFunctor, double xTranslation=0.0, double yTranslation=0.0, double zTranslation=0.0)
Definition: Viewer3D.h:707
void glCreateListQuadMapsWired(const typename Display3D< Space, KSpace >::QuadsMap &aQuadMap, unsigned int idList)
RealPoint point1
The image domain coordinates.
Definition: Viewer3D.h:498
bool isValid() const
GLuint myCubesMapId
Definition: Viewer3D.h:1594
virtual void keyPressEvent(QKeyEvent *e)
void sortQuadFromCamera()
unsigned int myNbBallSetList
Definition: Viewer3D.h:1601
void updateImage3DEmbedding(RealPoint aPoint1, RealPoint aPoint2, RealPoint aPoint3, RealPoint aPoint4)
Definition: Viewer3D.h:681
GLfloat myLightSpecularCoeffs[4]
Definition: Viewer3D.h:1630
std::size_t myLineSetIndex
the index of the line of the domain in the lineSetList of the viewer
Definition: Viewer3D.h:513
bool myIsDoubleFaceRendering
true if is double face rendering
Definition: Viewer3D.h:1615
GLfloat myMaterialSpecularCoeffs[4]
Definition: Viewer3D.h:1629
Image image(domain)
void glUpdateLightRenderingMode() const
void updateList(bool needToUpdateBoundingBox=true)
bool myDrawDomain
for each pixel of the image, color or height ?
Definition: Viewer3D.h:581
double ZNear
znear distance
Definition: Viewer3D.h:1645
Aim: This semi abstract class defines the stream mechanism to display 3d primitive (like BallVector,...
Definition: Common.h:148
Display::SelectCallbackFct SelectCallbackFct
Definition: Viewer3D.h:145
void glDrawGLBall(const typename Viewer3D< Space, KSpace >::BallD3D &aBall)
std::string myMode
the mode of representation of the image domain
Definition: Viewer3D.h:511
unsigned int myNbListe
number of lists in myListToAff
Definition: Viewer3D.h:1599
GLuint myTriangleSetListWiredId
Definition: Viewer3D.h:1582
float myGLScaleFactorY
Definition: Viewer3D.h:1653
void blue(const unsigned char aBlueValue)