Skip to content

Commit

Permalink
Merge pull request #1250 from nnormand/SimpleMatrix-initialization
Browse files Browse the repository at this point in the history
[WIP] SimpleMatrix with initializer_list constructor
  • Loading branch information
JacquesOlivierLachaud authored Jul 7, 2017
2 parents 06bf04a + 7fe7c20 commit 1d4f575
Show file tree
Hide file tree
Showing 22 changed files with 1,368 additions and 1,331 deletions.
19 changes: 10 additions & 9 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,21 @@

## New Features / Critical Changes

## Changes

- *Math package*
- New SimpleMatrix constructor with a initializer_list argument
  (Nicolas Normand,
[#1250](https://github.com/DGtal-team/DGtal/pull/1250))
- *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

- *IO*
- TableReader can now read all elements contained in each line of a file
- TableReader can now read all elements contained in each line of a file
with the new method getLinesElementsFromFile().
(Bertrand Kerautret, [#1260](https://github.com/DGtal-team/DGtal/pull/1260))


## Bug Fixes

- *Shapes Package*
Expand All @@ -37,10 +38,10 @@
handle 32/16 bits images. Also includes a new testITKReader and ITK tests in
GenericReader.
(Bertrand Kerautret, [#1255](https://github.com/DGtal-team/DGtal/pull/1255))
- Viewer3D: fix bad light source move according X/Y mouse move and new Key_Z to
- Viewer3D: fix bad light source move according X/Y mouse move and new Key_Z to
move away/closer the light source.
(Bertrand Kerautret, [#1262](https://github.com/DGtal-team/DGtal/pull/1262))

- *Kernel Package*
- Fix testBasicPointFunctor. (Bertrand Kerautret
[#1245](https://github.com/DGtal-team/DGtal/pull/1245))
Expand All @@ -52,7 +53,7 @@
was also added to the generic readers when ITK is present (Bertrand
Kerautret [1251](https://github.com/DGtal-team/DGtal/pull/1245))
- Fix exampleArithDSS3d compilation (which was not activated).
(Bertrand Kerautret
(Bertrand Kerautret
[#1254](https://github.com/DGtal-team/DGtal/pull/1254))

# DGtal 0.9.3
Expand Down
2 changes: 1 addition & 1 deletion examples/geometry/curves/exampleArithDSS3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
#include <iostream>

#include "DGtal/io/viewers/Viewer3D.h"
#ifdef WITH_CAIRO
#ifdef WITH_CAIRO
#include "DGtal/io/boards/Board3DTo2D.h"
#endif

Expand Down
91 changes: 45 additions & 46 deletions examples/io/viewers/viewer3D-11-extension.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
*
* @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."
* \image html simple3dVisu1.png "Extending the Viewer3D interface: just press
* Shift+R and you have new points added randomly in the scene."
*/

///////////////////////////////////////////////////////////////////////////////
Expand All @@ -49,84 +50,82 @@ 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<Space,KSpace>::Extension
struct RandomPointKeyExtension : public Viewer3D<Space, KSpace>::Extension
{
RandomPointKeyExtension() {}
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 )
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;
}
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 )
virtual void init( Viewer & viewer )
{
viewer.setKeyDescription ( Qt::ShiftModifier+Qt::Key_R,
"Creates a random digital point." );
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
virtual QString helpString( const Viewer & viewer ) const
{
QString text( "<h2> Random point Viewer3D </h2>" );
text += "Press Shift+R to add points.";
return text;
}

};
//! [viewer3D-extension-derivation]

int main( int argc, char** argv )
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();
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();
}
// //
///////////////////////////////////////////////////////////////////////////////
2 changes: 1 addition & 1 deletion src/DGtal/io/Display3D.h
Original file line number Diff line number Diff line change
Expand Up @@ -897,7 +897,7 @@ namespace DGtal
std::set<SelectCallbackFctStore> mySelectCallBackFcts;

bool myBoundingPtChangedTag = false;

//----end of protected datas

// ------------------------- Internals ------------------------------------
Expand Down
64 changes: 32 additions & 32 deletions src/DGtal/io/Display3D.ih
Original file line number Diff line number Diff line change
Expand Up @@ -1195,38 +1195,38 @@ DGtal::Display3D< Space ,KSpace >::updateBoundingBox(const RealPoint &p)
}
else
{
if(p[0] <myBoundingPtLow[0])
{
myBoundingPtLow[0]= p[0];
myBoundingPtChangedTag = true;
}
if(p[1] <myBoundingPtLow[1])
{
myBoundingPtLow[1]= p[1];
myBoundingPtChangedTag = true;
}
if(p[2] <myBoundingPtLow[2])
{
myBoundingPtLow[2]= p[2];
myBoundingPtChangedTag = true;
}
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;
}
if ( p[ 0 ] < myBoundingPtLow[ 0 ] )
{
myBoundingPtLow[ 0 ] = p[ 0 ];
myBoundingPtChangedTag = true;
}
if ( p[ 1 ] < myBoundingPtLow[ 1 ] )
{
myBoundingPtLow[ 1 ] = p[ 1 ];
myBoundingPtChangedTag = true;
}

if ( p[ 2 ] < myBoundingPtLow[ 2 ] )
{
myBoundingPtLow[ 2 ] = p[ 2 ];
myBoundingPtChangedTag = true;
}

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;
}
}
}

Expand Down
Loading

0 comments on commit 1d4f575

Please sign in to comment.