31 #include <osg/Geometry> 
   33 #include <osg/Material> 
   34 #include <osg/ShapeDrawable> 
   35 #include <osg/StateAttribute> 
   37 #include "WMVectorPlot.h" 
   38 #include "WMVectorPlot.xpm" 
   39 #include "core/common/WColor.h" 
   40 #include "core/common/exceptions/WTypeMismatch.h" 
   41 #include "core/dataHandler/WDataHandlerEnums.h" 
   42 #include "core/kernel/WKernel.h" 
   43 #include "core/kernel/WSelectionManager.h" 
   65     return vectorplot_xpm;
 
   75     return "This module displays vector data as small vector representations on navigation slices and other surfaces.";
 
   80     m_input = std::shared_ptr< WModuleInputData < WDataSetVector > >(
 
  102                                                    "If active, the vectors are projected into the surface " 
  103                                                    "used to place them. Thus their " 
  104                                                    "representation is tangential to the surface.",
 
  107                                                    "Draw each vector in a color indicating its direction. ", 
false );
 
  109                                                    "This color is used if direction coloring is deactivated.",
 
  110                                                    WColor( 1.0, 0.0, 0.0, 1.0 ) );
 
  117                                          "Scaling the length of the plotted vectors",
 
  139         std::shared_ptr< WProgress > progress( 
new WProgress( 
"Vector Plot", 2 ) );
 
  142         std::shared_ptr< WDataSetVector > newDataSet = 
m_input->getData();
 
  143         bool dataChanged = ( 
m_dataSet != newDataSet );
 
  144         bool dataValid   = ( newDataSet != NULL );
 
  146         if( dataChanged && dataValid )
 
  151         if( dataValid && dataChanged )
 
  153             debugLog() << 
"Building Vector Plot";
 
  160             osg::ref_ptr< osg::Geode > newRootNode = 
new osg::Geode();
 
  170             m_rootNode->getOrCreateStateSet()->setMode( GL_LIGHTING, osg::StateAttribute::OFF );
 
  182     switch( ( *m_dataSet ).getValueSet()->getDataType() )
 
  184         case W_DT_SIGNED_INT:
 
  185             return buildPlotSlices< DataTypeRT< W_DT_SIGNED_INT >::type >();
 
  187             return buildPlotSlices< DataTypeRT< W_DT_FLOAT >::type >();
 
  189             return buildPlotSlices< DataTypeRT< W_DT_DOUBLE >::type >();
 
  191             return buildPlotSlices< DataTypeRT< W_DT_INT8 >::type >();
 
  193             return buildPlotSlices< DataTypeRT< W_DT_UINT16 >::type >();
 
  195             return buildPlotSlices< DataTypeRT< W_DT_UINT8 >::type >();
 
  197             return buildPlotSlices< DataTypeRT< W_DT_INT16 >::type >();
 
  199             return buildPlotSlices< DataTypeRT< W_DT_UINT32 >::type >();
 
  201             return buildPlotSlices< DataTypeRT< W_DT_INT64 >::type >();
 
  203             return buildPlotSlices< DataTypeRT< W_DT_UINT64 >::type >();
 
  218         osg::ref_ptr<osg::Drawable> old = osg::ref_ptr<osg::Drawable>( 
m_rootNode->getDrawable( 0 ) );
 
  246     for( 
size_t i = 0; i < verts->size(); ++i )
 
  248         std::vector< double > resultPos4D( 4 );
 
  249         resultPos4D[0] = mat( 0, 0 ) * ( *verts )[i][0] + mat( 0, 1 ) * ( *verts )[i][1] + mat( 0, 2 ) * ( *verts )[i][2] + mat( 0, 3 ) * 1;
 
  250         resultPos4D[1] = mat( 1, 0 ) * ( *verts )[i][0] + mat( 1, 1 ) * ( *verts )[i][1] + mat( 1, 2 ) * ( *verts )[i][2] + mat( 1, 3 ) * 1;
 
  251         resultPos4D[2] = mat( 2, 0 ) * ( *verts )[i][0] + mat( 2, 1 ) * ( *verts )[i][1] + mat( 2, 2 ) * ( *verts )[i][2] + mat( 2, 3 ) * 1;
 
  252         resultPos4D[3] = mat( 3, 0 ) * ( *verts )[i][0] + mat( 3, 1 ) * ( *verts )[i][1] + mat( 3, 2 ) * ( *verts )[i][2] + mat( 3, 3 ) * 1;
 
  254         ( *verts )[i][0] = resultPos4D[0] / resultPos4D[3];
 
  255         ( *verts )[i][1] = resultPos4D[1] / resultPos4D[3];
 
  256         ( *verts )[i][2] = resultPos4D[2] / resultPos4D[3];
 
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.
 
This callback allows you a simple usage of callbacks in your module.
 
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.
 
Show an glyph plot (in this case the glyphs are arrows) of a vector data set.
 
virtual void activate()
Callback for m_active.
 
virtual void connectors()
Initialize the connectors this module is using.
 
WPropBool m_showOnAxial
indicates whether the vector should be shown on axial slice
 
void transformVerts(osg::ref_ptr< osg::Vec3Array > verts)
Transforms the given vertices according to m_matrix.
 
WPropBool m_coloringMode
indicates a set color or direction color coding.
 
std::shared_ptr< WDataSetVector > m_dataSet
This is a pointer to the dataset the module is currently working on.
 
WPropBool m_projectOnSlice
projects the vectors on the slice.
 
WPropBool m_showOnSagittal
indicates whether the vector should be shown on sagittal slice
 
void updateCallback()
The update callback that is called for the osg node of this module.
 
osg::ref_ptr< osg::Geode > m_rootNode
The root node used for this modules graphics.
 
WPropDouble m_scale
Scaling of arrow length.
 
WPropDouble m_xSlice
x position of the slice
 
virtual void moduleMain()
Entry point after loading the module.
 
virtual const char ** getXPMIcon() const
Get the icon for this module in XPM format.
 
WPropBool m_showOnCoronal
indicates whether the vector should be shown on coronal slice
 
virtual void properties()
Initialize the properties for this module.
 
osg::ref_ptr< osg::Geometry > buildPlotSlices()
Creates a vector plot on the currently selected slices.
 
virtual const std::string getDescription() const
Gives back a description of this module.
 
std::shared_ptr< WModuleInputData< WDataSetVector > > m_input
An input connector used to get datasets from other modules.
 
virtual const std::string getName() const
Gives back the name of this module.
 
WPropDouble m_ySlice
y position of the slice
 
virtual ~WMVectorPlot()
Destructor.
 
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...
 
WMVectorPlot()
Default constructor.
 
WPosition m_oldPos
The previous position of the slides.
 
WPropDouble m_zSlice
z position of the slice
 
Class representing a single module of OpenWalnut.
 
virtual void properties()
Initialize properties in this function.
 
wlog::WStreamedLogger debugLog() const
Logger instance for comfortable debug logging.
 
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.
 
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.
 
std::shared_ptr< WProgressCombiner > m_progress
Progress indicator used as parent for all progress' of this module.
 
virtual void connectors()
Initialize connectors in this function.
 
This only is a 3d double vector.
 
Class managing progress inside of modules.
 
WBoolFlag m_shutdownFlag
Condition getting fired whenever the thread should quit.
 
Indicates invalid type of something.