Developer Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 * $Revision$ *
45 * $LastChangedBy$ *
46 * $Date$ *
47 * *
48 \*===========================================================================*/
49 
50 #include "MovePlugin.hh"
51 #include <ACG/QtScenegraph/QtManipulatorNode.hh>
52 
53 //***********************************************************************************
54 
56 
57  QVariant contextObject = contextActionHide_->data();
58  int nodeId = contextObject.toInt();
59 
60  if ( nodeId == -1)
61  return;
62 
63  // Get Node
65 
67  mNode = dynamic_cast<ACG::SceneGraph::QtTranslationManipulatorNode*>(node);
68 
69  if(mNode == 0) {
70  // Not a manipulator node
71  return;
72  }
73 
74  int objectId = mNode->getIdentifier();
75 
76  BaseObjectData* obj;
77  if ( ! PluginFunctions::getObject(objectId,obj) )
78  return;
79 
80  // Disconnect its signals to the plugin
81  disconnect(obj->manipulatorNode() , SIGNAL(manipulatorMoved(QtTranslationManipulatorNode*,QMouseEvent*)),
82  this , SLOT( manipulatorMoved(QtTranslationManipulatorNode*,QMouseEvent*)));
83 
84  disconnect(obj->manipulatorNode() , SIGNAL(positionChanged(QtTranslationManipulatorNode*)),
86 
87  obj->manipPlaced(false);
88  mNode->hide();
89 
90  emit nodeVisibilityChanged(obj->id());
91 
92 }
93 
95 
96  QVariant contextObject = contextAction_->data();
97  int nodeId = contextObject.toInt();
98 
99  if (nodeId == -1)
100  return;
101 
102  // Get Node
104 
106  mNode = dynamic_cast<ACG::SceneGraph::QtTranslationManipulatorNode*>(node);
107 
108  if (mNode == 0) {
109  // Not a manipulator node
110  return;
111  }
112 
113  int objectId = mNode->getIdentifier();
114 
115  BaseObjectData* obj;
116  if (!PluginFunctions::getObject(objectId, obj))
117  return;
118 
119  // Check if the widget has been created and show it.
120  movePropsWidget* pW = getDialogWidget(obj);
121  if (pW != 0) {
122  pW->show();
123  pW->raise();
124  return;
125  }
126 
127  pW = new movePropsWidget(obj->id());
128  pW->setWindowTitle(QString((mNode->name()).c_str()));
129 
130  connect(pW->posButton, SIGNAL(clicked() ), this, SLOT(slotSetPosition()));
131  connect(pW->axisAButton, SIGNAL(clicked() ), this, SLOT(slotToggleAxisA()));
132  connect(pW->axisBButton, SIGNAL(clicked() ), this, SLOT(slotToggleAxisB()));
133  connect(pW->dirButton, SIGNAL(clicked() ), this, SLOT(slotSetDirection()));
134 
135  connect(pW->transButton, SIGNAL(clicked() ), this, SLOT(slotTranslation()));
136  connect(pW->rotButton, SIGNAL(clicked() ), this, SLOT(slotRotate()));
137  connect(pW->scaleButton, SIGNAL(clicked() ), this, SLOT(slotScale()));
138 
139  connect(pW->projectTangentButton, SIGNAL(clicked() ), this, SLOT(slotProjectToTangentPlane()));
140  connect(pW->moveManipToCOG, SIGNAL(clicked() ), this, SLOT(slotMoveManipToCOG()));
141 
142  connect(pW->selectionRadioButton, SIGNAL(clicked()), this, SLOT(slotEnableSelectionMode()));
143  connect(pW->objectRadioButton, SIGNAL(clicked()), this, SLOT(slotEnableObjectMode()));
144 
145  // Values
146  BaseObjectData* object;
148  if (object->manipulatorNode()->visible()) {
149  const OpenMesh::Vec3d pos = object->manipulatorNode()->center();
150 
151  QString num;
152 
153  num = QString::number(pos[0]);
154  pW->posx->setText(num);
155  num = QString::number(pos[1]);
156  pW->posy->setText(num);
157  num = QString::number(pos[2]);
158  pW->posz->setText(num);
159 
160  OpenMesh::Vec3d direction = object->manipulatorNode()->directionX();
161  num = QString::number(direction[0]);
162  pW->dirxx->setText(num);
163  num = QString::number(direction[1]);
164  pW->dirxy->setText(num);
165  num = QString::number(direction[2]);
166  pW->dirxz->setText(num);
167 
168  direction = object->manipulatorNode()->directionY();
169  num = QString::number(direction[0]);
170  pW->diryx->setText(num);
171  num = QString::number(direction[1]);
172  pW->diryy->setText(num);
173  num = QString::number(direction[2]);
174  pW->diryz->setText(num);
175 
176  direction = object->manipulatorNode()->directionZ();
177  num = QString::number(direction[0]);
178  pW->dirzx->setText(num);
179  num = QString::number(direction[1]);
180  pW->dirzy->setText(num);
181  num = QString::number(direction[2]);
182  pW->dirzz->setText(num);
183  }
184  }
185 
187 
188  pW->show();
189  propsWindows_.append(pW);
190 }
void slotSetDirection()
Set Direction of manipulator in tab changed.
Definition: MovePlugin.cc:1150
std::string name() const
Returns: name of node (needs not be unique)
Definition: MeshNode2T.cc:391
bool manipPlaced()
Check if the manipulator has been placed.
void slotMoveManipToCOG()
Move the current manipulator to the cog of the object.
Definition: MovePlugin.cc:1358
bool visible()
Is node visible (status == Active)?
Definition: MeshNode2T.cc:385
QtTranslationManipulatorNode * manipulatorNode()
bool getObject(int _identifier, BSplineCurveObject *&_object)
void slotTranslation()
perform a translation for Manipulator in tab
Definition: MovePlugin.cc:1231
void setPickModeProps(movePropsWidget *_pW, const std::string &_pickmode)
List of properties dialogs (each corresponding to one manipulator)
Definition: MovePlugin.cc:494
ACG::SceneGraph::BaseNode * getSceneGraphRootNode()
get scenegraph root node
void ManipulatorPositionChanged(QtTranslationManipulatorNode *_node)
update object when its manipulator changes position
Definition: MovePlugin.cc:825
QList< movePropsWidget * > propsWindows_
List of properties dialogs (each corresponding to one manipulator)
Definition: MovePlugin.hh:483
QAction * contextActionHide_
Context menu entry to hide a manipulator.
Definition: MovePlugin.hh:489
QAction * contextAction_
Context menu entry for showing per manipulator settings.
Definition: MovePlugin.hh:486
movePropsWidget * getDialogWidget(BaseObjectData *_obj)
Get properties dialog widget that is attached to BaseDataObject obj.
Definition: MovePlugin.cc:2037
const std::string pickMode()
Get the current Picking mode.
int lastActiveManipulator_
Stores the last manipulator which has been clicked ( used for the toolbox dialog) ...
Definition: MovePlugin.hh:413
void slotEnableSelectionMode()
stores the current axes in the tool
Definition: MovePlugin.cc:475
void slotScale()
Scale (with values from Tab)
Definition: MovePlugin.cc:1564
void slotToggleAxisB()
Toggle the second axis for changing direction in tab.
Definition: MovePlugin.cc:1125
void showProps()
Show properties of move manipulator in a dialog ( Called via context for picking. Get the picked id f...
void slotSetPosition()
Position of manipulator in tab changed.
Definition: MovePlugin.cc:1030
BaseNode * find_node(BaseNode *_root, unsigned int _node_idx)
Find a node in the scene graph.
Definition: SceneGraph.cc:83
void slotProjectToTangentPlane()
Project the current manipulator onto the tangent plane of the object.
Definition: MovePlugin.cc:1336
void manipulatorMoved(QtTranslationManipulatorNode *_node, QMouseEvent *_event)
move the object when its manipulator moves
Definition: MovePlugin.cc:767
void slotEnableObjectMode()
stores the current axes in the tool
Definition: MovePlugin.cc:481
void slotRotate()
Rotate Manipulator (with values from Tab)
Definition: MovePlugin.cc:1416
void hideManipulator()
Hide the manipulator( Called via context for picking. Get the picked id from the Qvariant attached to...
void slotToggleAxisA()
Toggle the first axis for changing direction in tab.
Definition: MovePlugin.cc:1100
int getIdentifier()
Get an identifier for that manipulator.
int id() const
Definition: BaseObject.cc:201