File: SelectionSetInterface.h

package info (click to toggle)
darkradiant 3.9.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 41,080 kB
  • sloc: cpp: 264,743; ansic: 10,659; python: 1,852; xml: 1,650; sh: 92; makefile: 21
file content (63 lines) | stat: -rw-r--r-- 1,519 bytes parent folder | download | duplicates (4)
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
61
62
63
#pragma once

#include <pybind11/pybind11.h>

#include "iscript.h"
#include "iscriptinterface.h"
#include "iselectionset.h"

namespace script
{

// ========== SelectionSet Handling ==========

class ScriptSelectionSet
{
private:
	selection::ISelectionSetPtr _set;

	static std::string _emptyStr;
public:
	ScriptSelectionSet(const selection::ISelectionSetPtr& set);

	const std::string& getName();
	bool empty();
	void select();
	void deselect();
	void clear();
	void assignFromCurrentScene();
};

// Wrap around the ISelectionSetManager::Visitor interface
class SelectionSetVisitorWrapper :
	public selection::ISelectionSetManager::Visitor
{
public:
    void visit(const selection::ISelectionSetPtr& set) override
	{
		// Wrap this method to python
		PYBIND11_OVERLOAD_PURE(
			void,			/* Return type */
			selection::ISelectionSetManager::Visitor,    /* Parent class */
			visit,			/* Name of function in C++ (must match Python name) */
			ScriptSelectionSet(set)			/* Argument(s) */
		);
	}
};

class SelectionSetInterface :
	public IScriptInterface
{
public:
	// SelectionSetManager wrappers
	void foreachSelectionSet(selection::ISelectionSetManager::Visitor& visitor);
	ScriptSelectionSet createSelectionSet(const std::string& name);
	void deleteSelectionSet(const std::string& name);
	void deleteAllSelectionSets();
	ScriptSelectionSet findSelectionSet(const std::string& name);

	// IScriptInterface implementation
	void registerInterface(py::module& scope, py::dict& globals) override;
};

} // namespace script