Commit b8670736 authored by Isaak Lim's avatar Isaak Lim

- manipulatorMoved should now only be emitted for manipulator objects that were actually touched

- moveSelection should now only store backups if elements were actually selected and transformed

closes #1547

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@16758 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 0d057560
......@@ -106,7 +106,9 @@ contextActionHide_(0),
toAllTargets_(0),
hide_(true),
allTargets_(false),
placeMode_(false)
placeMode_(false),
noneSelected_(true),
transformedSelected_(false)
{
}
......@@ -575,27 +577,35 @@ void MovePlugin::moveObject(ACG::Matrix4x4d mat, int _id) {
* @param _type Type of mouse event ( release of the button creates a backup)
*/
void MovePlugin::moveSelection(ACG::Matrix4x4d _mat, int _id, QEvent::Type _type) {
// Get currently active primitive type
updateSelectionType();
// Get currently active primitive type
updateSelectionType();
if ( !_mat.is_identity() ){
noneSelected_ = true;
transformedSelected_ = false;
if (selectionType_ & VERTEX) {
transformVertexSelection( _id , _mat );
transformedSelected_ = true;
}
if (selectionType_ & FACE) {
transformFaceSelection( _id , _mat );
transformedSelected_ = true;
}
if (selectionType_ & EDGE) {
transformEdgeSelection( _id , _mat );
transformedSelected_ = true;
}
transformedSelected_ = transformedSelected_ && !noneSelected_;
emit updatedObject(_id, UPDATE_GEOMETRY);
}
//only create backups on mouseRelease
if ( _type == QEvent::MouseButtonRelease )
//only create backups on mouseRelease and something has to have been selected and transformed
if ( _type == QEvent::MouseButtonRelease && transformedSelected_ )
emit createBackup(_id,"Move Selection", UPDATE_GEOMETRY);
}
//------------------------------------------------------------------------------
......
......@@ -557,6 +557,12 @@ public slots :
bool allTargets_;
bool placeMode_;
/// stores if any elements were selected at all
bool noneSelected_;
/// stores if any selected elements where transformed
bool transformedSelected_;
};
#endif //MOVEPLUGIN_HH
......@@ -768,7 +768,6 @@ void MovePlugin::transform( int _objectId , IdList _vHandles, Matrix4x4 _matrix
* @param _matrix transformation matrix
*/
void MovePlugin::transformVertexSelection( int _objectId , Matrix4x4 _matrix ){
BaseObjectData* object;
if ( ! PluginFunctions::getObject(_objectId,object) ) {
emit log(LOGERR,tr("transform : unable to get object") );
......@@ -783,6 +782,8 @@ void MovePlugin::transformVertexSelection( int _objectId , Matrix4x4 _matrix ){
for (; v_it!=v_end; ++v_it)
if ( mesh.status(v_it).selected() )
{
if (noneSelected_)
noneSelected_ = false;
mesh.set_point (v_it, _matrix.transform_point ( mesh.point(v_it) ) );
mesh.set_normal(v_it, _matrix.transform_vector( mesh.normal(v_it) ) );
}
......@@ -795,6 +796,8 @@ void MovePlugin::transformVertexSelection( int _objectId , Matrix4x4 _matrix ){
for (; v_it!=v_end; ++v_it)
if ( mesh.status(v_it).selected() )
{
if (noneSelected_)
noneSelected_ = false;
mesh.set_point (v_it, _matrix.transform_point ( mesh.point(v_it) ) );
mesh.set_normal(v_it, _matrix.transform_vector( mesh.normal(v_it) ) );
}
......@@ -808,6 +811,8 @@ void MovePlugin::transformVertexSelection( int _objectId , Matrix4x4 _matrix ){
for (; v_it!=v_end; ++v_it)
if ( mesh.status(v_it).selected() )
{
if (noneSelected_)
noneSelected_ = false;
mesh.set_point (v_it, _matrix.transform_point ( mesh.point(v_it) ) );
mesh.set_normal(v_it, _matrix.transform_vector( mesh.normal(v_it) ) );
}
......@@ -820,8 +825,11 @@ void MovePlugin::transformVertexSelection( int _objectId , Matrix4x4 _matrix ){
PolyLine& line = (* PluginFunctions::polyLine(object) );
for ( int i = 0 ; i < (int)line.n_vertices(); ++i )
if ( line.vertex_selection(i) )
line.point(i) = _matrix.transform_point( line.point(i) );
if ( line.vertex_selection(i) ) {
if (noneSelected_)
noneSelected_ = false;
line.point(i) = _matrix.transform_point( line.point(i) );
}
}
#endif
#ifdef ENABLE_BSPLINE_CURVE_SUPPORT
......@@ -843,7 +851,7 @@ void MovePlugin::transformVertexSelection( int _objectId , Matrix4x4 _matrix ){
// Create backup if there was a change
// the backup is only created when the slot is called via scripting (sender == 0)
if ( !_matrix.is_identity() && (sender() == 0) )
if ( !_matrix.is_identity() && (sender() == 0) && !noneSelected_ )
emit createBackup(_objectId, "Transformation of Vertex Selection");
}
......@@ -856,7 +864,6 @@ void MovePlugin::transformVertexSelection( int _objectId , Matrix4x4 _matrix ){
* @param _matrix transformation matrix
*/
void MovePlugin::transformFaceSelection( int _objectId , Matrix4x4 _matrix ){
BaseObjectData* object;
if ( ! PluginFunctions::getObject(_objectId,object) ) {
emit log(LOGERR,tr("transform : unable to get object") );
......@@ -877,6 +884,8 @@ void MovePlugin::transformFaceSelection( int _objectId , Matrix4x4 _matrix ){
for (; f_it!=f_end; ++f_it)
if ( mesh.status(f_it).selected() )
{
if (noneSelected_)
noneSelected_ = false;
for(TriMesh::FVIter fv_it = mesh.fv_iter(f_it); fv_it; ++fv_it)
mesh.status(fv_it).set_tagged(true);
}
......@@ -901,6 +910,8 @@ void MovePlugin::transformFaceSelection( int _objectId , Matrix4x4 _matrix ){
for (; f_it!=f_end; ++f_it)
if ( mesh.status(f_it).selected() )
{
if (noneSelected_)
noneSelected_ = false;
for(PolyMesh::FVIter fv_it = mesh.fv_iter(f_it); fv_it; ++fv_it)
mesh.status(fv_it).set_tagged(true);
}
......@@ -926,6 +937,8 @@ void MovePlugin::transformFaceSelection( int _objectId , Matrix4x4 _matrix ){
for (; f_it!=f_end; ++f_it)
if ( mesh.status(f_it).selected() )
{
if (noneSelected_)
noneSelected_ = false;
for(TSplineMesh::FVIter fv_it = mesh.fv_iter(f_it); fv_it; ++fv_it)
mesh.status(fv_it).set_tagged(true);
}
......@@ -952,7 +965,7 @@ void MovePlugin::transformFaceSelection( int _objectId , Matrix4x4 _matrix ){
// Create backup if there was a change
// the backup is only created when the slot is called via scripting (sender == 0)
if ( !_matrix.is_identity() && (sender() == 0) )
if ( !_matrix.is_identity() && (sender() == 0) && !noneSelected_)
emit createBackup(_objectId, "Transformation of Face Selection");
}
......@@ -965,7 +978,6 @@ void MovePlugin::transformFaceSelection( int _objectId , Matrix4x4 _matrix ){
* @param _matrix transformation matrix
*/
void MovePlugin::transformEdgeSelection( int _objectId , Matrix4x4 _matrix ){
BaseObjectData* object;
if ( ! PluginFunctions::getObject(_objectId,object) ) {
emit log(LOGERR,tr("transform : unable to get object" ) );
......@@ -986,6 +998,8 @@ void MovePlugin::transformEdgeSelection( int _objectId , Matrix4x4 _matrix ){
for (; e_it!=e_end; ++e_it)
if ( mesh.status(e_it).selected() )
{
if (noneSelected_)
noneSelected_ = false;
TriMesh::HalfedgeHandle hh = mesh.halfedge_handle( e_it, 0 );
mesh.status( mesh.from_vertex_handle( hh ) ).set_tagged(true);
......@@ -1012,6 +1026,8 @@ void MovePlugin::transformEdgeSelection( int _objectId , Matrix4x4 _matrix ){
for (; e_it!=e_end; ++e_it)
if ( mesh.status(e_it).selected() )
{
if (noneSelected_)
noneSelected_ = false;
PolyMesh::HalfedgeHandle hh = mesh.halfedge_handle( e_it, 0 );
mesh.status( mesh.from_vertex_handle( hh ) ).set_tagged(true);
......@@ -1039,6 +1055,8 @@ void MovePlugin::transformEdgeSelection( int _objectId , Matrix4x4 _matrix ){
for (; e_it!=e_end; ++e_it)
if ( mesh.status(e_it).selected() )
{
if (noneSelected_)
noneSelected_ = false;
TSplineMesh::HalfedgeHandle hh = mesh.halfedge_handle( e_it, 0 );
mesh.status( mesh.from_vertex_handle( hh ) ).set_tagged(true);
......@@ -1077,7 +1095,7 @@ void MovePlugin::transformEdgeSelection( int _objectId , Matrix4x4 _matrix ){
// Create backup if there was a change
// the backup is only created when the slot is called via scripting (sender == 0)
if ( !_matrix.is_identity() && (sender() == 0) )
if ( !_matrix.is_identity() && (sender() == 0) && !noneSelected_)
emit createBackup(_objectId, "Transformation of Edge Selection");
}
......
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