//----------------------------------------------------------------------------------
//! Constructor
//----------------------------------------------------------------------------------
WEMVolume::WEMVolume (std::string type)
  : WEMInspector(type)
{
  ML_TRACE_IN("WEMVolume::WEMVolume()")

  FieldContainer *fields = getFieldContainer();
  ML_CHECK(fields);

  // Suppress calls of handleNotification on field changes.
  handleNotificationOff();

  // Add min, max volume, and corresponding index fields
  _minVolumeFld = fields->addFloat("minVolume");
  _minVolumeFld->setFloatValue(0.0f);
  _maxVolumeFld = fields->addFloat("maxVolume");
  _maxVolumeFld->setFloatValue(0.0f);
  _minVolumeIndexFld = fields->addInt("minVolumePatchIndex");
  _minVolumeIndexFld->setIntValue(0);
  _maxVolumeIndexFld = fields->addInt("maxVolumePatchIndex");
  _maxVolumeIndexFld->setIntValue(0);
  
  // Add output curve field
  _outputVolumeCurveFld = fields->addBase("outputVolumeCurve");
  _outputVolumeCurveFld->setBaseValue(&_outputVolumeCurve);

  // Reactivate calls of handleNotification on field changes.
  handleNotificationOn();
}
//----------------------------------------------------------------------------------
//! Constructor
//----------------------------------------------------------------------------------
WEMCMSelectPatches::WEMCMSelectPatches (std::string type)
  : WEMProcessor(type, false)
{
  ML_TRACE_IN("WEMCMSelectPatches::WEMCMSelectPatches()")

  FieldContainer *fields = getFieldContainer();
  ML_CHECK(fields);

  // Suppress calls of hanbdleNotification on field changes.
  handleNotificationOff();

  // WEM Patch start and end index field
  _patchStartIndexFld = fields->addInt("patchStartIndex");
  _patchStartIndexFld->setIntValue(0);
  _patchEndIndexFld = fields->addInt("patchEndIndex");
  _patchEndIndexFld->setIntValue(0);

  // Bool field to enable to select only one patch based on start index value
  _onePatchFld = fields->addBool("onePatch");
  _onePatchFld->setBoolValue(false);
  
  // Set auto apply fields
  _autoApplyFld->setBoolValue(true);

  _notifyFld = fields->addNotify("notify");
 
  // Reactivate calls of handleNotification on field changes.
  handleNotificationOn();
}
//----------------------------------------------------------------------------------
//! Constructor
//----------------------------------------------------------------------------------
WEMNodesToFile::WEMNodesToFile (std::string type)
  : WEMInspector(type)
{
  ML_TRACE_IN("WEMNodesToFile::WEMNodesToFile()")

  FieldContainer *fields = getFieldContainer();
  ML_CHECK(fields);

  // Suppress calls of handleNotification on field changes.
  handleNotificationOff();

  // Add filename field
  _filenameFld = fields->addString("filename");
  _filenameFld->setStringValue("");

  // Add transformix option field
  _transformixCompatibleFld = fields->addBool("transformixCompatible");
  _transformixCompatibleFld->setBoolValue(false);

  // Add save button
  _saveFld = fields->addNotify("save");

  // Reactivate calls of handleNotification on field changes.
  handleNotificationOn();
}
//----------------------------------------------------------------------------------
//! Constructor
//----------------------------------------------------------------------------------
WEMCenterOfMass::WEMCenterOfMass (std::string type)
  : WEMInspector(type)
{
  ML_TRACE_IN("WEMCenterOfMass::WEMCenterOfMass()")

  FieldContainer *fieldC = getFieldContainer();
  ML_CHECK(fieldC);

  // Suppress calls of handleNotification on field changes.
  handleNotificationOff();

  // Add output fields
  _centerOfMass = fieldC->addVec3f("centerOfMass");
  _centerOfMass->setVec3fValue(vec3(0.0,0.0,0.0));
  _inverseCenterOfMass = fieldC->addVec3f("inverseCenterOfMass");
  _inverseCenterOfMass->setVec3fValue(vec3(0.0,0.0,0.0));

  _useSurface = fieldC->addBool("useSurface");
  _useSurface->setBoolValue( false );

  // Reactivate calls of handleNotification on field changes.
  handleNotificationOn();
}
CSODistance::CSODistance() : BaseOp(0, 0)
{
  ML_TRACE_IN("CSODistance::CSODistance(int numInImages, int numOutImages) : BaseOp(numInImages, numOutImages)");

  handleNotificationOff();

  _csoList0 = NULL;
  _csoList1 = NULL;
  _tableHeader = "Id1,Id2,min,max,mean,stdDev";

  FieldContainer* fieldC = getFieldContainer();
  ML_CHECK(fieldC);

  (_input0CSOFld = fieldC->addBase("inCSOList"))->setBaseValue(NULL);
  (_input1CSOFld = fieldC->addBase("inCSOList1"))->setBaseValue(NULL);

  //////////////////////////////////////////////////////////////////////////

  char* distanceModes[LASTMODE];
  distanceModes[ FIRST2 ] = "First 2 CSOs";
  distanceModes[ INPLANE ] = "Match in plane";
  distanceModes[ INDEX ] = "Match index";
  _modeFld = fieldC->addEnum("mode",distanceModes,LASTMODE);
  _modeFld->setEnumValue( FIRST2 );

  //////////////////////////////////////////////////////////////////////////

  (_minimumDistanceFld = fieldC->addFloat("minimumDistance"))->setFloatValue(0);
  (_minimumDistancePoint1Fld = fieldC->addVec3f("minimumDistancePoint1"))->setVec3fValue(vec3(0.0,0.0,0.0));
  (_minimumDistancePoint2Fld = fieldC->addVec3f("minimumDistancePoint2"))->setVec3fValue(vec3(0.0,0.0,0.0));
  _distancesFld = addString("distances",_tableHeader );

  _AverageMinimumDistanceFld = addDouble("averageMinimumDistance", 0.0 );
  _AverageMeanDistanceFld    = addDouble("averageMeanDistance", 0.0 );
  _AverageMaxDistanceFld     = addDouble("averageMaximumDistance", 0.0 );

  //////////////////////////////////////////////////////////////////////////

  _tolleranceFld = addDouble("tollerance", 0.0001 );

  //////////////////////////////////////////////////////////////////////////

  _applyFld = fieldC->addNotify("apply");
  (_autoApplyFld = fieldC->addBool("autoApply"))->setBoolValue(true);
  _statusFld = fieldC->addString("status");
  _statusFld->setStringValue("Ready");

  //////////////////////////////////////////////////////////////////////////

  (_listenToRepaintNotificationsFld          = fieldC->addBool("listenToRepaintNotifications"))
    ->setBoolValue(false);
  (_listenToFinishingNotificationsFld        = fieldC->addBool("listenToFinishingNotifications"))
    ->setBoolValue(true);
  (_listenToSelectionChangedNotificationsFld = fieldC->addBool("listenToSelectionChangedNotifications"))
    ->setBoolValue(false);

  char* statisticsNames[LASTSTATISTIC];
  statisticsNames[ MIN ] = "Minimum";
  statisticsNames[ MAX ] = "Maximum";
  statisticsNames[ MEAN ] = "Mean";
  statisticsNames[ STDEV ] = "StDev";
  _curveStatistic = addEnum("curveStatistic",statisticsNames,LASTSTATISTIC );

  _isInNotificationCB = false; 	
  
  ML_CHECK_NEW(_outputXMarkerList,XMarkerList());

	(_outputXMarkerListFld = getFieldContainer()->addBase("outputXMarkerList"))->setBaseValue(NULL);

  _outputCurveList = new CurveList;
  (_outputCurveListFld = getFieldContainer()->addBase("outputCurveList"))->setBaseValue( _outputCurveList );

  handleNotificationOn();
}