MovePlugin.cc 41.5 KB
Newer Older
Jan Möbius's avatar
Jan Möbius committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14
//=============================================================================
//
//                               OpenFlipper
//        Copyright (C) 2008 by Computer Graphics Group, RWTH Aachen
//                           www.openflipper.org
//
//-----------------------------------------------------------------------------
//
//                                License
//
//  OpenFlipper is free software: you can redistribute it and/or modify
//  it under the terms of the GNU Lesser General Public License as published by
//  the Free Software Foundation, either version 3 of the License, or
//  (at your option) any later version.
15
//
Jan Möbius's avatar
Jan Möbius committed
16 17 18 19
//  OpenFlipper is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU Lesser General Public License for more details.
20
//
Jan Möbius's avatar
Jan Möbius committed
21 22 23 24 25 26 27 28 29 30
//  You should have received a copy of the GNU Lesser General Public License
//  along with OpenFlipper.  If not, see <http://www.gnu.org/licenses/>.
//
//-----------------------------------------------------------------------------
//
//   $Revision$
//   $Author$
//   $Date$
//
//=============================================================================
Jan Möbius's avatar
 
Jan Möbius committed
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57

#include <QtGui>

#include "MovePlugin.hh"

#include <iostream>
#include <ACG/GL/GLState.hh>
#include <QStringList>
#include <ACG/QtScenegraph/QtTranslationManipulatorNode.hh>

#include <OpenFlipper/BasePlugin/PluginFunctions.hh>
#include <OpenFlipper/common/GlobalOptions.hh>

#include <MeshTools/MeshFunctions.hh>
#include <MeshTools/MeshInfoT.hh>

#ifdef USE_OPENMP
#include <omp.h>
#endif

#ifdef ENABLE_POLYLINE_SUPPORT
#include <ObjectTypes/PolyLine/PolyLine.hh>
#endif



/** \brief Default Constructor
58
 *
Jan Möbius's avatar
 
Jan Möbius committed
59
 */
Jan Möbius's avatar
Dennis:  
Jan Möbius committed
60 61
MovePlugin::MovePlugin() :
 manMode_ (QtTranslationManipulatorNode::TranslationRotation)
Jan Möbius's avatar
 
Jan Möbius committed
62 63 64 65 66 67 68 69 70
{
    manip_size_          = 1.0;
    manip_size_modifier_ = 1.0;

    selectionType_ = VERTEX;
    selectionConnected_ = false;

    axisA_ = 0;
    axisB_ = 1;
71 72

    hide_ = true;
Jan Möbius's avatar
 
Jan Möbius committed
73 74 75 76 77 78 79 80
}


/*******************************************************************************
        BaseInterface implementation
 *******************************************************************************/

/** \brief Initialization of the plugin when it is loaded by the core
81
 *
Jan Möbius's avatar
 
Jan Möbius committed
82 83 84 85 86 87 88 89 90 91
 */
void MovePlugin::pluginsInitialized() {

  //PICKMODES
  emit addPickMode("Separator");
  emit addHiddenPickMode("Move");
  emit setPickModeMouseTracking ("Move", true);
  emit addHiddenPickMode("MoveSelection");
  emit setPickModeMouseTracking ("MoveSelection", true);

Jan Möbius's avatar
Dennis:  
Jan Möbius committed
92 93 94 95 96 97
  //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);

Jan Möbius's avatar
 
Jan Möbius committed
98 99
  //SCRIPTING SLOT DESCRIPTIONS
  setDescriptions();
100

101
  // CONTEXT MENU
102 103 104
  contextAction_ = new QAction("Set properties", this);
  contextAction_->setToolTip("Set properties");
  contextAction_->setStatusTip( contextAction_->toolTip() );
105

106
  emit addContextMenuItem(contextAction_ , CONTEXTNODEMENU );
107

108
  connect( contextAction_ , SIGNAL( triggered() ),
109
	   this, SLOT(showProps()) );
Jan Möbius's avatar
 
Jan Möbius committed
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147

  //TOOLBAR
  toolbar_ = new QToolBar("Transform and Move");

  toolBarActions_ = new QActionGroup(toolbar_);

  moveAction_ = new QAction(tr("&Move objects"), toolBarActions_);
  std::cerr << "Todo : Show all manipulators placed" << std::endl;
  moveAction_->setStatusTip(tr("Move object in 3D."));
  moveAction_->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"move-objects.png") );
  moveAction_->setCheckable(true);
  toolbar_->addAction(moveAction_);

  moveSelectionAction_ = new QAction(tr("Move selections on objects"), toolBarActions_);
  moveSelectionAction_->setStatusTip(tr("Move selections in 3D."));
  moveSelectionAction_->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"move-selections.png") );
  moveSelectionAction_->setCheckable(true);
  toolbar_->addAction(moveSelectionAction_);

  connect(toolBarActions_, SIGNAL(triggered(QAction*)), this, SLOT(slotSetMoveMode(QAction*)) );

  emit addToolbar(toolbar_);
}


/*******************************************************************************
        ToolBoxInterface implementation
 *******************************************************************************/

/** \brief Create the move toolbox-widget and return a reference to it
 *
 * @param _widget A reference to the move toolbox that we will return
 * @return return wether the widget was successfully generated
 */
