Commit 26336943 authored by Jan Möbius's avatar Jan Möbius
Browse files

Move Plugin ask if common cog should be used when moving objects

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@6763 383ad7c9-94d9-4d36-a494-682f7c89f535
parent bea23351
......@@ -298,6 +298,8 @@ void MovePlugin::slotKeyEvent (QKeyEvent* _event)
setManipMode (QtTranslationManipulatorNode::LocalRotation);
}
#include <qt4/QtGui/QDialog>
#include <qt4/QtGui/qmessagebox.h>
//------------------------------------------------------------------------------
void MovePlugin::slotKeyReleaseEvent (QKeyEvent* _event)
......@@ -1068,42 +1070,75 @@ void MovePlugin::slotScale() {
//------------------------------------------------------------------------------
/** \brief Move currently active or first Mesh with its COG to the origin
/** \brief Move target Meshes cog to the origin
*
*/
void MovePlugin::slotMoveToOrigin() {
for ( PluginFunctions::ObjectIterator o_it(PluginFunctions::TARGET_OBJECTS) ; o_it != PluginFunctions::objectsEnd(); ++o_it) {
bool useCommonCOG = false;
ACG::Vec3d cog = ACG::Vec3d(0.0,0.0,0.0);
if ( PluginFunctions::targetCount() > 1 ) {
QMessageBox::StandardButton button = QMessageBox::question( 0, tr("Use common COG?"), tr("Should the targets be moved depending on their common cog?"),QMessageBox::Yes|QMessageBox::No);
useCommonCOG = ( button == QMessageBox::Yes );
double count = 0.0;
// Compute cog for all objects
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 );
cog += MeshInfo::cog(mesh);
++count;
}
if ( o_it->dataType( DATA_POLY_MESH )) {
PolyMesh& mesh = *PluginFunctions::polyMesh(*o_it);
const PolyMesh::Point cog = MeshInfo::cog(mesh);
cog += MeshInfo::cog(mesh);
++count;
}
}
cog = cog / count;
}
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 );
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);
if ( !useCommonCOG )
cog = MeshInfo::cog(mesh);
o_it->manipulatorNode()->set_center( o_it->manipulatorNode()->center() - cog );
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 );
}
emit updatedObject( o_it->id() );
if ( o_it->dataType( DATA_POLY_MESH )) {
PolyMesh& mesh = *PluginFunctions::polyMesh(*o_it);
if ( !useCommonCOG )
cog = MeshInfo::cog(mesh);
updateManipulatorDialog();
o_it->manipulatorNode()->loadIdentity();
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 );
emit createBackup(o_it->id(),"Move to origin");
}
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();
emit updateView();
}
......@@ -1114,31 +1149,17 @@ void MovePlugin::slotMoveToOrigin() {
*/
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() ) {
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));
if ( object->dataType( DATA_TRIANGLE_MESH ) )
unifyBBDiag(*PluginFunctions::triMesh(object));
else if ( object->dataType( DATA_POLY_MESH ) )
unifyBBDiag(*PluginFunctions::polyMesh(object));
}
emit updatedObject( o_it->id() );
emit updatedObject( object->id() );
}
}
emit updateView();
}
emit updateView();
}
......
......@@ -192,7 +192,7 @@ class MovePlugin : public QObject, BaseInterface, MouseInterface, KeyInterface,
/// Scale (with values from Tab)
void slotScale();
/// Move currently active or first Mesh with its COG to the origin
/// Move target Meshes cog to the origin
void slotMoveToOrigin();
/// Scale Boundingbox Diagonal to unit size
......
<ui version="4.0" >
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>moveControls</class>
<widget class="QWidget" name="moveControls" >
<property name="geometry" >
<widget class="QWidget" name="moveControls">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
......@@ -9,88 +10,78 @@
<height>169</height>
</rect>
</property>
<property name="sizePolicy" >
<sizepolicy vsizetype="Preferred" hsizetype="Fixed" >
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize" >
<property name="maximumSize">
<size>
<width>348</width>
<height>16777215</height>
</size>
</property>
<property name="windowTitle" >
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_6" >
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<widget class="QCheckBox" name="targetObjects" >
<property name="text" >
<string>Apply Transformation to Target Objects</string>
</property>
<property name="checked" >
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QTabWidget" name="tabWidget" >
<property name="enabled" >
<widget class="QTabWidget" name="tabWidget">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy" >
<sizepolicy vsizetype="Expanding" hsizetype="Preferred" >
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="currentIndex" >
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tab" >
<attribute name="title" >
<widget class="QWidget" name="tab">
<attribute name="title">
<string>Move</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_3" >
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QPushButton" name="moveToOrigin" >
<property name="toolTip" >
<widget class="QPushButton" name="moveToOrigin">
<property name="toolTip">
<string>Move COG to origin</string>
</property>
<property name="statusTip" >
<property name="statusTip">
<string>Move COG of selected objects to origin</string>
</property>
<property name="whatsThis" >
<property name="whatsThis">
<string>Moves the selected objects such that
their center of gravity is at the origin.</string>
</property>
<property name="text" >
<property name="text">
<string>Move COG to origin</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="Transform" >
<attribute name="title" >
<widget class="QWidget" name="Transform">
<attribute name="title">
<string>Transform</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_2" >
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QPushButton" name="unifyBoundingBoxDiagonal" >
<property name="toolTip" >
<widget class="QPushButton" name="unifyBoundingBoxDiagonal">
<property name="toolTip">
<string>Normalize bounding box diagonal of objects</string>
</property>
<property name="statusTip" >
<property name="statusTip">
<string>Normalize bounding box diagonal of objects</string>
</property>
<property name="whatsThis" >
<property name="whatsThis">
<string>Rescale objects such that its bounding box
diagonal has length one.</string>
</property>
<property name="text" >
<property name="text">
<string>Unify Boundingbox Diagonal</string>
</property>
</widget>
......
......@@ -118,32 +118,23 @@
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../MovePlugin.cc" line="353"/>
<location filename="../MovePlugin.cc" line="355"/>
<source>moveObject called for unsupported Object Type</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../MovePlugin.cc" line="553"/>
<location filename="../MovePlugin.cc" line="578"/>
<location filename="../MovePlugin.cc" line="555"/>
<location filename="../MovePlugin.cc" line="580"/>
<source>Picking failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../MovePlugin.cc" line="639"/>
<location filename="../MovePlugin.cc" line="722"/>
<location filename="../MovePlugin.cc" line="729"/>
<location filename="../MovePlugin.cc" line="799"/>
<location filename="../MovePlugin.cc" line="941"/>
<source>Wrong Format for X Coordinate</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../MovePlugin.cc" line="641"/>
<location filename="../MovePlugin.cc" line="724"/>
<location filename="../MovePlugin.cc" line="731"/>
<location filename="../MovePlugin.cc" line="801"/>
<location filename="../MovePlugin.cc" line="943"/>
<source>Wrong Format for Y Coordinate</source>
<source>Wrong Format for X Coordinate</source>
<translation type="unfinished"></translation>
</message>
<message>
......@@ -152,82 +143,101 @@
<location filename="../MovePlugin.cc" line="733"/>
<location filename="../MovePlugin.cc" line="803"/>
<location filename="../MovePlugin.cc" line="945"/>
<source>Wrong Format for Y Coordinate</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../MovePlugin.cc" line="645"/>
<location filename="../MovePlugin.cc" line="728"/>
<location filename="../MovePlugin.cc" line="735"/>
<location filename="../MovePlugin.cc" line="805"/>
<location filename="../MovePlugin.cc" line="947"/>
<source>Wrong Format for Z Coordinate</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../MovePlugin.cc" line="672"/>
<location filename="../MovePlugin.cc" line="697"/>
<location filename="../MovePlugin.cc" line="674"/>
<location filename="../MovePlugin.cc" line="699"/>
<source>X Direction</source>
<translation type="unfinished"></translation>
<translation type="unfinished">X Richtung</translation>
</message>
<message>
<location filename="../MovePlugin.cc" line="673"/>
<location filename="../MovePlugin.cc" line="698"/>
<location filename="../MovePlugin.cc" line="675"/>
<location filename="../MovePlugin.cc" line="700"/>
<source>Y Direction</source>
<translation type="unfinished"></translation>
<translation type="unfinished">Y Richtung</translation>
</message>
<message>
<location filename="../MovePlugin.cc" line="674"/>
<location filename="../MovePlugin.cc" line="699"/>
<location filename="../MovePlugin.cc" line="676"/>
<location filename="../MovePlugin.cc" line="701"/>
<source>Z Direction</source>
<translation type="unfinished"></translation>
<translation type="unfinished">Z Richtung</translation>
</message>
<message>
<location filename="../MovePlugin.cc" line="758"/>
<location filename="../MovePlugin.cc" line="760"/>
<source>The axes of the new direction have to be orthogonal</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../MovePlugin.cc" line="870"/>
<location filename="../MovePlugin.cc" line="872"/>
<source>TODO Project for multiple targets</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../MovePlugin.cc" line="873"/>
<location filename="../MovePlugin.cc" line="875"/>
<source>TODO Project for one target</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../MovePlugin.cc" line="948"/>
<location filename="../MovePlugin.cc" line="950"/>
<source>Wrong Format for Angle</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../MovePlugin.cc" line="1014"/>
<location filename="../MovePlugin.cc" line="1016"/>
<source>Wrong Format for factor 1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../MovePlugin.cc" line="1016"/>
<location filename="../MovePlugin.cc" line="1018"/>
<source>Wrong Format for factor 2</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../MovePlugin.cc" line="1018"/>
<location filename="../MovePlugin.cc" line="1020"/>
<source>Wrong Format for factor 3</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../MovePlugin.cc" line="1402"/>
<location filename="../MovePlugin.cc" line="1437"/>
<location filename="../MovePlugin.cc" line="1082"/>
<source>Use common COG?</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../MovePlugin.cc" line="1082"/>
<source>Should the targets be moved depending on their common cog or on their own?</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../MovePlugin.cc" line="1423"/>
<location filename="../MovePlugin.cc" line="1458"/>
<source>Enable Vertex Selection</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../MovePlugin.cc" line="1409"/>
<location filename="../MovePlugin.cc" line="1439"/>
<location filename="../MovePlugin.cc" line="1430"/>
<location filename="../MovePlugin.cc" line="1460"/>
<source>Enable Edge Selection</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../MovePlugin.cc" line="1412"/>
<location filename="../MovePlugin.cc" line="1441"/>
<location filename="../MovePlugin.cc" line="1433"/>
<location filename="../MovePlugin.cc" line="1462"/>
<source>Enable Face Selection</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../MovePlugin.cc" line="1424"/>
<location filename="../MovePlugin.cc" line="1445"/>
<source>Unable to connect to Selection-Plugin. MoveSelection will work on vertices only.</source>
<translation type="unfinished"></translation>
</message>
......@@ -437,56 +447,55 @@
<context>
<name>moveControls</name>
<message>
<location filename="../moveControls.ui" line="25"/>
<location filename="../moveControls.ui" line="26"/>
<source>Form</source>
<translation>Dialog</translation>
</message>
<message>
<location filename="../moveControls.ui" line="31"/>
<source>Apply Transformation to Target Objects</source>
<translation>Wende Transformationen auf Ziel Objekte an</translation>
<translation type="obsolete">Wende Transformationen auf Ziel Objekte an</translation>
</message>
<message>
<location filename="../moveControls.ui" line="54"/>
<location filename="../moveControls.ui" line="45"/>
<source>Move</source>
<translation>Verschieben</translation>
</message>
<message>
<location filename="../moveControls.ui" line="60"/>
<location filename="../moveControls.ui" line="70"/>
<location filename="../moveControls.ui" line="51"/>
<location filename="../moveControls.ui" line="61"/>
<source>Move COG to origin</source>
<translation>Verschiebe Schwerpunkt in Ursprung</translation>
</message>
<message>
<location filename="../moveControls.ui" line="63"/>
<location filename="../moveControls.ui" line="54"/>
<source>Move COG of selected objects to origin</source>
<translation>Verschiebe Schwerpunkt aller selektierten Objeckte in den Ursprung</translation>
</message>
<message>
<location filename="../moveControls.ui" line="66"/>
<location filename="../moveControls.ui" line="57"/>
<source>Moves the selected objects such that
their center of gravity is at the origin.</source>
<translation>Verschiebe Schwerpunkt aller selektierten Objeckte in den Ursprung.</translation>
</message>
<message>
<location filename="../moveControls.ui" line="78"/>
<location filename="../moveControls.ui" line="69"/>
<source>Transform</source>
<translation>Transformieren</translation>
</message>
<message>
<location filename="../moveControls.ui" line="84"/>
<location filename="../moveControls.ui" line="87"/>
<location filename="../moveControls.ui" line="75"/>
<location filename="../moveControls.ui" line="78"/>
<source>Normalize bounding box diagonal of objects</source>
<translation>Normalisiere Bounding Box aller Objekte</translation>
</message>
<message>
<location filename="../moveControls.ui" line="90"/>
<location filename="../moveControls.ui" line="81"/>
<source>Rescale objects such that its bounding box
diagonal has length one.</source>
<translation>Skaliere alle Objekte, so das ihre Bounding Box Diagonale die Länge 1 hat.</translation>
</message>
<message>
<location filename="../moveControls.ui" line="94"/>
<location filename="../moveControls.ui" line="85"/>
<source>Unify Boundingbox Diagonal</source>
<translation>Normalisiere Bounding Box Diagonale</translation>
</message>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment