24 #include <CuttingSurface.hpp> 26 #include <Information.hpp> 35 #include <QSharedPointer> 36 #include <QStringList> 37 #include <QTextStream> 52 #define PROCESS_VERSION 1243 226 enum SystemCommand { LOAD_VIEW = 1, SAVE_VIEW, UPDATE_STRUCTURE, SET_CURRENT_STACK, TAKE_SNAPSHOT, RESET_PROJECT };
228 class PrivateProcess;
244 const char* what()
const throw() {
245 return "Process canceled by user.";
260 static unsigned int processVersion;
262 typedef std::vector<Stack*>::iterator stack_iterator;
263 typedef std::vector<Stack*>::const_iterator const_stack_iterator;
265 typedef std::vector<Mesh*>::iterator mesh_iterator;
266 typedef std::vector<Mesh*>::const_iterator const_mesh_iterator;
292 void actingFile(
const QString& filename,
bool project_file =
false);
307 int stackCount()
const;
315 Stack* currentStack();
319 int currentStackId()
const;
323 void setCurrentStackId(
int i);
326 std::pair<stack_iterator, stack_iterator> stacks();
328 std::pair<const_stack_iterator, const_stack_iterator> stacks()
const;
340 bool deleteStack(
int i);
345 int meshCount()
const;
357 int currentMeshId()
const;
361 void setCurrentMeshId(
int i);
364 std::pair<mesh_iterator, mesh_iterator> meshes();
366 std::pair<const_mesh_iterator, const_mesh_iterator> meshes()
const;
376 bool deleteMesh(
int i);
381 int selectedLabel()
const;
386 void setSelectedLabel(
int label);
391 float globalBrightness();
396 float globalContrast();
403 void setGlobalBrightness(
float value);
410 void setGlobalContrast(
float value);
415 bool meshSelection()
const;
419 bool lineBorderSelection()
const;
434 bool setErrorMessage(
const QString& str);
444 void setWarningMessage(
const QString& str);
448 QString warningMessage()
const;
478 const Clip* clip1()
const;
482 const Clip* clip2()
const;
486 const Clip* clip3()
const;
523 virtual QString type()
const = 0;
532 virtual bool operator()(
const QStringList& parms) = 0;
537 virtual QString name()
const = 0;
541 virtual QString description()
const = 0;
627 return parmDefaults().size();
638 STACK_NON_EMPTY = 0x01,
639 STACK_VISIBLE = 0x02,
643 STACK_TRANSFORMED = 0x10,
644 STACK_NON_SCALED = 0x20,
645 STACK_NON_TRANSFORMED = 0x40,
653 STORE_NON_EMPTY = 0x0001,
654 STORE_VISIBLE = 0x0002,
655 STORE_EMPTY = 0x0004,
657 STORE_LABEL = 0x0008,
658 STORE_NON_LABEL = 0x0010,
660 STORE_SCALED = 0x0020,
661 STORE_TRANSFORMED = 0x0040,
662 STORE_NON_SCALED = 0x0080,
663 STORE_NON_TRANSFORMED = 0x0100,
674 MESH_NON_EMPTY = 0x000001,
675 MESH_VISIBLE = 0x000002,
677 MESH_HEAT = 0x000004,
678 MESH_LABEL = 0x000008,
679 MESH_NORMAL = 0x000010,
681 MESH_SIGNAL = 0x000020,
682 MESH_TEXTURE = 0x000040,
683 MESH_IMAGE = 0x000080,
685 MESH_SHOW_MESH = 0x000100,
686 MESH_SHOW_SURF = 0x000200,
689 MESH_BORDER = 0x000800,
690 MESH_CELLMAP = 0x001000,
692 MESH_CELLS = 0x002000,
693 MESH_IMG_TEX = 0x004000,
694 MESH_SCALED = 0x008000,
695 MESH_TRANSFORMED = 0x010000,
697 MESH_EMPTY = 0x020000,
698 MESH_NON_CELLS = 0x040000,
699 MESH_NON_IMG_TEX = 0x080000,
700 MESH_NON_SCALED = 0x100000,
701 MESH_NON_TRANSFORMED = 0x200000,
703 MESH_PARENT = 0x400000,
704 MESH_LABEL_PARENT = 0x800000
733 CheckState& store(
int checks = STORE_ANY,
int which = CHECK_CURRENT);
737 CheckState& stack(
int checks = STACK_ANY,
int which = CHECK_CURRENT);
741 CheckState& mesh(
int checks = MESH_ANY,
int which = CHECK_CURRENT);
792 bool systemCommand(SystemCommand cmd,
const QStringList& parms);
796 bool stackCheck(
int checks,
int which);
800 bool storeCheck(
int checks,
int which);
804 bool meshCheck(
int checks,
int which);
809 QString stackError(
int checks,
int which);
813 QString storeError(
int checks,
int which);
817 QString meshError(
int checks,
int which);
830 friend class SetupProcess;
846 const Mesh* mesh(
int i) {
849 const Mesh* currentMesh() {
852 std::pair<const_mesh_iterator, const_mesh_iterator> meshes()
const {
866 friend class SetupProcess;
885 const Stack* stack(
int i) {
888 const Stack* currentStack() {
891 std::pair<const_stack_iterator, const_stack_iterator> stacks()
const {
905 friend class SetupProcess;
923 Mesh* currentMesh() {
926 Stack* stack(
int i) {
929 Stack* currentStack() {
932 std::pair<stack_iterator, stack_iterator> stacks() {
935 std::pair<const_stack_iterator, const_stack_iterator> stacks()
const {
938 std::pair<mesh_iterator, mesh_iterator> meshes() {
941 std::pair<const_mesh_iterator, const_mesh_iterator> meshes()
const {
945 bool setCurrentStack(
int id,
bool is_main);
949 bool takeSnapshot(
QString filename,
float overSampling = 1.0f,
int width = 0,
int height = 0,
int quality = 95,
950 bool expand_frustum =
false);
957 template <
typename P>
struct ProcessFactory {
958 typedef P ProcessType;
960 ProcessFactory() : cnt(0) {}
961 ProcessFactory(
const ProcessFactory&) : cnt(0) {}
962 virtual ~ProcessFactory() {}
964 virtual ProcessType* operator()(
const ProcessType&
process)
const = 0;
970 template struct mgx_EXPORT ProcessFactory<StackProcess>;
971 template struct mgx_EXPORT ProcessFactory<MeshProcess>;
972 template struct mgx_EXPORT ProcessFactory<GlobalProcess>;
975 template <
typename P,
typename Process>
struct ClassProcessFactory :
public ProcessFactory<P> {
976 ClassProcessFactory() : ProcessFactory<P>() {}
977 ClassProcessFactory(
const ClassProcessFactory& copy) : ProcessFactory<P>(copy) {}
979 typedef P ProcessType;
980 virtual ProcessType* operator()(
const ProcessType&
process)
const {
985 template <
typename X>
struct FactoryPointer {
986 typedef X ProcessType;
987 typedef ProcessFactory<X> value;
988 typedef ProcessFactory<X>* pointer;
989 typedef ProcessFactory<X>& reference;
990 typedef const ProcessFactory<X>* const_pointer;
991 typedef const ProcessFactory<X>& const_reference;
993 FactoryPointer() : p(0) {}
995 FactoryPointer(pointer ptr) : p(ptr)
1000 template <
typename T>
1001 FactoryPointer(T* ptr) : p(ptr)
1006 FactoryPointer(
const FactoryPointer& other) : p(other.p)
1011 template <
typename T>
1012 FactoryPointer(
const FactoryPointer<T>& other) : p(other.p)
1021 operator bool()
const {
return bool(p); }
1023 ProcessType* operator()(
const ProcessType&
process)
const {
1024 return (*p)(process);
1027 template <
typename T> FactoryPointer& operator=(
const T* other)
1037 FactoryPointer& operator=(
const FactoryPointer& other)
1047 template <
typename T> FactoryPointer& operator=(
const FactoryPointer<T>& other)
1057 bool operator==(
const FactoryPointer& other)
const {
1058 return p == other.p;
1061 bool operator!=(
const FactoryPointer& other)
const {
1062 return p != other.p;
1065 reference operator*() {
1068 pointer operator->() {
1072 const_reference operator*()
const {
1075 const_pointer operator->()
const {
1079 uintptr_t id()
const {
1080 return (uintptr_t)p;
1090 Information::out <<
"Deleting factory for " << util::qdemangle(
typeid(*p).name())
1107 template <
typename P>
struct Registration {
1108 typedef P ProcessType;
1109 typedef FactoryPointer<P> processFactory;
1112 Registration(processFactory f,
const char* class_name,
unsigned int compiledVersion);
1114 static factoryList& processFactories();
1116 processFactory factory;
1117 const char* classname;
1120 static factoryList factories;
1123 template <
typename P>
1124 Registration<P>::Registration(processFactory f,
const char* class_name,
unsigned int compiledVersion)
1125 : factory(), classname(class_name)
1128 Information::out <<
"Registration of process " << util::qdemangle(classname) <<
" at address 0x" 1130 <<
" Type of data: " << util::qdemangle(
typeid(*f).name()) << endl;
1132 if(Process::processVersion != compiledVersion) {
1134 err <<
"Error registering factory " << util::qdemangle(class_name) << endl
1135 <<
" It has been compiled against a different revision of MorphoGraphX:" <<
QString::number(compiledVersion)
1136 << endl <<
" and MorphoGraphX is running process revision:" <<
QString::number(Process::processVersion)
1140 if(!factory and DEBUG)
1141 Information::out <<
"Storing null factory!" << endl;
1142 processFactories() << factory;
1146 template <
typename P> Registration<P>::~Registration()
1150 Information::out <<
"Unregistration of process " << util::qdemangle(classname) <<
" at address 0x" 1152 <<
" Type of data: " << util::qdemangle(
typeid(*factory).name()) << endl;
1155 int size_before = list.size();
1156 for(
int i = 0; i < list.size(); ++i) {
1157 if(list[i] == factory) {
1162 if(DEBUG and list.size() == size_before) {
1163 Information::out <<
"Error, could not find processFactory to remove" << endl;
1174 template struct mgx_EXPORT Registration<StackProcess>;
1175 template struct mgx_EXPORT Registration<MeshProcess>;
1176 template struct mgx_EXPORT Registration<GlobalProcess>;
1178 template <
typename P>
typename Registration<P>::factoryList Registration<P>::factories;
1181 typedef Registration<StackProcess> StackRegistration;
1182 typedef Registration<MeshProcess> MeshRegistration;
1183 typedef Registration<GlobalProcess> GlobalRegistration;
1185 typedef StackRegistration::processFactory stackProcessFactory;
1186 typedef MeshRegistration::processFactory meshProcessFactory;
1187 typedef GlobalRegistration::processFactory globalProcessFactory;
1190 return StackRegistration::processFactories();
1193 return MeshRegistration::processFactories();
1196 return GlobalRegistration::processFactories();
1207 #define REGISTER_STACK_PROCESS(ClassName) \ 1208 mgx::process::StackRegistration ClassName ## registration(new ClassProcessFactory<StackProcess, ClassName>(), \ 1209 typeid(ClassName).name(), PROCESS_VERSION) 1218 #define REGISTER_MESH_PROCESS(ClassName) \ 1219 mgx::process::MeshRegistration ClassName ## registration(new ClassProcessFactory<MeshProcess, ClassName>(), \ 1220 typeid(ClassName).name(), PROCESS_VERSION) 1229 #define REGISTER_GLOBAL_PROCESS(ClassName) \ 1230 mgx::process::GlobalRegistration ClassName ## registration(new ClassProcessFactory<GlobalProcess, ClassName>(), \ 1231 typeid(ClassName).name(), PROCESS_VERSION) 1268 typedef FactoryPointer<P> processFactory;
1280 mgx_EXPORT
extern stackProcessesMap_t stackProcesses;
1281 mgx_EXPORT
extern meshProcessesMap_t meshProcesses;
1282 mgx_EXPORT
extern globalProcessesMap_t globalProcesses;
1308 size_t* nbParms = 0);
1335 return (b ?
"Yes" :
"No");
StackProcess(const StackProcess ©)
Copy constructor.
Definition: Process.hpp:841
Definition: CuttingSurface.hpp:28
virtual uint numParms() const
Returns the number of named string for this process.
Definition: Process.hpp:626
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:843
virtual QString type() const
Returns a string identifying the process type.
Definition: Process.hpp:882
virtual QStringList parmDescs() const
List of parameters descriptions.
Definition: Process.hpp:564
QStringList parmNames
List of named parameters of the process.
Definition: Process.hpp:1242
Definition of a process, without the process factory.
Definition: Process.hpp:1239
Definition: Process.hpp:751
MeshCheckType
Enumeration for the bitfield that identifies mesh properties.
Definition: Process.hpp:672
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:1240
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:240
std::pair< stack_iterator, stack_iterator > stacks()
Iterate over all the stacks.
QIcon icon
Icon of the process.
Definition: Process.hpp:1246
Definition of a process, including the process factory.
Definition: Process.hpp:1258
This class holds the actual mesh as a VV Graph and all sort of properties for it, including visualiza...
Definition: Mesh.hpp:177
Definition: MorphoGraphX.hpp:53
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:636
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:550
GlobalProcess(const GlobalProcess ©)
Copy constructor.
Definition: Process.hpp:914
CheckType
Enumeration of the type of checks that can be performed.
Definition: Process.hpp:710
This namespace contains all the API of MorphoGraphX.
Definition: Assert.hpp:26
QStringList parms
List of parameters/parameter defaults.
Definition: Process.hpp:1244
virtual QStringList parmDefaults() const
List of default parms.
Definition: Process.hpp:570
QStringList storeChoice() const
Helper function that provides a list of choices for choosing from the main or work stack...
Definition: Process.hpp:617
QString description
Description of the process.
Definition: Process.hpp:1241
StoreCheckType
Enumeration for the bitfield that identifies store properties.
Definition: Process.hpp:651
virtual ~Process()
Virtual destructor.
Definition: Process.hpp:282
virtual QString type() const
Returns a string identifying the process type.
Definition: Process.hpp:917
void userCancel() const
Throw an exception informing the system that the user canceled the current process.
Definition: Process.hpp:453
processFactory factory
Process factory.
Definition: Process.hpp:1272
CheckWhich
Definition: Process.hpp:716
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:35
This is the main process class, the one all process inherit from.
Definition: Process.hpp:258
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:601
Global processes have full mutable access to all properties of the process.
Definition: Process.hpp:904
mgx_EXPORT bool stringToBool(const QString &string)
Helper function converting a string into a boolean.
This namespace contains all the classes needed to define processes.
virtual QIcon icon() const
Icon to use to represent the process in the GUI.
Definition: Process.hpp:587
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:223
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:1243
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:725
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:1264
Stack processes have non-mutable access to meshes and mutable access to stacks.
Definition: Process.hpp:829
QStringList booleanChoice() const
Helper function that provides a list of choices for a boolean argument.
Definition: Process.hpp:609
QString folder
Folder in which to place the process.
Definition: Process.hpp:1245
Mesh * currentMesh()
Returns the current mesh (i.e.
QString boolToString(bool b)
Helper function converting a boolean into a string.
Definition: Process.hpp:1334
MeshProcess(const MeshProcess ©)
Copy constructor.
Definition: Process.hpp:877
ParmChoiceMap parmChoice
Map of choices for parameters.
Definition: Process.hpp:1249
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:865
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:578