DGtal 2.1.0
Loading...
Searching...
No Matches
io/viewers/viewer3D-10-interaction.cpp

Simple selection of a surfel (with shift + left click) with the Polyscope Viewer proposed by DGtal. 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).

* $ ./examples/io/viewers/viewer3D-10-interaction
* 
Example of PolyscopeViewer interaction with the selection of surfels.
#include <iostream>
#include "DGtal/base/Common.h"
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/io/viewers/PolyscopeViewer.h"
using namespace std;
using namespace DGtal;
using namespace Z3i;
typedef MyViewer::Callback Callback;
typedef KSpace::SCell SCell;
// Standard services - public :
//
struct MyCallback : public Callback {
void OnClick(
const std::string& name, size_t index,
void* polyscopeStructure
) {
((void) index); ((void) data); ((void) polyscopeStructure);
std::cout << "Item name: " << name << std::endl;
}
};
int main()
{
Point p1( 0, 0, 0 );
Point p2( 5, 5 ,5 );
Point p3( 2, 3, 4 );
K.init( p1, p2, true );
Point v1 = Z3i::Point(10, 10,10);
Point v2 = Z3i::Point(9, 9, 9);
Point v3 = Z3i::Point(11, 11,11);
MyViewer viewer( K );
viewer.setCallback(new MyCallback);
Z3i::SCell surfel1 = K.sCell( Point( 1, 1, 2 ), KSpace::POS );
Z3i::SCell surfel2 = K.sCell( Point( 3, 3, 4 ), KSpace::NEG );
Z3i::SCell surfel3 = K.sCell( Point( 5, 6, 5 ), KSpace::POS );
viewer.draw(surfel1, "Surfel 1");
viewer.draw(surfel2, "Surfel 2");
viewer << Point(0, 0, 1) << Point(1, 1, 2);
viewer.show();
return 0;
}
// //
Z3i::SCell SCell
DGtal is the top-level namespace which contains all DGtal functions and types.
STL namespace.
Data required to display an object.
Definition Display3D.h:247
Represents a signed cell in a cellular grid space by its Khalimsky coordinates and a boolean value.
void OnClick(const std::string &name, size_t index, const DisplayData< MyViewer::RealPoint > &data, void *polyscopeStructure)
unsigned int index(DGtal::uint32_t n, unsigned int b)
Definition testBits.cpp:44
int main()
Definition testBits.cpp:56
MyPointD Point
KSpace K
MyViewer::Callback Callback
PolyscopeViewer< Space, KSpace > MyViewer