Developer Documentation
MoveContextMenu.cc
1 /*===========================================================================*\
2 * *
3 * OpenFlipper *
4  * Copyright (c) 2001-2015, RWTH-Aachen University *
5  * Department of Computer Graphics and Multimedia *
6  * All rights reserved. *
7  * www.openflipper.org *
8  * *
9  *---------------------------------------------------------------------------*
10  * This file is part of OpenFlipper. *
11  *---------------------------------------------------------------------------*
12  * *
13  * Redistribution and use in source and binary forms, with or without *
14  * modification, are permitted provided that the following conditions *
15  * are met: *
16  * *
17  * 1. Redistributions of source code must retain the above copyright notice, *
18  * this list of conditions and the following disclaimer. *
19  * *
20  * 2. Redistributions in binary form must reproduce the above copyright *
21  * notice, this list of conditions and the following disclaimer in the *
22  * documentation and/or other materials provided with the distribution. *
23  * *
24  * 3. Neither the name of the copyright holder nor the names of its *
25  * contributors may be used to endorse or promote products derived from *
26  * this software without specific prior written permission. *
27  * *
28  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
29  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
30  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
31  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
32  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
33  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
34  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
35  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
36  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
37  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
38  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
39 * *
40 \*===========================================================================*/
41 
42 
43 
44 #include "MovePlugin.hh"
45 #include <ACG/QtScenegraph/QtManipulatorNode.hh>
46 
47 //***********************************************************************************
48 
50 
51  QVariant contextObject = contextActionHide_->data();
52  int nodeId = contextObject.toInt();
53 
54  if ( nodeId == -1)
55  return;
56 
57  // Get Node
59 
61  mNode = dynamic_cast<ACG::SceneGraph::QtTranslationManipulatorNode*>(node);
62 
63  if(mNode == 0) {
64  // Not a manipulator node
65  return;
66  }
67 
68  int objectId = mNode->getIdentifier();
69 
70  BaseObjectData* obj;
71  if ( ! PluginFunctions::getObject(objectId,obj) )
72  return;
73 
74  // Disconnect its signals to the plugin
75  disconnect(obj->manipulatorNode() , SIGNAL(manipulatorMoved(QtTranslationManipulatorNode*,QMouseEvent*)),
76  this , SLOT( manipulatorMoved(QtTranslationManipulatorNode*,QMouseEvent*)));
77 
78  disconnect(obj->manipulatorNode() , SIGNAL(positionChanged(QtTranslationManipulatorNode*)),
80 
81  obj->manipPlaced(false);
82  mNode->hide();
83 
84  emit nodeVisibilityChanged(obj->id());
85 
86 }
87 
89 
90  QVariant contextObject = contextAction_->data();
91  int nodeId = contextObject.toInt();
92 
93  if (nodeId == -1)
94  return;
95 
96  // Get Node
98 
100  mNode = dynamic_cast<ACG::SceneGraph::QtTranslationManipulatorNode*>(node);
101 
102  if (mNode == 0) {
103  // Not a manipulator node
104  return;
105  }
106 
107  int objectId = mNode->getIdentifier();
108 
109  BaseObjectData* obj;
110  if (!PluginFunctions::getObject(objectId, obj))
111  return;
112 
113  // Check if the widget has been created and show it.
114  movePropsWidget* pW = getDialogWidget(obj);
115  if (pW != 0) {
116  pW->show();
117  pW->raise();
118  return;
119  }
120 
121  pW = new movePropsWidget(obj->id());
122  pW->setWindowTitle(QString((mNode->name()).c_str()));
123 
124  connect(pW->posButton, SIGNAL(clicked() ), this, SLOT(slotSetPosition()));
125  connect(pW->axisAButton, SIGNAL(clicked() ), this, SLOT(slotToggleAxisA()));
126  connect(pW->axisBButton, SIGNAL(clicked() ), this, SLOT(slotToggleAxisB()));
127  connect(pW->dirButton, SIGNAL(clicked() ), this, SLOT(slotSetDirection()));
128 
129  connect(pW->transButton, SIGNAL(clicked() ), this, SLOT(slotTranslation()));
130  connect(pW->rotButton, SIGNAL(clicked() ), this, SLOT(slotRotate()));
131  connect(pW->scaleButton, SIGNAL(clicked() ), this, SLOT(slotScale()));
132 
133  connect(pW->projectTangentButton, SIGNAL(clicked() ), this, SLOT(slotProjectToTangentPlane()));
134  connect(pW->moveManipToCOG, SIGNAL(clicked() ), this, SLOT(slotMoveManipToCOG()));
135 
136  connect(pW->selectionRadioButton, SIGNAL(clicked()), this, SLOT(slotEnableSelectionMode()));
137  connect(pW->objectRadioButton, SIGNAL(clicked()), this, SLOT(slotEnableObjectMode()));
138 
139  // Values
140  BaseObjectData* object;
142  if (object->manipulatorNode()->visible()) {
143  const OpenMesh::Vec3d pos = object->manipulatorNode()->center();
144 
145  QString num;
146 
147  num = QString::number(pos[0]);
148  pW->posx->setText(num);
149  num = QString::number(pos[1]);
150  pW->posy->setText(num);
151  num = QString::number(pos[2]);
152  pW->posz->setText(num);
153 
154  OpenMesh::Vec3d direction = object->manipulatorNode()->directionX();
155  num = QString::number(direction[0]);
156  pW->dirxx->setText(num);
157  num = QString::number(direction[1]);
158  pW->dirxy->setText(num);
159  num = QString::number(direction[2]);
160  pW->dirxz->setText(num);
161 
162  direction = object->manipulatorNode()->directionY();
163  num = QString::number(direction[0]);
164  pW->diryx->setText(num);
165  num = QString::number(direction[1]);
166  pW->diryy->setText(num);
167  num = QString::number(direction[2]);
168  pW->diryz->setText(num);
169 
170  direction = object->manipulatorNode()->directionZ();
171  num = QString::number(direction[0]);
172  pW->dirzx->setText(num);
173  num = QString::number(direction[1]);
174  pW->dirzy->setText(num);
175  num = QString::number(direction[2]);
176  pW->dirzz->setText(num);
177  }
178  }
179 
181 
182  pW->show();
183  propsWindows_.append(pW);
184 }
void slotEnableSelectionMode()
stores the current axes in the tool
Definition: MovePlugin.cc:476
void slotToggleAxisB()
Toggle the second axis for changing direction in tab.
Definition: MovePlugin.cc:1127
bool visible()
Is node visible (status == Active)?
bool manipPlaced()
Check if the manipulator has been placed.
int id() const
Definition: BaseObject.cc:190
std::string name() const
Returns: name of node (needs not be unique)
void setPickModeProps(movePropsWidget *_pW, const std::string &_pickmode)
List of properties dialogs (each corresponding to one manipulator)
Definition: MovePlugin.cc:495
void slotSetPosition()
Position of manipulator in tab changed.
Definition: MovePlugin.cc:1032
void slotToggleAxisA()
Toggle the first axis for changing direction in tab.
Definition: MovePlugin.cc:1102
movePropsWidget * getDialogWidget(BaseObjectData *_obj)
Get properties dialog widget that is attached to BaseDataObject obj.
Definition: MovePlugin.cc:2099
void showProps()
Show properties of move manipulator in a dialog ( Called via context for picking. Get the picked id f...
void slotSetDirection()
Set Direction of manipulator in tab changed.
Definition: MovePlugin.cc:1152
QList< movePropsWidget * > propsWindows_
List of properties dialogs (each corresponding to one manipulator)
Definition: MovePlugin.hh:476
bool getObject(const int _identifier, BaseObject *&_object)
Get the object which has the given identifier.
void slotScale()
Scale (with values from Tab)
Definition: MovePlugin.cc:1578
void slotProjectToTangentPlane()
Project the current manipulator onto the tangent plane of the object.
Definition: MovePlugin.cc:1338
void slotEnableObjectMode()
stores the current axes in the tool
Definition: MovePlugin.cc:482
QAction * contextAction_
Context menu entry for showing per manipulator settings.
Definition: MovePlugin.hh:479
QAction * contextActionHide_
Context menu entry to hide a manipulator.
Definition: MovePlugin.hh:482
void ManipulatorPositionChanged(QtTranslationManipulatorNode *_node)
update object when its manipulator changes position
Definition: MovePlugin.cc:832
void slotTranslation()
perform a translation for Manipulator in tab
Definition: MovePlugin.cc:1233
int getIdentifier()
Get an identifier for that manipulator.
void manipulatorMoved(QtTranslationManipulatorNode *_node, QMouseEvent *_event)
move the object when its manipulator moves
Definition: MovePlugin.cc:774
void slotMoveManipToCOG()
Move the current manipulator to the cog of the object.
Definition: MovePlugin.cc:1360
BaseNode * find_node(BaseNode *_root, unsigned int _node_idx)
Find a node in the scene graph.
Definition: SceneGraph.cc:77
void hideManipulator()
Hide the manipulator( Called via context for picking. Get the picked id from the Qvariant attached to...
int lastActiveManipulator_
Stores the last manipulator which has been clicked ( used for the toolbox dialog) ...
Definition: MovePlugin.hh:406
void slotRotate()
Rotate Manipulator (with values from Tab)
Definition: MovePlugin.cc:1422
QtTranslationManipulatorNode * manipulatorNode()
ACG::SceneGraph::BaseNode * getSceneGraphRootNode()
get scenegraph root node
const std::string pickMode()
Get the current Picking mode.