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
49 void MovePlugin::hideManipulator() {
50
51 QVariant contextObject = contextActionHide_->data();
52 int nodeId = contextObject.toInt();
53
54 if ( nodeId == -1)
55 return;
56
57 // Get Node
58 ACG::SceneGraph::BaseNode* node = ACG::SceneGraph::find_node( PluginFunctions::getSceneGraphRootNode(), nodeId );
59
60 ACG::SceneGraph::QtTranslationManipulatorNode* mNode;
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*)),
79 this , SLOT( ManipulatorPositionChanged(QtTranslationManipulatorNode*)));
80
81 obj->manipPlaced(false);
82 mNode->hide();
83
84 emit nodeVisibilityChanged(obj->id());
85
86 }
87
88 void MovePlugin::showProps(){
89
90 QVariant contextObject = contextAction_->data();
91 int nodeId = contextObject.toInt();
92
93 if (nodeId == -1)
94 return;
95
96 // Get Node
97 ACG::SceneGraph::BaseNode* node = ACG::SceneGraph::find_node(PluginFunctions::getSceneGraphRootNode(), nodeId);
98
99 ACG::SceneGraph::QtTranslationManipulatorNode* mNode;
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;
141 if (PluginFunctions::getObject(lastActiveManipulator_, 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
180 setPickModeProps(pW,PluginFunctions::pickMode());
181
182 pW->show();
183 propsWindows_.append(pW);
184 }
MovePlugin::slotEnableSelectionMode
void slotEnableSelectionMode()
stores the current axes in the tool
Definition: MovePlugin.cc:476
MovePlugin::slotToggleAxisB
void slotToggleAxisB()
Toggle the second axis for changing direction in tab.
Definition: MovePlugin.cc:1127
ACG::SceneGraph::ACG::SceneGraph::BaseNode::visible
bool visible()
Is node visible (status == Active)?
Definition: MeshNode2T_impl.hh:409
BaseObjectData::manipPlaced
bool manipPlaced()
Check if the manipulator has been placed.
Definition: BaseObjectData.cc:279
BaseObject::id
int id() const
Definition: BaseObject.cc:190
ACG::SceneGraph::ACG::SceneGraph::BaseNode::name
std::string name() const
Returns: name of node (needs not be unique)
Definition: MeshNode2T_impl.hh:415
MovePlugin::setPickModeProps
void setPickModeProps(movePropsWidget *_pW, const std::string &_pickmode)
List of properties dialogs (each corresponding to one manipulator)
Definition: MovePlugin.cc:495
MovePlugin::slotSetPosition
void slotSetPosition()
Position of manipulator in tab changed.
Definition: MovePlugin.cc:1032
MovePlugin::slotToggleAxisA
void slotToggleAxisA()
Toggle the first axis for changing direction in tab.
Definition: MovePlugin.cc:1102
MovePlugin::getDialogWidget
movePropsWidget * getDialogWidget(BaseObjectData *_obj)
Get properties dialog widget that is attached to BaseDataObject obj.
Definition: MovePlugin.cc:2099
MovePlugin::showProps
void showProps()
Show properties of move manipulator in a dialog ( Called via context for picking. Get the picked id f...
Definition: MoveContextMenu.cc:88
MovePlugin::slotSetDirection
void slotSetDirection()
Set Direction of manipulator in tab changed.
Definition: MovePlugin.cc:1152
movePropsWidget
Definition: MoveProps.hh:48
MovePlugin::propsWindows_
QList< movePropsWidget * > propsWindows_
List of properties dialogs (each corresponding to one manipulator)
Definition: MovePlugin.hh:476
PluginFunctions::getObject
bool getObject(const int _identifier, BaseObject *&_object)
Get the object which has the given identifier.
Definition: PluginFunctions.cc:294
MovePlugin::slotScale
void slotScale()
Scale (with values from Tab)
Definition: MovePlugin.cc:1578
MovePlugin::slotProjectToTangentPlane
void slotProjectToTangentPlane()
Project the current manipulator onto the tangent plane of the object.
Definition: MovePlugin.cc:1338
MovePlugin::slotEnableObjectMode
void slotEnableObjectMode()
stores the current axes in the tool
Definition: MovePlugin.cc:482
MovePlugin::contextAction_
QAction * contextAction_
Context menu entry for showing per manipulator settings.
Definition: MovePlugin.hh:479
MovePlugin::contextActionHide_
QAction * contextActionHide_
Context menu entry to hide a manipulator.
Definition: MovePlugin.hh:482
MovePlugin::ManipulatorPositionChanged
void ManipulatorPositionChanged(QtTranslationManipulatorNode *_node)
update object when its manipulator changes position
Definition: MovePlugin.cc:832
MovePlugin::slotTranslation
void slotTranslation()
perform a translation for Manipulator in tab
Definition: MovePlugin.cc:1233
ACG::SceneGraph::QtTranslationManipulatorNode
Definition: QtTranslationManipulatorNode.hh:81
ACG::SceneGraph::QtTranslationManipulatorNode::getIdentifier
int getIdentifier()
Get an identifier for that manipulator.
Definition: QtTranslationManipulatorNode.hh:130
MovePlugin::manipulatorMoved
void manipulatorMoved(QtTranslationManipulatorNode *_node, QMouseEvent *_event)
move the object when its manipulator moves
Definition: MovePlugin.cc:774
MovePlugin::slotMoveManipToCOG
void slotMoveManipToCOG()
Move the current manipulator to the cog of the object.
Definition: MovePlugin.cc:1360
ACG::SceneGraph::BaseNode
Definition: BaseNode.hh:104
OpenMesh::VectorT< double, 3 >
ACG::SceneGraph::find_node
BaseNode * find_node(BaseNode *_root, unsigned int _node_idx)
Find a node in the scene graph.
Definition: SceneGraph.cc:77
MovePlugin::hideManipulator
void hideManipulator()
Hide the manipulator( Called via context for picking. Get the picked id from the Qvariant attached to...
Definition: MoveContextMenu.cc:49
BaseObjectData
Definition: BaseObjectData.hh:102
MovePlugin::lastActiveManipulator_
int lastActiveManipulator_
Stores the last manipulator which has been clicked ( used for the toolbox dialog) ...
Definition: MovePlugin.hh:406
MovePlugin::slotRotate
void slotRotate()
Rotate Manipulator (with values from Tab)
Definition: MovePlugin.cc:1422
BaseObjectData::manipulatorNode
QtTranslationManipulatorNode * manipulatorNode()
Definition: BaseObjectData.cc:255
PluginFunctions::getSceneGraphRootNode
ACG::SceneGraph::BaseNode * getSceneGraphRootNode()
get scenegraph root node
Definition: PluginFunctions.cc:957
PluginFunctions::pickMode
const std::string pickMode()
Get the current Picking mode.
Definition: PluginFunctions.cc:575