Commit 1254d4ac authored by Mike Kremer's avatar Mike Kremer
Browse files

Adapted MoveSelection to new selection plugin architecture.

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@11568 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 2cfe7158
...@@ -85,7 +85,6 @@ MovePlugin::MovePlugin() : ...@@ -85,7 +85,6 @@ MovePlugin::MovePlugin() :
manip_size_modifier_ = 1.0; manip_size_modifier_ = 1.0;
selectionType_ = VERTEX; selectionType_ = VERTEX;
selectionConnected_ = false;
axisA_ = 0; axisA_ = 0;
axisB_ = 1; axisB_ = 1;
...@@ -486,13 +485,19 @@ void MovePlugin::moveObject(ACG::Matrix4x4d mat, int _id) { ...@@ -486,13 +485,19 @@ void MovePlugin::moveObject(ACG::Matrix4x4d mat, int _id) {
*/ */
void MovePlugin::moveSelection(ACG::Matrix4x4d mat, int _id, QEvent::Type _type) { void MovePlugin::moveSelection(ACG::Matrix4x4d mat, int _id, QEvent::Type _type) {
// Get currently active primitive type
updateSelectionType();
if ( !mat.is_identity() ){ if ( !mat.is_identity() ){
if (selectionType_ == VERTEX) if (selectionType_ == VERTEX) {
transformVertexSelection( _id , mat ); transformVertexSelection( _id , mat );
else if (selectionType_ == FACE) }
else if (selectionType_ == FACE) {
transformFaceSelection( _id , mat ); transformFaceSelection( _id , mat );
else if (selectionType_ == EDGE) }
else if (selectionType_ == EDGE) {
transformEdgeSelection( _id , mat ); transformEdgeSelection( _id , mat );
}
emit updatedObject(_id, UPDATE_GEOMETRY); emit updatedObject(_id, UPDATE_GEOMETRY);
} }
...@@ -1591,8 +1596,6 @@ void MovePlugin::slotSetMoveMode(QAction* _action) { ...@@ -1591,8 +1596,6 @@ void MovePlugin::slotSetMoveMode(QAction* _action) {
if (_action == moveSelectionAction_){ if (_action == moveSelectionAction_){
connectSelectionActions();
PluginFunctions::actionMode(Viewer::PickingMode); PluginFunctions::actionMode(Viewer::PickingMode);
PluginFunctions::pickMode("MoveSelection"); PluginFunctions::pickMode("MoveSelection");
...@@ -1850,63 +1853,31 @@ void MovePlugin::unifyBBDiag( MeshT& _mesh, ACG::Vec3d& _bb_min, ACG::Vec3d& _bb ...@@ -1850,63 +1853,31 @@ void MovePlugin::unifyBBDiag( MeshT& _mesh, ACG::Vec3d& _bb_min, ACG::Vec3d& _bb
/** \brief Connect to SelectionPlugin /** \brief Connect to SelectionPlugin
* *
*/ */
void MovePlugin::connectSelectionActions(){ void MovePlugin::updateSelectionType(){
if (!selectionConnected_){
selectionConnected_ = true;
bool connected = false; selectionType_ = VERTEX;
QToolBar* selToolBar = 0;
emit getToolBar( "Selection", selToolBar );
if (selToolBar != 0){
QActionGroup* actionGroup = 0;
for (int i=0; i < selToolBar->actions().count(); i++){ bool functionExistsMeshV;
if( selToolBar->actions().at(i)->text() == tr("Enable Vertex Selection") ){ emit functionExists("meshobjectselection", "vertexTypeActive()", functionExistsMeshV);
bool functionExistsMeshE;
emit functionExists("meshobjectselection", "edgeTypeActive()", functionExistsMeshE);
bool functionExistsMeshF;
emit functionExists("meshobjectselection", "faceTypeActive()", functionExistsMeshF);
actionGroup = selToolBar->actions().at(i)->actionGroup(); if(functionExistsMeshV && functionExistsMeshE && functionExistsMeshF) {
if ( selToolBar->actions().at(i)->isChecked() ) // Make RPC call
if(RPC::callFunctionValue<bool>("meshobjectselection", "vertexTypeActive")) {
selectionType_ = VERTEX; selectionType_ = VERTEX;
} else if(RPC::callFunctionValue<bool>("meshobjectselection", "edgeTypeActive")) {
} else if ( (selToolBar->actions().at(i)->text() == tr("Enable Edge Selection") )
&& (selToolBar->actions().at(i)->isChecked()) )
selectionType_ = EDGE; selectionType_ = EDGE;
else if ( (selToolBar->actions().at(i)->text() == tr("Enable Face Selection") ) } else if(RPC::callFunctionValue<bool>("meshobjectselection", "faceTypeActive")) {
&& (selToolBar->actions().at(i)->isChecked()) )
selectionType_ = FACE; selectionType_ = FACE;
} }
if (actionGroup != 0){ } else {
connect( actionGroup, SIGNAL( triggered(QAction*) ), this, SLOT(slotSelectionModeChanged(QAction*)) ); emit log(LOGWARN, tr("Unable to connect to Selection-Plugin. MoveSelection will work on vertices only."));
connected = true;
}
} }
if (!connected)
emit log(LOGWARN, tr("Unable to connect to Selection-Plugin. MoveSelection will work on vertices only."));
}
}
//------------------------------------------------------------------------------
/** \brief The SelectionMode in SelectionPlugin Changed
*
* @param _action the action on the Selection-Toolbar that was hit
*/
void MovePlugin::slotSelectionModeChanged(QAction* _action){
if (_action->text() == tr("Enable Vertex Selection"))
selectionType_ = VERTEX;
if (_action->text() == tr("Enable Edge Selection"))
selectionType_ = EDGE;
if (_action->text() == tr("Enable Face Selection"))
selectionType_ = FACE;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
......
...@@ -71,8 +71,6 @@ ...@@ -71,8 +71,6 @@
#include "MoveProps.hh" #include "MoveProps.hh"
#include "MoveObjectMarker.hh" #include "MoveObjectMarker.hh"
enum SelectionType {VERTEX, EDGE, FACE };
/** Plugin for moving objects and selections /** Plugin for moving objects and selections
*/ */
class MovePlugin : public QObject, BaseInterface, MouseInterface, KeyInterface, PickingInterface, ToolboxInterface, BackupInterface, LoggingInterface, ScriptInterface,ToolbarInterface, ContextMenuInterface, LoadSaveInterface, RPCInterface class MovePlugin : public QObject, BaseInterface, MouseInterface, KeyInterface, PickingInterface, ToolboxInterface, BackupInterface, LoggingInterface, ScriptInterface,ToolbarInterface, ContextMenuInterface, LoadSaveInterface, RPCInterface
...@@ -91,6 +89,9 @@ class MovePlugin : public QObject, BaseInterface, MouseInterface, KeyInterface, ...@@ -91,6 +89,9 @@ class MovePlugin : public QObject, BaseInterface, MouseInterface, KeyInterface,
Q_INTERFACES(LoadSaveInterface) Q_INTERFACES(LoadSaveInterface)
Q_INTERFACES(RPCInterface) Q_INTERFACES(RPCInterface)
public:
enum SelectionType {VERTEX, EDGE, FACE};
signals: signals:
// BaseInterface // BaseInterface
void updateView(); void updateView();
...@@ -389,20 +390,14 @@ class MovePlugin : public QObject, BaseInterface, MouseInterface, KeyInterface, ...@@ -389,20 +390,14 @@ class MovePlugin : public QObject, BaseInterface, MouseInterface, KeyInterface,
* @{ */ * @{ */
//=========================================================================== //===========================================================================
/// have we already tried to connect to Selection Plugin?
bool selectionConnected_;
/// Current SelectionType of SelectionPlugin /// Current SelectionType of SelectionPlugin
SelectionType selectionType_; SelectionType selectionType_;
/// Connect to SelectionPlugin /// Get current primitive selection
void connectSelectionActions(); void updateSelectionType();
private slots: private slots:
/// The SelectionMode changed in SelectionPlugin
void slotSelectionModeChanged(QAction* _action);
/// Sets whether all targets should be affected or not /// Sets whether all targets should be affected or not
void setAllTargets(bool _state); void setAllTargets(bool _state);
......
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