Skip to content

Commit

Permalink
#5128: Rename Manipulator interface type to IManipulator.
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Sep 12, 2021
1 parent 813de90 commit 08b271e
Show file tree
Hide file tree
Showing 14 changed files with 95 additions and 94 deletions.
7 changes: 4 additions & 3 deletions include/imanipulator.h
Expand Up @@ -22,9 +22,11 @@ struct WorkZone;
* example, the rotation Manipulator draws several circles which cause rotations
* around specific axes.
*/
class Manipulator
class IManipulator
{
public:
using Ptr = std::shared_ptr<IManipulator>;

// Manipulator type enum, user-defined manipulators should return "Custom"
enum Type
{
Expand Down Expand Up @@ -75,7 +77,7 @@ class Manipulator
virtual void transform(const Matrix4& pivot2world, const VolumeTest& view, const Vector2& devicePoint, unsigned int flags) = 0;
};

virtual ~Manipulator() {}
virtual ~IManipulator() {}

// ID and Type management
virtual std::size_t getId() const = 0;
Expand All @@ -100,6 +102,5 @@ class Manipulator
// Manipulators should indicate whether component editing is supported or not
virtual bool supportsComponentManipulation() const = 0;
};
typedef std::shared_ptr<Manipulator> ManipulatorPtr;

}
12 changes: 6 additions & 6 deletions include/iselection.h
Expand Up @@ -85,17 +85,17 @@ class SelectionSystem :
virtual void removeObserver(Observer* observer) = 0;

// Returns the ID of the registered manipulator
virtual std::size_t registerManipulator(const selection::ManipulatorPtr& manipulator) = 0;
virtual void unregisterManipulator(const selection::ManipulatorPtr& manipulator) = 0;
virtual std::size_t registerManipulator(const selection::IManipulator::Ptr& manipulator) = 0;
virtual void unregisterManipulator(const selection::IManipulator::Ptr& manipulator) = 0;

virtual selection::Manipulator::Type getActiveManipulatorType() = 0;
virtual selection::IManipulator::Type getActiveManipulatorType() = 0;

// Returns the currently active Manipulator, which is always non-null
virtual const selection::ManipulatorPtr& getActiveManipulator() = 0;
virtual const selection::IManipulator::Ptr& getActiveManipulator() = 0;
virtual void setActiveManipulator(std::size_t manipulatorId) = 0;
virtual void setActiveManipulator(selection::Manipulator::Type manipulatorType) = 0;
virtual void setActiveManipulator(selection::IManipulator::Type manipulatorType) = 0;

virtual sigc::signal<void, selection::Manipulator::Type>& signal_activeManipulatorChanged() = 0;
virtual sigc::signal<void, selection::IManipulator::Type>& signal_activeManipulatorChanged() = 0;

virtual const SelectionInfo& getSelectionInfo() = 0;

Expand Down
28 changes: 14 additions & 14 deletions radiant/selection/ManipulateMouseTool.cpp
Expand Up @@ -94,11 +94,11 @@ unsigned int ManipulateMouseTool::getRefreshMode()

