Skip to content

Commit

Permalink
#6146: Change SelectionSystem::eMode to enum class SelectionMode
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Nov 1, 2022
1 parent 3844b18 commit 07c233f
Show file tree
Hide file tree
Showing 22 changed files with 130 additions and 128 deletions.
26 changes: 14 additions & 12 deletions include/iselection.h
Expand Up @@ -48,6 +48,16 @@ namespace selection
Edge,
Face,
};

// The selection strategy determining the scene objects chosen for selection tests
enum class SelectionMode
{
Entity, // Entities only
Primitive, // Primitives (no components), entities take precedence
GroupPart, // Child Primitives of non-worldspawn entities
Component, // Components
MergeAction, // Merge Action nodes only
};
}

namespace selection
Expand All @@ -64,15 +74,6 @@ class SelectionSystem :
eCycle, // This is active if the mouse STAYS at the same position and Alt-Shift is held
};

enum EMode
{
eEntity,
ePrimitive,
eGroupPart,
eComponent,
eMergeAction,
};

/** greebo: An SelectionSystem::Observer gets notified
* as soon as the selection is changed.
*/
Expand Down Expand Up @@ -106,12 +107,13 @@ class SelectionSystem :

virtual const SelectionInfo& getSelectionInfo() = 0;

virtual void SetMode(EMode mode) = 0;
virtual EMode Mode() const = 0;
virtual void setSelectionMode(SelectionMode mode) = 0;
virtual SelectionMode getSelectionMode() const = 0;

virtual void SetComponentMode(ComponentSelectionMode mode) = 0;
virtual ComponentSelectionMode ComponentMode() const = 0;

virtual sigc::signal<void, EMode>& signal_selectionModeChanged() = 0;
virtual sigc::signal<void, SelectionMode>& signal_selectionModeChanged() = 0;
virtual sigc::signal<void, ComponentSelectionMode>& signal_componentModeChanged() = 0;

virtual std::size_t countSelected() const = 0;
Expand Down
2 changes: 1 addition & 1 deletion include/iselectiontest.h
Expand Up @@ -374,7 +374,7 @@ class ISceneSelectionTesterFactory
* Returns an instance of a selection tester suitable for testing
* scene nodes according to the given purpose/selection mode.
*/
virtual ISceneSelectionTester::Ptr createSceneSelectionTester(SelectionSystem::EMode mode) = 0;
virtual ISceneSelectionTester::Ptr createSceneSelectionTester(SelectionMode mode) = 0;
};

} // namespace
2 changes: 1 addition & 1 deletion libs/render/RenderableCollectorBase.h
Expand Up @@ -117,7 +117,7 @@ class RenderableCollectorBase :

if (highlightFlags & Renderable::Highlight::Selected)
{
if (GlobalSelectionSystem().Mode() != selection::SelectionSystem::eComponent)
if (GlobalSelectionSystem().getSelectionMode() != selection::SelectionMode::Component)
{
setHighlightFlag(Highlight::Faces, true);
}
Expand Down
9 changes: 5 additions & 4 deletions libs/scene/Group.h
@@ -1,5 +1,6 @@
#pragma once

#include "i18n.h"
#include "imap.h"
#include "iundo.h"
#include "iselection.h"
Expand Down Expand Up @@ -34,8 +35,8 @@ inline void checkGroupSelectedAvailable()
throw cmd::ExecutionNotPossible(_("No map loaded"));
}

if (GlobalSelectionSystem().Mode() != SelectionSystem::ePrimitive &&
GlobalSelectionSystem().Mode() != SelectionSystem::eGroupPart)
if (GlobalSelectionSystem().getSelectionMode() != SelectionMode::Primitive &&
GlobalSelectionSystem().getSelectionMode() != SelectionMode::GroupPart)
{
throw cmd::ExecutionNotPossible(_("Groups can be formed in Primitive and Group Part selection mode only"));
}
Expand Down Expand Up @@ -109,8 +110,8 @@ inline void checkUngroupSelectedAvailable()
throw cmd::ExecutionNotPossible(_("No map loaded"));
}