bool MovePlugin::initializeToolbox(QWidget*& _widget)
{
   toolboxActive_ = false;
   tool_ = new moveToolbarWidget();
Jan Möbius's avatar
Jan Möbius committed
148
   tool_ -> setMaximumWidth(300);
Jan Möbius's avatar
 
Jan Möbius committed
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170
   _widget = tool_;

   connect(tool_->moveToOrigin,SIGNAL(clicked() ),this,SLOT(slotMoveToOrigin()));

   tool_->moveToOrigin->setIcon( QIcon(OpenFlipper::Options::iconDirStr() + OpenFlipper::Options::dirSeparator() + "moveToCOG.png") );
   tool_->moveToOrigin->setIconSize(QSize(48,48));

   connect(tool_->unifyBoundingBoxDiagonal,SIGNAL(clicked() ),this,SLOT(slotUnifyBoundingBoxDiagonal()));
   tool_->unifyBoundingBoxDiagonal->setIcon( QIcon(OpenFlipper::Options::iconDirStr() + OpenFlipper::Options::dirSeparator() + "unifyBB.png") );
   tool_->unifyBoundingBoxDiagonal->setIconSize(QSize(48,48));

   lastActiveManipulator_ = -1;

   return true;
}


/*******************************************************************************
        MouseInterface implementation
 *******************************************************************************/

/** \brief MouseWheel event occured
171
 *
Jan Möbius's avatar
 
Jan Möbius committed
172 173 174 175 176 177 178
 * @param _event the event that occured
 */
void MovePlugin::slotMouseWheelEvent(QWheelEvent * _event, const std::string & /*_mode*/)
{
   manip_size_modifier_ = manip_size_modifier_ - (float)_event->delta() / 120.0 * 0.1;
   for ( PluginFunctions::ObjectIterator o_it(PluginFunctions::ALL_OBJECTS) ; o_it != PluginFunctions::objectsEnd(); ++o_it)
         o_it->manipulatorNode()->set_size(manip_size_ * manip_size_modifier_);
Jan Möbius's avatar
Dennis:  
Jan Möbius committed
179
   emit visibilityChanged (-1);
Jan Möbius's avatar
 
Jan Möbius committed
180 181 182 183 184 185
}


//------------------------------------------------------------------------------

/** \brief MousePress event occured
186
 *
Jan Möbius's avatar
 
Jan Möbius committed
187 188 189 190
 * @param _event the event that occured
 */
void MovePlugin::slotMouseEvent( QMouseEvent* _event )
{
Jan Möbius's avatar
Dennis:  
Jan Möbius committed
191 192 193 194 195 196 197 198 199 200 201 202 203 204
  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)
205
           if ( o_it->manipPlaced() )
Jan Möbius's avatar
Dennis:  
Jan Möbius committed
206 207 208
                o_it->manipulatorNode()->setMode (mode);
     }
  }
Jan Möbius's avatar
 
Jan Möbius committed
209

Jan Möbius's avatar
Dennis:  
Jan Möbius committed
210 211
  if (((PluginFunctions::pickMode() == ("Move")) || (PluginFunctions::pickMode() == ("MoveSelection"))) &&
      PluginFunctions::actionMode() == Viewer::PickingMode) {
Jan Möbius's avatar
 
Jan Möbius committed
212

Jan Möbius's avatar
Dennis:  
Jan Möbius committed
213 214 215 216 217 218
    if (_event->type() == QEvent::MouseButtonDblClick) {

      placeManip(_event);
      updateManipulatorDialog();
      return;
    }
Jan Möbius's avatar
 
Jan Möbius committed
219

Jan Möbius's avatar
Dennis:  
Jan Möbius committed
220 221 222
    // interaction
    ACG::SceneGraph::MouseEventAction action(_event);
    PluginFunctions::traverse(action);
Jan Möbius's avatar
 
Jan Möbius committed
223

Jan Möbius's avatar
Dennis:  
Jan Möbius committed
224 225
    if (_event->buttons() == Qt::LeftButton)
      emit visibilityChanged (-1);
Jan Möbius's avatar
Dennis:  
Jan Möbius committed
226

Jan Möbius's avatar
Dennis:  
Jan Möbius committed
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253
  }
}

/*******************************************************************************
        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);
     }
  }
Jan Möbius's avatar
 
Jan Möbius committed
254 255
}

Jan Möbius's avatar
Dennis:  
Jan Möbius committed
256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275
//------------------------------------------------------------------------------

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);
     }
  }
}
Jan Möbius's avatar
 
Jan Möbius committed
276 277 278 279 280 281

/*******************************************************************************
        PickingInterface implementation
 *******************************************************************************/

/** \brief slot is called when the pickMode changed
282
 *
Jan Möbius's avatar
 
Jan Möbius committed
283 284 285 286
 * @param _mode new pickMode
 */
void MovePlugin::slotPickModeChanged( const std::string& _mode)
{
287 288 289 290
	moveAction_->setChecked(_mode == "Move");
	moveSelectionAction_->setChecked(_mode == "MoveSelection");

	hide_ = !(_mode == "Move" || _mode == "MoveSelection");
Jan Möbius's avatar
 
Jan Möbius committed
291

292
	showManipulators();
Jan Möbius's avatar
 
Jan Möbius committed
293 294 295 296 297 298 299 300
}


/*******************************************************************************
        MovePlugin implementation
 *******************************************************************************/

/** \brief Move object with given transformation matrix
301
 *
Jan Möbius's avatar
 
Jan Möbius committed
302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336
 * @param mat transformation matrix
 * @param _id id of the object
 */
void MovePlugin::moveObject(ACG::Matrix4x4d mat, int _id) {
  BaseObjectData* object;
  if ( ! PluginFunctions::getObject(_id,object) ) {
    emit log(LOGERR,"moveObject called for not existing Object Id");
    return;
  }

  switch ( object->dataType() ) {
    case DATA_TRIANGLE_MESH:
      transformMesh(mat , *PluginFunctions::triMesh(object) );
      break;
    case DATA_POLY_MESH:
      transformMesh(mat , *PluginFunctions::polyMesh(object) );
      break;
    case DATA_POLY_LINE:
      #ifdef ENABLE_POLYLINE_SUPPORT
      transformPolyLine(mat , *PluginFunctions::polyLine(object) );
      #endif
      break;
    default:
      emit log(LOGERR,"moveObject called for unsupported Object Type");
      return;
  }

  emit updatedObject(_id);
  emit createBackup(_id,"Move");
}


