Commit 690a41aa authored by Jan Möbius's avatar Jan Möbius

Dennis:

Control-manipulator-modes-outside-of-node
Change-manipulator-mode-on-keypress



git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@5698 383ad7c9-94d9-4d36-a494-682f7c89f535
parent f606b233
......@@ -57,7 +57,8 @@
/** \brief Default Constructor
*
*/
MovePlugin::MovePlugin()
MovePlugin::MovePlugin() :
manMode_ (QtTranslationManipulatorNode::TranslationRotation)
{
manip_size_ = 1.0;
manip_size_modifier_ = 1.0;
......@@ -86,6 +87,12 @@ void MovePlugin::pluginsInitialized() {
emit addHiddenPickMode("MoveSelection");
emit setPickModeMouseTracking ("MoveSelection", true);
//KEYS
emit registerKey (Qt::Key_Shift, Qt::ShiftModifier, "Manipulator rotation", true);
emit registerKey (Qt::Key_Shift, Qt::NoModifier, "Manipulator rotation", true);
emit registerKey (Qt::Key_Control, Qt::ControlModifier, "Resize", true);
emit registerKey (Qt::Key_Control, Qt::NoModifier, "Resize", true);
//SCRIPTING SLOT DESCRIPTIONS
setDescriptions();
......@@ -179,26 +186,91 @@ void MovePlugin::slotMouseWheelEvent(QWheelEvent * _event, const std::string & /
*/
void MovePlugin::slotMouseEvent( QMouseEvent* _event )
{
if ( ( (PluginFunctions::pickMode() == ("Move")) || (PluginFunctions::pickMode() == ("MoveSelection")) ) &&
PluginFunctions::actionMode() == Viewer::PickingMode ) {
QtTranslationManipulatorNode::ManipulatorMode mode;
if (_event->modifiers() & Qt::ControlModifier)
mode = QtTranslationManipulatorNode::Resize;
else if (_event->modifiers() & Qt::ShiftModifier)
mode = QtTranslationManipulatorNode::LocalRotation;
else
mode = QtTranslationManipulatorNode::TranslationRotation;
if (mode != manMode_)
{
manMode_ = mode;
if ((PluginFunctions::pickMode() == "Move" ) || (PluginFunctions::pickMode() == "MoveSelection" )) {
for ( PluginFunctions::ObjectIterator o_it(PluginFunctions::ALL_OBJECTS) ;
o_it != PluginFunctions::objectsEnd(); ++o_it)
if ( o_it->manipPlaced() )
o_it->manipulatorNode()->setMode (mode);
}
}
if (_event->type() == QEvent::MouseButtonDblClick) {
if (((PluginFunctions::pickMode() == ("Move")) || (PluginFunctions::pickMode() == ("MoveSelection"))) &&
PluginFunctions::actionMode() == Viewer::PickingMode) {
placeManip(_event);
updateManipulatorDialog();
return;
}
if (_event->type() == QEvent::MouseButtonDblClick) {
// interaction
ACG::SceneGraph::MouseEventAction action(_event);
PluginFunctions::traverse(action);
placeManip(_event);
updateManipulatorDialog();
return;
}
if (_event->buttons() == Qt::LeftButton)
emit visibilityChanged (-1);
// interaction
ACG::SceneGraph::MouseEventAction action(_event);
PluginFunctions::traverse(action);
}
if (_event->buttons() == Qt::LeftButton)
emit visibilityChanged (-1);
}
}
/*******************************************************************************
KeyInterface implementation
*******************************************************************************/
void MovePlugin::slotKeyEvent (QKeyEvent* _event)
{
QtTranslationManipulatorNode::ManipulatorMode mode;
if (_event->key() == Qt::Key_Control)
mode = QtTranslationManipulatorNode::Resize;
else if (_event->key () == Qt::Key_Shift)
mode = QtTranslationManipulatorNode::LocalRotation;
else
mode = QtTranslationManipulatorNode::TranslationRotation;
if (mode != manMode_)
{
if ((PluginFunctions::pickMode() == "Move" ) || (PluginFunctions::pickMode() == "MoveSelection" )) {
manMode_ = mode;
for (PluginFunctions::ObjectIterator o_it(PluginFunctions::ALL_OBJECTS);
o_it != PluginFunctions::objectsEnd(); ++o_it)
if (o_it->manipPlaced())
o_it->manipulatorNode()->setMode (mode);
}
}
}
//------------------------------------------------------------------------------
void MovePlugin::slotKeyReleaseEvent (QKeyEvent* _event)
{
QtTranslationManipulatorNode::ManipulatorMode mode = manMode_;
if ((_event->key() == Qt::Key_Control && manMode_ == QtTranslationManipulatorNode::Resize) ||
(_event->key() == Qt::Key_Shift && manMode_ == QtTranslationManipulatorNode::LocalRotation))
mode = QtTranslationManipulatorNode::TranslationRotation;
if (mode != manMode_)
{
if ((PluginFunctions::pickMode() == "Move" ) || (PluginFunctions::pickMode() == "MoveSelection" )) {
manMode_ = mode;
for (PluginFunctions::ObjectIterator o_it(PluginFunctions::ALL_OBJECTS);
o_it != PluginFunctions::objectsEnd(); ++o_it)
if (o_it->manipPlaced())
o_it->manipulatorNode()->setMode (mode);
}
}
}
/*******************************************************************************
PickingInterface implementation
......@@ -405,6 +477,7 @@ void MovePlugin::placeManip(QMouseEvent * _event)
object->manipulatorNode()->set_draw_cylinder(true);
object->manipulatorNode()->set_autosize(QtTranslationManipulatorNode::Once);
object->manipulatorNode()->set_size(manip_size_ * manip_size_modifier_);
object->manipulatorNode()->setMode (manMode_);
object->manipulatorNode()->show();
object->manipulatorNode()->apply_transformation( PluginFunctions::pickMode() == "Move" );
......
......@@ -56,11 +56,12 @@ enum SelectionType {VERTEX, EDGE, FACE };
/** Plugin for moving objects and selections
*/
class MovePlugin : public QObject, BaseInterface, MouseInterface, PickingInterface, ToolboxInterface, BackupInterface, LoggingInterface, ScriptInterface,ToolbarInterface, ContextMenuInterface
class MovePlugin : public QObject, BaseInterface, MouseInterface, KeyInterface, PickingInterface, ToolboxInterface, BackupInterface, LoggingInterface, ScriptInterface,ToolbarInterface, ContextMenuInterface
{
Q_OBJECT
Q_INTERFACES(BaseInterface)
Q_INTERFACES(MouseInterface)
Q_INTERFACES(KeyInterface)
Q_INTERFACES(PickingInterface)
Q_INTERFACES(ToolboxInterface)
Q_INTERFACES(BackupInterface)
......@@ -99,6 +100,9 @@ class MovePlugin : public QObject, BaseInterface, MouseInterface, PickingInterfa
void addToolbar(QToolBar* _toolbar);
void getToolBar( QString _name, QToolBar*& _toolbar);
// KeyInterface
void registerKey(int _key, Qt::KeyboardModifiers _modifiers, QString _description, bool _multiUse = false);
private slots :
// BaseInterface
......@@ -108,6 +112,10 @@ class MovePlugin : public QObject, BaseInterface, MouseInterface, PickingInterfa
void slotMouseWheelEvent(QWheelEvent * _event, const std::string & _mode);
void slotMouseEvent( QMouseEvent* _event );
// KeyInterface
void slotKeyEvent (QKeyEvent* _event);
void slotKeyReleaseEvent (QKeyEvent* _event);
// PickingInterface
void slotPickModeChanged( const std::string& _mode);
......@@ -268,6 +276,11 @@ class MovePlugin : public QObject, BaseInterface, MouseInterface, PickingInterfa
/// Move selection on an object with given id
void moveSelection(ACG::Matrix4x4d mat, int _id);
private:
/// Holds the current manipulator mode
QtTranslationManipulatorNode::ManipulatorMode manMode_;
/** @} */
//===========================================================================
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment