Developer Documentation

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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
55 void MovePlugin::hideManipulator() {
56
57 QVariant contextObject = contextActionHide_->data();
58 int nodeId = contextObject.toInt();
59
60 if ( nodeId == -1)
61 return;
62
63 // Get Node
64 ACG::SceneGraph::BaseNode* node = ACG::SceneGraph::find_node( PluginFunctions::getSceneGraphRootNode(), nodeId );
65
66 ACG::SceneGraph::QtTranslationManipulatorNode* mNode;
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*)),
85 this , SLOT( ManipulatorPositionChanged(QtTranslationManipulatorNode*)));
86
87 obj->manipPlaced(false);
88 mNode->hide();
89
90 emit nodeVisibilityChanged(obj->id());
91
92 }
93
94 void MovePlugin::showProps(){
95
96 QVariant contextObject = contextAction_->data();
97 int nodeId = contextObject.toInt();
98
99 if (nodeId == -1)
100 return;
101
102 // Get Node
103 ACG::SceneGraph::BaseNode* node = ACG::SceneGraph::find_node(PluginFunctions::getSceneGraphRootNode(), nodeId);
104
105 ACG::SceneGraph::QtTranslationManipulatorNode* mNode;
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;
147 if (PluginFunctions::getObject(lastActiveManipulator_, 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
186 setPickModeProps(pW,PluginFunctions::pickMode());
187
188 pW->show();
189 propsWindows_.append(pW);
190 }
MovePlugin::slotSetDirection
void slotSetDirection()
Set Direction of manipulator in tab changed.
Definition: MovePlugin.cc:1150
ACG::SceneGraph::BaseNode
Definition: BaseNode.hh:135
ACG::SceneGraph::ACG::SceneGraph::BaseNode::name
std::string name() const
Returns: name of node (needs not be unique)
Definition: MeshNode2T.cc:391
BaseObjectData::manipPlaced
bool manipPlaced()
Check if the manipulator has been placed.
Definition: BaseObjectData.cc:281
MovePlugin::slotMoveManipToCOG
void slotMoveManipToCOG()
Move the current manipulator to the cog of the object.
Definition: MovePlugin.cc:1358
BaseObjectData
Definition: BaseObjectData.hh:105
ACG::SceneGraph::ACG::SceneGraph::BaseNode::visible
bool visible()
Is node visible (status == Active)?
Definition: MeshNode2T.cc:385
BaseObjectData::manipulatorNode
QtTranslationManipulatorNode * manipulatorNode()
Definition: BaseObjectData.cc:261
PluginFunctions::getObject
bool getObject(int _identifier, BSplineCurveObject *&_object)
Definition: PluginFunctionsBSplineCurve.cc:75
MovePlugin::slotTranslation
void slotTranslation()
perform a translation for Manipulator in tab
Definition: MovePlugin.cc:1231
MovePlugin::setPickModeProps
void setPickModeProps(movePropsWidget *_pW, const std::string &_pickmode)
List of properties dialogs (each corresponding to one manipulator)
Definition: MovePlugin.cc:494
PluginFunctions::getSceneGraphRootNode
ACG::SceneGraph::BaseNode * getSceneGraphRootNode()
get scenegraph root node
Definition: PluginFunctions.cc:961
MovePlugin::ManipulatorPositionChanged
void ManipulatorPositionChanged(QtTranslationManipulatorNode *_node)
update object when its manipulator changes position
Definition: MovePlugin.cc:825
MovePlugin::propsWindows_
QList< movePropsWidget * > propsWindows_
List of properties dialogs (each corresponding to one manipulator)
Definition: MovePlugin.hh:483
MovePlugin::contextActionHide_
QAction * contextActionHide_
Context menu entry to hide a manipulator.
Definition: MovePlugin.hh:489
MovePlugin::contextAction_
QAction * contextAction_
Context menu entry for showing per manipulator settings.
Definition: MovePlugin.hh:486
MovePlugin::getDialogWidget
movePropsWidget * getDialogWidget(BaseObjectData *_obj)
Get properties dialog widget that is attached to BaseDataObject obj.
Definition: MovePlugin.cc:2037
ACG::SceneGraph::QtTranslationManipulatorNode
Definition: QtTranslationManipulatorNode.hh:87
movePropsWidget
Definition: MoveProps.hh:60
PluginFunctions::pickMode
const std::string pickMode()
Get the current Picking mode.
Definition: PluginFunctions.cc:579
MovePlugin::lastActiveManipulator_
int lastActiveManipulator_
Stores the last manipulator which has been clicked ( used for the toolbox dialog) ...
Definition: MovePlugin.hh:413
OpenMesh::VectorT< double, 3 >
MovePlugin::slotEnableSelectionMode
void slotEnableSelectionMode()
stores the current axes in the tool
Definition: MovePlugin.cc:475
MovePlugin::slotScale
void slotScale()
Scale (with values from Tab)
Definition: MovePlugin.cc:1564
MovePlugin::slotToggleAxisB
void slotToggleAxisB()
Toggle the second axis for changing direction in tab.
Definition: MovePlugin.cc:1125
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:94
MovePlugin::slotSetPosition
void slotSetPosition()
Position of manipulator in tab changed.
Definition: MovePlugin.cc:1030
ACG::SceneGraph::find_node
BaseNode * find_node(BaseNode *_root, unsigned int _node_idx)
Find a node in the scene graph.
Definition: SceneGraph.cc:83
MovePlugin::slotProjectToTangentPlane
void slotProjectToTangentPlane()
Project the current manipulator onto the tangent plane of the object.
Definition: MovePlugin.cc:1336
MovePlugin::manipulatorMoved
void manipulatorMoved(QtTranslationManipulatorNode *_node, QMouseEvent *_event)
move the object when its manipulator moves
Definition: MovePlugin.cc:767
MovePlugin::slotEnableObjectMode
void slotEnableObjectMode()
stores the current axes in the tool
Definition: MovePlugin.cc:481
MovePlugin::slotRotate
void slotRotate()
Rotate Manipulator (with values from Tab)
Definition: MovePlugin.cc:1416
MovePlugin::hideManipulator
void hideManipulator()
Hide the manipulator( Called via context for picking. Get the picked id from the Qvariant attached to...
Definition: MoveContextMenu.cc:55
MovePlugin::slotToggleAxisA
void slotToggleAxisA()
Toggle the first axis for changing direction in tab.
Definition: MovePlugin.cc:1100
ACG::SceneGraph::QtTranslationManipulatorNode::getIdentifier
int getIdentifier()
Get an identifier for that manipulator.
Definition: QtTranslationManipulatorNode.hh:136
BaseObject::id
int id() const
Definition: BaseObject.cc:201