14 #include <CuttingSurface.hpp>
16 #include <Information.hpp>
25 #include <QSharedPointer>
26 #include <QStringList>
27 #include <QTextStream>
42 #define PROCESS_VERSION 1243
93 namespace mgx {
namespace process {
216 enum SystemCommand { LOAD_VIEW = 1, SAVE_VIEW, UPDATE_STRUCTURE, SET_CURRENT_STACK, TAKE_SNAPSHOT, RESET_PROJECT };
218 class PrivateProcess;
234 const char* what()
const throw() {
235 return "Process canceled by user.";
250 static unsigned int processVersion;
252 typedef std::vector<Stack*>::iterator stack_iterator;
253 typedef std::vector<Stack*>::const_iterator const_stack_iterator;
255 typedef std::vector<Mesh*>::iterator mesh_iterator;
256 typedef std::vector<Mesh*>::const_iterator const_mesh_iterator;
282 void actingFile(
const QString& filename,
bool project_file =
false);
297 int stackCount()
const;
305 Stack* currentStack();
309 int currentStackId()
const;
313 void setCurrentStackId(
int i);
316 std::pair<stack_iterator, stack_iterator> stacks();
318 std::pair<const_stack_iterator, const_stack_iterator> stacks()
const;
330 bool deleteStack(
int i);
335 int meshCount()
const;
347 int currentMeshId()
const;
351 void setCurrentMeshId(
int i);
354 std::pair<mesh_iterator, mesh_iterator> meshes();
356 std::pair<const_mesh_iterator, const_mesh_iterator> meshes()
const;
366 bool deleteMesh(
int i);
371 int selectedLabel()
const;
376 void setSelectedLabel(
int label);
381 float globalBrightness();
386 float globalContrast();
393 void setGlobalBrightness(
float value);
400 void setGlobalContrast(
float value);
405 bool meshSelection()
const;
409 bool lineBorderSelection()
const;
424 bool setErrorMessage(
const QString& str);
434 void setWarningMessage(
const QString& str);
438 QString warningMessage()
const;
468 const Clip* clip1()
const;
472 const Clip* clip2()
const;
476 const Clip* clip3()
const;
513 virtual QString type()
const = 0;
522 virtual bool operator()(
const QStringList& parms) = 0;
531 virtual QString description()
const = 0;
617 return parmDefaults().size();
628 STACK_NON_EMPTY = 0x01,
629 STACK_VISIBLE = 0x02,
633 STACK_TRANSFORMED = 0x10,
634 STACK_NON_SCALED = 0x20,
635 STACK_NON_TRANSFORMED = 0x40,
643 STORE_NON_EMPTY = 0x0001,
644 STORE_VISIBLE = 0x0002,
645 STORE_EMPTY = 0x0004,
647 STORE_LABEL = 0x0008,
648 STORE_NON_LABEL = 0x0010,
650 STORE_SCALED = 0x0020,
651 STORE_TRANSFORMED = 0x0040,
652 STORE_NON_SCALED = 0x0080,
653 STORE_NON_TRANSFORMED = 0x0100,
664 MESH_NON_EMPTY = 0x000001,
665 MESH_VISIBLE = 0x000002,
667 MESH_HEAT = 0x000004,
668 MESH_LABEL = 0x000008,
669 MESH_NORMAL = 0x000010,
671 MESH_SIGNAL = 0x000020,
672 MESH_TEXTURE = 0x000040,
673 MESH_IMAGE = 0x000080,
675 MESH_SHOW_MESH = 0x000100,
676 MESH_SHOW_SURF = 0x000200,
679 MESH_BORDER = 0x000800,
680 MESH_CELLMAP = 0x001000,
682 MESH_CELLS = 0x002000,
683 MESH_IMG_TEX = 0x004000,
684 MESH_SCALED = 0x008000,
685 MESH_TRANSFORMED = 0x010000,
687 MESH_EMPTY = 0x020000,
688 MESH_NON_CELLS = 0x040000,
689 MESH_NON_IMG_TEX = 0x080000,
690 MESH_NON_SCALED = 0x100000,
691 MESH_NON_TRANSFORMED = 0x200000,
693 MESH_PARENT = 0x400000,
694 MESH_LABEL_PARENT = 0x800000
723 CheckState& store(
int checks = STORE_ANY,
int which = CHECK_CURRENT);
727 CheckState& stack(
int checks = STACK_ANY,
int which = CHECK_CURRENT);
731 CheckState& mesh(
int checks = MESH_ANY,
int which = CHECK_CURRENT);
782 bool systemCommand(SystemCommand cmd,
const QStringList& parms);
786 bool stackCheck(
int checks,
int which);
790 bool storeCheck(
int checks,
int which);
794 bool meshCheck(
int checks,
int which);
799 QString stackError(
int checks,
int which);
803 QString storeError(
int checks,
int which);
807 QString meshError(
int checks,
int which);
820 friend class SetupProcess;
836 const Mesh* mesh(
int i) {
839 const Mesh* currentMesh() {
842 std::pair<const_mesh_iterator, const_mesh_iterator> meshes()
const {
856 friend class SetupProcess;
875 const Stack* stack(
int i) {
878 const Stack* currentStack() {
881 std::pair<const_stack_iterator, const_stack_iterator> stacks()
const {
895 friend class SetupProcess;
913 Mesh* currentMesh() {
916 Stack* stack(
int i) {
919 Stack* currentStack() {
922 std::pair<stack_iterator, stack_iterator> stacks() {
925 std::pair<const_stack_iterator, const_stack_iterator> stacks()
const {
928 std::pair<mesh_iterator, mesh_iterator> meshes() {
931 std::pair<const_mesh_iterator, const_mesh_iterator> meshes()
const {
935 bool setCurrentStack(
int id,
bool is_main);
939 bool takeSnapshot(
QString filename,
float overSampling = 1.0f,
int width = 0,
int height = 0,
int quality = 95,
940 bool expand_frustum =
false);
947 template <
typename P>
struct ProcessFactory {
948 typedef P ProcessType;
950 ProcessFactory() : cnt(0) {}
951 ProcessFactory(
const ProcessFactory&) : cnt(0) {}
952 virtual ~ProcessFactory() {}
954 virtual ProcessType* operator()(
const ProcessType& process)
const = 0;
960 template struct mgx_EXPORT ProcessFactory<StackProcess>;
961 template struct mgx_EXPORT ProcessFactory<MeshProcess>;
962 template struct mgx_EXPORT ProcessFactory<GlobalProcess>;
965 template <
typename P,
typename Process>
struct ClassProcessFactory :
public ProcessFactory<P> {
966 ClassProcessFactory() : ProcessFactory<P>() {}
967 ClassProcessFactory(
const ClassProcessFactory& copy) : ProcessFactory<P>(copy) {}
969 typedef P ProcessType;
970 virtual ProcessType* operator()(
const ProcessType& process)
const {
971 return new Process(process);
975 template <
typename X>
struct FactoryPointer {
976 typedef X ProcessType;
977 typedef ProcessFactory<X> value;
978 typedef ProcessFactory<X>* pointer;
979 typedef ProcessFactory<X>& reference;
980 typedef const ProcessFactory<X>* const_pointer;
981 typedef const ProcessFactory<X>& const_reference;
983 FactoryPointer() : p(0) {}
985 FactoryPointer(pointer ptr) : p(ptr)
990 template <
typename T>
991 FactoryPointer(T* ptr) : p(ptr)
996 FactoryPointer(
const FactoryPointer& other) : p(other.p)
1001 template <
typename T>
1002 FactoryPointer(
const FactoryPointer<T>& other) : p(other.p)
1011 operator bool()
const {
return bool(p); }
1013 ProcessType* operator()(
const ProcessType& process)
const {
1014 return (*p)(process);
1017 template <
typename T> FactoryPointer& operator=(
const T* other)
1027 FactoryPointer& operator=(
const FactoryPointer& other)
1037 template <
typename T> FactoryPointer& operator=(
const FactoryPointer<T>& other)
1047 bool operator==(
const FactoryPointer& other)
const {
1048 return p == other.p;
1051 bool operator!=(
const FactoryPointer& other)
const {
1052 return p != other.p;
1055 reference operator*() {
1058 pointer operator->() {
1062 const_reference operator*()
const {
1065 const_pointer operator->()
const {
1069 uintptr_t id()
const {
1070 return (uintptr_t)p;
1080 Information::out <<
"Deleting factory for " << util::qdemangle(
typeid(*p).name())
1097 template <
typename P>
struct Registration {
1098 typedef P ProcessType;
1099 typedef FactoryPointer<P> processFactory;
1102 Registration(processFactory f,
const char* class_name,
unsigned int compiledVersion);
1104 static factoryList& processFactories();
1106 processFactory factory;
1107 const char* classname;
1110 static factoryList factories;
1113 template <
typename P>
1114 Registration<P>::Registration(processFactory f,
const char* class_name,
unsigned int compiledVersion)
1115 : factory(), classname(class_name)
1118 Information::out <<
"Registration of process " << util::qdemangle(classname) <<
" at address 0x"
1120 <<
" Type of data: " << util::qdemangle(
typeid(*f).name()) << endl;
1122 if(Process::processVersion != compiledVersion) {
1124 err <<
"Error registering factory " << util::qdemangle(class_name) << endl
1125 <<
" It has been compiled against a different revision of MorphoGraphX:" <<
QString::number(compiledVersion)
1126 << endl <<
" and MorphoGraphX is running process revision:" <<
QString::number(Process::processVersion)
1130 if(!factory and DEBUG)
1131 Information::out <<
"Storing null factory!" << endl;
1132 processFactories() << factory;
1136 template <
typename P> Registration<P>::~Registration()
1140 Information::out <<
"Unregistration of process " << util::qdemangle(classname) <<
" at address 0x"
1142 <<
" Type of data: " << util::qdemangle(
typeid(*factory).name()) << endl;
1145 int size_before = list.
size();
1146 for(
int i = 0; i < list.
size(); ++i) {
1147 if(list[i] == factory) {
1152 if(DEBUG and list.
size() == size_before) {
1153 Information::out <<
"Error, could not find processFactory to remove" << endl;
1164 template struct mgx_EXPORT Registration<StackProcess>;
1165 template struct mgx_EXPORT Registration<MeshProcess>;
1166 template struct mgx_EXPORT Registration<GlobalProcess>;
1168 template <
typename P>
typename Registration<P>::factoryList Registration<P>::factories;
1171 typedef Registration<StackProcess> StackRegistration;
1172 typedef Registration<MeshProcess> MeshRegistration;
1173 typedef Registration<GlobalProcess> GlobalRegistration;
1175 typedef StackRegistration::processFactory stackProcessFactory;
1176 typedef MeshRegistration::processFactory meshProcessFactory;
1177 typedef GlobalRegistration::processFactory globalProcessFactory;
1180 return StackRegistration::processFactories();
1183 return MeshRegistration::processFactories();
1186 return GlobalRegistration::processFactories();
1197 #define REGISTER_STACK_PROCESS(ClassName) \
1198 mgx::process::StackRegistration ClassName ## registration(new ClassProcessFactory<StackProcess, ClassName>(), \
1199 typeid(ClassName).name(), PROCESS_VERSION)
1208 #define REGISTER_MESH_PROCESS(ClassName) \
1209 mgx::process::MeshRegistration ClassName ## registration(new ClassProcessFactory<MeshProcess, ClassName>(), \
1210 typeid(ClassName).name(), PROCESS_VERSION)
1219 #define REGISTER_GLOBAL_PROCESS(ClassName) \
1220 mgx::process::GlobalRegistration ClassName ## registration(new ClassProcessFactory<GlobalProcess, ClassName>(), \
1221 typeid(ClassName).name(), PROCESS_VERSION)
1258 typedef FactoryPointer<P> processFactory;
1270 mgx_EXPORT
extern stackProcessesMap_t stackProcesses;
1271 mgx_EXPORT
extern meshProcessesMap_t meshProcesses;
1272 mgx_EXPORT
extern globalProcessesMap_t globalProcesses;
1298 size_t* nbParms = 0);
1325 return (b ?
"Yes" :
"No");
StackProcess(const StackProcess ©)
Copy constructor.
Definition: Process.hpp:831
Definition: CuttingSurface.hpp:18
virtual uint numParms() const
Returns the number of named string for this process.
Definition: Process.hpp:616
Stack * currentStack()
Returns the current stack (i.e.
This file contains the defines the forall loops.
virtual QString type() const
Returns a string identifying the process type.
Definition: Process.hpp:833
AttribBase(const QString &name) const QString & name()
Default constructor of named attribute.
Definition: Attributes.hpp:54
virtual QString type() const
Returns a string identifying the process type.
Definition: Process.hpp:872
virtual QStringList parmDescs() const
List of parameters descriptions.
Definition: Process.hpp:554
QStringList parmNames
List of named parameters of the process.
Definition: Process.hpp:1232
Definition of a process, without the process factory.
Definition: Process.hpp:1229
Definition: Process.hpp:741
MeshCheckType
Enumeration for the bitfield that identifies mesh properties.
Definition: Process.hpp:662
mgx_EXPORT bool validProcessName(const QString &processType, const QString &processName)
Check if the processName exist in the list of processType.
std::pair< mesh_iterator, mesh_iterator > meshes()
Iterate over all the meshs.
QString name
Name of the process.
Definition: Process.hpp:1230
mgx_EXPORT bool stringToWorkStore(const QString &string)
Returns true if string correspond to the work store, false otherwise.
mgx_EXPORT bool checkProcessParms(const QString &processType, const QString &processName, const QStringList &parms, size_t *nbParms=0)
Check if the parameters have enough defaults.
number(long n, int base=10)
Exception launched when a user clicks the Cancel button.
Definition: Process.hpp:230
std::pair< stack_iterator, stack_iterator > stacks()
Iterate over all the stacks.
QIcon icon
Icon of the process.
Definition: Process.hpp:1236
Definition of a process, including the process factory.
Definition: Process.hpp:1248
This class holds the actual mesh as a VV Graph and all sort of properties for it, including visualiza...
Definition: Mesh.hpp:167
Definition: MorphoGraphX.hpp:43
mgx_EXPORT bool saveDefaultParms(const QString &processType, const QString &processName, const QStringList &parms)
Save the default parameters in memory.
StackCheckType
Enumeration for the bitfield that identifies stack properties.
Definition: Process.hpp:626
Stack * stack(int i)
Returns the ith stack, or 0 if there is no such stack.
virtual QString folder() const
Folder in which to place the process.
Definition: Process.hpp:540
GlobalProcess(const GlobalProcess ©)
Copy constructor.
Definition: Process.hpp:904
CheckType
Enumeration of the type of checks that can be performed.
Definition: Process.hpp:700
QStringList parms
List of parameters/parameter defaults.
Definition: Process.hpp:1234
virtual QStringList parmDefaults() const
List of default parms.
Definition: Process.hpp:560
QStringList storeChoice() const
Helper function that provides a list of choices for choosing from the main or work stack...
Definition: Process.hpp:607
QString description
Description of the process.
Definition: Process.hpp:1231
StoreCheckType
Enumeration for the bitfield that identifies store properties.
Definition: Process.hpp:641
virtual ~Process()
Virtual destructor.
Definition: Process.hpp:272
virtual QString type() const
Returns a string identifying the process type.
Definition: Process.hpp:907
void userCancel() const
Throw an exception informing the system that the user canceled the current process.
Definition: Process.hpp:443
processFactory factory
Process factory.
Definition: Process.hpp:1262
CheckWhich
Definition: Process.hpp:706
Mesh * mesh(int i)
Returns the ith mesh.
The Stack class represent the dimensions of the 3D data, and the frames transformations.
Definition: Stack.hpp:25
This is the main process class, the one all process inherit from.
Definition: Process.hpp:248
virtual bool initialize(QStringList &, QWidget *)
This is an optional method that is called only when a process is launched from the GUI...
Definition: Process.hpp:591
Global processes have full mutable access to all properties of the process.
Definition: Process.hpp:894
mgx_EXPORT bool stringToBool(const QString &string)
Helper function converting a string into a boolean.
virtual QIcon icon() const
Icon to use to represent the process in the GUI.
Definition: Process.hpp:577
mgx_EXPORT QStringList listProcesses(const QString &processType)
Returns the list of names of the processes of a given type.
mgx_EXPORT bool getLastParms(const QString &processType, const QString &processName, QStringList &parms)
Get the parameters for a given process.
QHash< int, QStringList > ParmChoiceMap
Type of the dictionary giving the list of possible strings for each argument.
Definition: Process.hpp:213
mgx_EXPORT BaseProcessDefinition * getBaseProcessDefinition(const QString &processType, const QString &processName)
Retrieves the process definition from the type and name of the process.
QStringList parmDescs
List of descriptions of named parameters.
Definition: Process.hpp:1233
mgx_EXPORT bool validProcessType(const QString &processType)
Check if processType is a valid type (i.e.
Class that construct a state check on the current process.
Definition: Process.hpp:715
mgx_EXPORT bool getDefaultParms(const QString &processType, const QString &processName, QStringList &parms)
Get the default parameters for a given process (i.e. the ones defined by the process) ...
bool systemCommand(SystemCommand cmd, const QStringList &parms)
Method that can be used to launch a system command.
This files contains the definition of a mesh for the Process API.
P process_t
Type of the generated process.
Definition: Process.hpp:1254
Stack processes have non-mutable access to meshes and mutable access to stacks.
Definition: Process.hpp:819
QStringList booleanChoice() const
Helper function that provides a list of choices for a boolean argument.
Definition: Process.hpp:599
QString folder
Folder in which to place the process.
Definition: Process.hpp:1235
Mesh * currentMesh()
Returns the current mesh (i.e.
QString boolToString(bool b)
Helper function converting a boolean into a string.
Definition: Process.hpp:1324
MeshProcess(const MeshProcess ©)
Copy constructor.
Definition: Process.hpp:867
ParmChoiceMap parmChoice
Map of choices for parameters.
Definition: Process.hpp:1239
Defines the Vector class template This file is shared by cuda, do not include headers that nvcc can't...
Mesh processes have mutable access to meshes and non-mutable access to stacks.
Definition: Process.hpp:855
mgx_EXPORT bool stringToMainStore(const QString &string)
Returns true if string correspond to the main store, false otherwise.
virtual ParmChoiceMap parmChoice() const
Purely for GUI purposes, provides for some of the parms parameter a choice.
Definition: Process.hpp:568