diff --git a/.travis/install_deps_macos.sh b/.travis/install_deps_macos.sh index 07172373d2..7488e2af57 100755 --- a/.travis/install_deps_macos.sh +++ b/.travis/install_deps_macos.sh @@ -4,8 +4,10 @@ # Note: gmp and boost already installed # brew update -#brew install qt5 doxygen homebrew/science/hdf5 graphviz graphicsmagick fftw eigen homebrew/boneyard/libqglviewer -brew install qt5 graphicsmagick fftw eigen homebrew/boneyard/libqglviewer +#brew install qt5 doxygen homebrew/science/hdf5 graphviz graphicsmagick fftw eigen +brew install qt5 graphicsmagick fftw eigen +# Explicit install of libqglviewer +brew install http://liris.cnrs.fr/david.coeurjolly/misc/libqglviewer.rb ## Temporary HDF5 build issue export BTYPE="$BTYPE -DWITH_HDF5=false" && echo "Disabling HDF5 on MacOS"; diff --git a/ChangeLog.md b/ChangeLog.md index 3e9e9e61e6..e7a7725f59 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -2,6 +2,11 @@ ## New Features / Critical Changes +- *IO* + - New simple way to extend the QGLViewer-based Viewer3D interface, + for instance to add callbacks to key or mouse events, or to modify + what is drawn on the window. + (Jacques-Olivier Lachaud, [#1259](https://github.com/DGtal-team/DGtal/pull/1259)) ## Changes diff --git a/examples/io/viewers/CMakeLists.txt b/examples/io/viewers/CMakeLists.txt index 3b24a1beb8..4bc568a63c 100644 --- a/examples/io/viewers/CMakeLists.txt +++ b/examples/io/viewers/CMakeLists.txt @@ -11,6 +11,7 @@ SET(DGTAL_TESTS_SRC viewer3D-7bis-planes viewer3D-9-3Dimages viewer3D-10-interaction + viewer3D-11-extension demo-kernel-2 ) diff --git a/examples/io/viewers/viewer3D-11-extension.cpp b/examples/io/viewers/viewer3D-11-extension.cpp new file mode 100644 index 0000000000..e1a2bcc566 --- /dev/null +++ b/examples/io/viewers/viewer3D-11-extension.cpp @@ -0,0 +1,132 @@ +/** + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + **/ + +/** + * @file io/viewers/viewer3D-11-extension.cpp + * @ingroup examples/3dViewer + * @author Jacques-Olivier Lachaud (\c jacques-olivier.lachaud@univ-savoie.fr ) + * Laboratory of Mathematics (CNRS, UMR 5127), University of Savoie, France + * + * @date 2017/03/05 + * + * Simple example of class Viewer3D. + * + * This file is part of the DGtal library. + */ + +/** + * Example of extension of Viewer3D interface by deriving the class + * Viewer3D::Extension. Here we have added a callback to the + * "Shift+R" keypressed event, which adds a point randomly in the domain. + * + * @see moduleQGLExtension + * \example io/viewers/viewer3D-11-extension.cpp + * \image html simple3dVisu1.png "Extending the Viewer3D interface: just press Shift+R and you have new points added randomly in the scene." + */ + +/////////////////////////////////////////////////////////////////////////////// +#include + +#include "DGtal/base/Common.h" +#include "DGtal/helpers/StdDefs.h" +#include "DGtal/io/viewers/Viewer3D.h" +/////////////////////////////////////////////////////////////////////////////// + +using namespace std; +using namespace DGtal; +using namespace Z3i; + + +/////////////////////////////////////////////////////////////////////////////// +// Standard services - public : + + +//! [viewer3D-extension-derivation] +// Deriving from Viewer3D::Extension to add new callbacks to events. +struct RandomPointKeyExtension : public Viewer3D::Extension +{ + RandomPointKeyExtension() {} + + // Here we override the "key pressed" event, and a point randomly in + // the scene if the key "Shift+R" is pressed. + virtual bool keyPressEvent ( Viewer& viewer, QKeyEvent * event ) + { + bool handled = false; + // Get event modifiers key + const Qt::KeyboardModifiers modifiers = event->modifiers(); + if( ( event->key() == Qt::Key_R ) && ( modifiers == Qt::ShiftModifier ) ) + { + typedef Viewer::KSpace KSpace; + Point p = viewer.space().lowerBound(); + Point q = viewer.space().upperBound(); + Point d = q - p; + Point a( ( rand() % d[ 0 ] ) + p[ 0 ], + ( rand() % d[ 1 ] ) + p[ 1 ], + ( rand() % d[ 2 ] ) + p[ 2 ] ); + viewer << a; + viewer << Viewer::updateDisplay; + trace.info() << "Adding point " << a << std::endl; + handled = true; + } + return handled; + } + + // We also override the Viewer3D::init method to add a key + // description in the help window. + virtual void init( Viewer& viewer ) + { + viewer.setKeyDescription ( Qt::ShiftModifier+Qt::Key_R, + "Creates a random digital point." ); + } + + // We also override the Viewer3D::helpString method to add a + // description to the viewer. + virtual QString helpString(const Viewer& viewer) const + { + QString text( "

Random point Viewer3D