if (GlobalSelectionSystem().Mode() != SelectionSystem::ePrimitive &&
GlobalSelectionSystem().Mode() != SelectionSystem::eGroupPart)
if (GlobalSelectionSystem().getSelectionMode() != SelectionMode::Primitive &&
GlobalSelectionSystem().getSelectionMode() != SelectionMode::GroupPart)
{
throw cmd::ExecutionNotPossible(_("Groups can be dissolved in Primitive and Group Part selection mode only"));
}
Expand Down
2 changes: 1 addition & 1 deletion libs/shaderlib.h
Expand Up @@ -103,7 +103,7 @@ inline int findAndReplaceShader(const std::string& find, const std::string& repl

if (selectedOnly)
{
if (GlobalSelectionSystem().Mode() != selection::SelectionSystem::eComponent)
if (GlobalSelectionSystem().getSelectionMode() != selection::SelectionMode::Component)
{
// Find & replace all the brush and patch shaders
GlobalSelectionSystem().foreachFace(std::ref(replacer));
Expand Down
12 changes: 6 additions & 6 deletions radiant/selection/SceneManipulateMouseTool.cpp
Expand Up @@ -31,7 +31,7 @@ bool SceneManipulateMouseTool::manipulationIsPossible()
assert(activeManipulator);

bool dragComponentMode = activeManipulator->getType() == selection::IManipulator::Drag &&
GlobalSelectionSystem().Mode() == selection::SelectionSystem::eComponent;
GlobalSelectionSystem().getSelectionMode() == selection::SelectionMode::Component;

return dragComponentMode || !nothingSelected();
}
Expand Down Expand Up @@ -68,14 +68,14 @@ bool SceneManipulateMouseTool::gridIsEnabled()

bool SceneManipulateMouseTool::nothingSelected() const
{
switch (GlobalSelectionSystem().Mode())
switch (GlobalSelectionSystem().getSelectionMode())
{
case selection::SelectionSystem::eComponent:
case selection::SelectionMode::Component:
return GlobalSelectionSystem().countSelectedComponents() == 0;

case selection::SelectionSystem::eGroupPart:
case selection::SelectionSystem::ePrimitive:
case selection::SelectionSystem::eEntity:
case selection::SelectionMode::GroupPart:
case selection::SelectionMode::Primitive:
case selection::SelectionMode::Entity:
return GlobalSelectionSystem().countSelected() == 0;

default:
Expand Down
22 changes: 11 additions & 11 deletions radiant/ui/SelectionModeToggle.h
Expand Up @@ -52,10 +52,10 @@ class SelectionModeToggle
{
GlobalCommandSystem().executeCommand("ToggleMergeActionSelectionMode");

return GlobalSelectionSystem().Mode() == selection::SelectionSystem::eMergeAction;
return GlobalSelectionSystem().getSelectionMode() == selection::SelectionMode::MergeAction;
});

onSelectionModeChanged(GlobalSelectionSystem().Mode());
onSelectionModeChanged(GlobalSelectionSystem().getSelectionMode());
onComponentModeChanged(GlobalSelectionSystem().ComponentMode());
}

Expand All @@ -66,7 +66,7 @@ class SelectionModeToggle
}

private:
void onSelectionModeChanged(selection::SelectionSystem::EMode selectionMode)
void onSelectionModeChanged(selection::SelectionMode selectionMode)
{
auto componentMode = GlobalSelectionSystem().ComponentMode();

Expand All @@ -75,30 +75,30 @@ class SelectionModeToggle

void onComponentModeChanged(selection::ComponentSelectionMode componentMode)
{
auto selectionMode = GlobalSelectionSystem().Mode();
auto selectionMode = GlobalSelectionSystem().getSelectionMode();

updateToggleState(selectionMode, componentMode);
}

void updateToggleState(selection::SelectionSystem::EMode selectionMode, selection::ComponentSelectionMode componentMode)
void updateToggleState(selection::SelectionMode selectionMode, selection::ComponentSelectionMode componentMode)
{
GlobalEventManager().setToggled("DragVertices",
selectionMode == selection::SelectionSystem::eComponent && componentMode == selection::ComponentSelectionMode::Vertex);
selectionMode == selection::SelectionMode::Component && componentMode == selection::ComponentSelectionMode::Vertex);

GlobalEventManager().setToggled("DragEdges",
selectionMode == selection::SelectionSystem::eComponent && componentMode == selection::ComponentSelectionMode::Edge);
selectionMode == selection::SelectionMode::Component && componentMode == selection::ComponentSelectionMode::Edge);

GlobalEventManager().setToggled("DragFaces",
selectionMode == selection::SelectionSystem::eComponent && componentMode == selection::ComponentSelectionMode::Face);
selectionMode == selection::SelectionMode::Component && componentMode == selection::ComponentSelectionMode::Face);

