1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
#pragma once
#include <Python.h>
#include <QObject>
#include "fab/types/shape.h"
#include "fab/types/bounds.h"
/*
* Abstract base class used to export files from a Shape
*/
class ExportWorker : public QObject
{
Q_OBJECT
public:
explicit ExportWorker(Shape s, Bounds b, QString f, float r)
: shape(s), bounds(b), filename(f), resolution(r), halt(0) {}
/*
* Synchronous part of export (e.g. getting resolution from dialog)
*/
virtual void run()=0;
/*
* Asynchronous part of export (e.g. actually meshing the model)
*/
virtual void async()=0;
/*
* Handles async running and stopping
*/
void runAsync();
/*
* Checks if _filename is writable.
* If so, returns true; otherwise, shows a warning and returns false.
*/
bool checkWritable() const;
protected:
/*
* These are constants for the export worker and set at call-time
*/
const Shape shape;
const Bounds bounds;
const QString filename;
const float resolution;
/*
* These are variables that are set by dialogs (and don't persist
* between calls to the worker).
*/
float _resolution;
QString _filename;
/*
* Flag used to abort rendering
*/
volatile int halt;
};
|