" ); + text += "Press Shift+R to add points."; + return text; + } + +}; +//! [viewer3D-extension-derivation] + +int main( int argc, char** argv ) +{ + + QApplication application(argc,argv); + + Point p1( 0, 0, 0 ); + Point p2( 5, 5 ,5 ); + Point p3( 2, 3, 4 ); + Domain domain( p1, p2 ); + + typedef Viewer3D<> MyViewer; + KSpace K; + K.init( p1, p2, true ); + //! [viewer3D-extension-set-extension] + MyViewer viewer( K ); + viewer.setExtension( new RandomPointKeyExtension ); + //! [viewer3D-extension-set-extension] + viewer.show(); + viewer << domain; + viewer << p1 << p2 << p3; + + viewer<< MyViewer::updateDisplay; + return application.exec(); +} +// // +/////////////////////////////////////////////////////////////////////////////// diff --git a/src/DGtal/io/Display3D.h b/src/DGtal/io/Display3D.h index aa9b01c91b..d09cef774d 100644 --- a/src/DGtal/io/Display3D.h +++ b/src/DGtal/io/Display3D.h @@ -896,6 +896,8 @@ namespace DGtal /// std::set mySelectCallBackFcts; + bool myBoundingPtChangedTag = false; + //----end of protected datas // ------------------------- Internals ------------------------------------ diff --git a/src/DGtal/io/Display3D.ih b/src/DGtal/io/Display3D.ih index c9b429501a..d2c183f41e 100644 --- a/src/DGtal/io/Display3D.ih +++ b/src/DGtal/io/Display3D.ih @@ -1191,16 +1191,42 @@ DGtal::Display3D< Space ,KSpace >::updateBoundingBox(const RealPoint &p) myBoundingPtUp[1]= p[1]; myBoundingPtUp[2]= p[2]; myBoundingPtEmptyTag = false; + myBoundingPtChangedTag = true; } else { - if(p[0] myBoundingPtUp[0]) myBoundingPtUp[0]= p[0]; - if(p[1] >myBoundingPtUp[1]) myBoundingPtUp[1]= p[1]; - if(p[2] >myBoundingPtUp[2]) myBoundingPtUp[2]= p[2]; + if(p[0] myBoundingPtUp[0]) + { + myBoundingPtUp[0]= p[0]; + myBoundingPtChangedTag = true; + } + if(p[1] >myBoundingPtUp[1]) + { + myBoundingPtUp[1]= p[1]; + myBoundingPtChangedTag = true; + } + if(p[2] >myBoundingPtUp[2]) + { + myBoundingPtUp[2]= p[2]; + myBoundingPtChangedTag = true; + } } } diff --git a/src/DGtal/io/doc/moduleQGLExtension.dox b/src/DGtal/io/doc/moduleQGLExtension.dox new file mode 100644 index 0000000000..16a64d498c --- /dev/null +++ b/src/DGtal/io/doc/moduleQGLExtension.dox @@ -0,0 +1,88 @@ + + +/* + * Useful to avoid writing DGtal:: in front of every class. + */ +namespace DGtal { + +/** + * @page moduleQGLExtension Extending the QGLViewer Viewer3D interface + * + * + * This part of the manual describes how to extend the standard + * Viewer3D interface of DGtal. For instance, you wish to assign new + * handlers keys or to mouse event, or you wish to display or + * select other graphical elements. To do that, you just have to write + * a class that derived from Viewer3D::Extension and overrides some + * methods to get your desired behaviour. + * + * @author Jacques-Olivier Lachaud + * + * @since 9.4 + * + * Related examples: viewer3D-11-extension.cpp + * + * Related modules: \ref moduleQGLInteraction + * + * [TOC] + * + * \section QGLExtension_sec1 Extending the standard behavior of Viewer3D + * + * The Viewer3D interface provides a very handy way of visualising 3D + * scenes, digital objects or meshes in DGtal, and is bundled with + * many functionalities (like moving the light, selecting some + * objects, etc). However it is not directly extensible as is, and, + * for several reasons, you cannot derive from the Viewer3D class + * directly to add some new functionalities. + * + * Therefore we provide the class Viewer3D::Extension so that you can + * extend the viewer in several ways. The principle is very easy. This + * interface provides a set of empty virtual methods so you just have + * to override them in order to change the behavior of the viewer. For + * instance, you just have to override + * Viewer3D::Extension::keyPressEvent to capture other key events. You + * can override all the following methods: + * + * - Viewer3D::Extension::keyPressEvent. This method may be + * overloaded to capture other key events. + * + * - Viewer3D::Extension::drawWithNames. This method is useful for + * drawing elements with additional information for selection (see also \ref moduleQGLInteraction). + * + * - Viewer3D::Extension::draw. This method is useful for drawing elements that are not directly handled by Viewer3D. + * + * - Viewer3D::Extension::init. This method is useful at initialization (e.g. adding lights manipulators). + * + * - Viewer3D::Extension::helpString. This method is useful to change the help message. + * + * - Viewer3D::Extension::postSelection. This method is useful to take + * care of mouse selection events. + * + * - Viewer3D::Extension::mouseMoveEvent. This method is useful to + * take care of mouse movements. + * + * - Viewer3D::Extension::mousePressEvent. This method is useful to + * take care of mouse button press events. + * + * - Viewer3D::Extension::mouseReleaseEvent. This method is useful to + * take care of mouse button release events. + * + * The example below shows how to capture "Shift+R" key pressed + * events, so that each time this event occurs random points are added + * to the 3D scene. + * + * @snippet io/viewers/viewer3D-11-extension.cpp viewer3D-extension-derivation + * + * \section QGLExtension_sec2 Activating your extension in some viewer + * + * Once you have built a class that derives from Viewer3D::Extension, + * it remains to create some instance of this extension and to hand it + * to your viewer. This is done by the following lines. + * + * @snippet io/viewers/viewer3D-11-extension.cpp viewer3D-extension-set-extension + * + * The viewer will take care of freeing your instanciated extension object. + * For a complete example, see viewer3D-11-extension.cpp. + */ + +} diff --git a/src/DGtal/io/doc/packageIO.dox b/src/DGtal/io/doc/packageIO.dox index 288efb022d..9b9bd39e7b 100644 --- a/src/DGtal/io/doc/packageIO.dox +++ b/src/DGtal/io/doc/packageIO.dox @@ -49,6 +49,7 @@ In this package, we present DGtal tools and utilities to import/export images an - \ref moduleBoard2D (Jacques-Olivier Lachaud, Nicolas Normand, David Coeurjolly, Martial Tola) - \ref moduleDisplay3D (Bertrand Kerautret, Martial Tola, Aline Martin, David Coeurjolly) - \ref moduleQGLInteraction (Jacques-Olivier Lachaud, Bertrand Kerautret) + - \ref moduleQGLExtension (Jacques-Olivier Lachaud) - \ref moduleIO (David Coeurjolly, Bertrand Kerautret, Martial Tola, Pierre Gueth) @b Package @b Concepts @b Overview diff --git a/src/DGtal/io/viewers/Viewer3D.h b/src/DGtal/io/viewers/Viewer3D.h index 6f439ac867..8792a163ad 100644 --- a/src/DGtal/io/viewers/Viewer3D.h +++ b/src/DGtal/io/viewers/Viewer3D.h @@ -118,8 +118,8 @@ namespace DGtal * used to compute the Euclidean coordinate of digital * objects/khalimksy cells. * - * @tparam Space any model of Digital 3D Space - * @tparam KSpace any mode of Khalimksky 3D space + * @tparam TSpace any model of Digital 3D Space + * @tparam TKSpace any mode of Khalimksky 3D space * * @note You *must* provide a Khalimksy space at instanciation if * you wish to display cells with the viewer. If you are not going @@ -127,32 +127,163 @@ namespace DGtal * * @see Display3D, Board3DTo2D */ - template < typename Space = SpaceND<3>, - typename KSpace = KhalimskySpaceND<3> > - class Viewer3D : public QGLViewer, public Display3D + template < typename TSpace = SpaceND<3>, + typename TKSpace = KhalimskySpaceND<3> > + class Viewer3D : public QGLViewer, public Display3D { - BOOST_CONCEPT_ASSERT((concepts::CSpace)); + BOOST_CONCEPT_ASSERT((concepts::CSpace)); //---------------overwritting some functions of Display3D ------------------- // ----------------------- public types ------------------------------ public: - - typedef Display3D Display; + typedef TSpace Space; + typedef TKSpace KSpace; + typedef Viewer3D Self; + typedef Display3D Display; typedef typename Display::SelectCallbackFct SelectCallbackFct; + typedef typename Display::RealPoint RealPoint; using Display::getSelectCallback3D; - typedef typename Display::RealPoint RealPoint; enum RenderingMode {RenderingDefault, RenderingMetallic, RenderingPlastic, RenderingLambertian }; + /** + * Interface that can be used so that one can extend a few service + * of Viewer3D, like keyPressEvent and others. You may thus give an + * extension to a Viewer3D by simply handling it a pointer to an + * object deriving from this class. + */ + struct Extension { + /// The associated viewer. + typedef Viewer3D Viewer; + + /// This method may be overloaded to capture other key + /// events. It will be called at the beginning of Viewer3D::keyPressEvent. + /// + /// @param viewer the viewer calling this method + /// @param event the key event + /// + /// @return 'true' if the event was handled (in this case, + /// Viewer3D::keyPressEvent will not do anything). + virtual bool keyPressEvent ( Viewer& viewer, QKeyEvent * event ) + { + boost::ignore_unused_variable_warning( viewer ); + boost::ignore_unused_variable_warning( event ); + return false; + } + + /// This method may be overloaded and is called at the beginning + /// of Viewer3D::drawWithNames. This method is useful for + /// drawing elements with additional information for selection. + /// + /// @param viewer the viewer calling this method + virtual void drawWithNames( Viewer& viewer ) + { + boost::ignore_unused_variable_warning( viewer ); + } + + /// This method may be overloaded and is called at the beginning + /// of Viewer3D::draw. This method is called for drawing + /// elements. + /// + /// @param viewer the viewer calling this method + virtual void draw( Viewer& viewer ) + { + boost::ignore_unused_variable_warning( viewer ); + } + + /// This method may be overloaded and is called at QGLViewer + /// initialization. It will be called at the beginning of + /// Viewer3D::init. + /// @param viewer the viewer calling this method + virtual void init(Viewer& viewer) + { + boost::ignore_unused_variable_warning( viewer ); + } + + /// This method may be overloaded and is called when pressing + /// help. It will be added before Viewer3D::helpString. + /// + /// @param viewer the viewer calling this method + /// @return astring corresponding to the help of the viewer (list of commands, etc) + virtual QString helpString(const Viewer& viewer) const + { + boost::ignore_unused_variable_warning( viewer ); + return ""; + } + + /// This method may be overloaded to take care of a mouse + /// selection event. It will be called at the beginning of + /// Viewer3D::postSelection. + /// + /// @param viewer the viewer calling this method + /// @param point the point clicked by the user in the window + /// + /// @return 'true' if the event was handled (in this case, + /// Viewer3D::postSelection will not do anything). + virtual bool postSelection(const Viewer& viewer, const QPoint& point ) + { + boost::ignore_unused_variable_warning( viewer ); + boost::ignore_unused_variable_warning( point ); + return false; + } + + /// This method may be overloaded to capture other mouse move + /// events. It will be called at the beginning of Viewer3D::mouseMoveEvent. + /// + /// @param viewer the viewer calling this method + /// @param event the mouse move event + /// + /// @return 'true' if the event was handled (in this case, + /// Viewer3D::mouseMoveEvent will not do anything). + virtual bool mouseMoveEvent(const Viewer& viewer, QMouseEvent* event ) + { + boost::ignore_unused_variable_warning( viewer ); + boost::ignore_unused_variable_warning( event ); + return false; + } + + /// This method may be overloaded to capture other mouse press + /// events. It will be called at the beginning of Viewer3D::mousePressEvent. + /// + /// @param viewer the viewer calling this method + /// @param event the mouse press event + /// + /// @return 'true' if the event was handled (in this case, + /// Viewer3D::mousePressEvent will not do anything). + virtual bool mousePressEvent(const Viewer& viewer, QMouseEvent* event ) + { + boost::ignore_unused_variable_warning( viewer ); + boost::ignore_unused_variable_warning( event ); + return false; + } + + /// This method may be overloaded to capture other mouse release + /// events. It will be called at the beginning of Viewer3D::mouseReleaseEvent. + /// + /// @param viewer the viewer calling this method + /// @param event the mouse release event + /// + /// @return 'true' if the event was handled (in this case, + /// Viewer3D::mouseReleaseEvent will not do anything). + virtual bool mouseReleaseEvent(const Viewer& viewer, QMouseEvent* event ) + { + boost::ignore_unused_variable_warning( viewer ); + boost::ignore_unused_variable_warning( event ); + return false; + } + + }; + // ----------------------- Standard services ------------------------------ public: /** * Constructor */ - Viewer3D() :QGLViewer(), Display3D() + Viewer3D() :QGLViewer(), Display3D(), + myExtension( 0 ) { resize(800,600); }; @@ -161,11 +292,29 @@ namespace DGtal *Constructor with a khalimsky space * @param KSEmb the Khalimsky space */ - Viewer3D(const KSpace &KSEmb):QGLViewer(), Display3D(KSEmb) + Viewer3D(const KSpace &KSEmb):QGLViewer(), Display3D(KSEmb), + myExtension( 0 ) { resize(800,600); } + /// Sets the extension \a ext to the viewer. The object is + /// acquired by the viewer and should be dynamically allocated. + /// @param ext any dynamically allocated object deriving from Extension. + void setExtension( Extension* ext ) + { + if ( myExtension != 0 ) delete myExtension; + myExtension = ext; + } + + /// Removes the current extension to the viewer or does nothing if + /// no extension was present. + void removeExtension() + { + if ( myExtension != 0 ) delete myExtension; + myExtension = 0; + } + /** * Set camera position. * @param ax x position. @@ -815,6 +964,16 @@ namespace DGtal public: + /// To call the protected method `drawLight`. + void drawSomeLight( GLenum light ) const + { + QGLViewer::drawLight( light ); + } + /// To call the protected method `drawLight`. + void drawSomeLight( GLenum light, float zoom ) const + { + QGLViewer::drawLight( light, zoom ); + } @@ -1490,12 +1649,14 @@ namespace DGtal std::vector myGSImageList; /// Used to store all the domains std::vector myImageDomainList; - + /// Stored a possible extension to the viewer (pointer owned). + Extension* myExtension; + }; // end of class Viewer3D - template < typename Space, typename KSpace> + template < typename TSpace, typename TKSpace> /** * Overloads 'operator<<' for displaying objects of class 'Viewer3D'. * @param out the output stream where the object is written. @@ -1503,7 +1664,7 @@ namespace DGtal * @return the output stream after the writing. */ std::ostream& - operator<< ( std::ostream & out, const Viewer3D & object ); + operator<< ( std::ostream & out, const Viewer3D & object ); } // namespace DGtal diff --git a/src/DGtal/io/viewers/Viewer3D.ih b/src/DGtal/io/viewers/Viewer3D.ih index 31781fbdaf..2e2b7732cc 100644 --- a/src/DGtal/io/viewers/Viewer3D.ih +++ b/src/DGtal/io/viewers/Viewer3D.ih @@ -64,10 +64,10 @@ using namespace qglviewer; -template < typename Space ,typename KSpace > +template < typename TSpace, typename TKSpace > inline void -DGtal::Viewer3D::rotateDomain(Image2DDomainD3D &anDom, double angleRotation, +DGtal::Viewer3D::rotateDomain(Image2DDomainD3D &anDom, double angleRotation, ImageDirection rotationDir){ DGtal::PointVector<3, int> pt; pt[0] = (int) (anDom.point1[0]+anDom.point2[0]+anDom.point3[0]+anDom.point4[0])/4.0; @@ -75,20 +75,20 @@ DGtal::Viewer3D::rotateDomain(Image2DDomainD3D &anDom, double ang pt[2] = (int) (anDom.point1[2]+anDom.point2[2]+anDom.point3[2]+anDom.point4[2])/4.0; rotateImageVertex(anDom, angleRotation, rotationDir); - std::vector::LineD3D> &aVectLine = Viewer3D::myLineSetList.at(anDom.myLineSetIndex); + std::vector::LineD3D> &aVectLine = Viewer3D::myLineSetList.at(anDom.myLineSetIndex); for(unsigned int i = 0; i< aVectLine.size();i++){ - typename DGtal::Display3D::LineD3D &aLine = aVectLine.at(i); + typename DGtal::Display3D::LineD3D &aLine = aVectLine.at(i); rotateLineD3D(aLine, pt, angleRotation, rotationDir ); } } -template < typename Space ,typename KSpace > +template < typename TSpace, typename TKSpace > template inline void -DGtal::Viewer3D::rotatePoint(TValues &x, TValues &y, TValues &z, +DGtal::Viewer3D::rotatePoint(TValues &x, TValues &y, TValues &z, double cx, double cy, double cz, double angleRotation, ImageDirection rotationDir){ double dx = x-cx; double dy = y-cy; double dz = z-cz; @@ -109,11 +109,11 @@ DGtal::Viewer3D::rotatePoint(TValues &x, TValues &y, TValues &z, -template < typename Space ,typename KSpace > +template < typename TSpace, typename TKSpace > template < typename TContainer > inline void -DGtal::Viewer3D::rotateLineD3D(typename DGtal::Display3D::LineD3D &aLine, +DGtal::Viewer3D::rotateLineD3D(typename DGtal::Display3D::LineD3D &aLine, DGtal::PointVector<3, int, TContainer> pt, double angleRotation, ImageDirection dirRotation){ double dx1 = aLine.point1[0] - pt[0]; double dy1 = aLine.point1[1] - pt[1]; double dz1 = aLine.point1[2] - pt[2]; @@ -144,48 +144,48 @@ DGtal::Viewer3D::rotateLineD3D(typename DGtal::Display3D +template < typename TSpace, typename TKSpace > inline unsigned int -DGtal::Viewer3D< Space ,KSpace >::getCurrentDomainNumber() +DGtal::Viewer3D::getCurrentDomainNumber() { return myImageDomainList.size(); } -template < typename Space ,typename KSpace > +template < typename TSpace, typename TKSpace > inline unsigned int -DGtal::Viewer3D< Space ,KSpace >::getCurrentGLImageNumber() +DGtal::Viewer3D::getCurrentGLImageNumber() { return myGSImageList.size(); } -template < typename Space ,typename KSpace > +template < typename TSpace, typename TKSpace > inline void -DGtal::Viewer3D< Space ,KSpace >::addTextureImage(const typename Viewer3D< Space ,KSpace >::TextureImage &image) +DGtal::Viewer3D::addTextureImage(const typename Viewer3D::TextureImage &image) { myGSImageList.push_back(image); - Display3D< Space, KSpace>::updateBoundingBox(image.point1); - Display3D< Space, KSpace>::updateBoundingBox(image.point2); - Display3D< Space, KSpace>::updateBoundingBox(image.point3); - Display3D< Space, KSpace>::updateBoundingBox(image.point4); + Display3D::updateBoundingBox(image.point1); + Display3D::updateBoundingBox(image.point2); + Display3D::updateBoundingBox(image.point3); + Display3D::updateBoundingBox(image.point4); } -template < typename Space ,typename KSpace > +template < typename TSpace, typename TKSpace > template < typename TImageType, typename TFunctor > inline void -DGtal::Viewer3D< Space ,KSpace >::updateTextureImage(unsigned int imageIndex, const TImageType & image, const TFunctor & aFunctor, +DGtal::Viewer3D::updateTextureImage(unsigned int imageIndex, const TImageType & image, const TFunctor & aFunctor, double xTranslation, double yTranslation, double zTranslation, double rotationAngle, ImageDirection rotationDir) { BOOST_CONCEPT_ASSERT(( concepts::CConstImage < TImageType > )); assert ( imageIndex< myGSImageList.size()); - typename Viewer3D< Space ,KSpace >::TextureImage &anImage = myGSImageList.at(imageIndex); + typename Viewer3D::TextureImage &anImage = myGSImageList.at(imageIndex); Display::updateBoundingBox(RealPoint(anImage.point1[0]+xTranslation, anImage.point1[1]+yTranslation, anImage.point1[2]+zTranslation)); @@ -211,21 +211,21 @@ DGtal::Viewer3D< Space ,KSpace >::updateTextureImage(unsigned int imageIndex, co } -template < typename Space ,typename KSpace > +template < typename TSpace, typename TKSpace > inline void -DGtal::Viewer3D< Space ,KSpace >::updateOrientationTextureImage(unsigned int imageIndex, +DGtal::Viewer3D::updateOrientationTextureImage(unsigned int imageIndex, double xPosition, double yPosition, double zPosition, ImageDirection newDirection) { assert ( imageIndex< myGSImageList.size()); - typename Viewer3D< Space ,KSpace >::TextureImage &anImage = myGSImageList.at(imageIndex); - Display3D< Space, KSpace>::updateBoundingBox(anImage.point1); - Display3D< Space, KSpace>::updateBoundingBox(anImage.point2); - Display3D< Space, KSpace>::updateBoundingBox(anImage.point3); - Display3D< Space, KSpace>::updateBoundingBox(anImage.point4); + typename Viewer3D::TextureImage &anImage = myGSImageList.at(imageIndex); + Display3D::updateBoundingBox(anImage.point1); + Display3D::updateBoundingBox(anImage.point2); + Display3D::updateBoundingBox(anImage.point3); + Display3D::updateBoundingBox(anImage.point4); anImage.updateImageOrientation(newDirection, xPosition, yPosition, zPosition); if(anImage.myDrawDomain) { @@ -236,29 +236,29 @@ DGtal::Viewer3D< Space ,KSpace >::updateOrientationTextureImage(unsigned int ima } } -template < typename Space ,typename KSpace > +template < typename TSpace, typename TKSpace > inline void -DGtal::Viewer3D::updateEmbeddingTextureImage(unsigned int anImageIndex, +DGtal::Viewer3D::updateEmbeddingTextureImage(unsigned int anImageIndex, typename Space::Point aPoint1, typename Space::Point aPoint2, typename Space::Point aPoint3, typename Space::Point aPoint4) { assert ( anImageIndex< myGSImageList.size()); - typename Viewer3D< Space ,KSpace >::TextureImage &anImage = myGSImageList.at(anImageIndex); - Display3D< Space, KSpace>::updateBoundingBox(aPoint1); - Display3D< Space, KSpace>::updateBoundingBox(aPoint2); - Display3D< Space, KSpace>::updateBoundingBox(aPoint3); - Display3D< Space, KSpace>::updateBoundingBox(aPoint4); + typename Viewer3D::TextureImage &anImage = myGSImageList.at(anImageIndex); + Display3D::updateBoundingBox(aPoint1); + Display3D::updateBoundingBox(aPoint2); + Display3D::updateBoundingBox(aPoint3); + Display3D::updateBoundingBox(aPoint4); anImage.updateImage3DEmbedding(aPoint1, aPoint2, aPoint3, aPoint4); } -template < typename Space ,typename KSpace > +template < typename TSpace, typename TKSpace > inline void -DGtal::Viewer3D< Space ,KSpace >::TextureImage::updateImageOrientation( ImageDirection normalDir, +DGtal::Viewer3D::TextureImage::updateImageOrientation( ImageDirection normalDir, double xBottomLeft, double yBottomLeft, double zBottomLeft) { if(normalDir==zDirection) @@ -283,10 +283,10 @@ DGtal::Viewer3D< Space ,KSpace >::TextureImage::updateImageOrientation( ImageDir myDirection=normalDir; } -template < typename Space ,typename KSpace > +template < typename TSpace, typename TKSpace > inline void -DGtal::Viewer3D< Space ,KSpace >::Image2DDomainD3D::updateDomainOrientation(ImageDirection normalDir, +DGtal::Viewer3D::Image2DDomainD3D::updateDomainOrientation(ImageDirection normalDir, double xBottomLeft, double yBottomLeft, double zBottomLeft) { if(normalDir==zDirection) @@ -312,10 +312,10 @@ DGtal::Viewer3D< Space ,KSpace >::Image2DDomainD3D::updateDomainOrientation(Imag } -template < typename Space ,typename KSpace > +template < typename TSpace, typename TKSpace > inline void -DGtal::Viewer3D< Space ,KSpace >::Image2DDomainD3D::translateDomain (double xTranslation, +DGtal::Viewer3D::Image2DDomainD3D::translateDomain (double xTranslation, double yTranslation, double zTranslation) { @@ -326,36 +326,36 @@ DGtal::Viewer3D< Space ,KSpace >::Image2DDomainD3D::translateDomain (double xTra } -template < typename Space ,typename KSpace > +template < typename TSpace, typename TKSpace > template < typename TDomain> void -DGtal::Viewer3D< Space ,KSpace >::addImage2DDomainD3D(const TDomain &aDomain, +DGtal::Viewer3D::addImage2DDomainD3D(const TDomain &aDomain, std::string mode, const DGtal::Color &aColor) { - typename DGtal::Viewer3D< Space ,KSpace >::Image2DDomainD3D anImageDomain(aDomain); + typename DGtal::Viewer3D::Image2DDomainD3D anImageDomain(aDomain); anImageDomain.color = aColor; anImageDomain.myMode = mode; - anImageDomain.myLineSetIndex=Viewer3D::myLineSetList.size(); + anImageDomain.myLineSetIndex=Viewer3D::myLineSetList.size(); myImageDomainList.push_back(anImageDomain); - Display3D< Space, KSpace>::updateBoundingBox(anImageDomain.point1); - Display3D< Space, KSpace>::updateBoundingBox(anImageDomain.point2); - Display3D< Space, KSpace>::updateBoundingBox(anImageDomain.point3); - Display3D< Space, KSpace>::updateBoundingBox(anImageDomain.point4); + Display3D::updateBoundingBox(anImageDomain.point1); + Display3D::updateBoundingBox(anImageDomain.point2); + Display3D::updateBoundingBox(anImageDomain.point3); + Display3D::updateBoundingBox(anImageDomain.point4); - std::vector::LineD3D> vectLines= compute2DDomainLineRepresentation(anImageDomain); - Viewer3D::myLineSetList.push_back(vectLines); + std::vector::LineD3D> vectLines= compute2DDomainLineRepresentation(anImageDomain); + Viewer3D::myLineSetList.push_back(vectLines); } -template < typename Space ,typename KSpace > +template < typename TSpace, typename TKSpace > inline -std::vector::LineD3D> -DGtal::Viewer3D< Space ,KSpace >::compute2DDomainLineRepresentation( typename DGtal::Viewer3D< Space ,KSpace >::Image2DDomainD3D &anImageDomain ) +std::vector::LineD3D> +DGtal::Viewer3D::compute2DDomainLineRepresentation( typename DGtal::Viewer3D::Image2DDomainD3D &anImageDomain ) { - std::vector::LineD3D> vectLinesResu= compute2DDomainLineRepresentation(anImageDomain, 0.05); - std::vector::LineD3D> vectLinesVerso= compute2DDomainLineRepresentation(anImageDomain, -0.05); + std::vector::LineD3D> vectLinesResu= compute2DDomainLineRepresentation(anImageDomain, 0.05); + std::vector::LineD3D> vectLinesVerso= compute2DDomainLineRepresentation(anImageDomain, -0.05); for(unsigned int i=0; i::compute2DDomainLineRepresentation( typename DG } -template < typename Space ,typename KSpace > +template < typename TSpace, typename TKSpace > inline -std::vector::LineD3D> -DGtal::Viewer3D< Space ,KSpace >::compute2DDomainLineRepresentation(typename DGtal::Viewer3D< Space ,KSpace >::Image2DDomainD3D &anImageDomain, double delta ) +std::vector::LineD3D> +DGtal::Viewer3D::compute2DDomainLineRepresentation(typename DGtal::Viewer3D::Image2DDomainD3D &anImageDomain, double delta ) { - std::vector::LineD3D> aLineSet; - typename Viewer3D::LineD3D aLine; + std::vector::LineD3D> aLineSet; + typename Viewer3D::LineD3D aLine; aLine.color = anImageDomain.color; aLine.width=0.1; @@ -499,24 +499,24 @@ DGtal::Viewer3D< Space ,KSpace >::compute2DDomainLineRepresentation(typename DGt } -template < typename Space ,typename KSpace > +template < typename TSpace, typename TKSpace > inline void -DGtal::Viewer3D< Space ,KSpace >::updateAn2DDomainOrientation(unsigned int domainIndex, +DGtal::Viewer3D::updateAn2DDomainOrientation(unsigned int domainIndex, double xPosition, double yPosition, double zPosition, ImageDirection newDirection) { ASSERT( domainIndex < myImageDomainList.size()); - typename Viewer3D< Space ,KSpace >::Image2DDomainD3D &aDomain = myImageDomainList.at(domainIndex); + typename Viewer3D::Image2DDomainD3D &aDomain = myImageDomainList.at(domainIndex); - Display3D< Space, KSpace>::updateBoundingBox(aDomain.point1); - Display3D< Space, KSpace>::updateBoundingBox(aDomain.point2); - Display3D< Space, KSpace>::updateBoundingBox(aDomain.point3); - Display3D< Space, KSpace>::updateBoundingBox(aDomain.point4); + Display3D::updateBoundingBox(aDomain.point1); + Display3D::updateBoundingBox(aDomain.point2); + Display3D::updateBoundingBox(aDomain.point3); + Display3D::updateBoundingBox(aDomain.point4); aDomain.updateDomainOrientation(newDirection, xPosition, yPosition, zPosition); - std::vector::LineD3D> vectNewLines= compute2DDomainLineRepresentation(aDomain); - std::vector::LineD3D> &vectLines = Viewer3D::myLineSetList.at(aDomain.myLineSetIndex); + std::vector::LineD3D> vectNewLines= compute2DDomainLineRepresentation(aDomain); + std::vector::LineD3D> &vectLines = Viewer3D::myLineSetList.at(aDomain.myLineSetIndex); vectLines.clear(); for(unsigned int i=0; i::updateAn2DDomainOrientation(unsigned int domai } -template < typename Space ,typename KSpace > +template < typename TSpace, typename TKSpace > inline void -DGtal::Viewer3D< Space ,KSpace >::translateAn2DDomain(unsigned int domainIndex, double xTranslation, double yTranslation, double zTranslation) +DGtal::Viewer3D::translateAn2DDomain(unsigned int domainIndex, double xTranslation, double yTranslation, double zTranslation) { - typename Viewer3D< Space ,KSpace >::Image2DDomainD3D &anDomain = myImageDomainList.at(domainIndex); + typename Viewer3D::Image2DDomainD3D &anDomain = myImageDomainList.at(domainIndex); anDomain.translateDomain(xTranslation, yTranslation, zTranslation); - Display3D< Space, KSpace>::updateBoundingBox(anDomain.point1); - Display3D< Space, KSpace>::updateBoundingBox(anDomain.point2); - Display3D< Space, KSpace>::updateBoundingBox(anDomain.point3); - Display3D< Space, KSpace>::updateBoundingBox(anDomain.point4); + Display3D::updateBoundingBox(anDomain.point1); + Display3D::updateBoundingBox(anDomain.point2); + Display3D::updateBoundingBox(anDomain.point3); + Display3D::updateBoundingBox(anDomain.point4); - std::vector::LineD3D> &vectLines = Viewer3D::myLineSetList.at(anDomain.myLineSetIndex); + std::vector::LineD3D> &vectLines = Viewer3D::myLineSetList.at(anDomain.myLineSetIndex); for(unsigned int i=0; i::LineD3D &aLine = vectLines.at(i); + typename DGtal::Display3D::LineD3D &aLine = vectLines.at(i); aLine.point1[0]=aLine.point1[0]+xTranslation; aLine.point1[1]=aLine.point1[1]+yTranslation; aLine.point1[2]=aLine.point1[2]+zTranslation; aLine.point2[0]=aLine.point2[0]+xTranslation; aLine.point2[1]=aLine.point2[1]+yTranslation; aLine.point2[2]=aLine.point2[2]+zTranslation; } } -template < typename Space ,typename KSpace > +template < typename TSpace, typename TKSpace > inline std::string -DGtal::Viewer3D< Space ,KSpace >::TextureImage::className() const +DGtal::Viewer3D::TextureImage::className() const { return "TextureImage"; } -template +template inline -DGtal::Viewer3D & -DGtal::Viewer3D::operator<<(const DGtal::Color & aColor) +DGtal::Viewer3D & +DGtal::Viewer3D::operator<<(const DGtal::Color & aColor) { myDefaultColor=aColor; return *this; } -template +template inline -DGtal::Viewer3D & -DGtal::Viewer3D::operator<<(const typename Viewer3D::StreamKey & key) +DGtal::Viewer3D & +DGtal::Viewer3D::operator<<(const typename Viewer3D::StreamKey & key) { switch (key) { - case Viewer3D::updateDisplay: - Viewer3D::updateList(); + case Viewer3D::updateDisplay: + Viewer3D::updateList(); break; - case Viewer3D::addNewList: - Viewer3D::createNewCubeList(); + case Viewer3D::addNewList: + Viewer3D::createNewCubeList(); break; - case Viewer3D::shiftSurfelVisu: - Viewer3D::myCurrentfShiftVisuPrisms+=0.3; + case Viewer3D::shiftSurfelVisu: + Viewer3D::myCurrentfShiftVisuPrisms+=0.3; break; } return *this; } -template +template template inline -DGtal::Viewer3D & -DGtal::Viewer3D::operator<<( const TDrawableWithViewer3D & object ) +DGtal::Viewer3D & +DGtal::Viewer3D::operator<<( const TDrawableWithViewer3D & object ) { BOOST_CONCEPT_ASSERT((concepts::CDrawableWithViewer3D< TDrawableWithViewer3D, Space, KSpace >)); - DGtal::Viewer3DFactory::draw(*this, object); + DGtal::Viewer3DFactory::draw(*this, object); return *this; } @@ -602,11 +602,11 @@ DGtal::Viewer3D::operator<<( const TDrawableWithViewer3D & object /////////////////////////////////////////////////////////////////////////////// // Implementation of inline functions and external operators // -template +template inline std::ostream& DGtal::operator<< ( std::ostream & out, - const Viewer3D & object ) + const Viewer3D & object ) { object.selfDisplay ( out ); return out; @@ -632,40 +632,41 @@ DGtal::operator<< ( std::ostream & out, // end of surcharge // /////////////////////////////////////////////////////////////////////////////// -template< typename Space, typename KSpace> +template< typename TSpace, typename TKSpace> inline void -DGtal::Viewer3D::drawWithNames() +DGtal::Viewer3D::drawWithNames() { // JOL: 2014/10/15. This method is called only when the user tries // to select some graphic object through QGLViewer. By default, // selection is left clic + shift key. // JOL: 2014/10/15. This is my addition for interacting with // quads. Seems to work well. + if ( myExtension != 0 ) myExtension->drawWithNames( *this ); glCallList ( myQuadsMapId ); glCallList ( myCubesMapId ); - for ( unsigned int i=0; i::myLineSetList.size(); i++ ) + for ( unsigned int i=0; i::myLineSetList.size(); i++ ) { glCallList ( myLineSetListId+i ); } - for ( unsigned int i=0; i::myBallSetList.size(); i++ ) + for ( unsigned int i=0; i::myBallSetList.size(); i++ ) { glCallList(myBallSetListId+i); } } -template< typename Space, typename KSpace> +template< typename TSpace, typename TKSpace> inline void -DGtal::Viewer3D::draw() +DGtal::Viewer3D::draw() { - + if ( myExtension != 0 ) myExtension->draw( *this ); glPushMatrix(); glMultMatrixd ( manipulatedFrame()->matrix() ); @@ -683,10 +684,10 @@ DGtal::Viewer3D::draw() glLightfv(GL_LIGHT0, GL_POSITION, myLightPosition); unsigned int i = 0; - typename vector< typename Viewer3D::ClippingPlaneD3D >::const_iterator it = Viewer3D::myClippingPlaneList.begin(); + typename vector< typename Viewer3D::ClippingPlaneD3D >::const_iterator it = Viewer3D::myClippingPlaneList.begin(); // OpenGL can't draw more than GL_MAX_CLIP_PLANES clipping plane - while ( i < GL_MAX_CLIP_PLANES && it !=Viewer3D::myClippingPlaneList.end() ) + while ( i < GL_MAX_CLIP_PLANES && it !=Viewer3D::myClippingPlaneList.end() ) { double eq [4]; eq[0]=it->a; @@ -733,12 +734,12 @@ DGtal::Viewer3D::draw() } - for ( unsigned int j=0; j< Viewer3D::myLineSetList.size(); j++ ) + for ( unsigned int j=0; j< Viewer3D::myLineSetList.size(); j++ ) { - if ( Viewer3D::myLineSetList.at ( j ).size() !=0 ) + if ( Viewer3D::myLineSetList.at ( j ).size() !=0 ) { glLineWidth ( max(myGLLineMinWidth, - Viewer3D::myLineSetList.at ( j ).at ( 0 ).width )) ; + Viewer3D::myLineSetList.at ( j ).at ( 0 ).width )) ; } glCallList(myLineSetListId+j); } @@ -748,14 +749,14 @@ DGtal::Viewer3D::draw() glCallList( myCubesMapId ); - for ( unsigned int j=0; j< Viewer3D::myBallSetList.size(); j++ ) + for ( unsigned int j=0; j< Viewer3D::myBallSetList.size(); j++ ) { if(myUseGLPointsForBalls) { - if ( Viewer3D::myBallSetList.at ( j ).size() !=0 ) + if ( Viewer3D::myBallSetList.at ( j ).size() !=0 ) { glPointSize ( max(myGLPointMinWidth, - ( Viewer3D::myBallSetList.at ( j ).at ( 0 ).radius ) )); + ( Viewer3D::myBallSetList.at ( j ).at ( 0 ).radius ) )); } } else @@ -769,7 +770,7 @@ DGtal::Viewer3D::draw() glCallList(myQuadsMapId); if(myViewWire) { - glLineWidth ( max(myGLLineMinWidth,Viewer3D::myMeshDefaultLineWidth /distCam )); + glLineWidth ( max(myGLLineMinWidth,Viewer3D::myMeshDefaultLineWidth /distCam )); glCallList(myQuadsMapWiredId); } @@ -778,7 +779,7 @@ DGtal::Viewer3D::draw() if(myViewWire) { glLineWidth ( max(myGLLineMinWidth, - Viewer3D::myMeshDefaultLineWidth /distCam )); + Viewer3D::myMeshDefaultLineWidth /distCam )); glCallList(myTriangleSetListWiredId); } @@ -787,7 +788,7 @@ DGtal::Viewer3D::draw() if(myViewWire) { glLineWidth (max(myGLLineMinWidth, - Viewer3D::myMeshDefaultLineWidth /distCam )); + Viewer3D::myMeshDefaultLineWidth /distCam )); glCallList(myPolygonSetListWiredId); } @@ -800,25 +801,26 @@ DGtal::Viewer3D::draw() } -template< typename Space, typename KSpace> +template< typename TSpace, typename TKSpace> void -DGtal::Viewer3D::selfDisplay ( std::ostream & out ) const +DGtal::Viewer3D::selfDisplay ( std::ostream & out ) const { out << "[Viewer3D]"; } -template< typename Space, typename KSpace> +template< typename TSpace, typename TKSpace> bool -DGtal::Viewer3D::isValid() const +DGtal::Viewer3D::isValid() const { return true; } -template< typename Space, typename KSpace> +template< typename TSpace, typename TKSpace> void -DGtal::Viewer3D::init() +DGtal::Viewer3D::init() { + if ( myExtension != 0 ) myExtension->init( *this ); myAutoSaveState = false; myIsMovingLight = false; myLigthRotationStep = 0.01; @@ -847,34 +849,34 @@ DGtal::Viewer3D::init() glEnable(GL_LIGHT0); glEnable(GL_DEPTH_TEST); - Viewer3D::myMeshDefaultLineWidth=10.0; + Viewer3D::myMeshDefaultLineWidth=10.0; myNbListe=0; myViewWire=false; setBackgroundColor ( QColor ( 217, 228, 255 ) ); setForegroundColor ( QColor ( 217, 22, 25 ) ); - Viewer3D::createNewCubeList ( ); - vector::LineD3D> listeLine; - Viewer3D::myLineSetList.push_back ( listeLine ); - vector::BallD3D> listeBall; - Viewer3D::myBallSetList.push_back ( listeBall ); - Viewer3D::myCurrentFillColor = Color ( 220, 220, 220 ); - Viewer3D::myCurrentLineColor = Color ( 22, 22, 222, 50 ); + Viewer3D::createNewCubeList ( ); + vector::LineD3D> listeLine; + Viewer3D::myLineSetList.push_back ( listeLine ); + vector::BallD3D> listeBall; + Viewer3D::myBallSetList.push_back ( listeBall ); + Viewer3D::myCurrentFillColor = Color ( 220, 220, 220 ); + Viewer3D::myCurrentLineColor = Color ( 22, 22, 222, 50 ); myDefaultBackgroundColor = Color ( backgroundColor().red(), backgroundColor().green(), backgroundColor().blue() ); myIsBackgroundDefault=true; - Viewer3D::myBoundingPtLow[0]=-10.0;//numeric_limits::max( ); - Viewer3D::myBoundingPtLow[1]=-10.0;//numeric_limits::max( ); - Viewer3D::myBoundingPtLow[2]=-10.0;//numeric_limits::max( ); - - Viewer3D::myBoundingPtUp[0]=-10.0;//numeric_limits::min( ); - Viewer3D::myBoundingPtUp[1]=-10.0;//numeric_limits::min( ); - Viewer3D:: myBoundingPtUp[2]=-10.0;//numeric_limits::min( ); - Viewer3D::createNewCubeList ( ); - typename std::vector< typename Viewer3D::CubeD3D> aKSCubeList; - - Viewer3D::myCurrentfShiftVisuPrisms=0.0; - Viewer3D::myDefaultColor= Color ( 255, 255, 255 ); + Viewer3D::myBoundingPtLow[0]=-10.0;//numeric_limits::max( ); + Viewer3D::myBoundingPtLow[1]=-10.0;//numeric_limits::max( ); + Viewer3D::myBoundingPtLow[2]=-10.0;//numeric_limits::max( ); + + Viewer3D::myBoundingPtUp[0]=-10.0;//numeric_limits::min( ); + Viewer3D::myBoundingPtUp[1]=-10.0;//numeric_limits::min( ); + Viewer3D:: myBoundingPtUp[2]=-10.0;//numeric_limits::min( ); + Viewer3D::createNewCubeList ( ); + typename std::vector< typename Viewer3D::CubeD3D> aKSCubeList; + + Viewer3D::myCurrentfShiftVisuPrisms=0.0; + Viewer3D::myDefaultColor= Color ( 255, 255, 255 ); camera()->showEntireScene(); setKeyDescription ( Qt::Key_E, "Export the current display into OFF file (just Cube, surfel and SurfelPrism for now)." ); setKeyDescription ( Qt::Key_W, "Switch display with and without wired view of triangle and quad faces." ); @@ -886,7 +888,6 @@ DGtal::Viewer3D::init() setKeyDescription ( Qt::Key_R, "Reset default scale for 3 axes to 1.0f." ); setKeyDescription ( Qt::Key_D, "Enable/Disable the two side face rendering." ); setKeyDescription ( Qt::Key_O, "Switch the ball display mode (quad ball display (default) or OpenGL point)." ); - setKeyDescription ( Qt::Key_R, "Reset default scale for 3 axes to 1.0f." ); setKeyDescription ( Qt::Key_M, "Switch the rendering mode bewteen Default, Metallic and Plastic mode." ); setKeyDescription ( Qt::Key_P, "Switch the light source position mode between the camera mode (default: the light source position is fixed according to the camera position) and scene mode (the light source position is fixed according the scene coordinate system)." ); #if !defined (QGLVIEWER_VERSION) || QGLVIEWER_VERSION < 0x020500 @@ -908,34 +909,34 @@ DGtal::Viewer3D::init() } -template< typename Space, typename KSpace> +template< typename TSpace, typename TKSpace> void -DGtal::Viewer3D::sortSurfelFromCamera() +DGtal::Viewer3D::sortSurfelFromCamera() { CompFarthestVoxelFromCamera comp; comp.posCam= camera()->position(); - for (auto &mapElem: Viewer3D::myCubesMap) + for (auto &mapElem: Viewer3D::myCubesMap) { DGtal::trace.info() << "sort quad size" << mapElem.second.size() << std::endl; sort ( mapElem.second.begin(), mapElem.second.end(), comp ); } CompFarthestSurfelFromCamera compSurf; - DGtal::trace.info() << "sort surfel size" << Viewer3D::myPrismList.size() << std::endl; - sort ( Viewer3D::myPrismList.begin(), Viewer3D::myPrismList.end(), compSurf ); + DGtal::trace.info() << "sort surfel size" << Viewer3D::myPrismList.size() << std::endl; + sort ( Viewer3D::myPrismList.begin(), Viewer3D::myPrismList.end(), compSurf ); } -template< typename Space, typename KSpace> +template< typename TSpace, typename TKSpace> void -DGtal::Viewer3D::sortTriangleFromCamera() +DGtal::Viewer3D::sortTriangleFromCamera() { CompFarthestTriangleFromCamera comp; comp.posCam= camera()->position(); - for (auto &listElem: Viewer3D::myTriangleSetList) + for (auto &listElem: Viewer3D::myTriangleSetList) { sort ( listElem.begin(), listElem.end(), comp ); } @@ -943,14 +944,14 @@ DGtal::Viewer3D::sortTriangleFromCamera() -template< typename Space, typename KSpace> +template< typename TSpace, typename TKSpace> void -DGtal::Viewer3D::sortQuadFromCamera() +DGtal::Viewer3D::sortQuadFromCamera() { CompFarthestSurfelFromCamera comp; comp.posCam= camera()->position(); - for (auto &listElem: Viewer3D::myQuadsMap) + for (auto &listElem: Viewer3D::myQuadsMap) { DGtal::trace.info() << "sort quad size" << listElem.second.size() << std::endl; sort ( listElem.second.begin(), listElem.second.end(), comp ); @@ -958,14 +959,14 @@ DGtal::Viewer3D::sortQuadFromCamera() } -template< typename Space, typename KSpace> +template< typename TSpace, typename TKSpace> void -DGtal::Viewer3D::sortPolygonFromCamera() +DGtal::Viewer3D::sortPolygonFromCamera() { CompFarthestPolygonFromCamera comp; comp.posCam= camera()->position(); - for (auto &listElem: Viewer3D::myPolygonSetList) + for (auto &listElem: Viewer3D::myPolygonSetList) { DGtal::trace.info() << "sort polygon size" << listElem.size() << std::endl; sort ( listElem.begin(), listElem.end(), comp ); @@ -976,10 +977,15 @@ DGtal::Viewer3D::sortPolygonFromCamera() -template< typename Space, typename KSpace> +template< typename TSpace, typename TKSpace> void -DGtal::Viewer3D::postSelection ( const QPoint& point ) +DGtal::Viewer3D::postSelection ( const QPoint& point ) { + bool handled = false; + if ( myExtension != 0 ) + handled = myExtension->postSelection( *this, point ); + if ( handled ) return; + camera()->convertClickToLine ( point, myOrig, myDir ); bool found; this->myPosSelector= point; @@ -1003,9 +1009,9 @@ DGtal::Viewer3D::postSelection ( const QPoint& point ) -template< typename Space, typename KSpace> +template< typename TSpace, typename TKSpace> void -DGtal::Viewer3D::updateList ( bool needToUpdateBoundingBox ) +DGtal::Viewer3D::updateList ( bool needToUpdateBoundingBox ) { // glDeleteLists @@ -1022,10 +1028,10 @@ DGtal::Viewer3D::updateList ( bool needToUpdateBoundingBox ) // Storing ID for each list myCubesMapId = glGenLists(1); - myLineSetListId = glGenLists(Viewer3D::myLineSetList.size()); - myNbLineSetList = Viewer3D::myLineSetList.size(); - myBallSetListId = glGenLists(Viewer3D::myBallSetList.size()); - myNbBallSetList = Viewer3D::myBallSetList.size(); + myLineSetListId = glGenLists(Viewer3D::myLineSetList.size()); + myNbLineSetList = Viewer3D::myLineSetList.size(); + myBallSetListId = glGenLists(Viewer3D::myBallSetList.size()); + myNbBallSetList = Viewer3D::myBallSetList.size(); myTriangleSetListId = glGenLists(1); myTriangleSetListWiredId = glGenLists(1); myCubeSetListWiredId = glGenLists(1); @@ -1045,72 +1051,73 @@ DGtal::Viewer3D::updateList ( bool needToUpdateBoundingBox ) - glCreateListCubesMaps(Viewer3D::myCubesMap, myCubesMapId); + glCreateListCubesMaps(Viewer3D::myCubesMap, myCubesMapId); - glCreateListQuadD3D(Viewer3D::myPrismList, myPrismListId); + glCreateListQuadD3D(Viewer3D::myPrismList, myPrismListId); myNbListe++; - for ( unsigned int j=0; j::myLineSetList.size(); j++ ) + for ( unsigned int j=0; j::myLineSetList.size(); j++ ) { - glCreateListLines(Viewer3D::myLineSetList.at(j), myLineSetListId+j); + glCreateListLines(Viewer3D::myLineSetList.at(j), myLineSetListId+j); myNbListe++; } - for ( unsigned int j=0; j::myBallSetList.size(); j++ ) + for ( unsigned int j=0; j::myBallSetList.size(); j++ ) { - glCreateListBalls(Viewer3D::myBallSetList.at (j), myBallSetListId+j); + glCreateListBalls(Viewer3D::myBallSetList.at (j), myBallSetListId+j); myNbListe++; } // First list: quad faces. - glCreateListQuadMaps(Viewer3D::myQuadsMap, myQuadsMapId); + glCreateListQuadMaps(Viewer3D::myQuadsMap, myQuadsMapId); myNbListe++; // Second list: Wired version of quad face. - glCreateListQuadMapsWired(Viewer3D::myQuadsMap,myQuadsMapWiredId); + glCreateListQuadMapsWired(Viewer3D::myQuadsMap,myQuadsMapWiredId); myNbListe++; // Third list: Triangle faces. - glCreateListTriangles( Viewer3D::myTriangleSetList, myTriangleSetListId); + glCreateListTriangles( Viewer3D::myTriangleSetList, myTriangleSetListId); myNbListe++; // Fourth list: Wired version of triangle face. - glCreateListTrianglesWired(Viewer3D::myTriangleSetList, myTriangleSetListWiredId); + glCreateListTrianglesWired(Viewer3D::myTriangleSetList, myTriangleSetListWiredId); myNbListe++; // Fifth list: Polygonal faces. - glCreateListPolygons(Viewer3D::myPolygonSetList, myPolygonSetListId); + glCreateListPolygons(Viewer3D::myPolygonSetList, myPolygonSetListId); myNbListe++; // Sixth list: Wired version of polygonal face. - glCreateListPolygonsWired(Viewer3D::myPolygonSetList, myPolygonSetListWiredId); + glCreateListPolygonsWired(Viewer3D::myPolygonSetList, myPolygonSetListWiredId); myNbListe++; // Seventh list: Textured images. glUpdateTextureImages(myGSImageList); - - if ( needToUpdateBoundingBox ) + if ( needToUpdateBoundingBox && Viewer3D::myBoundingPtChangedTag ) { - setSceneBoundingBox ( qglviewer::Vec ( Viewer3D::myBoundingPtLow[0], - Viewer3D::myBoundingPtLow[1], - Viewer3D::myBoundingPtLow[2] ), - qglviewer::Vec ( Viewer3D::myBoundingPtUp[0], - Viewer3D::myBoundingPtUp[1], - Viewer3D::myBoundingPtUp[2] ) ); + setSceneBoundingBox ( qglviewer::Vec ( Viewer3D::myBoundingPtLow[0], + Viewer3D::myBoundingPtLow[1], + Viewer3D::myBoundingPtLow[2] ), + qglviewer::Vec ( Viewer3D::myBoundingPtUp[0], + Viewer3D::myBoundingPtUp[1], + Viewer3D::myBoundingPtUp[2] ) ); showEntireScene(); + Viewer3D::myBoundingPtChangedTag = false; } + updateGL(); glPopMatrix(); } -template< typename Space, typename KSpace> +template< typename TSpace, typename TKSpace> void -DGtal::Viewer3D::glDrawGLBall (const typename Viewer3D::BallD3D &aBall ) +DGtal::Viewer3D::glDrawGLBall (const typename Viewer3D::BallD3D &aBall ) { double thetaResolution = aBall.resolution; double thetaStep= (2.0*M_PI)/thetaResolution; @@ -1140,10 +1147,18 @@ DGtal::Viewer3D::glDrawGLBall (const typename Viewer3D +template< typename TSpace, typename TKSpace> void -DGtal::Viewer3D::mousePressEvent ( QMouseEvent *e ) +DGtal::Viewer3D::mousePressEvent ( QMouseEvent *e ) { + bool handled = false; + // Checks if an extension is present. + if ( myExtension != 0 ) + { + handled = myExtension->mousePressEvent( *this, e ); + if ( handled ) return; + } + if(e->modifiers() == (Qt::ControlModifier|Qt::ShiftModifier)) { myIsMovingLight=true; @@ -1165,10 +1180,18 @@ DGtal::Viewer3D::mousePressEvent ( QMouseEvent *e ) } } -template< typename Space, typename KSpace> +template< typename TSpace, typename TKSpace> void -DGtal::Viewer3D::mouseReleaseEvent ( QMouseEvent *e ) +DGtal::Viewer3D::mouseReleaseEvent ( QMouseEvent *e ) { + bool handled = false; + // Checks if an extension is present. + if ( myExtension != 0 ) + { + handled = myExtension->mouseReleaseEvent( *this, e ); + if ( handled ) return; + } + if(e->modifiers() == (Qt::ControlModifier|Qt::ShiftModifier) || myIsMovingLight){ myIsMovingLight=false; updateGL(); @@ -1177,10 +1200,18 @@ DGtal::Viewer3D::mouseReleaseEvent ( QMouseEvent *e ) } } -template< typename Space, typename KSpace> +template< typename TSpace, typename TKSpace> void -DGtal::Viewer3D::mouseMoveEvent ( QMouseEvent *e ) +DGtal::Viewer3D::mouseMoveEvent ( QMouseEvent *e ) { + bool handled = false; + // Checks if an extension is present. + if ( myExtension != 0 ) + { + handled = myExtension->mouseMoveEvent( *this, e ); + if ( handled ) return; + } + if(e->modifiers() == (Qt::ControlModifier|Qt::ShiftModifier)){ int varX = e->x() - myRefMouseXPos; int varY = e->y() - myRefMouseYPos; @@ -1204,11 +1235,17 @@ DGtal::Viewer3D::mouseMoveEvent ( QMouseEvent *e ) -template< typename Space, typename KSpace> +template< typename TSpace, typename TKSpace> void -DGtal::Viewer3D::keyPressEvent ( QKeyEvent *e ) +DGtal::Viewer3D::keyPressEvent ( QKeyEvent *e ) { bool handled = false; + // Checks if an extension is present. + if ( myExtension != 0 ) + { + handled = myExtension->keyPressEvent( *this, e ); + if ( handled ) return; + } if( e->key() == Qt::Key_D) { @@ -1220,7 +1257,7 @@ DGtal::Viewer3D::keyPressEvent ( QKeyEvent *e ) if( e->key() == Qt::Key_E) { trace.info() << "Exporting mesh..." ; - operator>> (*this, "exportedMesh.off"); + operator>> (*this, "exportedMesh.off"); trace.info() << "[done]"<< endl ; } if( e->key() == Qt::Key_M) @@ -1374,11 +1411,14 @@ DGtal::Viewer3D::keyPressEvent ( QKeyEvent *e ) -template< typename Space, typename KSpace> +template< typename TSpace, typename TKSpace> QString -DGtal::Viewer3D::helpString() const +DGtal::Viewer3D::helpString() const { - QString text ( "

