32 #include <osg/Geometry>
34 #include "WMCoordinateSystem.h"
35 #include "WMCoordinateSystem.xpm"
36 #include "WTalairachConverter.h"
37 #include "core/common/WPropertyHelper.h"
38 #include "core/dataHandler/WDataHandler.h"
39 #include "core/dataHandler/WDataSet.h"
40 #include "core/dataHandler/WDataSetScalar.h"
41 #include "core/dataHandler/WSubject.h"
42 #include "core/dataHandler/exceptions/WDHNoSuchSubject.h"
43 #include "core/graphicsEngine/WGEGeodeUtils.h"
44 #include "core/kernel/WKernel.h"
45 #include "core/kernel/WSelectionManager.h"
51 WModule(), m_dirty( false ), m_drawOffset( 0.02 ),
67 return coordinateSystem_xpm;
74 "Dataset to create atlas surfaces from." ) );
120 return "Coordinate System";
125 return "This module displays coordinate systems as overlay within the main 3D view.";
175 infoLog() <<
"Selected " << s.
at( 0 )->getName() <<
" coordinate system.";
184 infoLog() <<
"Set new AC point.";
191 infoLog() <<
"Set new PC point.";
198 infoLog() <<
"Set new IHP point.";
226 m_rulerNode = osg::ref_ptr< osg::Group >(
new osg::Group() );
254 if( ch[0] != cho[0] || ch[1] != cho[1] || ch[2] != cho[2] ||
m_dirty )
266 std::shared_ptr< WGridRegular3D > grid = std::dynamic_pointer_cast< WGridRegular3D >(
m_dataSet->getGrid() );
268 double xOff = grid->getOffsetX();
269 double yOff = grid->getOffsetY();
270 double zOff = grid->getOffsetZ();
311 std::shared_ptr< WGridRegular3D > grid = std::dynamic_pointer_cast< WGridRegular3D >(
m_dataSet->getGrid() );
313 double xOff = grid->getOffsetX();
314 double yOff = grid->getOffsetY();
315 double zOff = grid->getOffsetZ();
328 for(
size_t x = 0; x < grid->getNbCoordsX(); ++x )
331 for(
size_t y = 0; y < grid->getNbCoordsY(); ++y )
333 for(
size_t z = 0; z < grid->getNbCoordsZ(); ++z )
335 double v =
m_dataSet->getValueAt( x, y, z );
344 flt[0] =
static_cast< float > ( x * xOff );
348 for(
int x = grid->getNbCoordsX() - 1; x > -1; --x )
351 for(
size_t y = 0; y < grid->getNbCoordsY(); ++y )
353 for(
size_t z = 0; z < grid->getNbCoordsZ(); ++z )
355 double v =
m_dataSet->getValueAt( x, y, z );
364 brb[0] =
static_cast< float > ( x * xOff );
369 for(
size_t y = 0; y < grid->getNbCoordsY(); ++y )
372 for(
size_t x = 0; x < grid->getNbCoordsX(); ++x )
374 for(
size_t z = 0; z < grid->getNbCoordsZ(); ++z )
376 double v =
m_dataSet->getValueAt( x, y, z );
385 flt[1] =
static_cast< float > ( y * yOff );
389 for(
int y = grid->getNbCoordsY() - 1; y > -1; --y )
392 for(
size_t x = 0; x < grid->getNbCoordsX(); ++x )
394 for(
size_t z = 0; z < grid->getNbCoordsZ(); ++z )
396 double v =
m_dataSet->getValueAt( x, y, z );
405 brb[1] =
static_cast< float > ( y * yOff );
410 for(
size_t z = 0; z < grid->getNbCoordsZ(); ++z )
413 for(
size_t x = 0; x < grid->getNbCoordsX(); ++x )
415 for(
size_t y = 0; y < grid->getNbCoordsY(); ++y )
417 double v =
m_dataSet->getValueAt( x, y, z );
426 flt[2] =
static_cast< float > ( z * zOff );
430 for(
int z = grid->getNbCoordsZ() - 1; z > -1; --z )
433 for(
size_t x = 0; x < grid->getNbCoordsX(); ++x )
435 for(
size_t y = 0; y < grid->getNbCoordsY(); ++y )
437 double v =
m_dataSet->getValueAt( x, y, z );
446 brb[2] =
static_cast< float > ( z * zOff );
454 flt[0] = std::min( tmpflt[0], tmpbrb[0] );
455 flt[1] = std::max( tmpflt[1], tmpbrb[1] );
456 flt[2] = std::max( tmpflt[2], tmpbrb[2] );
457 brb[0] = std::max( tmpflt[0], tmpbrb[0] );
458 brb[1] = std::min( tmpflt[1], tmpbrb[1] );
459 brb[2] = std::min( tmpflt[2], tmpbrb[2] );
472 std::shared_ptr< WTalairachConverter > talairachConverter =
485 talairachConverter->setAp( ap );
486 talairachConverter->setPp( pp );
487 talairachConverter->setSp( sp );
488 talairachConverter->setIp( ip );
489 talairachConverter->setLp( lp );
490 talairachConverter->setRp( rp );
507 osg::ref_ptr< WRulerOrtho > ruler1 = osg::ref_ptr< WRulerOrtho >(
510 osg::ref_ptr< WRulerOrtho > ruler2 = osg::ref_ptr< WRulerOrtho >(
530 osg::ref_ptr< WRulerOrtho > ruler1 = osg::ref_ptr< WRulerOrtho >(
533 osg::ref_ptr< WRulerOrtho > ruler2 = osg::ref_ptr< WRulerOrtho >(
553 osg::ref_ptr< WRulerOrtho > ruler1 = osg::ref_ptr< WRulerOrtho >(
556 osg::ref_ptr< WRulerOrtho > ruler2 = osg::ref_ptr< WRulerOrtho >(
575 osg::ref_ptr< osg::Geode > gridGeode = osg::ref_ptr< osg::Geode >(
new osg::Geode() );
576 osg::ref_ptr< osg::Geometry > geometry = osg::ref_ptr< osg::Geometry >(
new osg::Geometry() );
577 osg::Vec3Array* vertices =
new osg::Vec3Array;
587 for(
int i = p1[1]; i < p2[1] + 2; ++i )
591 vertices->push_back( osg::Vec3( position, i, p1[2] ) );
592 vertices->push_back( osg::Vec3( position, i, p2[2] + 1 ) );
595 for(
int i = p1[2]; i < p2[2] + 2; ++i )
599 vertices->push_back( osg::Vec3( position, p1[1], i ) );
600 vertices->push_back( osg::Vec3( position, p2[1] + 1, i ) );
606 std::shared_ptr< WTalairachConverter > tc =
m_coordConverter->getTalairachConverter();
608 for(
int i = -110; i < 81; i += 10 )
613 vertices->push_back( osg::Vec3( position, tmpPoint1[1], tmpPoint1[2] ) );
614 vertices->push_back( osg::Vec3( position, tmpPoint2[1], tmpPoint2[2] ) );
616 for(
int i = -50; i < 81; i += 10 )
621 vertices->push_back( osg::Vec3( position, tmpPoint1[1], tmpPoint1[2] ) );
622 vertices->push_back( osg::Vec3( position, tmpPoint2[1], tmpPoint2[2] ) );
628 geometry->setVertexArray( vertices );
629 osg::DrawElementsUInt* lines =
new osg::DrawElementsUInt( osg::PrimitiveSet::LINES, 0 );
631 for(
size_t i = 0; i < vertices->size(); ++i )
633 lines->push_back( i );
635 geometry->addPrimitiveSet( lines );
637 osg::StateSet* state = geometry->getOrCreateStateSet();
638 state->setMode( GL_LIGHTING, osg::StateAttribute::OFF | osg::StateAttribute::PROTECTED );
640 gridGeode->addDrawable( geometry );
656 osg::ref_ptr< osg::Geode > gridGeode = osg::ref_ptr< osg::Geode >(
new osg::Geode() );
657 osg::ref_ptr< osg::Geometry > geometry = osg::ref_ptr< osg::Geometry >(
new osg::Geometry() );
658 osg::Vec3Array* vertices =
new osg::Vec3Array;
668 for(
int i = p1[0]; i < p2[0] + 2; ++i )
672 vertices->push_back( osg::Vec3( i, position, p1[2] ) );
673 vertices->push_back( osg::Vec3( i, position, p2[2] + 1 ) );
676 for(
int i = p1[2]; i < p2[2] + 2; ++i )
680 vertices->push_back( osg::Vec3( p1[1], position, i ) );
681 vertices->push_back( osg::Vec3( p2[1] + 1, position, i ) );
687 std::shared_ptr< WTalairachConverter > tc =
m_coordConverter->getTalairachConverter();
689 for(
int i = -80; i < 81; i += 10 )
694 vertices->push_back( osg::Vec3( tmpPoint1[0], position, tmpPoint1[2] ) );
695 vertices->push_back( osg::Vec3( tmpPoint2[0], position, tmpPoint2[2] ) );
697 for(
int i = -50; i < 81; i += 10 )
702 vertices->push_back( osg::Vec3( tmpPoint1[0], position, tmpPoint1[2] ) );
703 vertices->push_back( osg::Vec3( tmpPoint2[0], position, tmpPoint2[2] ) );
709 geometry->setVertexArray( vertices );
710 osg::DrawElementsUInt* lines =
new osg::DrawElementsUInt( osg::PrimitiveSet::LINES, 0 );
712 for(
size_t i = 0; i < vertices->size(); ++i )
714 lines->push_back( i );
716 geometry->addPrimitiveSet( lines );
718 osg::StateSet* state = geometry->getOrCreateStateSet();
719 state->setMode( GL_LIGHTING, osg::StateAttribute::OFF | osg::StateAttribute::PROTECTED );
721 gridGeode->addDrawable( geometry );
737 osg::ref_ptr< osg::Geode > gridGeode = osg::ref_ptr< osg::Geode >(
new osg::Geode() );
738 osg::ref_ptr< osg::Geometry > geometry = osg::ref_ptr< osg::Geometry >(
new osg::Geometry() );
739 osg::Vec3Array* vertices =
new osg::Vec3Array;
749 for(
int i = p1[1]; i < p2[1] + 2; ++i )
753 vertices->push_back( osg::Vec3( p1[0], i, position ) );
754 vertices->push_back( osg::Vec3( p2[0] + 1, i, position ) );
757 for(
int i = p1[0]; i < p2[0] + 2; ++i )
761 vertices->push_back( osg::Vec3( i, p1[1], position ) );
762 vertices->push_back( osg::Vec3( i, p2[1] + 1, position ) );
768 std::shared_ptr< WTalairachConverter > tc =
m_coordConverter->getTalairachConverter();
770 for(
int i = -80; i < 81; i += 10 )
775 vertices->push_back( osg::Vec3( tmpPoint1[0], tmpPoint1[1], position ) );
776 vertices->push_back( osg::Vec3( tmpPoint2[0], tmpPoint2[1], position ) );
778 for(
int i = -110; i < 81; i += 10 )
783 vertices->push_back( osg::Vec3( tmpPoint1[0], tmpPoint1[1], position ) );
784 vertices->push_back( osg::Vec3( tmpPoint2[0], tmpPoint2[1], position ) );
790 geometry->setVertexArray( vertices );
791 osg::DrawElementsUInt* lines =
new osg::DrawElementsUInt( osg::PrimitiveSet::LINES, 0 );
793 for(
size_t i = 0; i < vertices->size(); ++i )
795 lines->push_back( i );
797 geometry->addPrimitiveSet( lines );
799 osg::StateSet* state = geometry->getOrCreateStateSet();
800 state->setMode( GL_LIGHTING, osg::StateAttribute::OFF | osg::StateAttribute::PROTECTED );
802 gridGeode->addDrawable( geometry );
const vec_type & getMax() const
Gives the back upper right aka maximum corner.
const vec_type & getMin() const
Gives the front lower left aka minimum corner.
virtual void wait() const
Wait for the condition.
void setResetable(bool resetable=true, bool autoReset=true)
Sets the resetable flag.
virtual void add(std::shared_ptr< WCondition > condition)
Adds another condition to the set of conditions to wait for.
Class to provide conversion for a given coordinate in 3D space.
This callback allows you a simple usage of callbacks in your module.
Class to wrap around the osg Group node and providing a thread safe add/removal mechanism.
A class containing a list of named items.
This class represents a subset of a WItemSelection.
virtual const std::shared_ptr< WItemSelectionItem > at(size_t index) const
Gets the selected item with the given index.
virtual size_t getItemIndexOfSelected(size_t index) const
Helps to get the index of an selected item in the WItemSelection.
std::shared_ptr< WSelectionManager > getSelectionManager()
get for selection manager
static WKernel * getRunningKernel()
Returns pointer to the currently running kernel.
std::shared_ptr< WGraphicsEngine > getGraphicsEngine() const
Returns pointer to currently running instance of graphics engine.
class that implements the various coordinate systems as overlays within the 3D view
std::shared_ptr< WCoordConverter > m_coordConverter
stores pointer
virtual const char ** getXPMIcon() const
Get the icon for this module in XPM format.
void propertyChanged()
Callback to listen for property changes.
WPropPosition m_brb
upper boundary of the dataset
bool m_dirty
flag true if something happened that requires redrawing of gfx
void addRulersSagittal()
helper function to create rulers
osg::ref_ptr< osg::Group > m_rulerNode
node for the bounding box
std::shared_ptr< WModuleInputData< WDataSetScalar > > m_input
Input connector required by this module.
virtual const std::string getName() const
void addRulersAxial()
helper function to create rulers
int m_viewAngle
stores the last view angle
WPropPosition m_ac
anterior commissure
WMCoordinateSystem()
standard constructor
virtual void moduleMain()
WPropBool m_showSagittal
show rulers on the sagittal slice
WPropTrigger m_ihpTrigger
button to reset the ihp point;
WPropPosition m_flt
lower boundary of the dataset
WPropBool m_showGridAxial
show grid on the axial slice
WPropBool m_showCoronal
show rulers on the coronal slice
WPropBool m_showAxial
show rulers on the axial slice
void updateCallback()
the shader object for this module
WPropPosition m_ihp
inter hemispherical point
WPropSelection m_csSelection
selection for coordinate system mode
std::shared_ptr< WItemSelection > m_possibleSelections
selection for coordinate system mode
void addSagittalGrid(float position)
helper function to create a grid overlay on the sagittal slice
void findBoundingBox()
helper function that computes the innerBoundingBox for the actual data
virtual std::shared_ptr< WModule > factory() const
Due to the prototype design pattern used to build modules, this method returns a new instance of this...
void initTalairachConverter()
creates and initializes a talairach converter object
virtual ~WMCoordinateSystem()
destructor
osg::ref_ptr< WGEGroupNode > m_rootNode
the root node for this module
WPropTrigger m_pcTrigger
button to reset the pc point
std::shared_ptr< const WDataSetScalar > m_dataSet
pointer to dataSet to be able to access it throughout the whole module.
virtual void connectors()
Initialize the connectors this module is using.
WPropBool m_showGridCoronal
show grid on the coronal slice
virtual const std::string getDescription() const
void addAxialGrid(float position)
helper function to create a grid overlay on the axial slice
WPropTrigger m_acTrigger
button to reset the ac point
WPropPosition m_crosshair
position of the navigation slices
virtual void activate()
Callback for m_active.
void properties()
initialize the properties for this module
WPropPosition m_pc
posterior commissure
void addRulersCoronal()
helper function to create rulers
void addCoronalGrid(float position)
helper function to create a grid overlay on the coronal slice
float m_drawOffset
offset from slices to draw geometry on
WPropBool m_showGridSagittal
show grid on the sagittal slice
WPropBool m_showNumbersOnRulers
show/hide numbers on rulers
void createGeometry()
initial creation function for the slice geometry
Class representing a single module of OpenWalnut.
virtual void properties()
Initialize properties in this function.
void addConnector(std::shared_ptr< WModuleInputConnector > con)
Adds the specified connector to the list of inputs.
std::shared_ptr< WProperties > m_properties
The property object for the module.
std::shared_ptr< WProperties > m_infoProperties
The property object for the module containing only module whose purpose is "PV_PURPOSE_INFORMNATION".
void ready()
Call this whenever your module is ready and can react on property changes.
WConditionSet m_moduleState
The internal state of the module.
virtual void activate()
Callback for m_active.
WPropBool m_active
True whenever the module should be active.
wlog::WStreamedLogger infoLog() const
Logger instance for comfortable info logging.
virtual void connectors()
Initialize connectors in this function.
This only is a 3d double vector.
boost::function< void(std::shared_ptr< WPropertyBase >)> PropertyChangeNotifierType
Signal signature emitted during set operations.
class to implement rulers orthogonally
class to provide conversions between world or voxel space coordinates und Talairach coordinates
WBoolFlag m_shutdownFlag
Condition getting fired whenever the thread should quit.
@ PV_TRIGGER_TRIGGERED
Trigger property: got triggered.
@ PV_TRIGGER_READY
Trigger property: is ready to be triggered (again)
void addTo(WPropSelection prop)
Add the PC_NOTEMPTY constraint to the property.
void addTo(WPropSelection prop)
Add the PC_SELECTONLYONE constraint to the property.