//------------------------------------------------------------------------------

/** \brief Move selection on an object with given transformation matrix
337
 *
Jan Möbius's avatar
 
Jan Möbius committed
338 339 340 341
 * Which Selection (Vertex, Edge, Face) is used is determined by the
 * current SelectionMode in SelectionPlugin.
 * If the Plugin is unable to communicate with SelectionPlugin, Vertex Selection is used.
 *
342 343
 * @param mat
 * @param _id
Jan Möbius's avatar
 
Jan Möbius committed
344 345 346 347 348 349 350 351 352 353 354 355 356 357
 */
void MovePlugin::moveSelection(ACG::Matrix4x4d mat, int _id) {

  if (selectionType_ == VERTEX)
    transformVertexSelection( _id , mat );
  else if (selectionType_ == FACE)
    transformFaceSelection( _id , mat );
  else if (selectionType_ == EDGE)
    transformEdgeSelection( _id , mat );

  emit updatedObject(_id);
//   emit createBackup(_id,"MoveSelection");
}

358 359 360
//------------------------------------------------------------------------------

/** \brief Hide context menu entry when right clicking on node other than manipulator node
361
 *
362 363 364
 * @param _nodeId Identifier of node that has been clicked
 */
void MovePlugin::slotUpdateContextMenuNode( int _nodeId ) {
365

366
    ACG::SceneGraph::BaseNode* node = ACG::SceneGraph::find_node( PluginFunctions::getSceneGraphRootNode(), _nodeId );
367

368
    if (node == 0) return;
369

370 371 372 373 374 375 376
    if(node->className() != "QtTranslationManipulatorNode") {
	contextAction_->setVisible(false);
    }
    else {
	contextAction_->setVisible(true);
    }
}
Jan Möbius's avatar
 
Jan Möbius committed
377 378 379 380

//------------------------------------------------------------------------------

/** \brief move the object when its manipulator moves
381
 *
Jan Möbius's avatar
 
Jan Möbius committed
382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432
 * @param _node the manipulator node
 * @param _event the mouse event
 */
void MovePlugin::manipulatorMoved( QtTranslationManipulatorNode* _node , QMouseEvent* _event) {

  // React on event only in move mode
  if ( PluginFunctions::pickMode() != "Move" && PluginFunctions::pickMode() != "MoveSelection" )
    return;

  OpenFlipper::Options::redrawDisabled( true );

  // Apply changes only on Release for moveMode and after every movement in MoveSelection Mode
  if ( (_event->type() == QEvent::MouseButtonRelease) || (PluginFunctions::pickMode() == "MoveSelection") ) {

    int objectId = _node->getIdentifier();

    ACG::Matrix4x4d mat;
    mat.identity();
    mat = _node->matrix();

    // Reset Node
    _node->loadIdentity();
    _node->set_center(mat.transform_point(_node->center()));

    // Always move the object which corresponds to the manipulator
    if (PluginFunctions::pickMode() != "MoveSelection")
      moveObject( mat, objectId );
    else
      moveSelection( mat, objectId );

    for ( PluginFunctions::ObjectIterator o_it(PluginFunctions::TARGET_OBJECTS ) ; o_it != PluginFunctions::objectsEnd(); ++o_it)  {
      if ( ( o_it->id() != objectId ) && !o_it->manipulatorNode()->visible() ) { // If it has its own manipulator active, dont move it
        if (PluginFunctions::pickMode() != "MoveSelection")
          moveObject( mat,o_it->id() );
        else
          moveSelection( mat,o_it->id() );
      }
    }

    lastActiveManipulator_ = objectId;
    updateManipulatorDialog();
  }

  OpenFlipper::Options::redrawDisabled( false );

}


//------------------------------------------------------------------------------

/** \brief update object when its manipulator changes position
433
 *
Jan Möbius's avatar
 
Jan Möbius committed
434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459
 * @param _node the manipulator node
 */
void MovePlugin::ManipulatorPositionChanged(QtTranslationManipulatorNode* _node ) {

  // Position has been changed of the manipulator by a direct function
  int objectId = _node->getIdentifier();

  BaseObjectData* object;
  PluginFunctions::getObject(objectId,object);

  // Assume that it has a good position now
  object->manipPlaced( true );

  // Show manipulator only if in Move mode
  if ( PluginFunctions::pickMode() == "Move" )
    _node->show();

  lastActiveManipulator_ = objectId;
  updateManipulatorDialog();

}


//------------------------------------------------------------------------------

/** \brief Place and show the Manipulator
460
 *
Jan Möbius's avatar
 
Jan Möbius committed
461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481
 * @param _event  mouseEvent that occured
 */
void MovePlugin::placeManip(QMouseEvent * _event)
{
   unsigned int  node_idx, target_idx;
   OpenMesh::Vec3d         hitPoint;

   if ( PluginFunctions::scenegraphPick(ACG::SceneGraph::PICK_ANYTHING,_event->pos(), node_idx, target_idx,&hitPoint) ) {

      BaseObjectData* object;

      if ( PluginFunctions::getPickedObject(node_idx, object) ) {
         object->manipPlaced( true );

         if ( !object->picked(node_idx) ) {
            emit log(LOGWARN,"Picking failed");
         }

         object->manipulatorNode()->loadIdentity();
         object->manipulatorNode()->set_center(hitPoint);
         object->manipulatorNode()->set_draw_cylinder(true);
Jan Möbius's avatar
Dennis:  
Jan Möbius committed
482
         object->manipulatorNode()->set_autosize(QtTranslationManipulatorNode::Once);
Jan Möbius's avatar
 
Jan Möbius committed
483
         object->manipulatorNode()->set_size(manip_size_ * manip_size_modifier_);
Jan Möbius's avatar
Dennis:  
Jan Möbius committed
484
         object->manipulatorNode()->setMode (manMode_);
Jan Möbius's avatar
 
Jan Möbius committed
485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511
         object->manipulatorNode()->show();

         object->manipulatorNode()->apply_transformation( PluginFunctions::pickMode() == "Move" );

         connect(object->manipulatorNode() , SIGNAL(manipulatorMoved(QtTranslationManipulatorNode*,QMouseEvent*)),
                 this                      , SLOT(  manipulatorMoved(QtTranslationManipulatorNode*,QMouseEvent*)));

         connect(object->manipulatorNode() , SIGNAL(positionChanged(QtTranslationManipulatorNode*)),
                 this                      , SLOT(  ManipulatorPositionChanged(QtTranslationManipulatorNode*)));

         lastActiveManipulator_ = object->id();

         emit updateView();
      } else {
         emit log(LOGERR,"Picking ok, but Object was not found in the Object list");
      }

   } else {
       emit log(LOGWARN,"Picking failed");
   }

}