bool ManipulateMouseTool::selectManipulator(const render::View& view, const Vector2& devicePoint, const Vector2& deviceEpsilon)
{
const selection::ManipulatorPtr& activeManipulator = GlobalSelectionSystem().getActiveManipulator();
const auto& activeManipulator = GlobalSelectionSystem().getActiveManipulator();

assert(activeManipulator);

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

if (!nothingSelected() || dragComponentMode)
Expand Down Expand Up @@ -144,7 +144,7 @@ bool ManipulateMouseTool::selectManipulator(const render::View& view, const Vect

void ManipulateMouseTool::handleMouseMove(const render::View& view, const Vector2& devicePoint)
{
const selection::ManipulatorPtr& activeManipulator = GlobalSelectionSystem().getActiveManipulator();
const auto& activeManipulator = GlobalSelectionSystem().getActiveManipulator();
assert(activeManipulator);

// Check if the active manipulator is selected in the first place
Expand Down Expand Up @@ -179,12 +179,12 @@ void ManipulateMouseTool::handleMouseMove(const render::View& view, const Vector
#endif

// Query keyboard modifier state and pass them as flags
int constraintFlag = selection::Manipulator::Component::Constraint::Unconstrained;
constraintFlag |= wxGetKeyState(WXK_SHIFT) ? selection::Manipulator::Component::Constraint::Type1 : 0;
constraintFlag |= wxGetKeyState(WXK_ALT) ? selection::Manipulator::Component::Constraint::Type3 : 0;
int constraintFlag = selection::IManipulator::Component::Constraint::Unconstrained;
constraintFlag |= wxGetKeyState(WXK_SHIFT) ? selection::IManipulator::Component::Constraint::Type1 : 0;
constraintFlag |= wxGetKeyState(WXK_ALT) ? selection::IManipulator::Component::Constraint::Type3 : 0;

// Grid constraint is ON by default, unless CTRL is held
constraintFlag |= wxGetKeyState(WXK_CONTROL) ? 0 : selection::Manipulator::Component::Constraint::Grid;
constraintFlag |= wxGetKeyState(WXK_CONTROL) ? 0 : selection::IManipulator::Component::Constraint::Grid;

// Get the component of the currently active manipulator (done by selection test)
// and call the transform method
Expand All @@ -202,7 +202,7 @@ void ManipulateMouseTool::endMove()
{
freezeTransforms();

const selection::ManipulatorPtr& activeManipulator = GlobalSelectionSystem().getActiveManipulator();
const auto& activeManipulator = GlobalSelectionSystem().getActiveManipulator();
assert(activeManipulator);

_manipulationActive = false;
Expand All @@ -215,26 +215,26 @@ void ManipulateMouseTool::endMove()
{
std::ostringstream command;

if (activeManipulator->getType() == selection::Manipulator::Translate)
if (activeManipulator->getType() == selection::IManipulator::Translate)
{
command << "translateTool";
//outputTranslation(command);
}
else if (activeManipulator->getType() == selection::Manipulator::Rotate)
else if (activeManipulator->getType() == selection::IManipulator::Rotate)
{
command << "rotateTool";
//outputRotation(command);
}
else if (activeManipulator->getType() == selection::Manipulator::Scale)
else if (activeManipulator->getType() == selection::IManipulator::Scale)
{
command << "scaleTool";
//outputScale(command);
}
else if (activeManipulator->getType() == selection::Manipulator::Drag)
else if (activeManipulator->getType() == selection::IManipulator::Drag)
{
command << "dragTool";
}
else if (activeManipulator->getType() == selection::Manipulator::ModelScale)
else if (activeManipulator->getType() == selection::IManipulator::ModelScale)
{
command << "modelScaleTool";
}
Expand All @@ -248,7 +248,7 @@ void ManipulateMouseTool::endMove()

void ManipulateMouseTool::cancelMove()
{
const selection::ManipulatorPtr& activeManipulator = GlobalSelectionSystem().getActiveManipulator();
const auto& activeManipulator = GlobalSelectionSystem().getActiveManipulator();
assert(activeManipulator);

_manipulationActive = false;
Expand Down
14 changes: 7 additions & 7 deletions radiant/textool/TexTool.cpp
Expand Up @@ -80,7 +80,7 @@ TexTool::TexTool() :
#if 0
registerManipulator(std::make_shared<RotateManipulator>(_pivot, 8, 64.0f));
#endif
_defaultManipulatorType = selection::Manipulator::Rotate;
_defaultManipulatorType = selection::IManipulator::Rotate;
setActiveManipulator(_defaultManipulatorType);
}

Expand Down Expand Up @@ -1217,7 +1217,7 @@ TextureToolMouseEvent TexTool::createMouseEvent(const Vector2& point, const Vect
return TextureToolMouseEvent(*this, normalisedDeviceCoords, delta);
}

std::size_t TexTool::registerManipulator(const selection::ManipulatorPtr& manipulator)
std::size_t TexTool::registerManipulator(const selection::IManipulator::Ptr& manipulator)
{
std::size_t newId = 1;

Expand All @@ -1243,7 +1243,7 @@ std::size_t TexTool::registerManipulator(const selection::ManipulatorPtr& manipu
return newId;
}

void TexTool::unregisterManipulator(const selection::ManipulatorPtr& manipulator)
void TexTool::unregisterManipulator(const selection::IManipulator::Ptr& manipulator)
{
for (Manipulators::const_iterator i = _manipulators.begin(); i != _manipulators.end(); ++i)
{
Expand All @@ -1256,12 +1256,12 @@ void TexTool::unregisterManipulator(const selection::ManipulatorPtr& manipulator
}
}

selection::Manipulator::Type TexTool::getActiveManipulatorType()
selection::IManipulator::Type TexTool::getActiveManipulatorType()
{
return _activeManipulator->getType();
}

const selection::ManipulatorPtr& TexTool::getActiveManipulator()
const selection::IManipulator::Ptr& TexTool::getActiveManipulator()
{
return _activeManipulator;
}
Expand All @@ -1285,7 +1285,7 @@ void TexTool::setActiveManipulator(std::size_t manipulatorId)
#endif
}

void TexTool::setActiveManipulator(selection::Manipulator::Type manipulatorType)
void TexTool::setActiveManipulator(selection::IManipulator::Type manipulatorType)
{
for (const Manipulators::value_type& pair : _manipulators)
{
Expand All @@ -1305,7 +1305,7 @@ void TexTool::setActiveManipulator(selection::Manipulator::Type manipulatorType)
rError() << "Cannot activate non-existent manipulator by type " << manipulatorType << std::endl;
}

sigc::signal<void, selection::Manipulator::Type>& TexTool::signal_activeManipulatorChanged()
sigc::signal<void, selection::IManipulator::Type>& TexTool::signal_activeManipulatorChanged()
{
return _sigActiveManipulatorChanged;
}
Expand Down
20 changes: 10 additions & 10 deletions radiant/textool/TexTool.h
Expand Up @@ -90,14 +90,14 @@ class TexTool :
sigc::connection _undoHandler;
sigc::connection _redoHandler;

typedef std::map<std::size_t, selection::ManipulatorPtr> Manipulators;
typedef std::map<std::size_t, selection::IManipulator::Ptr> Manipulators;
Manipulators _manipulators;

// The currently active manipulator
selection::ManipulatorPtr _activeManipulator;
selection::Manipulator::Type _defaultManipulatorType;
selection::IManipulator::Ptr _activeManipulator;
selection::IManipulator::Type _defaultManipulatorType;

sigc::signal<void, selection::Manipulator::Type> _sigActiveManipulatorChanged;
sigc::signal<void, selection::IManipulator::Type> _sigActiveManipulatorChanged;

private:
// This is where the static shared_ptr of the singleton instance is held.
Expand Down Expand Up @@ -281,14 +281,14 @@ class TexTool :
static void registerCommands();

// Returns the ID of the registered manipulator
std::size_t registerManipulator(const selection::ManipulatorPtr& manipulator);
void unregisterManipulator(const selection::ManipulatorPtr& manipulator);
std::size_t registerManipulator(const selection::IManipulator::Ptr& manipulator);
void unregisterManipulator(const selection::IManipulator::Ptr& manipulator);

selection::Manipulator::Type getActiveManipulatorType();
const selection::ManipulatorPtr& getActiveManipulator();
selection::IManipulator::Type getActiveManipulatorType();
const selection::IManipulator::Ptr& getActiveManipulator();
void setActiveManipulator(std::size_t manipulatorId);
void setActiveManipulator(selection::Manipulator::Type manipulatorType);
sigc::signal<void, selection::Manipulator::Type>& signal_activeManipulatorChanged();
void setActiveManipulator(selection::IManipulator::Type manipulatorType);
sigc::signal<void, selection::IManipulator::Type>& signal_activeManipulatorChanged();

/** greebo: Returns the number of selected TexToolItems.
*/
Expand Down
14 changes: 7 additions & 7 deletions radiant/textool/tools/TextureToolManipulateMouseTool.cpp
Expand Up @@ -146,7 +146,7 @@ bool TextureToolManipulateMouseTool::selectManipulator(const render::View& view,

void TextureToolManipulateMouseTool::handleMouseMove(const render::View& view, const Vector2& devicePoint)
{
const selection::ManipulatorPtr& activeManipulator = TexTool::Instance().getActiveManipulator();
const auto& activeManipulator = TexTool::Instance().getActiveManipulator();
assert(activeManipulator);

// Check if the active manipulator is selected in the first place
Expand Down Expand Up @@ -181,12 +181,12 @@ void TextureToolManipulateMouseTool::handleMouseMove(const render::View& view, c
#endif

// Query keyboard modifier state and pass them as flags
int constraintFlag = selection::Manipulator::Component::Constraint::Unconstrained;
constraintFlag |= wxGetKeyState(WXK_SHIFT) ? selection::Manipulator::Component::Constraint::Type1 : 0;
constraintFlag |= wxGetKeyState(WXK_ALT) ? selection::Manipulator::Component::Constraint::Type3 : 0;
int constraintFlag = selection::IManipulator::Component::Constraint::Unconstrained;
constraintFlag |= wxGetKeyState(WXK_SHIFT) ? selection::IManipulator::Component::Constraint::Type1 : 0;
constraintFlag |= wxGetKeyState(WXK_ALT) ? selection::IManipulator::Component::Constraint::Type3 : 0;

// Grid constraint is ON by default, unless CTRL is held
constraintFlag |= wxGetKeyState(WXK_CONTROL) ? 0 : selection::Manipulator::Component::Constraint::Grid;
constraintFlag |= wxGetKeyState(WXK_CONTROL) ? 0 : selection::IManipulator::Component::Constraint::Grid;

// Get the component of the currently active manipulator (done by selection test)
// and call the transform method
Expand All @@ -204,7 +204,7 @@ void TextureToolManipulateMouseTool::endMove()
{
freezeTransforms();

const selection::ManipulatorPtr& activeManipulator = TexTool::Instance().getActiveManipulator();
const auto& activeManipulator = TexTool::Instance().getActiveManipulator();
assert(activeManipulator);

_manipulationActive = false;
Expand All @@ -224,7 +224,7 @@ void TextureToolManipulateMouseTool::endMove()

void TextureToolManipulateMouseTool::cancelMove()
{
const selection::ManipulatorPtr& activeManipulator = TexTool::Instance().getActiveManipulator();
const auto& activeManipulator = TexTool::Instance().getActiveManipulator();
assert(activeManipulator);

_manipulationActive = false;
Expand Down
10 changes: 5 additions & 5 deletions radiant/ui/ManipulatorToggle.h
Expand Up @@ -57,13 +57,13 @@ class ManipulatorToggle
}

private:
void onActiveManipulatorChanged(selection::Manipulator::Type type)
void onActiveManipulatorChanged(selection::IManipulator::Type type)
{
GlobalEventManager().setToggled("ToggleClipper", GlobalClipper().clipMode());
GlobalEventManager().setToggled("MouseTranslate", type == selection::Manipulator::Translate);
GlobalEventManager().setToggled("MouseRotate", type == selection::Manipulator::Rotate);
GlobalEventManager().setToggled("MouseDrag", type == selection::Manipulator::Drag);
GlobalEventManager().setToggled("ToggleModelScaleManipulator", type == selection::Manipulator::ModelScale);
GlobalEventManager().setToggled("MouseTranslate", type == selection::IManipulator::Translate);
GlobalEventManager().setToggled("MouseRotate", type == selection::IManipulator::Rotate);
GlobalEventManager().setToggled("MouseDrag", type == selection::IManipulator::Drag);
GlobalEventManager().setToggled("ToggleModelScaleManipulator", type == selection::IManipulator::ModelScale);
}
};

Expand Down
2 changes: 1 addition & 1 deletion radiantcore/clipper/Clipper.cpp
Expand Up @@ -200,7 +200,7 @@ void Clipper::splitClip() {
}

bool Clipper::clipMode() const {
return GlobalSelectionSystem().getActiveManipulatorType() == selection::Manipulator::Clip;
return GlobalSelectionSystem().getActiveManipulatorType() == selection::IManipulator::Clip;
}

void Clipper::onClipMode(bool enabled) {
Expand Down

0 comments on commit 08b271e

Please sign in to comment.