Simple selection of a surfel (with shift + left click) with the QGLViewer proposed by DGtal (Viewer3D). You may associates names (i.e. integers) to surfels or to group of surfels. You may associate reactions or callback functions to named graphical objects (surfels in DGtal 0.9).
#include <iostream>
#include "DGtal/base/Common.h"
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/io/viewers/Viewer3D.h"
using namespace std;
using namespace Z3i;
typedef Viewer3D<Space,KSpace> MyViewer;
typedef MyViewer::SelectCallbackFct SelectCallbackFct;
struct BigDataCells
{
std::map< DGtal::int32_t, Z3i::SCell > cells;
};
struct BigDataVoxels
{
std::map< DGtal::int32_t, Z3i::Point > voxels;
};
{
BigDataCells* bg = (BigDataCells*) data;
stringstream ssMessage;
ssMessage << "Reaction1 with name " << name << " cell " << bg->K.sKCoords( bg->cells[ name ] ) ;
((MyViewer *) viewer)->displayMessage(QString(ssMessage.str().c_str()), 100000);
trace.
info() << ssMessage.str() << std::endl;
return 0;
}
{
BigDataCells* bg = (BigDataCells*) data;
stringstream ssMessage;
ssMessage << "Reaction23 with name " << name << " cell " << bg->K.sKCoords( bg->cells[ name ] );
((MyViewer *) viewer)->displayMessage(QString(ssMessage.str().c_str()), 100000);
trace.
info() << ssMessage.str() << std::endl;
return 0;
}
{
BigDataVoxels* bg = (BigDataVoxels*) data;
stringstream ssMessage;
ssMessage << "Reaction4 with name " << name << " Voxel " << bg->voxels[name] ;
((MyViewer *) viewer)->displayMessage(QString(ssMessage.str().c_str()), 100000);
trace.
info() << ssMessage.str() << std::endl;
return 0;
}
int main(
int argc,
char** argv )
{
QApplication application(argc,argv);
BigDataCells data;
BigDataVoxels dataV;
dataV.voxels[4001] = v1;
dataV.voxels[4002] = v2;
dataV.voxels[4003] = v3;
viewer.show();
viewer.displayMessage(QString("You can use [shift + click right] on surfels or voxel to interact ..."), 100000);
data.cells[ 10001 ] = surfel1;
data.cells[ 10002 ] = surfel2;
data.cells[ 10003 ] = surfel3;
viewer << SetMode3D( surfel1.className(), "Basic" );
viewer << SetName3D( 10001 ) << CustomColors3D( Color::Red, Color::Red ) << surfel1;
viewer << SetName3D( 10002 ) << CustomColors3D( Color::Green, Color::Green ) << surfel2;
viewer << SetName3D( 10003 ) << CustomColors3D( Color::Blue, Color::Blue ) << surfel3;
viewer << SetSelectCallback3D( reaction1, &data, 10001, 10001 );
viewer << SetSelectCallback3D( reaction23, &data, 10002, 10003 );
viewer << SetName3D( 4001 ) << v1;
viewer << SetName3D( 4002 ) << v2;
viewer << SetName3D( 4003 ) << v3;
viewer << SetSelectCallback3D( reaction4, &dataV, 4001,4003 );
viewer<< MyViewer::updateDisplay;
return application.exec();
}
DGtal is the top-level namespace which contains all DGtal functions and types.
boost::int32_t int32_t
signed 32-bit integer.
int main(int argc, char **argv)