OpenWalnut  1.5.0dev
WMScalarOperator.cpp
1 //---------------------------------------------------------------------------
2 //
3 // Project: OpenWalnut ( http://www.openwalnut.org )
4 //
5 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6 // For more information see http://www.openwalnut.org/copying
7 //
8 // This file is part of OpenWalnut.
9 //
10 // OpenWalnut is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // OpenWalnut is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public License
21 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
22 //
23 //---------------------------------------------------------------------------
24 
25 #include <cmath>
26 #include <fstream>
27 #include <iostream>
28 #include <memory>
29 #include <stdint.h>
30 #include <string>
31 #include <vector>
32 
33 #include <boost/variant.hpp>
34 
35 #include "WMScalarOperator.h"
36 #include "WMScalarOperator.xpm"
37 #include "core/common/WAssert.h"
38 #include "core/common/WProgress.h"
39 #include "core/common/WStringUtils.h"
40 #include "core/common/WTypeTraits.h"
41 #include "core/common/exceptions/WTypeMismatch.h"
42 #include "core/dataHandler/WDataHandler.h"
43 #include "core/dataHandler/WDataHandlerEnums.h"
44 #include "core/dataHandler/WGridRegular3D.h"
45 #include "core/dataHandler/exceptions/WDHValueSetMismatch.h"
46 #include "core/kernel/WKernel.h"
47 
48 // This line is needed by the module loader to actually find your module.
49 W_LOADABLE_MODULE( WMScalarOperator )
50 
52  WModule()
53 {
54  // initialize
55 }
56 
58 {
59  // cleanup
61 }
62 
63 std::shared_ptr< WModule > WMScalarOperator::factory() const
64 {
65  return std::shared_ptr< WModule >( new WMScalarOperator() );
66 }
67 
68 const char** WMScalarOperator::getXPMIcon() const
69 {
70  return WMScalarOperator_xpm;
71 }
72 
73 const std::string WMScalarOperator::getName() const
74 {
75  return "Scalar Operator";
76 }
77 
78 const std::string WMScalarOperator::getDescription() const
79 {
80  return "Applies an selected operator on both datasets on a per-voxel basis. Until now, it assumes that both grids are the same.";
81 }
82 
84 {
85  m_inputA = WModuleInputData< WDataSetScalar >::createAndAdd( shared_from_this(), "operandA", "First operand of operation( A, B )." );
86  m_inputB = WModuleInputData< WDataSetScalar >::createAndAdd( shared_from_this(), "operandB", "Second operand of operation( A, B )." );
87 
88  m_output = WModuleOutputData< WDataSetScalar >::createAndAdd( shared_from_this(), "result", "Result of voxel-wise operation( A, B )." );
89 
90  // call WModules initialization
92 }
93 
95 {
96  m_propCondition = std::shared_ptr< WCondition >( new WCondition() );
97 
98  // create a list of operations here
99  m_operations = std::shared_ptr< WItemSelection >( new WItemSelection() );
100  m_operations->addItem( "A + B", "Add A to B." ); // NOTE: you can add XPM images here.
101  m_operations->addItem( "A - B", "Subtract B from A." );
102  m_operations->addItem( "A * B", "Scale A by B." );
103  m_operations->addItem( "A / B", "Divide A by B." );
104  m_operations->addItem( "abs( A - B )", "Absolute value of A - B." );
105  m_operations->addItem( "abs( A )", "Absolute value of A." );
106  m_operations->addItem( "clamp( lower, upper, A )", "Clamp A between lower and upper so that l <= A <= u." );
107  m_operations->addItem( "A * upper", "Scale data by factor." );
108  m_operations->addItem( "Binarize A by upper", "Values > upper, become 1, below or equal become 0" );
109 
110  m_opSelection = m_properties->addProperty( "Operation", "The operation to apply on A and B.", m_operations->getSelectorFirst(),
111  m_propCondition );
114 
115  m_lowerBorder = m_properties->addProperty( "Lower", "Lower border used for clamping.", 0.0, m_propCondition );
116  m_lowerBorder->removeConstraint( PC_MIN );
117  m_lowerBorder->removeConstraint( PC_MAX );
118  m_upperBorder = m_properties->addProperty( "Upper", "Upper border used for clamping.", 1.0, m_propCondition );
119  m_upperBorder->removeConstraint( PC_MIN );
120  m_upperBorder->removeConstraint( PC_MAX );
121 
123 }
124 
125 /**
126  * Some math ops.
127  */
128 namespace math
129 {
130  /**
131  * Absolute value of the specified parameter.
132  * \param u the value for which the absolute value should be returned
133  *
134  * \return absolute of u
135  */
136  template < typename T >
137  inline T wabs( T u )
138  {
139  return std::abs( u );
140  }
141 
142  /**
143  * Absolute value of the specified parameter. This is a template specialization for std::abs as 64bit Ints are not supported everywhere.
144  *
145  * \param u the value for which the absolute value should be returned
146  *
147  * \return absolute of u
148  */
149  inline int64_t wabs( int64_t u )
150  {
151  return u < 0 ? -u : u;
152  }
153 
154  /**
155  * Absolute value of the specified parameter. This is a template specialization for std::abs as it does not allow unsigned types.
156  *
157  * \param u the value for which the absolute value should be returned
158  *
159  * \return absolute of u
160  */
161  inline uint8_t wabs( uint8_t u )
162  {
163  return u;
164  }
165 
166  /**
167  * Absolute value of the specified parameter. This is a template specialization for std::abs as it does not allow unsigned types.
168  *
169  * \param u the value for which the absolute value should be returned
170  *
171  * \return absolute of u
172  */
173  inline uint16_t wabs( uint16_t u )
174  {
175  return u;
176  }
177 
178  /**
179  * Absolute value of the specified parameter. This is a template specialization for std::abs as it does not allow unsigned types.
180  *
181  * \param u the value for which the absolute value should be returned
182  *
183  * \return absolute of u
184  */
185  inline uint32_t wabs( uint32_t u )
186  {
187  return u;
188  }
189 
190  /**
191  * Absolute value of the specified parameter. This is a template specialization for std::abs as it does not allow unsigned types.
192  *
193  * \param u the value for which the absolute value should be returned
194  *
195  * \return absolute of u
196  */
197  inline uint64_t wabs( uint64_t u )
198  {
199  return u;
200  }
201 }
202 
203 /**
204  * Operator applying some op to both arguments.
205  *
206  * \tparam T Type of each parameter and the result
207  * \param a the first operant
208  * \param b the second operant
209  *
210  * \return result
211  */
212 template< typename T >
213 inline T opAbsMinus( T a, T b )
214 {
215  return math::wabs( a - b );
216 }
217 
218 /**
219  * Operator applying some op to both arguments.
220  *
221  * \tparam T Type of each parameter and the result
222  * \param a the first operant
223  * \param b the second operant
224  *
225  * \return result
226  */
227 template< typename T >
228 inline T opPlus( T a, T b )
229 {
230  return a + b;
231 }
232 
233 /**
234  * Operator applying some op to both arguments.
235  *
236  * \tparam T Type of each parameter and the result
237  * \param a the first operant
238  * \param b the second operant
239  *
240  * \return result
241  */
242 template< typename T >
243 inline T opMinus( T a, T b )
244 {
245  return a - b;
246 }
247 
248 /**
249  * Operator applying some op to both arguments.
250  *
251  * \tparam T Type of each parameter and the result
252  * \param a the first operant
253  * \param b the second operant
254  *
255  * \return result
256  */
257 template< typename T >
258 inline T opTimes( T a, T b )
259 {
260  return a * b;
261 }
262 
263 /**
264  * Operator applying some op to both arguments.
265  *
266  * \tparam T Type of each parameter and the result
267  * \param a the first operant
268  * \param b the second operant
269  *
270  * \return result
271  */
272 template< typename T >
273 inline T opDiv( T a, T b )
274 {
275  return a / b;
276 }
277 
278 /**
279  * Operator applying some op to argument.
280  *
281  * \tparam T Type of each parameter and the result
282  * \param a the first operant
283  * \param l lower border
284  * \param u upper border
285  *
286  * \return result
287  */
288 template< typename T >
289 inline T opAbs( T a, T /* l */, T /* u */ )
290 {
291  return math::wabs( a );
292 }
293 
294 /**
295  * Operator binarizing some op with certain threshold.
296  *
297  * \tparam T Type of each parameter and the result
298  * \param a the value to binarize
299  * \param l lower border
300  * \param u upper border, used to decied if value greater becomes one or beneath or equal becomes 0.
301  *
302  * \return result
303  */
304 template< typename T >
305 inline T opBinarizeByA( T a, T /* l */, T u )
306 {
307  return ( a > u ) ? 1 : 0;
308 }
309 
310 /**
311  * Operator applying some op to argument.
312  *
313  * \tparam T Type of each parameter and the result
314  * \param a the first operant
315  * \param l lower border
316  * \param u upper border
317  *
318  * \return result
319  */
320 template< typename T >
321 inline T opClamp( T a, T l, T u )
322 {
323  T uclamp = a > u ? u : a;
324  return uclamp < l ? l : uclamp;
325 }
326 
327 /**
328  * Operator applying some op to argument.
329  *
330  * \tparam T Type of each parameter and the result
331  * \param v the first operant
332  * \param l ignored
333  * \param u scaler
334  *
335  * \return result
336  */
337 template< typename T >
338 inline T opScaleByA( T v, T /* l */, T u )
339 {
340  return v * u;
341 }
342 
343 /**
344  * The second visitor which got applied to the second value set. It discriminates the integral type and applies the operator in a per value
345  * style.
346  *
347  * \tparam VSetAType The integral type of the first valueset.
348  */
349 template< typename VSetAType >
350 class VisitorVSetB: public boost::static_visitor< std::shared_ptr< WValueSetBase > >
351 {
352 public:
353  /**
354  * Creates visitor for the second level of cascading. Takes the first value set as parameter. This visitor applies the operation o to A and
355  * B: o(A,B).
356  *
357  * \param vsetA the first value set
358  * \param opIdx The operator index. Depending on the index, the right operation is selected
359  */
360  VisitorVSetB( const WValueSet< VSetAType >* const vsetA, size_t opIdx = 0 ):
361  boost::static_visitor< result_type >(),
362  m_vsetA( vsetA ),
363  m_opIdx( opIdx )
364  {
365  }
366 
367  /**
368  * Visitor on the second valueset. This applies the operation.
369  *
370  * \tparam VSetBType the integral type of the currently visited valueset.
371  * \param vsetB the valueset currently visited (B).
372  *
373  * \return the result of o(A,B)
374  */
375  template < typename VSetBType >
376  result_type operator()( const WValueSet< VSetBType >* const& vsetB ) const // NOLINT
377  {
378  // get best matching return scalar type
380 
381  size_t order = m_vsetA->order();
382  size_t dim = m_vsetA->dimension();
384  std::vector< ResultT > data;
385  data.resize( m_vsetA->rawSize() );
386 
387  // discriminate the right operation with the correct type. It would be nicer to use some kind of strategy pattern here, but the template
388  // character of the operators forbids it as template methods can't be virtual. Besides this, at some point in the module main the
389  // selector needs to be queried and its index mapped to a pointer. This is what we do here.
390  boost::function< ResultT( ResultT, ResultT ) > op;
391  switch( m_opIdx )
392  {
393  case 1:
394  op = &opMinus< ResultT >;
395  break;
396  case 2:
397  op = &opTimes< ResultT >;
398  break;
399  case 3:
400  op = &opDiv< ResultT >;
401  break;
402  case 4:
403  op = &opAbsMinus< ResultT >;
404  break;
405  case 0:
406  default:
407  op = &opPlus< ResultT >;
408  break;
409  }
410 
411  // apply op to each value
412  const VSetAType* a = m_vsetA->rawData();
413  const VSetBType* b = vsetB->rawData();
414  for( size_t i = 0; i < m_vsetA->rawSize(); ++i )
415  {
416  data[ i ] = op( static_cast< ResultT >( a[ i ] ), static_cast< ResultT >( b[ i ] ) );
417  }
418 
419  // create result value set
420  std::shared_ptr< WValueSet< ResultT > > result = std::shared_ptr< WValueSet< ResultT > >(
421  new WValueSet< ResultT >( order,
422  dim,
423  std::shared_ptr< std::vector< ResultT > >( new std::vector< ResultT >( data ) ),
424  type )
425  );
426  return result;
427  }
428 
429  /**
430  * The first valueset.
431  */
433 
434  /**
435  * The operator index.
436  */
437  size_t m_opIdx;
438 };
439 
440 /**
441  * Visitor for discriminating the type of the first valueset. It simply creates a new instance of VisitorVSetB with the proper integral type of
442  * the first value set.
443  */
444 class VisitorVSetA: public boost::static_visitor< std::shared_ptr< WValueSetBase > >
445 {
446 public:
447  /**
448  * Create visitor instance. The specified valueset gets visited if the first one is visited using this visitor.
449  *
450  * \param vsetB The valueset to visit during this visit.
451  * \param opIdx The operator index. Forwarded to VisitorVSetB
452  */
453  VisitorVSetA( WValueSetBase* vsetB, size_t opIdx = 0 ):
454  boost::static_visitor< result_type >(),
455  m_vsetB( vsetB ),
456  m_opIdx( opIdx )
457  {
458  }
459 
460  /**
461  * Called by boost::varying during static visiting. Creates a new VisitorVSetB which finally applies the operation.
462  *
463  * \tparam T the real integral type of the first value set.
464  * \param vsetA the first valueset currently visited.
465  *
466  * \return the result from the operation with this and the second value set
467  */
468  template < typename T >
469  result_type operator()( const WValueSet< T >* const& vsetA ) const // NOLINT
470  {
471  // visit the second value set as we now know the type of the first one
472  VisitorVSetB< T > visitor( vsetA, m_opIdx );
473  return m_vsetB->applyFunction( visitor );
474  }
475 
476  /**
477  * The valueset where to cascade.
478  */
480 
481  /**
482  * The operator index.
483  */
484  size_t m_opIdx;
485 };
486 
487 /**
488  * Visitor for discriminating the type of the first valueset. It should be used for operations on ONE valueset.
489  */
490 class VisitorVSetSingleArgument: public boost::static_visitor< std::shared_ptr< WValueSetBase > >
491 {
492 public:
493  /**
494  * Create visitor instance. The specified valueset gets visited if the first one is visited using this visitor.
495  *
496  * \param opIdx The operator index. Forwarded to VisitorVSetB
497  */
498  explicit VisitorVSetSingleArgument( size_t opIdx = 0 ):
499  boost::static_visitor< result_type >(),
500  m_opIdx( opIdx )
501  {
502  }
503 
504  /**
505  * Called by boost::varying during static visiting. Applies the operation to it
506  *
507  * \tparam T the real integral type of the first value set.
508  * \param vsetA the first valueset currently visited.
509  *
510  * \return the result from the operation with this and the second value set
511  */
512  template < typename T >
513  result_type operator()( const WValueSet< T >* const& vsetA ) const // NOLINT
514  {
515  // get best matching return scalar type
516  typedef T ResultT;
517 
518  size_t order = vsetA->order();
519  size_t dim = vsetA->dimension();
521  std::vector< ResultT > data;
522  data.resize( vsetA->rawSize() );
523 
524  // discriminate the right operation with the correct type. It would be nicer to use some kind of strategy pattern here, but the template
525  // character of the operators forbids it as template methods can't be virtual. Besides this, at some point in the module main the
526  // selector needs to be queried and its index mapped to a pointer. This is what we do here.
527  boost::function< ResultT( ResultT, ResultT l, ResultT u ) > op;
528  switch( m_opIdx )
529  {
530  case 5:
531  op = &opAbs< ResultT >;
532  break;
533  case 6:
534  op = &opClamp< ResultT >;
535  break;
536  case 7:
537  op = &opScaleByA< ResultT >;
538  break;
539  case 8:
540  op = &opBinarizeByA< ResultT >;
541  break;
542  default:
543  op = &opAbs< ResultT >;
544  break;
545  }
546 
547  // apply op to each value
548  const T* a = vsetA->rawData();
549  for( size_t i = 0; i < vsetA->rawSize(); ++i )
550  {
551  data[ i ] = op( a[ i ], m_lowerBorder, m_upperBorder );
552  }
553 
554  // create result value set
555  std::shared_ptr< WValueSet< ResultT > > result = std::shared_ptr< WValueSet< ResultT > >(
556  new WValueSet< ResultT >( order,
557  dim,
558  std::shared_ptr< std::vector< ResultT > >( new std::vector< ResultT >( data ) ),
559  type )
560  );
561  return result;
562  }
563 
564  /**
565  * Set lower and upper border needed for several ops.
566  *
567  * \param l lower border
568  * \param u upper border
569  */
570  void setBorder( double l, double u )
571  {
572  m_lowerBorder = l;
573  m_upperBorder = u;
574  }
575 
576  /**
577  * The operator index.
578  */
579  size_t m_opIdx;
580 
581  /**
582  * Lower border needed for several ops.
583  */
585 
586  /**
587  * Upper border needed for several ops.
588  */
590 };
591 
593 {
594  // let the main loop awake if the data changes or the properties changed.
595  m_moduleState.setResetable( true, true );
596  m_moduleState.add( m_inputA->getDataChangedCondition() );
597  m_moduleState.add( m_inputB->getDataChangedCondition() );
599 
600  // signal ready state
601  ready();
602 
603  // loop until the module container requests the module to quit
604  while( !m_shutdownFlag() )
605  {
606  // Now, the moduleState variable comes into play. The module can wait for the condition, which gets fired whenever the input receives data
607  // or an property changes. The main loop now waits until something happens.
608  debugLog() << "Waiting ...";
610 
611  // woke up since the module is requested to finish
612  if( m_shutdownFlag() )
613  {
614  break;
615  }
616 
617  bool propsChanged = m_lowerBorder->changed() || m_upperBorder->changed();
618 
619  // has the data changed?
620  if( m_opSelection->changed() || propsChanged || m_inputA->handledUpdate() || m_inputB->handledUpdate() )
621  {
622  std::shared_ptr< WDataSetScalar > dataSetA = m_inputA->getData();
623  std::shared_ptr< WDataSetScalar > dataSetB = m_inputB->getData();
624  if( !dataSetA )
625  {
626  // reset output if input was reset/disconnected
627  debugLog() << "Resetting output.";
628  m_output->reset();
629  continue;
630  }
631 
632  // the first value-set is always needed -> grab it
633  std::shared_ptr< WValueSetBase > valueSetA = dataSetA->getValueSet();
634 
635  // use a custom progress combiner
636  std::shared_ptr< WProgress > prog = std::shared_ptr< WProgress >(
637  new WProgress( "Applying operator on data" ) );
638  m_progress->addSubProgress( prog );
639 
640  // apply the operation to each voxel
641  debugLog() << "Processing ...";
642 
643  // kind of operation?
644  WItemSelector s = m_opSelection->get( true );
645 
646  // this keeps the result
647  std::shared_ptr< WValueSetBase > newValueSet;
648 
649  // single operand operation?
650  if( ( s == 5 ) || ( s == 6 ) || ( s == 7 ) || ( s == 8 ) )
651  {
652  VisitorVSetSingleArgument visitor( s ); // the visitor cascades to the second value set
653  visitor.setBorder( m_lowerBorder->get( true ), m_upperBorder->get( true ) );
654  newValueSet = valueSetA->applyFunction( visitor );
655  }
656  else // multiple operands:
657  {
658  // valid data?
659  if( dataSetB )
660  {
661  std::shared_ptr< WValueSetBase > valueSetB = dataSetB->getValueSet();
662 
663  // both value sets need to be the same
664  bool match = ( valueSetA->dimension() == valueSetB->dimension() ) &&
665  ( valueSetA->order() == valueSetB->order() ) &&
666  ( valueSetA->rawSize() == valueSetB->rawSize() );
667  if( !match )
668  {
669  throw WDHValueSetMismatch( std::string( "The two value sets are not of equal size, dimension and order." ) );
670  }
671 
672  VisitorVSetA visitor( valueSetB.get(), s ); // the visitor cascades to the second value set
673  newValueSet = valueSetA->applyFunction( visitor );
674 
675  // Create the new dataset and export it
676  m_output->updateData( std::shared_ptr<WDataSetScalar>( new WDataSetScalar( newValueSet, m_inputA->getData()->getGrid() ) ) );
677  }
678  else
679  {
680  // reset output if input was reset/disconnected
681  debugLog() << "Resetting output.";
682  m_output->reset();
683 
684  // remove progress too
685  prog->finish();
686  m_progress->removeSubProgress( prog );
687 
688  continue;
689  }
690  }
691 
692  // Create the new dataset and export it
693  if( newValueSet )
694  {
695  m_output->updateData( std::shared_ptr<WDataSetScalar>( new WDataSetScalar( newValueSet, dataSetA->getGrid() ) ) );
696  }
697 
698  // done
699  prog->finish();
700  m_progress->removeSubProgress( prog );
701  }
702  }
703 }
704 
Visitor for discriminating the type of the first valueset.
result_type operator()(const WValueSet< T > *const &vsetA) const
Called by boost::varying during static visiting.
size_t m_opIdx
The operator index.
VisitorVSetA(WValueSetBase *vsetB, size_t opIdx=0)
Create visitor instance.
WValueSetBase * m_vsetB
The valueset where to cascade.
The second visitor which got applied to the second value set.
result_type operator()(const WValueSet< VSetBType > *const &vsetB) const
Visitor on the second valueset.
const WValueSet< VSetAType > *const m_vsetA
The first valueset.
VisitorVSetB(const WValueSet< VSetAType > *const vsetA, size_t opIdx=0)
Creates visitor for the second level of cascading.
size_t m_opIdx
The operator index.
Visitor for discriminating the type of the first valueset.
result_type operator()(const WValueSet< T > *const &vsetA) const
Called by boost::varying during static visiting.
VisitorVSetSingleArgument(size_t opIdx=0)
Create visitor instance.
size_t m_opIdx
The operator index.
void setBorder(double l, double u)
Set lower and upper border needed for several ops.
double m_lowerBorder
Lower border needed for several ops.
double m_upperBorder
Upper border needed for several ops.
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 encapsulate boost::condition_variable_any.
Definition: WCondition.h:42
An exception that should be used whenever two valuesets are used which need to be of same size,...
This data set type contains scalars as values.
A class containing a list of named items.
This class represents a subset of a WItemSelection.
Definition: WItemSelector.h:53
Operators for processing two WDataSetScalar.
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...
WMScalarOperator()
Standard constructor.
virtual const char ** getXPMIcon() const
Get the icon for this module in XPM format.
virtual const std::string getDescription() const
Gives back a description of this module.
std::shared_ptr< WModuleOutputData< WDataSetScalar > > m_output
The only output of this filter module.
virtual const std::string getName() const
Gives back the name of this module.
WPropDouble m_lowerBorder
Lower border used for clamping.
WPropDouble m_upperBorder
Upper border used for clamping.
std::shared_ptr< WItemSelection > m_operations
A list of operations that are possible.
std::shared_ptr< WCondition > m_propCondition
A condition used to notify about changes in several properties.
~WMScalarOperator()
Destructor.
std::shared_ptr< WModuleInputData< WDataSetScalar > > m_inputB
Input connector required by this module.
virtual void properties()
Initialize the properties for this module.
WPropSelection m_opSelection
The currently selected operation.
std::shared_ptr< WModuleInputData< WDataSetScalar > > m_inputA
Input connector required by this module.
virtual void moduleMain()
Entry point after loading the module.
virtual void connectors()
Initialize the connectors this module is using.
static PtrType createAndAdd(std::shared_ptr< WModule > module, std::string name="", std::string description="")
Convenience method to create a new instance of this in data connector with proper type and add it to ...
static PtrType createAndAdd(std::shared_ptr< WModule > module, std::string name="", std::string description="")
Convenience method to create a new instance of this out data connector with proper type and add it to...
Class representing a single module of OpenWalnut.
Definition: WModule.h:72
virtual void properties()
Initialize properties in this function.
Definition: WModule.cpp:212
wlog::WStreamedLogger debugLog() const
Logger instance for comfortable debug logging.
Definition: WModule.cpp:575
void removeConnectors()
Removes all connectors properly.
Definition: WModule.cpp:194
std::shared_ptr< WProperties > m_properties
The property object for the module.
Definition: WModule.h:640
void ready()
Call this whenever your module is ready and can react on property changes.
Definition: WModule.cpp:505
WConditionSet m_moduleState
The internal state of the module.
Definition: WModule.h:703
std::shared_ptr< WProgressCombiner > m_progress
Progress indicator used as parent for all progress' of this module.
Definition: WModule.h:652
virtual void connectors()
Initialize connectors in this function.
Definition: WModule.cpp:208
Class managing progress inside of modules.
Definition: WProgress.h:42
WBoolFlag m_shutdownFlag
Condition getting fired whenever the thread should quit.
Class for checking the "better" type if two integral types are known.
Definition: WTypeTraits.h:46
Abstract base class to all WValueSets.
Definition: WValueSetBase.h:60
virtual size_t dimension() const
Func_T::result_type applyFunction(Func_T const &func)
Apply a function object to this valueset.
virtual size_t order() const
const T * rawData() const
Sometimes we need raw access to the data array, for e.g.
Definition: WValueSet.h:240
virtual size_t rawSize() const
Definition: WValueSet.h:184
dataType
Data types and number values taken from the nifti1.h, at this point it's unknown if it makes sense to...
void addTo(WPropSelection prop)
Add the PC_NOTEMPTY constraint to the property.
void addTo(WPropSelection prop)
Add the PC_SELECTONLYONE constraint to the property.
Some math ops.
T wabs(T u)
Absolute value of the specified parameter.
An object that knows an appropriate dataType flag for the typename T.