Skip to content

Commit 8b60a26

Browse files
authored
Merge pull request #69 from klaussilveira/feat/groups
Added group management panel and recursive ungroup command
2 parents 1efb5e3 + fd74b76 commit 8b60a26

16 files changed

Lines changed: 862 additions & 0 deletions

include/ui/iusercontrol.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ struct UserControl
8383
constexpr static const char* AasVisualisationPanel = "AasVisualisationPanel";
8484
constexpr static const char* OrthoBackgroundPanel = "OrthoBackgroundPanel";
8585
constexpr static const char* DecalShooter = "DecalShooter";
86+
constexpr static const char* SelectionGroupPanel = "SelectionGroupPanel";
8687
};
8788

8889
}

libs/scene/Group.h

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,4 +179,39 @@ inline void ungroupSelected()
179179
SceneChangeNotify();
180180
}
181181

182+
/**
183+
* Dissolve all group memberships of the currently selected nodes,
184+
* removing every nested group level at once.
185+
* Will throw cmd::ExecutionNotPossible if it cannot execute.
186+
*/
187+
inline void ungroupSelectedRecursively()
188+
{
189+
checkUngroupSelectedAvailable();
190+
191+
UndoableCommand cmd("UngroupSelectedRecursively");
192+
193+
std::set<std::size_t> ids;
194+
195+
GlobalSelectionSystem().foreachSelected([&](const scene::INodePtr& node)
196+
{
197+
std::shared_ptr<IGroupSelectable> selectable = std::dynamic_pointer_cast<IGroupSelectable>(node);
198+
199+
if (!selectable) return;
200+
201+
for (std::size_t id : selectable->getGroupIds())
202+
{
203+
ids.insert(id);
204+
}
205+
});
206+
207+
auto& selGroupMgr = detail::getMapSelectionGroupManager();
208+
209+
std::for_each(ids.begin(), ids.end(), [&](std::size_t id)
210+
{
211+
selGroupMgr.deleteSelectionGroup(id);
212+
});
213+
214+
SceneChangeNotify();
215+
}
216+
182217
}

radiant/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ add_executable(darkradiant
162162
ui/terrain/TerrainGeneratorDialog.cpp
163163
ui/script/ScriptMenu.cpp
164164
ui/script/ScriptWindow.cpp
165+
ui/selectiongroup/SelectionGroupPanel.cpp
165166
ui/selectionset/SelectionSetToolmenu.cpp
166167
ui/skin/SkinEditor.cpp
167168
ui/skin/SkinEditorTreeView.cpp

radiant/ui/UserInterfaceModule.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@
8484
#include "lightinspector/LightInspectorControl.h"
8585
#include "decalshooter/DecalShooterControl.h"
8686
#include "overlay/OrthoBackgroundControl.h"
87+
#include "selectiongroup/SelectionGroupControl.h"
8788
#include "patch/PatchInspectorControl.h"
8889
#include "surfaceinspector/SurfaceInspectorControl.h"
8990
#include "textool/TextureToolControl.h"
@@ -207,6 +208,12 @@ void UserInterfaceModule::initialiseModule(const IApplicationContext& ctx)
207208
[]() { return cmd::ExecutionNotPossible::ToBool(selection::checkUngroupSelectedAvailable); }),
208209
IOrthoContextMenu::SECTION_SELECTION_GROUPS);
209210

211+
GlobalOrthoContextMenu().addItem(std::make_shared<wxutil::MenuItem>(
212+
new wxutil::IconTextMenuItem(_("Ungroup Selection Recursively"), "ungroup_selection.png"),
213+
[]() { selection::ungroupSelectedRecursively(); },
214+
[]() { return cmd::ExecutionNotPossible::ToBool(selection::checkUngroupSelectedAvailable); }),
215+
IOrthoContextMenu::SECTION_SELECTION_GROUPS);
216+
210217
_longOperationHandler.reset(new LongRunningOperationHandler);
211218
_mapFileProgressHandler.reset(new MapFileProgressHandler);
212219
_autoSaveRequestHandler.reset(new AutoSaveRequestHandler);
@@ -271,6 +278,7 @@ void UserInterfaceModule::initialiseModule(const IApplicationContext& ctx)
271278
registerControl(std::make_shared<FindShaderControl>());
272279
registerControl(std::make_shared<OrthoBackgroundControl>());
273280
registerControl(std::make_shared<DecalShooterControl>());
281+
registerControl(std::make_shared<SelectionGroupControl>());
274282

275283
GlobalMainFrame().signal_MainFrameConstructed().connect([&]()
276284
{
@@ -312,6 +320,9 @@ void UserInterfaceModule::initialiseModule(const IApplicationContext& ctx)
312320
GlobalMainFrame().addControl(
313321
UserControl::DecalShooter, ControlSettings::floating(300, 200)
314322
);
323+
GlobalMainFrame().addControl(
324+
UserControl::SelectionGroupPanel, ControlSettings::floating(300, 400)
325+
);
315326

316327
_viewMenu = std::make_unique<ViewMenu>();
317328
});
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#pragma once
2+
3+
#include "i18n.h"
4+
#include "ui/iusercontrol.h"
5+
#include "SelectionGroupPanel.h"
6+
7+
namespace ui
8+
{
9+
10+
class SelectionGroupControl :
11+
public IUserControlCreator
12+
{
13+
public:
14+
std::string getControlName() override
15+
{
16+
return UserControl::SelectionGroupPanel;
17+
}
18+
19+
std::string getDisplayName() override
20+
{
21+
return _("Selection Groups");
22+
}
23+
24+
std::string getIcon() override
25+
{
26+
return "group_selection.png";
27+
}
28+
29+
wxWindow* createWidget(wxWindow* parent) override
30+
{
31+
return new SelectionGroupPanel(parent);
32+
}
33+
};
34+
35+
}

0 commit comments

Comments
 (0)