//------------------------------------------------------------------------------

/** \brief Checks if the manipulators should be visible or not
512
 *
Jan Möbius's avatar
 
Jan Möbius committed
513 514 515
 */
void MovePlugin::showManipulators( )
{
516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531
	if (!hide_ && (toolboxActive_ || (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()->show();
				o_it->manipulatorNode()->apply_transformation(
						PluginFunctions::pickMode() == "Move");
			}
	} else {
		for (PluginFunctions::ObjectIterator o_it(PluginFunctions::ALL_OBJECTS); o_it
				!= PluginFunctions::objectsEnd(); ++o_it)

			o_it->manipulatorNode()->hide();
	}
Jan Möbius's avatar
 
Jan Möbius committed
532

533
	emit updateView();
Jan Möbius's avatar
 
Jan Möbius committed
534 535 536

}

537
//------------------------------------------------------------------------------
Jan Möbius's avatar
 
Jan Möbius committed
538

539
/** \brief Get Dialog Widget that contains the button
540
 *
541 542 543 544 545 546 547
 * @param _but Reference to QPushButton object that has been pressed
 */
movePropsWidget* MovePlugin::getDialogFromButton(QPushButton* _but) {

    if(_but == 0) return 0;
    return dynamic_cast<movePropsWidget*>((((_but->parentWidget())->parentWidget())->parentWidget()));
}
Jan Möbius's avatar
 
Jan Möbius committed
548 549 550
//------------------------------------------------------------------------------

/** \brief Position of manipulator in tab changed
551
 *
Jan Möbius's avatar
 
Jan Möbius committed
552 553
 */
void MovePlugin::slotSetPosition() {
554

555 556 557
    QPushButton* but = dynamic_cast<QPushButton*>(QObject::sender());
    movePropsWidget* pW = getDialogFromButton(but);
    if(pW == 0) return;
558

559
    TriMesh::Point newpos;
560

561 562 563 564 565 566 567
    bool ok = false;
    newpos[0] =  (pW->nposx->text()).toDouble(&ok);
    if ( !ok ) { emit log(LOGERR,"Wrong Format for X Coordinate"); return; }
    newpos[1] =  (pW->nposy->text()).toDouble(&ok);
    if ( !ok ) { emit log(LOGERR,"Wrong Format for Y Coordinate"); return; }
    newpos[2] =  (pW->nposz->text()).toDouble(&ok);
    if ( !ok ) { emit log(LOGERR,"Wrong Format for Z Coordinate"); return; }
568

569 570 571 572 573 574 575
    BaseObjectData* object;
    if ( PluginFunctions::getObject(lastActiveManipulator_ , object) ) {
	if (  object->manipulatorNode()->visible() )
	    object->manipulatorNode()->set_center( newpos );
	updateManipulatorDialog();
	emit updateView();
    }
Jan Möbius's avatar
 
Jan Möbius committed
576 577 578 579 580 581
}


//------------------------------------------------------------------------------

/** \brief Toggle the first axis for changing direction in tab
582
 *
Jan Möbius's avatar
 
Jan Möbius committed
583 584
 */
void MovePlugin::slotToggleAxisA() {
585

586 587 588
    QPushButton* but = dynamic_cast<QPushButton*>(QObject::sender());
    movePropsWidget* pW = getDialogFromButton(but);
    if(pW == 0) return;
Jan Möbius's avatar
 
Jan Möbius committed
589 590

    axisA_ = (axisA_ + 1) % 3;
591

592 593
    if (axisA_ == axisB_)
	axisA_ = (axisA_ + 1) % 3;
594

595 596 597 598 599 600
    switch(axisA_){
	case 0: pW->axisAButton->setText("X Direction"); break;
	case 1: pW->axisAButton->setText("Y Direction"); break;
	case 2: pW->axisAButton->setText("Z Direction"); break;
	default: break;
    }
Jan Möbius's avatar
 
Jan Möbius committed
601 602 603 604 605 606
}


//------------------------------------------------------------------------------

/** \brief Toggle the second axis for changing direction in tab
607
 *
Jan Möbius's avatar
 
Jan Möbius committed
608 609
 */
void MovePlugin::slotToggleAxisB() {
610

611 612 613
    QPushButton* but = dynamic_cast<QPushButton*>(QObject::sender());
    movePropsWidget* pW = getDialogFromButton(but);
    if(pW == 0) return;
Jan Möbius's avatar
 
Jan Möbius committed
614 615

    axisB_ = (axisB_ + 1) % 3;
616

617 618
    if (axisA_ == axisB_)
	axisB_ = (axisB_ + 1) % 3;
619

620 621 622 623 624 625
    switch(axisB_){
	case 0: pW->axisBButton->setText("X Direction"); break;
	case 1: pW->axisBButton->setText("Y Direction"); break;
	case 2: pW->axisBButton->setText("Z Direction"); break;
	default: break;
    }
Jan Möbius's avatar
 
Jan Möbius committed
626 627 628 629 630 631
}


//------------------------------------------------------------------------------

/** \brief Set Direction of manipulator in tab changed
632
 *
Jan Möbius's avatar
 
Jan Möbius committed
633 634
 */
void MovePlugin::slotSetDirection() {
635

636 637 638
    QPushButton* but = dynamic_cast<QPushButton*>(QObject::sender());
    movePropsWidget* pW = getDialogFromButton(but);
    if(pW == 0) return;
Jan Möbius's avatar
 
Jan Möbius committed
639

640 641 642
    ACG::Vec3d newdirA,newdirB;
    ACG::Vec3d dirX,dirY;
    ACG::Vec3d dirZ(0.0,0.0,0.0);
643

644 645 646 647 648 649 650
    bool ok = false;
    newdirA[0] =  (pW->ndirAx->text()).toDouble(&ok);
    if ( !ok ) { emit log(LOGERR,"Wrong Format for X Coordinate");  return; }
    newdirA[1] =  (pW->ndirAy->text()).toDouble(&ok);
    if ( !ok ) { emit log(LOGERR,"Wrong Format for Y Coordinate"); return; }
    newdirA[2] =  (pW->ndirAz->text()).toDouble(&ok);
    if ( !ok ) { emit log(LOGERR,"Wrong Format for Z Coordinate"); return; }
651

652 653 654 655 656 657
    newdirB[0] =  (pW->ndirBx->text()).toDouble(&ok);
    if ( !ok ) { emit log(LOGERR,"Wrong Format for X Coordinate");  return; }
    newdirB[1] =  (pW->ndirBy->text()).toDouble(&ok);
    if ( !ok ) { emit log(LOGERR,"Wrong Format for Y Coordinate"); return; }
    newdirB[2] =  (pW->ndirBz->text()).toDouble(&ok);
    if ( !ok ) { emit log(LOGERR,"Wrong Format for Z Coordinate"); return; }
658

659 660
    bool xAxis = false;
    bool yAxis = false;
661

662 663 664 665 666
    switch(axisA_){
	case  0: dirX = newdirA; xAxis = true; break;
	case  1: dirY = newdirA; yAxis = true; break;
	default: dirZ = newdirA; break;
    }
667

668 669 670 671 672
    switch(axisB_){
	case  0: dirX = newdirB; xAxis = true; break;
	case  1: dirY = newdirB; yAxis = true; break;
	default: dirZ = newdirB; break;
    }
673

674 675
    if (!xAxis)
	dirX = dirY % dirZ;
676

677 678
    if (!yAxis)
	dirY = dirX % dirZ;
679 680


681 682 683 684
    if ( (dirX | dirY) != 0.0){
	emit log(LOGERR,"The axes of the new direction have to be orthogonal");
	return;
    }
685

686 687 688 689
//    // Apply to All Target Objects
//     if ( pW->targetObjects->isChecked() ) {
// 	for ( PluginFunctions::ObjectIterator o_it(PluginFunctions::TARGET_OBJECTS) ;
//              o_it PluginFunctions::objectsEnd(); ++o_it){
690
//
691 692 693
// 	    o_it->manipulatorNode()->set_direction( dirX, dirY );
// 	}
//     }
694

695 696 697
    BaseObjectData* object = pW->getBaseObjectData();
    if ( object != 0 ) {
        if (  object->manipulatorNode()->visible() ){
Jan Möbius's avatar
 
Jan Möbius committed
698 699

            object->manipulatorNode()->set_direction( dirX, dirY );
700 701
	}
    } else return;
702

703 704
    updateManipulatorDialog();
    emit updateView();
Jan Möbius's avatar
 
Jan Möbius committed
705 706 707 708 709 710
}


//------------------------------------------------------------------------------

/** \brief perform a translation for Manipulator in tab
711
 *
Jan Möbius's avatar
 
Jan Möbius committed
712 713
 */
void MovePlugin::slotTranslation() {
714

715 716 717
    QPushButton* but = dynamic_cast<QPushButton*>(QObject::sender());
    movePropsWidget* pW = getDialogFromButton(but);
    if(pW == 0) return;
Jan Möbius's avatar
 
Jan Möbius committed
718

719
    ACG::Vec3d translation;
720

721 722 723 724 725 726 727
    bool ok = false;
    translation[0] =  (pW->translationX->text()).toDouble(&ok);
    if ( !ok ) { emit log(LOGERR,"Wrong Format for X Coordinate");  return; }
    translation[1] =  (pW->translationY->text()).toDouble(&ok);
    if ( !ok ) { emit log(LOGERR,"Wrong Format for Y Coordinate"); return; }
    translation[2] =  (pW->translationZ->text()).toDouble(&ok);
    if ( !ok ) { emit log(LOGERR,"Wrong Format for Z Coordinate"); return; }
728

729 730
	// Apply to All Target Objects
//     if ( pW->targetObjects->isChecked() ) {
731
//
732 733 734 735 736 737 738 739
// 	int manipcount = 0; // Check how many of the target meshes have an visible manipulator
// 	int targets = 0;        // Count the number of target meshes
// 	for ( PluginFunctions::ObjectIterator o_it(PluginFunctions::TARGET_OBJECTS) ; o_it != PluginFunctions::objectsEnd(); ++o_it)  {
// 	    ++targets;
// 	    if ( ! o_it->manipulatorNode()->hidden() ) {
// 		++ manipcount;
// 	    }
// 	}
740
//
741 742
// 	if (manipcount == 0 ) // No manipulator -> no translation
// 	    return;
743
//
744 745 746 747 748 749
// 	for ( PluginFunctions::ObjectIterator o_it(PluginFunctions::TARGET_OBJECTS,DataType( DATA_TRIANGLE_MESH | DATA_POLY_MESH )) ;
// 		o_it != PluginFunctions::objectsEnd(); ++o_it)  {
// 	    if ( manipcount > 1 ) { // Use manipulator direction for each target mesh
// 		if ( o_it->manipulatorNode()->hidden() )
// 		    continue;
// 	    }
750
//
751
// 	    translate( o_it->id() , translation );
752
//
753 754 755 756
// 	    o_it->manipulatorNode()->set_center( o_it->manipulatorNode()->center() + translation  );
// 	    emit createBackup(o_it->id(),"Translation");
// 	    emit updatedObject(o_it->id());
// 	}
757
//
758
//     }
759

760
    BaseObjectData* object = pW->getBaseObjectData();
761 762 763
	if (object != 0) {
		if (object->manipulatorNode()->visible() &&
				(object->target() || !pW->targetObjects->isChecked())) {
Jan Möbius's avatar
 
Jan Möbius committed
764

765
			translate(object->id(), translation);
766

767 768 769 770 771 772 773
			object->manipulatorNode()->set_center(
					object->manipulatorNode()->center() + translation);
			emit createBackup(object->id(), "Translation");
			emit updatedObject(object->id());
		}
	} else {
		return;
774
	}
Jan Möbius's avatar
 
Jan Möbius committed
775

776

777 778 779
    updateManipulatorDialog();
    emit scriptInfo(QString("slotTranslation()"));
    emit updateView();
Jan Möbius's avatar
 
Jan Möbius committed
780 781 782 783 784 785
}


//------------------------------------------------------------------------------

/** \brief Project the current manipulator onto the tangent plane of the object
786
 *
Jan Möbius's avatar
 
Jan Möbius committed
787 788
 */
void MovePlugin::slotProjectToTangentPlane() {
789

790 791 792 793 794 795 796 797 798 799 800
    QPushButton* but = dynamic_cast<QPushButton*>(QObject::sender());
    movePropsWidget* pW = getDialogFromButton(but);
    if(pW == 0) return;

    if ( pW->targetObjects->isChecked() ) {
	emit log(LOGWARN,"TODO Project for multiple targets");
	return;
    } else {
	emit log(LOGWARN,"TODO Project for one target");
	return;
    }
Jan Möbius's avatar
 
Jan Möbius committed
801 802 803 804 805 806 807

}


//------------------------------------------------------------------------------

/** \brief Move the current manipulator to the cog of the object
808
 *
Jan Möbius's avatar
 
Jan Möbius committed
809 810
 */
void MovePlugin::slotMoveManipToCOG() {
811

812 813 814
    QPushButton* but = dynamic_cast<QPushButton*>(QObject::sender());
    movePropsWidget* pW = getDialogFromButton(but);
    if(pW == 0) return;
815 816


817 818 819 820
//     if ( pW->targetObjects->isChecked() ) {
// 	for ( PluginFunctions::ObjectIterator o_it(PluginFunctions::TARGET_OBJECTS) ; o_it != PluginFunctions::objectsEnd(); ++o_it)  {
// 		if (  o_it->manipulatorNode()->hidden() )
// 		continue;
821
//
822 823 824 825
// 		if ( o_it->dataType( DATA_TRIANGLE_MESH ) )
// 		o_it->manipulatorNode()->set_center( MeshInfo::cog(*PluginFunctions::triMesh(*o_it) ) );
// 		else if ( o_it->dataType( DATA_POLY_MESH ) )
// 		o_it->manipulatorNode()->set_center( MeshInfo::cog(*PluginFunctions::polyMesh(*o_it)) );
826
//
827 828 829 830
// 		updateManipulatorDialog();
// 		o_it->manipulatorNode()->loadIdentity();
// 	}
//     } else {
831

832 833 834
    BaseObjectData* object = pW->getBaseObjectData();
    if ( object != 0 ) {
	if (  object->manipulatorNode()->visible() ){
835

836 837 838 839
	    if ( object->dataType( DATA_TRIANGLE_MESH ) )
	    object->manipulatorNode()->set_center( MeshInfo::cog(*PluginFunctions::triMesh(object)) );
	    else if ( object->dataType( DATA_POLY_MESH ) )
	    object->manipulatorNode()->set_center( MeshInfo::cog(*PluginFunctions::polyMesh(object)) );
Jan Möbius's avatar
 
Jan Möbius committed
840

841 842 843 844
	    updateManipulatorDialog();
	    object->manipulatorNode()->loadIdentity();
	}
    }
Jan Möbius's avatar
 
Jan Möbius committed
845

846
    emit updateView();
Jan Möbius's avatar
 
Jan Möbius committed
847 848 849 850 851 852
}


//------------------------------------------------------------------------------

/** \brief Rotate Manipulator (with values from Tab)
853
 *
Jan Möbius's avatar
 
Jan Möbius committed
854 855
 */
void MovePlugin::slotRotate() {
856

857 858 859
    QPushButton* but = dynamic_cast<QPushButton*>(QObject::sender());
    movePropsWidget* pW = getDialogFromButton(but);
    if(pW == 0) return;
860

861 862
    TriMesh::Point axis;
    double angle;
863

864 865 866 867 868 869 870
    bool ok = false;
    axis[0] =  (pW->rotx->text()).toDouble(&ok);
    if ( !ok ) { emit log(LOGERR,"Wrong Format for X Coordinate");  return; }
    axis[1] =  (pW->roty->text()).toDouble(&ok);
    if ( !ok ) { emit log(LOGERR,"Wrong Format for Y Coordinate"); return; }
    axis[2] =  (pW->rotz->text()).toDouble(&ok);
    if ( !ok ) { emit log(LOGERR,"Wrong Format for Z Coordinate"); return; }
871

872 873
    angle =  (pW->rotAngle->text()).toDouble(&ok);
    if ( !ok ) {  emit log(LOGERR,"Wrong Format for Angle"); return; }
874

875 876 877 878 879
//     if ( pW->targetObjects->isChecked() ) {
// 	for ( PluginFunctions::ObjectIterator o_it(PluginFunctions::TARGET_OBJECTS) ; o_it != PluginFunctions::objectsEnd(); ++o_it)  {
// 		if (  o_it->manipulatorNode()->hidden() )
// 		continue;
// 		o_it->manipulatorNode()->rotate(  angle,axis);
880
//
881 882
// 		if (o_it->dataType( DATA_TRIANGLE_MESH ) )
// 		transformMesh(  o_it->manipulatorNode()->matrix() , (*PluginFunctions::triMesh(*o_it)) );
883
//
884 885
// 		if (o_it->dataType( DATA_POLY_MESH ) )
// 		transformMesh(  o_it->manipulatorNode()->matrix() , (*PluginFunctions::polyMesh(*o_it)) );
886
//
887 888
// 		o_it->manipulatorNode()->loadIdentity();
// 		updateManipulatorDialog();
889
//
890 891 892 893
// 		emit createBackup(o_it->id(),"Rotation");
// 		emit updatedObject(o_it->id());
// 	}
//     } else {
894 895


896
    BaseObjectData* object = pW->getBaseObjectData();
897 898 899
	if (object != 0) {
		if (object->manipulatorNode()->visible() && (object->target()
				|| !pW->targetObjects->isChecked())) {
900

901
			object->manipulatorNode()->rotate(angle, axis);
902

903 904 905
			if (object->dataType(DATA_TRIANGLE_MESH))
				transformMesh(getLastManipulatorMatrix(true),
						(*PluginFunctions::triMesh(object)));
906

907 908 909
			if (object->dataType(DATA_POLY_MESH))
				transformMesh(getLastManipulatorMatrix(true),
						(*PluginFunctions::polyMesh(object)));
910

911
			updateManipulatorDialog();
912

913 914 915
			emit createBackup(object->id(), "Rotation");
			emit updatedObject(object->id());
		}
916
	}
917

918 919
	emit scriptInfo(QString("slotRotate()"));
	emit updateView();
Jan Möbius's avatar
 
Jan Möbius committed
920 921 922 923 924 925
}


//------------------------------------------------------------------------------

/** \brief Scale Manipulator (with values from Tab)
926
 *
Jan Möbius's avatar
 
Jan Möbius committed
927 928
 */
void MovePlugin::slotScale() {
929

930 931 932
    QPushButton* but = dynamic_cast<QPushButton*>(QObject::sender());
    movePropsWidget* pW = getDialogFromButton(but);
    if(pW == 0) return;
933 934


935
    TriMesh::Point scale;
936

937 938 939 940 941 942 943
    bool ok = false;
    scale[0] =  (pW->scalex->text()).toDouble(&ok);
    if ( !ok ) { emit log(LOGERR,"Wrong Format for factor 1");  return; }
    scale[1] =  (pW->scaley->text()).toDouble(&ok);
    if ( !ok ) { emit log(LOGERR,"Wrong Format for factor 2"); return; }
    scale[2] =  (pW->scalez->text()).toDouble(&ok);
    if ( !ok ) { emit log(LOGERR,"Wrong Format for factor 3"); return; }
944

945 946 947 948 949
//    if ( pW->targetObjects->isChecked() ) {
// 	for ( PluginFunctions::ObjectIterator o_it(PluginFunctions::TARGET_OBJECTS) ; o_it != PluginFunctions::objectsEnd(); ++o_it)  {
// 		if (  o_it->manipulatorNode()->hidden() )
// 		continue;
// 		o_it->manipulatorNode()->scale(  scale);
950
//
951 952
// 		if (o_it->dataType( DATA_TRIANGLE_MESH ) )
// 		transformMesh(  o_it->manipulatorNode()->matrix() , (*PluginFunctions::triMesh(*o_it)) );
953
//
954 955
// 		if (o_it->dataType( DATA_POLY_MESH ) )
// 		transformMesh(  o_it->manipulatorNode()->matrix() , (*PluginFunctions::polyMesh(*o_it)) );
956
//
957 958
// 		o_it->manipulatorNode()->loadIdentity();
// 		updateManipulatorDialog();
959
//
960 961 962 963
// 		emit createBackup(o_it->id(),"Scaling");
// 		emit updatedObject(o_it->id());
// 	}
//     } else {
964 965


966
    BaseObjectData* object = pW->getBaseObjectData();
967 968 969
	if (object != 0) {
		if (object->manipulatorNode()->visible() && (object->target()
				|| !pW->targetObjects->isChecked())) {
Jan Möbius's avatar
 
Jan Möbius committed
970

971
			object->manipulatorNode()->scale(scale);
972

973 974 975
			if (object->dataType(DATA_TRIANGLE_MESH))
				transformMesh(getLastManipulatorMatrix(true),
						(*PluginFunctions::triMesh(object)));
976

977 978 979
			if (object->dataType(DATA_POLY_MESH))
				transformMesh(getLastManipulatorMatrix(true),
						(*PluginFunctions::polyMesh(object)));
980

981
			updateManipulatorDialog();
982

983 984 985
			emit createBackup(object->id(), "Scaling");
			emit updatedObject(object->id());
		}
986
	}
Jan Möbius's avatar
 
Jan Möbius committed
987

988 989
    emit scriptInfo(QString("slotScale()"));
    emit updateView();
Jan Möbius's avatar
 
Jan Möbius committed
990 991 992 993 994 995 996
}


//------------------------------------------------------------------------------


/** \brief Move currently active or first Mesh with its COG to the origin
997
 *
Jan Möbius's avatar
 
Jan Möbius committed
998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037
 */
void MovePlugin::slotMoveToOrigin() {

   for ( PluginFunctions::ObjectIterator o_it(PluginFunctions::TARGET_OBJECTS) ; o_it != PluginFunctions::objectsEnd(); ++o_it)  {
      if ( o_it->dataType( DATA_TRIANGLE_MESH )) {
         TriMesh& mesh = *PluginFunctions::triMesh(*o_it);
         const TriMesh::Point cog = MeshInfo::cog(mesh);

         for ( TriMesh::VertexIter v_it = mesh.vertices_begin(); v_it != mesh.vertices_end() ; ++v_it)
            mesh.set_point(v_it , ( mesh.point(v_it) ) - cog );

         o_it->manipulatorNode()->set_center( o_it->manipulatorNode()->center() - cog );
      }

      if ( o_it->dataType( DATA_POLY_MESH )) {
         PolyMesh& mesh = *PluginFunctions::polyMesh(*o_it);
         const PolyMesh::Point cog = MeshInfo::cog(mesh);

         for ( PolyMesh::VertexIter v_it = mesh.vertices_begin(); v_it != mesh.vertices_end() ; ++v_it)
            mesh.set_point(v_it , ( mesh.point(v_it) ) - cog );

         o_it->manipulatorNode()->set_center( o_it->manipulatorNode()->center() - cog );

      }

      emit updatedObject( o_it->id() );

      updateManipulatorDialog();
      o_it->manipulatorNode()->loadIdentity();

      emit createBackup(o_it->id(),"Move to origin");
   }

   emit updateView();
}


//------------------------------------------------------------------------------

/** \brief Scale Boundingbox Diagonal to unit size
1038
 *
Jan Möbius's avatar
 
Jan Möbius committed
1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072
 */
void MovePlugin::slotUnifyBoundingBoxDiagonal()
{
   if ( tool_->targetObjects->isChecked() ) {
       for ( PluginFunctions::ObjectIterator o_it(PluginFunctions::TARGET_OBJECTS) ; o_it != PluginFunctions::objectsEnd(); ++o_it)  {
            if ( o_it->dataType( DATA_TRIANGLE_MESH ) )
              unifyBBDiag(*PluginFunctions::triMesh(*o_it));
            else if ( o_it->dataType( DATA_POLY_MESH ) )
             unifyBBDiag(*PluginFunctions::polyMesh(*o_it));

            emit updatedObject( o_it->id() );

       }
   } else {
      BaseObjectData* object;
      if ( PluginFunctions::getObject(lastActiveManipulator_ , object) ) {
         if (  object->manipulatorNode()->visible() ) {

            if ( object->dataType( DATA_TRIANGLE_MESH ) )
              unifyBBDiag(*PluginFunctions::triMesh(object));
            else if ( object->dataType( DATA_POLY_MESH ) )
             unifyBBDiag(*PluginFunctions::polyMesh(object));
         }

         emit updatedObject( object->id() );
      }
   }
   emit updateView();
}


//------------------------------------------------------------------------------

/** \brief Update the Dialog with the last clicked manipulator
1073
 *
Jan Möbius's avatar
 
Jan Möbius committed
1074 1075
 */
void MovePlugin::updateManipulatorDialog() {
1076

1077 1078 1079 1080
    BaseObjectData* object;
    if ( !PluginFunctions::getObject(lastActiveManipulator_ , object) ) {
	return;
    }
1081

1082
    if ( object->manipulatorNode()->visible() ) {
1083

1084 1085 1086
	// Get properties widget that corresponds to
        // to the last manipulated object
        movePropsWidget* pW = getDialogWidget(object);
1087

1088 1089
        // If there's no properties dialog yet...
        if(pW == 0) return;
1090

1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112
	const TriMesh::Point pos = object->manipulatorNode()->center();

	QString num;

	num = QString::number(pos[0]); pW->posx->setText(num);
	num = QString::number(pos[1]); pW->posy->setText(num);
	num = QString::number(pos[2]); pW->posz->setText(num);

	TriMesh::Point direction = object->manipulatorNode()->directionX();
	num = QString::number(direction[0]); pW->dirxx->setText(num);
	num = QString::number(direction[1]); pW->dirxy->setText(num);
	num = QString::number(direction[2]); pW->dirxz->setText(num);

	direction = object->manipulatorNode()->directionY();
	num = QString::number(direction[0]); pW->diryx->setText(num);
	num = QString::number(direction[1]); pW->diryy->setText(num);
	num = QString::number(direction[2]); pW->diryz->setText(num);

	direction = object->manipulatorNode()->directionZ();
	num = QString::number(direction[0]); pW->dirzx->setText(num);
	num = QString::number(direction[1]); pW->dirzy->setText(num);
	num = QString::number(direction[2]); pW->dirzz->setText(num);
1113

1114
    }
Jan Möbius's avatar
 
Jan Möbius committed
1115 1116
}

1117
//------------------------------------------------------------------------------
Jan Möbius's avatar
 
Jan Möbius committed
1118

1119
/** \brief Get pointer to corresponding dialog widget
1120
 *
1121 1122 1123
 * @param _obj the object to which the dialog is attached
 */
movePropsWidget* MovePlugin::getDialogWidget(BaseObjectData* _obj) {
1124

1125 1126 1127 1128 1129 1130 1131
    for(QList<movePropsWidget*>::iterator it = propsWindows_.begin();
       it != propsWindows_.end(); it++) {
	   if ((*it)->getBaseObjectData() == _obj)
	       return *it;
       }
    return 0;
}
Jan Möbius's avatar
 
Jan Möbius committed
1132 1133 1134
//------------------------------------------------------------------------------

/** \brief Called by Toolbar to enable move mode
1135
 *
Jan Möbius's avatar
 
Jan Möbius committed
1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151