44 #include "DGtal/base/Common.h"
45 #include "DGtal/helpers/StdDefs.h"
46 #include "DGtal/io/viewers/Viewer3D.h"
50 using namespace DGtal;
58 struct RandomPointKeyExtension :
public Viewer3D<Space, KSpace>::Extension
60 RandomPointKeyExtension()
66 virtual bool keyPressEvent(
Viewer & viewer, QKeyEvent * event )
70 const Qt::KeyboardModifiers modifiers =
event->modifiers();
71 if ( ( event->key() == Qt::Key_R ) && ( modifiers == Qt::ShiftModifier ) )
76 Point a( ( rand() % d[ 0 ] ) + p[ 0 ], ( rand() % d[ 1 ] ) + p[ 1 ],
77 ( rand() % d[ 2 ] ) + p[ 2 ] );
80 trace.
info() <<
"Adding point " << a << std::endl;
90 viewer.setKeyDescription( Qt::ShiftModifier + Qt::Key_R,
91 "Creates a random digital point." );
96 virtual QString helpString(
const Viewer & )
const
98 QString text(
"<h2> Random point Viewer3D </h2>" );
99 text +=
"Press Shift+R to add points.";
105 int main(
int argc,
char ** argv )
108 QApplication application( argc, argv );
117 K.
init( p1, p2,
true );
124 viewer << p1 << p2 << p3;
126 viewer << MyViewer::updateDisplay;
127 return application.exec();
const KSpace & space() const
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex,...
bool init(const Point &lower, const Point &upper, bool isClosed)
Specifies the upper and lower bounds for the maximal cells in this space.
virtual void show()
Overload QWidget method in order to add a call to updateList() method (to ensure that the lists are w...
void setExtension(Extension *ext)
DGtal is the top-level namespace which contains all DGtal functions and types.
int main(int argc, char **argv)
K init(Point(0, 0, 0), Point(512, 512, 512), true)