24 #include <QSharedPointer>
25 #include <QStringList>
26 #include <QTextStream>
57 #define PROCESS_VERSION 1380
190 enum SystemCommand { UPDATE_VIEWER, LOAD_VIEW, SAVE_VIEW, SET_CURRENT_STACK,
191 TAKE_SNAPSHOT, UPDATE_STATE, SET_STATUS };
193 class PrivateProcess;
208 const char*
what()
const throw() {
209 return "Process canceled by user.";
222 friend class SetupProcess;
259 void actingFile(
const QString& filename,
bool project_file =
false);
264 QString actingFile()
const;
269 QString pythonCall(
const QStringList &parms)
const;
274 int stackCount()
const;
282 Stack* currentStack();
290 int currentStackId()
const;
294 int otherStackId()
const;
298 void setCurrentStackId(
int i);
299 bool setCurrentStack(
int id,
const QString &store);
306 bool takeSnapshot(QString filename,
float overSampling = 1.0f,
int width = 0,
int height = 0,
int quality = 95,
307 bool expand_frustum =
false);
311 bool setStatus(
const QString &msg,
bool alsoPrint =
true);
316 bool systemCommand(
int command,
const QStringList &parms);
325 std::pair<stack_iterator, stack_iterator> stacks();
327 std::pair<const_stack_iterator, const_stack_iterator> stacks()
const;
339 bool deleteStack(
int i);
344 int meshCount()
const;
360 int currentMeshId()
const;
364 int otherMeshId()
const;
368 void setCurrentMeshId(
int i);
371 std::pair<mesh_iterator, mesh_iterator> meshes();
373 std::pair<const_mesh_iterator, const_mesh_iterator> meshes()
const;
383 bool deleteMesh(
int i);
388 int selectedLabel()
const;
393 void setSelectedLabel(
int label);
398 float globalBrightness();
403 float globalContrast();
410 void setGlobalBrightness(
float value);
417 void setGlobalContrast(
float value);
422 bool meshSelection()
const;
426 bool lineBorderSelection()
const;
439 bool loadView(
const QString &fileName);
443 bool saveView(
const QString &fileName);
448 bool setErrorMessage(
const QString& str);
453 QString errorMessage()
const;
458 void setWarningMessage(
const QString& str);
462 QString warningMessage()
const;
473 const QString& file()
const;
491 const Clip *clip1()
const;
495 const Clip *clip2()
const;
499 const Clip *clip3()
const;
517 Process *makeProcess(
const QString &processName);
522 template <
typename ProcessT>
525 p =
dynamic_cast<ProcessT*
>(makeProcess(processName));
535 bool setCurrentParms();
548 bool runProcess(
Process &proc, QStringList &parms)
throw();
556 bool runProcess(
const QString &processName, QStringList &parms)
throw();
579 virtual bool run() {
return true; }
602 STACK_NON_EMPTY = 0x01,
603 STACK_VISIBLE = 0x02,
607 STACK_TRANSFORMED = 0x10,
608 STACK_NON_SCALED = 0x20,
609 STACK_NON_TRANSFORMED = 0x40,
617 STORE_NON_EMPTY = 0x0001,
618 STORE_VISIBLE = 0x0002,
619 STORE_EMPTY = 0x0004,
621 STORE_LABEL = 0x0008,
622 STORE_NON_LABEL = 0x0010,
624 STORE_SCALED = 0x0020,
625 STORE_TRANSFORMED = 0x0040,
626 STORE_NON_SCALED = 0x0080,
627 STORE_NON_TRANSFORMED = 0x0100,
638 MESH_NON_EMPTY = 0x000001,
639 MESH_VISIBLE = 0x000002,
641 MESH_HEAT = 0x000004,
642 MESH_LABEL = 0x000008,
643 MESH_NORMAL = 0x000010,
645 MESH_SIGNAL = 0x000020,
646 MESH_TEXTURE = 0x000040,
647 MESH_IMAGE = 0x000080,
649 MESH_SHOW_MESH = 0x000100,
650 MESH_SHOW_SURF = 0x000200,
653 MESH_BORDER = 0x000800,
654 MESH_CELLMAP = 0x001000,
656 MESH_CELLS = 0x002000,
657 MESH_IMG_TEX = 0x004000,
658 MESH_SCALED = 0x008000,
659 MESH_TRANSFORMED = 0x010000,
661 MESH_EMPTY = 0x020000,
662 MESH_NON_CELLS = 0x040000,
663 MESH_NON_IMG_TEX = 0x080000,
664 MESH_NON_SCALED = 0x100000,
665 MESH_NON_TRANSFORMED = 0x200000,
667 MESH_USE_PARENTS = 0x400000,
696 CheckState& store(
int checks = STORE_ANY,
int which = CHECK_CURRENT);
700 CheckState& stack(
int checks = STACK_ANY,
int which = CHECK_CURRENT);
704 CheckState& mesh(
int checks = MESH_ANY,
int which = CHECK_CURRENT);
757 bool stackCheck(
int checks,
int which);
761 bool storeCheck(
int checks,
int which);
765 bool meshCheck(
int checks,
int which);
770 QString stackError(
int checks,
int which);
774 QString storeError(
int checks,
int which);
778 QString meshError(
int checks,
int which);
781 void systemCommandGui(
mgx::Process *,
int, QStringList);
782 void systemCommandProcess(
mgx::Process *,
int, QStringList);
788 struct mgx_EXPORT ProcessFactory
791 virtual ~ProcessFactory() {}
793 virtual Process* operator()(
const Process& process) = 0;
794 virtual void reload() = 0;
801 template<
typename ProcessName>
struct ClassProcessFactory :
public ProcessFactory
803 ClassProcessFactory() : ProcessFactory(), pPtr(0) {}
805 virtual Process* operator()(
const Process& process)
809 pPtr =
new ProcessName(process);
820 virtual ~ClassProcessFactory()
830 typedef std::tr1::shared_ptr<ProcessFactory> ProcessFactoryPtr;
832 struct mgx_EXPORT Registration {
833 typedef QList<ProcessFactoryPtr> factoryList;
835 Registration(ProcessFactoryPtr f,
const char* class_name,
unsigned int compiledVersion);
837 static factoryList& processFactories();
839 ProcessFactoryPtr factory;
840 const char* classname;
850 inline QList<ProcessFactoryPtr>& processFactories()
852 return Registration::processFactories();
863 #define REGISTER_PROCESS(ClassName) \
864 mgx::Registration ClassName ## registration( \
865 mgx::ProcessFactoryPtr(new mgx::ClassProcessFactory<ClassName>()), \
866 typeid(ClassName).name(), PROCESS_VERSION)
896 typedef QMap<QString, ProcessDefinition> processesMap_t;
898 mgx_EXPORT
extern processesMap_t processes;
917 mgx_EXPORT
bool getLastParms(
const QString& processName, QStringList& parms);
919 mgx_EXPORT
bool getDefaultParms(
const QString& processName, QStringList& parms);
921 mgx_EXPORT
bool saveDefaultParms(
const QString& processName,
const QStringList &parms);
923 mgx_EXPORT
bool checkProcessParms(
const QString& processName,
const QStringList &parms,
924 size_t* nbParms = 0);
930 mgx_EXPORT
bool getProcessText(
const QString &text, QString &tab, QString &folder, QString &name);