MorphoGraphX  2.0-1-227
Public Member Functions | List of all members
mgx::UserCancelException Class Reference

#include <Process.hpp>

+ Inheritance diagram for mgx::UserCancelException:

Public Member Functions

 UserCancelException ()
 
const char * what () const throw ()
 

Detailed Description

          Here is a template of a minimal process:

Basics

class DoNothing : public Process
{
public:
// Processes can only be created with the copy constructor
DoNothing(const StackProcess& proc) : Process(proc)
{
setName("Nothing");
setDescription("Do nothing");
}
// Define what the class do ... here it's nothing
bool run() { return true; }
};

Then, in the implementation file, you need to add:

REGISTER_PROCESS(DoNothing);

Which will take care of registering the process to the system when the library is loaded.

Recommendations

Beside the minimal process, it is recommended to structure the process in two functions: the first one taking generic arguments (i.e. a string list and a float list), the other one taking specific arguments. This way, your process will be easier to use from another C++ process.

Also, to help providing meaningful (and uniform) error messages, and to help you testing the current state of the process, the checkState() method is provided.

The structure then typically becomes:

class DoSomething : public Process
{
public:
// Add parameters in the constructor as follows:
// addParm(name, description, default, pick-list);
//
// Name, description, and default are all QStrings, pick-list is a QStringList.
//
DoSomething(const StackProcess& proc) : Process(proc)
{
setName("Nothing");
setDescription("Do nothing");
// This time, we have four parameters
addParm("Store", "The store to process", "Work", storeChoice);
addParm("Amount", "The amount to process", "2.0");
addParm("Verbose", "Report additional information?", "Yes", booleanChoice);
addParm("User Parm", "A dropdown defined by the user", "Case1", QStringList << "Case1" << "Case2");
}
// Run the process
bool run()
{
Store *store = currentStack()->work();
bool isneeded = stringToBool(parms[1]);
QString aname = parms[2];
float param = parms[3].toFloat();
bool result =
run(stringToStore(parm("Store")), parm("Amount").toDouble(), stringToBool(parm("Verbose")), parm("User Parm"));
// Update store if successful
if(result)
store->changed();
return result;
}
// run() with specialized arguments is recommended to be used by other C++ processes
bool run(Store *store, double amount, bool percent, const QString &userParm)
{
// Do what is needed, return false if failed
return true;
}
};

Exception launched when a user clicks the Cancel button. When writing your own processes, you should use the userCancel() method.

Definition at line 204 of file Process.hpp.

Constructor & Destructor Documentation

◆ UserCancelException()

mgx::UserCancelException::UserCancelException ( )
inline

Definition at line 206 of file Process.hpp.

Member Function Documentation

◆ what()

const char* mgx::UserCancelException::what ( ) const
throw (
)
inline

Definition at line 208 of file Process.hpp.


The documentation for this class was generated from the following file:
mgx::stringToBool
mgx_EXPORT bool stringToBool(const QString &string)
Helper function converting a string into a boolean.
REGISTER_PROCESS
#define REGISTER_PROCESS(ClassName)
Definition: Process.hpp:863