GlobalEventManager().setToggled("DragEntities",
selectionMode == selection::SelectionSystem::eEntity && componentMode == selection::ComponentSelectionMode::Default);
selectionMode == selection::SelectionMode::Entity && componentMode == selection::ComponentSelectionMode::Default);

GlobalEventManager().setToggled("SelectionModeGroupPart",
selectionMode == selection::SelectionSystem::eGroupPart && componentMode == selection::ComponentSelectionMode::Default);
selectionMode == selection::SelectionMode::GroupPart && componentMode == selection::ComponentSelectionMode::Default);

GlobalEventManager().setToggled("SelectionModeMergeActions",
selectionMode == selection::SelectionSystem::eMergeAction && componentMode == selection::ComponentSelectionMode::Default);
selectionMode == selection::SelectionMode::MergeAction && componentMode == selection::ComponentSelectionMode::Default);
}
};

Expand Down
2 changes: 1 addition & 1 deletion radiantcore/brush/BrushNode.cpp
Expand Up @@ -402,7 +402,7 @@ void BrushNode::onPreRender(const VolumeTest& volume)
}
}

if (isSelected() && GlobalSelectionSystem().Mode() == selection::SelectionSystem::eComponent ||
if (isSelected() && GlobalSelectionSystem().getSelectionMode() == selection::SelectionMode::Component ||
_numSelectedComponents > 0) // could be a single selected face without the brush being selected
{
updateSelectedPointsArray();
Expand Down
4 changes: 2 additions & 2 deletions radiantcore/map/Map.cpp
Expand Up @@ -404,7 +404,7 @@ void Map::setEditMode(EditMode mode)
if (_editMode == EditMode::Merge)
{
GlobalSelectionSystem().setSelectedAll(false);
GlobalSelectionSystem().SetMode(selection::SelectionSystem::eMergeAction);
GlobalSelectionSystem().setSelectionMode(selection::SelectionMode::MergeAction);

if (getRoot())
{
Expand All @@ -413,7 +413,7 @@ void Map::setEditMode(EditMode mode)
}
else
{
GlobalSelectionSystem().SetMode(selection::SelectionSystem::ePrimitive);
GlobalSelectionSystem().setSelectionMode(selection::SelectionMode::Primitive);

if (getRoot())
{
Expand Down
2 changes: 1 addition & 1 deletion radiantcore/map/RegionManager.cpp
Expand Up @@ -329,7 +329,7 @@ void RegionManager::setRegionFromSelection(const cmd::ArgumentList& args)
// Check, if there is anything selected
if (info.totalCount > 0)
{
if (GlobalSelectionSystem().Mode() != selection::SelectionSystem::eComponent)
if (GlobalSelectionSystem().getSelectionMode() != selection::SelectionMode::Component)
{
// Obtain the selection size (its min/max vectors)
AABB regionBounds = GlobalSelectionSystem().getWorkZone().bounds;
Expand Down
2 changes: 1 addition & 1 deletion radiantcore/patch/PatchNode.cpp
Expand Up @@ -383,7 +383,7 @@ void PatchNode::onPreRender(const VolumeTest& volume)

void PatchNode::renderHighlights(IRenderableCollector& collector, const VolumeTest& volume)
{
if (GlobalSelectionSystem().Mode() != selection::SelectionSystem::eComponent)
if (GlobalSelectionSystem().getSelectionMode() != selection::SelectionMode::Component)
{
// The coloured selection overlay should use the same triangulated surface to avoid z fighting
collector.setHighlightFlag(IRenderableCollector::Highlight::Faces, true);
Expand Down

0 comments on commit 07c233f

Please sign in to comment.