| 1 |
#pragma once |
| 2 |
|
| 3 |
#include "imodule.h" |
| 4 |
#include "iselectiontest.h" |
| 5 |
|
| 6 |
namespace selection |
| 7 |
{ |
| 8 |
|
| 9 |
enum class PasteMode |
| 10 |
{ |
| 11 |
// Shader is projected using the texdef matrix in the source |
| 12 |
Projected, |
| 13 |
|
| 14 |
// If a patch is hit, the algorithm will take the surface |
| 15 |
// topology of the patch into account, to avoid distortions. |
| 16 |
Natural, |
| 17 |
}; |
| 18 |
|
| 19 |
/** |
| 20 |
* Public interface of the shader clipboard which is able |
| 21 |
* to pick/copy/paste shaders from and to Texturable objects. |
| 22 |
*/ |
| 23 |
class IShaderClipboard : |
| 24 |
public RegisterableModule |
| 25 |
{ |
| 26 |
public: |
| 27 |
virtual ~IShaderClipboard() {} |
| 28 |
|
| 29 |
virtual void clear() = 0; |
| 30 |
|
| 31 |
// Returns the material name of the object in the clipboard (or an empty string) |
| 32 |
virtual std::string getShaderName() = 0; |
| 33 |
|
| 34 |
enum class SourceType |
| 35 |
{ |
| 36 |
Empty, |
| 37 |
Face, |
| 38 |
Patch, |
| 39 |
Shader, |
| 40 |
}; |
| 41 |
|
| 42 |
// Returns the type of element in the shaderclipboard's source slot |
| 43 |
virtual SourceType getSourceType() const = 0; |
| 44 |
|
| 45 |
// Sets the content of the shaderclipboard to the given material |
| 46 |
virtual void setSourceShader(const std::string& shader) = 0; |
| 47 |
|
| 48 |
virtual void pickFromSelectionTest(SelectionTest& test) = 0; |
| 49 |
|
| 50 |
/** |
| 51 |
* Pastes the shader from the source in the clipboard to the object |
| 52 |
* located by the given selection test. |
| 53 |
* |
| 54 |
* @pasteToAllFaces: if a brush is hit, the source shader will be pasted |
| 55 |
* to all its faces, not just the one hit by the selection test. |
| 56 |
* |
| 57 |
* Might throw a cmd::ExecutionFailure. |
| 58 |
*/ |
| 59 |
virtual void pasteShader(SelectionTest& test, PasteMode mode, bool pasteToAllFaces) = 0; |
| 60 |
|
| 61 |
/** |
| 62 |
* Will attempt to apply the texture coordinates of the source patch to the |
| 63 |
* target patch located by the given SelectionTest. |
| 64 |
* Will throw a cmd::ExecutionFailure if the source or target objects are not matching up. |
| 65 |
*/ |
| 66 |
virtual void pasteTextureCoords(SelectionTest& test) = 0; |
| 67 |
|
| 68 |
/** |
| 69 |
* Applies the material only to the object hit by the given selection test. |
| 70 |
* Will leave the rest of the surface properties unchanged, if possible. |
| 71 |
*/ |
| 72 |
virtual void pasteMaterialName(SelectionTest& test) = 0; |
| 73 |
|
| 74 |
/** |
| 75 |
* Is emitted when the shader source changes. |
| 76 |
*/ |
| 77 |
virtual sigc::signal<void>& signal_sourceChanged() = 0; |
| 78 |
}; |
| 79 |
|
| 80 |
} // namespace |
| 81 |
|
| 82 |
const char* const MODULE_SHADERCLIPBOARD("ShaderClipboard"); |
| 83 |
|
| 84 |
inline selection::IShaderClipboard& GlobalShaderClipboard() |
| 85 |
{ |
| 86 |
static module::InstanceReference<selection::IShaderClipboard> _reference(MODULE_SHADERCLIPBOARD); |
| 87 |
return _reference; |
| 88 |
} |