Skip to content

Commit

Permalink
Merge pull request #273 from kerautret/AddInfoMeshViewer
Browse files Browse the repository at this point in the history
Add info mesh viewer
  • Loading branch information
kerautret authored Jun 25, 2016
2 parents ca5ca79 + b1ded69 commit 4ec4381
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 9 deletions.
10 changes: 7 additions & 3 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,19 @@
- renaming of the shapeGenerator folder to generators (David Coeurjolly, [#268](https://github.com/DGtal-team/DGtalTools/pull/268)))

- *visualisation*:
- meshViewer: add a key to display mesh information about number of
vertex/faces.
(Bertrand Kerautret,
[#273](https://github.com/DGtal-team/DGtalTools/pull/272))

- 3dSDPViewer: fix the mesh display which was not given with their original
colors. (Bertrand Kerautret,
[#272](https://github.com/DGtal-team/DGtalTools/pull/272))

- 3dSDPViewer: add the possibility to display a set of point by using
different sphere sizes (specified in the input sdp file).
(Bertrand Kerautret,
[#252](https://github.com/DGtal-team/DGtalTools/pull/252))

(Bertrand Kerautret,
[#252](https://github.com/DGtal-team/DGtalTools/pull/252))
- sliceViewer: fix bug when imported image domain doesn't contain (0,0,0) point.
(Roland Denis, [#256](https://github.com/DGtal-team/DGtalTools/pull/256))
- 3dSDPViewer: add an option to display on screen the selected voxel.
Expand Down
56 changes: 50 additions & 6 deletions visualisation/meshViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,44 @@ using namespace DGtal;
*/


/**
* Custom Viewer3D to override KeyPressEvent method and handle new key display.
* It also desactivate the double Rendering mode for more efficiency.
**/
class CustomViewer3D: public Viewer3D<>
{
protected:

virtual void init()
{
Viewer3D<>::init();
Viewer3D<>::setKeyDescription ( Qt::Key_I, "Display mesh informations about #faces, #vertices" );
Viewer3D<>::setGLDoubleRenderingMode(false);
}
virtual void keyPressEvent(QKeyEvent *e){
bool handled = false;
if( e->key() == Qt::Key_I)
{
handled=true;
myIsDisplayingInfoMode = !myIsDisplayingInfoMode;
std::stringstream sstring;
Viewer3D<>::displayMessage(QString(myIsDisplayingInfoMode ?
myInfoDisplay.c_str() : " "), 1000000);
Viewer3D<>::updateGL();
}
if(!handled)
{
Viewer3D<>::keyPressEvent(e);
}
};

public:
std::string myInfoDisplay = "No information loaded...";
bool myIsDisplayingInfoMode = false;
};




///////////////////////////////////////////////////////////////////////////////
namespace po = boost::program_options;
Expand Down Expand Up @@ -239,7 +277,7 @@ int main( int argc, char** argv )


QApplication application(argc,argv);
Viewer3D<> viewer;
CustomViewer3D viewer;
std::stringstream title;
title << "Simple Mesh Viewer: " << inputFilenameVect[0];
viewer.setWindowTitle(title.str().c_str());
Expand Down Expand Up @@ -314,11 +352,17 @@ int main( int argc, char** argv )
viewer.setLineColor(vFieldLineColor);
viewer.addLine(vectPt1[i], vectPt2[i]);
}


}


viewer << Viewer3D<>::updateDisplay;
unsigned int nbVertex = 0;
unsigned int nbFaces = 0;
for(auto const &m: vectMesh)
{
nbVertex += m.nbVertex();
nbFaces +=m.nbFaces();
}
stringstream ss;
ss << "# faces: " << std::fixed << nbFaces << " #vertex: " << nbVertex;
viewer.myInfoDisplay = ss.str();
viewer << CustomViewer3D::updateDisplay;
return application.exec();
}

0 comments on commit 4ec4381

Please sign in to comment.