Viewer3D

" ); + QString text; + if ( myExtension != 0 ) text += myExtension->helpString( *this ); + + text += "

Viewer3D

"; text += "Use the mouse to move the camera around the object. "; text += "You can respectively revolve around, zoom and translate with the three mouse buttons. "; text += "Left and middle buttons pressed together rotate around the camera view direction axis

"; @@ -1399,9 +1439,9 @@ DGtal::Viewer3D::helpString() const -template< typename Space, typename KSpace> +template< typename TSpace, typename TKSpace> void -DGtal::Viewer3D::glCreateListCubesMaps(const typename DGtal::Display3D::CubesMap &aCubeMap, +DGtal::Viewer3D::glCreateListCubesMaps(const typename DGtal::Display3D::CubesMap &aCubeMap, unsigned int idList){ glNewList ( idList , GL_COMPILE ); @@ -1486,9 +1526,9 @@ DGtal::Viewer3D::glCreateListCubesMaps(const typename DGtal::Disp -template< typename Space, typename KSpace> +template< typename TSpace, typename TKSpace> void -DGtal::Viewer3D::glCreateListQuadD3D(const VectorQuad &aVectQuad, +DGtal::Viewer3D::glCreateListQuadD3D(const VectorQuad &aVectQuad, unsigned int idList){ glNewList ( idList, GL_COMPILE ); glPushName ( myNbListe ); @@ -1515,9 +1555,9 @@ DGtal::Viewer3D::glCreateListQuadD3D(const VectorQuad &aVectQuad, -template< typename Space, typename KSpace> +template< typename TSpace, typename TKSpace> void -DGtal::Viewer3D::glCreateListLines(const VectorLine &aVectLine, +DGtal::Viewer3D::glCreateListLines(const VectorLine &aVectLine, unsigned int idList){ glNewList ( idList, GL_COMPILE ); glDisable ( GL_LIGHTING ); @@ -1537,9 +1577,9 @@ DGtal::Viewer3D::glCreateListLines(const VectorLine &aVectLine, -template< typename Space, typename KSpace> +template< typename TSpace, typename TKSpace> void -DGtal::Viewer3D::glCreateListBalls(const VectorBall &aVectBall, +DGtal::Viewer3D::glCreateListBalls(const VectorBall &aVectBall, unsigned int idList){ if(myUseGLPointsForBalls) { @@ -1579,9 +1619,9 @@ DGtal::Viewer3D::glCreateListBalls(const VectorBall &aVectBall, -template< typename Space, typename KSpace> +template< typename TSpace, typename TKSpace> void -DGtal::Viewer3D::glCreateListQuadMaps(const typename DGtal::Display3D::QuadsMap &aQuadMap, +DGtal::Viewer3D::glCreateListQuadMaps(const typename DGtal::Display3D::QuadsMap &aQuadMap, unsigned int idList){ glNewList ( idList, GL_COMPILE ); for (auto & mapElem: aQuadMap) @@ -1633,9 +1673,9 @@ DGtal::Viewer3D::glCreateListQuadMaps(const typename DGtal::Displ -template< typename Space, typename KSpace> +template< typename TSpace, typename TKSpace> void -DGtal::Viewer3D::glCreateListQuadMapsWired(const typename DGtal::Display3D::QuadsMap &aQuadMap, +DGtal::Viewer3D::glCreateListQuadMapsWired(const typename DGtal::Display3D::QuadsMap &aQuadMap, unsigned int idList){ glNewList ( idList, GL_COMPILE ); glPushName ( myNbListe ); @@ -1647,24 +1687,24 @@ DGtal::Viewer3D::glCreateListQuadMapsWired(const typename DGtal:: for(auto const &q: mapElem.second) { glColor4ub ( 150.0,150.0,150.0,255.0 ); - glColor4ub ( Viewer3D::myCurrentLineColor.red(), - Viewer3D::myCurrentLineColor.green(), - Viewer3D::myCurrentLineColor.blue(), - Viewer3D::myCurrentLineColor.alpha() ); + glColor4ub ( Viewer3D::myCurrentLineColor.red(), + Viewer3D::myCurrentLineColor.green(), + Viewer3D::myCurrentLineColor.blue(), + Viewer3D::myCurrentLineColor.alpha() ); glVertex3f ( q.point1[0], q.point1[1], q.point1[2] ); glVertex3f ( q.point2[0], q.point2[1], q.point2[2] ); glVertex3f ( q.point2[0], q.point2[1], q.point2[2] ); - glColor4ub ( Viewer3D::myCurrentLineColor.red(), - Viewer3D::myCurrentLineColor.green(), - Viewer3D::myCurrentLineColor.blue(), - Viewer3D::myCurrentLineColor.alpha() ); + glColor4ub ( Viewer3D::myCurrentLineColor.red(), + Viewer3D::myCurrentLineColor.green(), + Viewer3D::myCurrentLineColor.blue(), + Viewer3D::myCurrentLineColor.alpha() ); glVertex3f ( q.point3[0], q.point3[1], q.point3[2] ); glVertex3f ( q.point3[0], q.point3[1], q.point3[2] ); glVertex3f ( q.point4[0], q.point4[1], q.point4[2] ); - glColor4ub ( Viewer3D::myCurrentLineColor.red(), - Viewer3D::myCurrentLineColor.green(), - Viewer3D::myCurrentLineColor.blue(), - Viewer3D::myCurrentLineColor.alpha() ); + glColor4ub ( Viewer3D::myCurrentLineColor.red(), + Viewer3D::myCurrentLineColor.green(), + Viewer3D::myCurrentLineColor.blue(), + Viewer3D::myCurrentLineColor.alpha() ); glVertex3f ( q.point4[0], q.point4[1], q.point4[2] ); glVertex3f ( q.point1[0], q.point1[1], q.point1[2] ); } @@ -1675,9 +1715,9 @@ DGtal::Viewer3D::glCreateListQuadMapsWired(const typename DGtal:: } -template< typename Space, typename KSpace> +template< typename TSpace, typename TKSpace> void -DGtal::Viewer3D::glCreateListTriangles(const std::vector &aVectTriangle, +DGtal::Viewer3D::glCreateListTriangles(const std::vector &aVectTriangle, unsigned int idList){ glNewList ( idList, GL_COMPILE ); glPushName ( myNbListe ); @@ -1699,9 +1739,9 @@ DGtal::Viewer3D::glCreateListTriangles(const std::vector +template< typename TSpace, typename TKSpace> void -DGtal::Viewer3D::glCreateListTrianglesWired(const std::vector &aVectTriangle, +DGtal::Viewer3D::glCreateListTrianglesWired(const std::vector &aVectTriangle, unsigned int idList){ glNewList ( idList, GL_COMPILE ); glPushName ( myNbListe ); @@ -1711,10 +1751,10 @@ DGtal::Viewer3D::glCreateListTrianglesWired(const std::vector::myCurrentLineColor.red(), - Viewer3D::myCurrentLineColor.green(), - Viewer3D::myCurrentLineColor.blue(), - Viewer3D::myCurrentLineColor.alpha() ); + glColor4ub ( Viewer3D::myCurrentLineColor.red(), + Viewer3D::myCurrentLineColor.green(), + Viewer3D::myCurrentLineColor.blue(), + Viewer3D::myCurrentLineColor.alpha() ); glVertex3f (t.point1[0],t.point1[1],t.point1[2] ); glVertex3f (t.point2[0],t.point2[1],t.point2[2] ); glVertex3f (t.point2[0],t.point2[1],t.point2[2] ); @@ -1730,9 +1770,9 @@ DGtal::Viewer3D::glCreateListTrianglesWired(const std::vector +template< typename TSpace, typename TKSpace> void -DGtal::Viewer3D::glCreateListPolygons(const std::vector &aVectPolygon, +DGtal::Viewer3D::glCreateListPolygons(const std::vector &aVectPolygon, unsigned int idList){ glNewList ( idList, GL_COMPILE ); glPushName ( myNbListe ); @@ -1757,9 +1797,9 @@ DGtal::Viewer3D::glCreateListPolygons(const std::vector +template< typename TSpace, typename TKSpace> void -DGtal::Viewer3D::glCreateListPolygonsWired(const std::vector &aVectPolygon, +DGtal::Viewer3D::glCreateListPolygonsWired(const std::vector &aVectPolygon, unsigned int idList){ glNewList ( idList, GL_COMPILE ); glPushName ( myNbListe ); @@ -1769,10 +1809,10 @@ DGtal::Viewer3D::glCreateListPolygonsWired(const std::vector::myCurrentLineColor.red(), - Viewer3D::myCurrentLineColor.green(), - Viewer3D::myCurrentLineColor.blue() , - Viewer3D::myCurrentLineColor.alpha() ); + glColor4ub ( Viewer3D::myCurrentLineColor.red(), + Viewer3D::myCurrentLineColor.green(), + Viewer3D::myCurrentLineColor.blue() , + Viewer3D::myCurrentLineColor.alpha() ); for(unsigned int j=0;j < (p.vertices).size();j++) { glVertex3f ( (p.vertices).at(j)[0], (p.vertices).at(j)[1], (p.vertices).at ( j )[2] ); @@ -1788,9 +1828,9 @@ DGtal::Viewer3D::glCreateListPolygonsWired(const std::vector +template< typename TSpace, typename TKSpace> void -DGtal::Viewer3D::glUpdateTextureImages(const VectorTextureImage &aVectImage){ +DGtal::Viewer3D::glUpdateTextureImages(const VectorTextureImage &aVectImage){ for(unsigned int j=0; j::glUpdateTextureImages(const VectorTextureImage myVectTextureImage.clear(); for(unsigned int j=0; j::TextureImage aGSImage = aVectImage.at(j); + typename Viewer3D::TextureImage aGSImage = aVectImage.at(j); GLTextureImage textureImg(aGSImage); glGenTextures(1, &textureImg.myTextureName); @@ -1808,11 +1848,11 @@ DGtal::Viewer3D::glUpdateTextureImages(const VectorTextureImage glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - if(textureImg.myMode==Viewer3D::GrayScaleMode) + if(textureImg.myMode==Viewer3D::GrayScaleMode) { glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, textureImg.myBufferWidth, textureImg.myBufferHeight, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, textureImg.myTextureImageBufferGS); - }else if(textureImg.myMode==Viewer3D::RGBMode) + }else if(textureImg.myMode==Viewer3D::RGBMode) { glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, textureImg.myBufferWidth, textureImg.myBufferHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, textureImg.myTextureImageBufferRGB); @@ -1821,9 +1861,9 @@ DGtal::Viewer3D::glUpdateTextureImages(const VectorTextureImage } } -template< typename Space, typename KSpace> +template< typename TSpace, typename TKSpace> void -DGtal::Viewer3D::glUpdateLightRenderingMode() const +DGtal::Viewer3D::glUpdateLightRenderingMode() const { if(myIsDoubleFaceRendering) glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE); @@ -1833,9 +1873,9 @@ DGtal::Viewer3D::glUpdateLightRenderingMode() const -template< typename Space, typename KSpace> +template< typename TSpace, typename TKSpace> QDomElement -DGtal::Viewer3D::domElement(const QString& name, QDomDocument& document) const +DGtal::Viewer3D::domElement(const QString& name, QDomDocument& document) const { // Creates a custom node for a light position QDomElement deRendering = document.createElement("Rendering"); @@ -1853,9 +1893,9 @@ DGtal::Viewer3D::domElement(const QString& name, QDomDocument& do -template< typename Space, typename KSpace> +template< typename TSpace, typename TKSpace> void -DGtal::Viewer3D::initFromDOMElement(const QDomElement& element) +DGtal::Viewer3D::initFromDOMElement(const QDomElement& element) { // Restore standard state QGLViewer::initFromDOMElement(element); @@ -1892,9 +1932,9 @@ DGtal::Viewer3D::initFromDOMElement(const QDomElement& element) } -template< typename Space, typename KSpace> +template< typename TSpace, typename TKSpace> void -DGtal::Viewer3D::closeEvent ( QCloseEvent * e ){ +DGtal::Viewer3D::closeEvent ( QCloseEvent * e ){ if (myAutoSaveState) { saveStateToFile(); @@ -1902,27 +1942,27 @@ DGtal::Viewer3D::closeEvent ( QCloseEvent * e ){ QGLWidget::closeEvent(e); } -template< typename Space, typename KSpace> +template< typename TSpace, typename TKSpace> void -DGtal::Viewer3D::setGLDoubleRenderingMode(bool doubleSidedRendering) +DGtal::Viewer3D::setGLDoubleRenderingMode(bool doubleSidedRendering) { myIsDoubleFaceRendering = doubleSidedRendering; glUpdateLightRenderingMode(); } -template< typename Space, typename KSpace> +template< typename TSpace, typename TKSpace> void -DGtal::Viewer3D::setGLMaterialShininessCoefficient(const GLfloat matShininessCoeff) +DGtal::Viewer3D::setGLMaterialShininessCoefficient(const GLfloat matShininessCoeff) { myMaterialShininessCoeff = matShininessCoeff; updateGL(); } -template< typename Space, typename KSpace> +template< typename TSpace, typename TKSpace> void -DGtal::Viewer3D::setGLLightAmbientCoefficients(const GLfloat lightAmbientCoeffs [4]) +DGtal::Viewer3D::setGLLightAmbientCoefficients(const GLfloat lightAmbientCoeffs [4]) { myLightAmbientCoeffs[0] = lightAmbientCoeffs[0]; myLightAmbientCoeffs[1] = lightAmbientCoeffs[1]; @@ -1932,9 +1972,9 @@ DGtal::Viewer3D::setGLLightAmbientCoefficients(const GLfloat ligh } -template< typename Space, typename KSpace> +template< typename TSpace, typename TKSpace> void -DGtal::Viewer3D::setGLLightDiffuseCoefficients(const GLfloat lightDiffuseCoeffs [4]) +DGtal::Viewer3D::setGLLightDiffuseCoefficients(const GLfloat lightDiffuseCoeffs [4]) { myLightDiffuseCoeffs[0] = lightDiffuseCoeffs[0]; myLightDiffuseCoeffs[1] = lightDiffuseCoeffs[1]; @@ -1944,18 +1984,18 @@ DGtal::Viewer3D::setGLLightDiffuseCoefficients(const GLfloat ligh } -template< typename Space, typename KSpace> +template< typename TSpace, typename TKSpace> void -DGtal::Viewer3D::setUseGLPointForBalls(const bool useOpenGLPt) +DGtal::Viewer3D::setUseGLPointForBalls(const bool useOpenGLPt) { myUseGLPointsForBalls = useOpenGLPt; } -template< typename Space, typename KSpace> +template< typename TSpace, typename TKSpace> void -DGtal::Viewer3D::updateRenderingCoefficients(const RenderingMode aRenderMode, bool displayState) +DGtal::Viewer3D::updateRenderingCoefficients(const RenderingMode aRenderMode, bool displayState) { stringstream ss; ss << "Rendering mode "; @@ -1999,9 +2039,9 @@ DGtal::Viewer3D::updateRenderingCoefficients(const RenderingMode -template< typename Space, typename KSpace> +template< typename TSpace, typename TKSpace> void -DGtal::Viewer3D::setGLLightSpecularCoefficients(const GLfloat lightSpecularCoeffs [4]) +DGtal::Viewer3D::setGLLightSpecularCoefficients(const GLfloat lightSpecularCoeffs [4]) { myLightSpecularCoeffs[0] = lightSpecularCoeffs[0]; myLightSpecularCoeffs[1] = lightSpecularCoeffs[1]; @@ -2011,19 +2051,19 @@ DGtal::Viewer3D::setGLLightSpecularCoefficients(const GLfloat lig } -template +template inline void -DGtal::Viewer3D::show(){ +DGtal::Viewer3D::show(){ QGLWidget::show(); updateList(false); } -template +template inline void -DGtal::Viewer3D::paintGL(){ +DGtal::Viewer3D::paintGL(){ if (displaysInStereo()) { for (int view=1; view>=0; --view) @@ -2056,8 +2096,8 @@ DGtal::Viewer3D::paintGL(){ } -template< typename Space, typename KSpace> -void DGtal::Viewer3D::updateLightCoordsFromCamera() { +template< typename TSpace, typename TKSpace> +void DGtal::Viewer3D::updateLightCoordsFromCamera() { Vec posLCam; posLCam[0] = myLightPositionRefCamera[0]; posLCam[1] = myLightPositionRefCamera[1]; @@ -2071,8 +2111,8 @@ void DGtal::Viewer3D::updateLightCoordsFromCamera() { -template< typename Space, typename KSpace> -void DGtal::Viewer3D::updateRelativeCameraFromLightPosition() { +template< typename TSpace, typename TKSpace> +void DGtal::Viewer3D::updateRelativeCameraFromLightPosition() { Vec posL; posL[0] = myLightPosition[0]; posL[1] = myLightPosition[1];