File: Group.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 (133 lines) | stat: -rw-r--r-- 3,899 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#pragma once

#include "icommandsystem.h"
#include "iselection.h"
#include "inode.h"
#include <list>

namespace selection 
{

class ISelectionGroupManager;

namespace algorithm 
{

	class ParentPrimitivesToEntityWalker :
		public SelectionSystem::Visitor,
		public scene::NodeVisitor
	{
	private:
		// The target parent node
		const scene::INodePtr _parent;

		// The list of children to reparent
		mutable std::list<scene::INodePtr> _childrenToReparent;

		// Old parents will be checked for emptiness afterwards
		mutable std::set<scene::INodePtr> _oldParents;

	public:
		ParentPrimitivesToEntityWalker(const scene::INodePtr& parent) :
			_parent(parent)
		{}

		// Call this to perform the actual reparenting after traversal
		void reparent();

		// Selects all primitives which are to be reparented
		void selectReparentedPrimitives();

		// SelectionSystem::Visitor implementation
		void visit(const scene::INodePtr& node) const;

		// scene::NodeVisitor implementation
		bool pre(const scene::INodePtr& node);
	};

	// Collects all groupnodes
	class GroupNodeCollector :
		public SelectionSystem::Visitor
	{
	public:
		typedef std::list<scene::INodePtr> GroupNodeList;

	private:
		mutable GroupNodeList _groupNodes;

	public:
		void visit(const scene::INodePtr& node) const;

		const GroupNodeList& getList() const
		{
			return _groupNodes;
		}
	};

	/**
	 * greebo: Takes the selected primitives and converts them to func_static.
	 */
	void convertSelectedToFuncStatic(const cmd::ArgumentList& args);

	/** greebo: This reparents the child primitives of an entity container like func_static
	 * back to worldspawn and deletes the entity thereafter.
	 */
	void revertGroupToWorldSpawn(const cmd::ArgumentList& args);

	/** greebo: This re-parents the selected primitives to an entity. The entity has to
	 * 			be selected last. Emits an error message if the selection doesn't meet
	 * 			the requirements
	 */
	void parentSelection(const cmd::ArgumentList& args);

	/**
	 * greebo: Like the above method, but specialises on parent operations
	 * to the worldspawn entity.
	 */
	void parentSelectionToWorldspawn(const cmd::ArgumentList& args);

	/** greebo: Selects the children of the currently selected groupnodes.
	 * 			This deselects the groupnodes entities, so that ONLY the children
	 * 			are highlighted.
	 */
	void selectChildren(const cmd::ArgumentList& args);

	/**
	 * greebo: This selects all the children of an entity, given the case
	 * that a child of this entity is already selected. For instance,
	 * if a child brush of a func_static is selected, this command
	 * expands the selection to all other children (but not the
	 * func_static entity itself). Select a single primitive of
	 * the worldspawn entity and this command will select every primitive
	 * that is child of worldspawn.
	 */
	void expandSelectionToSiblings(const cmd::ArgumentList& args);

	/**
	 * greebo: This will select the parent entity of any currently selected 
	 * primitve. The child primitive will be deselected and the parent entity
	 * will be selected instead.
	 */
	void selectParentEntitiesOfSelected(const cmd::ArgumentList& args);

	/**
	 * greebo: Merges all selected group nodes (func_* entities).
	 * After this operation only the first group node is preserved
	 * and all child primitives are parented to it.
	 * The other group nodes are removed from the scene.
	 */
	void mergeSelectedEntities(const cmd::ArgumentList& args);

	/**
	 * Returns the selection group manager of the current map's root node.
	 * This will fail if there is no map root node, check this first.
	 */
	ISelectionGroupManager& getMapSelectionGroupManager();

	// Command targets
	void deleteAllSelectionGroupsCmd(const cmd::ArgumentList& args);
	void groupSelectedCmd(const cmd::ArgumentList& args);
	void ungroupSelectedCmd(const cmd::ArgumentList& args);

} // namespace algorithm
} // namespace selection