You are here: User's Guide > SPIP Plug-ins > Roughness Plug-in

Roughness Plug-in

A roughness plug-in enables you to calculate special parameters not supported by SPIP and get the results listed along with the other roughness parameters delivered by SPIP. Furthermore, you can have the parameters available for the ActiveReporter.

To create a Microsoft Visual Studio 2005 C++ File Importer project click

Plug-ins > Programming Tools > Project Creator and select Visual Studio 2005 C++ Roughness Parameters as Project Type:

 

When the project has been generated you will be asked if you want to open it and you may find it convenient to do so. Otherwise, you can later open its solution file (e.g., MyRoughnessPlugIn.sln) in Visual Studio.

 

The Project is now ready to be build: in Visual Studio click Build > Build Solution and the resulting .dll will put into the SPIP\UserDLL\Roughness\ folder where it is automatically found by SPIP next time SPIP is started. Note that roughness plug-ins should always be placed in the SPIP\UserDLL\Roughness\ folder to be recognized by SPIP.

 

extern "C" _declspec(dllexport) bool ImCalculateParameter( )

{

 // Define the Parameters which this function calculates

 ResultParameterSet ParameterResultMax, ParameterResultMin;

 

 ParameterResultMin.ID = L"SplugMin";

 ParameterResultMin.FriendlyName = L"Plugin parameter Min";

 ParameterResultMin.Result = 0;

 ParameterResultMin.FriendlyLongName = L"Plugin Roughness Parameter Min";

 ParameterResultMin.StandardRef = L"";

 ParameterResultMin.Unit= L"nm";

 

 ParameterResultMax.ID = L"SplugMax";

 ParameterResultMax.FriendlyName = L"Plugin parameter Max";

 ParameterResultMax.Result = 0;

 ParameterResultMax.FriendlyLongName = L"Plugin Roughness Parameter Max";

 ParameterResultMax.StandardRef = L"";

 ParameterResultMax.Unit= L"nm";

 

 CSpipExchange img;

 

 if (!img.Get_ImageData()){

  // SPIP is not providing any image data

  // Just return the definitions without calculation so that SPIP knows

  // what can be calculated

  img.Add_ParameterToResultList( ParameterResultMin);

  img.Add_ParameterToResultList( ParameterResultMax);

  return true;

 }

 else{

  // To do Add your calculation here

 

  float min, max;

  min = max = img.Data[0];

  int i = 0;

  for (int y=0; y<img.SizeY; y++){

   for (int x=0; x<img.SizeX;x ++, i++){

    if (img.Data[i] > max)

     max = img.Data[i];

    else if (img.Data[i] < min)

     min = img.Data[i];

   }

  }

  ParameterResultMin.Result = min;

  ParameterResultMax.Result = max;

  img.Add_ParameterToResultList( ParameterResultMin);

  img.Add_ParameterToResultList( ParameterResultMax);

 }

 return true;

}

 

The important functions to have in mind when constructing a roughness parameter plug-in are:

bool ImCalculateParameter() which is the function SPIP will be looking for when retrieving information about the supported parameters and call when performing a roughness analysis.

If you in some situation want to avoid the calculation for these parameters they may be deselected in the OptionsàPreferences dialog or via the roughness result grid dialog. Below is seen how the parameters will appear in the Roughness Analysis Parameters dialog:

 

When SPIP returns a NULL pointer from Get_ImageData() the function shall just provide information about the parameters that can be calculated. This information is defined in the ResultParameterSet structure and provided through the Add_ParameterToResultList function.

 

This function serves two purposes:

  1. It informs SPIP about the parameters this plug-in can provide

  2. In case a calculation has been performed it should also be used for delivering the parameter value.

The information is provided through the ResultParameterSet structure. Currently only the ID, FriendlyName, Unit and Result structure fields are used by SPIP. FriendlyLongName and StandardRef are meant for future use

 

It is possible to make your plug-in parameters available for Active Reporting you just have to click the Plug-Ins > Utilities > Make Plug-in Parameters Available for Active Reporting:

 

 

Next time you insert a SPIP control in a MS Word active reporter template you will be able to select your own plug-in parameters and have them show by their actual values or as e.g. statistical mean values in the summary field when combining Batch Processing with Active Reporting. Below is shown how the plug-in parameters may appear in the SPIP control dialog:

 

of