Commit 31145703 authored by Isaak Lim's avatar Isaak Lim

got rid of some unnecessary checks and member variables (Thanks to Vladimir Chalupecky)

refs #1547

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@16759 383ad7c9-94d9-4d36-a494-682f7c89f535
parent b8670736
...@@ -107,7 +107,6 @@ toAllTargets_(0), ...@@ -107,7 +107,6 @@ toAllTargets_(0),
hide_(true), hide_(true),
allTargets_(false), allTargets_(false),
placeMode_(false), placeMode_(false),
noneSelected_(true),
transformedSelected_(false) transformedSelected_(false)
{ {
...@@ -581,24 +580,16 @@ void MovePlugin::moveSelection(ACG::Matrix4x4d _mat, int _id, QEvent::Type _type ...@@ -581,24 +580,16 @@ void MovePlugin::moveSelection(ACG::Matrix4x4d _mat, int _id, QEvent::Type _type
updateSelectionType(); updateSelectionType();
if ( !_mat.is_identity() ){ if ( !_mat.is_identity() ){
noneSelected_ = true;
transformedSelected_ = false;
if (selectionType_ & VERTEX) { if (selectionType_ & VERTEX) {
transformVertexSelection( _id , _mat ); transformedSelected_ = transformVertexSelection( _id , _mat );
transformedSelected_ = true;
} }
if (selectionType_ & FACE) { if (selectionType_ & FACE) {
transformFaceSelection( _id , _mat ); transformedSelected_ = transformFaceSelection( _id , _mat );
transformedSelected_ = true;
} }
if (selectionType_ & EDGE) { if (selectionType_ & EDGE) {
transformEdgeSelection( _id , _mat ); transformedSelected_ = transformEdgeSelection( _id , _mat );
transformedSelected_ = true;
} }
transformedSelected_ = transformedSelected_ && !noneSelected_;
emit updatedObject(_id, UPDATE_GEOMETRY); emit updatedObject(_id, UPDATE_GEOMETRY);
} }
......
...@@ -481,13 +481,13 @@ public slots : ...@@ -481,13 +481,13 @@ public slots :
void transform( int _objectId , IdList _vHandles, Matrix4x4 _matrix ); void transform( int _objectId , IdList _vHandles, Matrix4x4 _matrix );
/// transform current selection of an Object by a given matrix /// transform current selection of an Object by a given matrix
void transformVertexSelection( int _objectId , Matrix4x4 _matrix ); bool transformVertexSelection( int _objectId , Matrix4x4 _matrix );
/// transform current selection of an Object by a given matrix /// transform current selection of an Object by a given matrix
void transformFaceSelection( int _objectId , Matrix4x4 _matrix ); bool transformFaceSelection( int _objectId , Matrix4x4 _matrix );
/// transform current selection of an Object by a given matrix /// transform current selection of an Object by a given matrix
void transformEdgeSelection( int _objectId , Matrix4x4 _matrix ); bool transformEdgeSelection( int _objectId , Matrix4x4 _matrix );
/// Transform handle region using the given transformation matrix /// Transform handle region using the given transformation matrix
void transformHandleRegion(int _objectId, Matrix4x4 _matrix); void transformHandleRegion(int _objectId, Matrix4x4 _matrix);
...@@ -558,9 +558,6 @@ public slots : ...@@ -558,9 +558,6 @@ public slots :
bool placeMode_; bool placeMode_;
/// stores if any elements were selected at all
bool noneSelected_;
/// stores if any selected elements where transformed /// stores if any selected elements where transformed
bool transformedSelected_; bool transformedSelected_;
}; };
......
...@@ -766,14 +766,17 @@ void MovePlugin::transform( int _objectId , IdList _vHandles, Matrix4x4 _matrix ...@@ -766,14 +766,17 @@ void MovePlugin::transform( int _objectId , IdList _vHandles, Matrix4x4 _matrix
* *
* @param _objectId id of an object * @param _objectId id of an object
* @param _matrix transformation matrix * @param _matrix transformation matrix
*
* @return returns true if selected elements were transformed
*/ */
void MovePlugin::transformVertexSelection( int _objectId , Matrix4x4 _matrix ){ bool MovePlugin::transformVertexSelection( int _objectId , Matrix4x4 _matrix ){
BaseObjectData* object; BaseObjectData* object;
if ( ! PluginFunctions::getObject(_objectId,object) ) { if ( ! PluginFunctions::getObject(_objectId,object) ) {
emit log(LOGERR,tr("transform : unable to get object") ); emit log(LOGERR,tr("transform : unable to get object") );
return; return false;
} }
bool noneSelected = true;
if ( object->dataType( DATA_TRIANGLE_MESH ) ) { if ( object->dataType( DATA_TRIANGLE_MESH ) ) {
TriMesh& mesh = (*PluginFunctions::triMesh(object)); TriMesh& mesh = (*PluginFunctions::triMesh(object));
...@@ -782,8 +785,7 @@ void MovePlugin::transformVertexSelection( int _objectId , Matrix4x4 _matrix ){ ...@@ -782,8 +785,7 @@ void MovePlugin::transformVertexSelection( int _objectId , Matrix4x4 _matrix ){
for (; v_it!=v_end; ++v_it) for (; v_it!=v_end; ++v_it)
if ( mesh.status(v_it).selected() ) if ( mesh.status(v_it).selected() )
{ {
if (noneSelected_) noneSelected = false;
noneSelected_ = false;
mesh.set_point (v_it, _matrix.transform_point ( mesh.point(v_it) ) ); mesh.set_point (v_it, _matrix.transform_point ( mesh.point(v_it) ) );
mesh.set_normal(v_it, _matrix.transform_vector( mesh.normal(v_it) ) ); mesh.set_normal(v_it, _matrix.transform_vector( mesh.normal(v_it) ) );
} }
...@@ -796,8 +798,7 @@ void MovePlugin::transformVertexSelection( int _objectId , Matrix4x4 _matrix ){ ...@@ -796,8 +798,7 @@ void MovePlugin::transformVertexSelection( int _objectId , Matrix4x4 _matrix ){
for (; v_it!=v_end; ++v_it) for (; v_it!=v_end; ++v_it)
if ( mesh.status(v_it).selected() ) if ( mesh.status(v_it).selected() )
{ {
if (noneSelected_) noneSelected = false;
noneSelected_ = false;
mesh.set_point (v_it, _matrix.transform_point ( mesh.point(v_it) ) ); mesh.set_point (v_it, _matrix.transform_point ( mesh.point(v_it) ) );
mesh.set_normal(v_it, _matrix.transform_vector( mesh.normal(v_it) ) ); mesh.set_normal(v_it, _matrix.transform_vector( mesh.normal(v_it) ) );
} }
...@@ -811,8 +812,7 @@ void MovePlugin::transformVertexSelection( int _objectId , Matrix4x4 _matrix ){ ...@@ -811,8 +812,7 @@ void MovePlugin::transformVertexSelection( int _objectId , Matrix4x4 _matrix ){
for (; v_it!=v_end; ++v_it) for (; v_it!=v_end; ++v_it)
if ( mesh.status(v_it).selected() ) if ( mesh.status(v_it).selected() )
{ {
if (noneSelected_) noneSelected = false;
noneSelected_ = false;
mesh.set_point (v_it, _matrix.transform_point ( mesh.point(v_it) ) ); mesh.set_point (v_it, _matrix.transform_point ( mesh.point(v_it) ) );
mesh.set_normal(v_it, _matrix.transform_vector( mesh.normal(v_it) ) ); mesh.set_normal(v_it, _matrix.transform_vector( mesh.normal(v_it) ) );
} }
...@@ -826,8 +826,7 @@ void MovePlugin::transformVertexSelection( int _objectId , Matrix4x4 _matrix ){ ...@@ -826,8 +826,7 @@ void MovePlugin::transformVertexSelection( int _objectId , Matrix4x4 _matrix ){
for ( int i = 0 ; i < (int)line.n_vertices(); ++i ) for ( int i = 0 ; i < (int)line.n_vertices(); ++i )
if ( line.vertex_selection(i) ) { if ( line.vertex_selection(i) ) {
if (noneSelected_) noneSelected = false;
noneSelected_ = false;
line.point(i) = _matrix.transform_point( line.point(i) ); line.point(i) = _matrix.transform_point( line.point(i) );
} }
} }
...@@ -838,6 +837,9 @@ void MovePlugin::transformVertexSelection( int _objectId , Matrix4x4 _matrix ){ ...@@ -838,6 +837,9 @@ void MovePlugin::transformVertexSelection( int _objectId , Matrix4x4 _matrix ){
} }
#endif #endif
if (noneSelected)
return false;
emit updatedObject(_objectId, UPDATE_GEOMETRY); emit updatedObject(_objectId, UPDATE_GEOMETRY);
QString matString; QString matString;
...@@ -851,8 +853,10 @@ void MovePlugin::transformVertexSelection( int _objectId , Matrix4x4 _matrix ){ ...@@ -851,8 +853,10 @@ void MovePlugin::transformVertexSelection( int _objectId , Matrix4x4 _matrix ){
// Create backup if there was a change // Create backup if there was a change
// the backup is only created when the slot is called via scripting (sender == 0) // the backup is only created when the slot is called via scripting (sender == 0)
if ( !_matrix.is_identity() && (sender() == 0) && !noneSelected_ ) if ( !_matrix.is_identity() && (sender() == 0) )
emit createBackup(_objectId, "Transformation of Vertex Selection"); emit createBackup(_objectId, "Transformation of Vertex Selection");
return true;
} }
...@@ -862,14 +866,17 @@ void MovePlugin::transformVertexSelection( int _objectId , Matrix4x4 _matrix ){ ...@@ -862,14 +866,17 @@ void MovePlugin::transformVertexSelection( int _objectId , Matrix4x4 _matrix ){
* *
* @param _objectId id of an object * @param _objectId id of an object
* @param _matrix transformation matrix * @param _matrix transformation matrix
*
* @return returns true if selected elements were transformed
*/ */
void MovePlugin::transformFaceSelection( int _objectId , Matrix4x4 _matrix ){ bool MovePlugin::transformFaceSelection( int _objectId , Matrix4x4 _matrix ){
BaseObjectData* object; BaseObjectData* object;
if ( ! PluginFunctions::getObject(_objectId,object) ) { if ( ! PluginFunctions::getObject(_objectId,object) ) {
emit log(LOGERR,tr("transform : unable to get object") ); emit log(LOGERR,tr("transform : unable to get object") );
return; return false;
} }
bool noneSelected = true;
if ( object->dataType( DATA_TRIANGLE_MESH ) ) { if ( object->dataType( DATA_TRIANGLE_MESH ) ) {
TriMesh& mesh = (*PluginFunctions::triMesh(object)); TriMesh& mesh = (*PluginFunctions::triMesh(object));
...@@ -884,8 +891,7 @@ void MovePlugin::transformFaceSelection( int _objectId , Matrix4x4 _matrix ){ ...@@ -884,8 +891,7 @@ void MovePlugin::transformFaceSelection( int _objectId , Matrix4x4 _matrix ){
for (; f_it!=f_end; ++f_it) for (; f_it!=f_end; ++f_it)
if ( mesh.status(f_it).selected() ) if ( mesh.status(f_it).selected() )
{ {
if (noneSelected_) noneSelected = false;
noneSelected_ = false;
for(TriMesh::FVIter fv_it = mesh.fv_iter(f_it); fv_it; ++fv_it) for(TriMesh::FVIter fv_it = mesh.fv_iter(f_it); fv_it; ++fv_it)
mesh.status(fv_it).set_tagged(true); mesh.status(fv_it).set_tagged(true);
} }
...@@ -910,8 +916,7 @@ void MovePlugin::transformFaceSelection( int _objectId , Matrix4x4 _matrix ){ ...@@ -910,8 +916,7 @@ void MovePlugin::transformFaceSelection( int _objectId , Matrix4x4 _matrix ){
for (; f_it!=f_end; ++f_it) for (; f_it!=f_end; ++f_it)
if ( mesh.status(f_it).selected() ) if ( mesh.status(f_it).selected() )
{ {
if (noneSelected_) noneSelected = false;
noneSelected_ = false;
for(PolyMesh::FVIter fv_it = mesh.fv_iter(f_it); fv_it; ++fv_it) for(PolyMesh::FVIter fv_it = mesh.fv_iter(f_it); fv_it; ++fv_it)
mesh.status(fv_it).set_tagged(true); mesh.status(fv_it).set_tagged(true);
} }
...@@ -937,8 +942,7 @@ void MovePlugin::transformFaceSelection( int _objectId , Matrix4x4 _matrix ){ ...@@ -937,8 +942,7 @@ void MovePlugin::transformFaceSelection( int _objectId , Matrix4x4 _matrix ){
for (; f_it!=f_end; ++f_it) for (; f_it!=f_end; ++f_it)
if ( mesh.status(f_it).selected() ) if ( mesh.status(f_it).selected() )
{ {
if (noneSelected_) noneSelected = false;
noneSelected_ = false;
for(TSplineMesh::FVIter fv_it = mesh.fv_iter(f_it); fv_it; ++fv_it) for(TSplineMesh::FVIter fv_it = mesh.fv_iter(f_it); fv_it; ++fv_it)
mesh.status(fv_it).set_tagged(true); mesh.status(fv_it).set_tagged(true);
} }
...@@ -951,6 +955,8 @@ void MovePlugin::transformFaceSelection( int _objectId , Matrix4x4 _matrix ){ ...@@ -951,6 +955,8 @@ void MovePlugin::transformFaceSelection( int _objectId , Matrix4x4 _matrix ){
} }
#endif #endif
if (noneSelected)
return false;
emit updatedObject(_objectId, UPDATE_GEOMETRY); emit updatedObject(_objectId, UPDATE_GEOMETRY);
...@@ -965,8 +971,10 @@ void MovePlugin::transformFaceSelection( int _objectId , Matrix4x4 _matrix ){ ...@@ -965,8 +971,10 @@ void MovePlugin::transformFaceSelection( int _objectId , Matrix4x4 _matrix ){
// Create backup if there was a change // Create backup if there was a change
// the backup is only created when the slot is called via scripting (sender == 0) // the backup is only created when the slot is called via scripting (sender == 0)
if ( !_matrix.is_identity() && (sender() == 0) && !noneSelected_) if ( !_matrix.is_identity() && (sender() == 0) )
emit createBackup(_objectId, "Transformation of Face Selection"); emit createBackup(_objectId, "Transformation of Face Selection");
return true;
} }
...@@ -976,14 +984,17 @@ void MovePlugin::transformFaceSelection( int _objectId , Matrix4x4 _matrix ){ ...@@ -976,14 +984,17 @@ void MovePlugin::transformFaceSelection( int _objectId , Matrix4x4 _matrix ){
* *
* @param _objectId id of an object * @param _objectId id of an object
* @param _matrix transformation matrix * @param _matrix transformation matrix
*
* @return returns true if selected elements were transformed
*/ */
void MovePlugin::transformEdgeSelection( int _objectId , Matrix4x4 _matrix ){ bool MovePlugin::transformEdgeSelection( int _objectId , Matrix4x4 _matrix ){
BaseObjectData* object; BaseObjectData* object;
if ( ! PluginFunctions::getObject(_objectId,object) ) { if ( ! PluginFunctions::getObject(_objectId,object) ) {
emit log(LOGERR,tr("transform : unable to get object" ) ); emit log(LOGERR,tr("transform : unable to get object" ) );
return; return false;
} }
bool noneSelected = true;
if ( object->dataType( DATA_TRIANGLE_MESH ) ) { if ( object->dataType( DATA_TRIANGLE_MESH ) ) {
TriMesh& mesh = (*PluginFunctions::triMesh(object)); TriMesh& mesh = (*PluginFunctions::triMesh(object));
...@@ -998,8 +1009,7 @@ void MovePlugin::transformEdgeSelection( int _objectId , Matrix4x4 _matrix ){ ...@@ -998,8 +1009,7 @@ void MovePlugin::transformEdgeSelection( int _objectId , Matrix4x4 _matrix ){
for (; e_it!=e_end; ++e_it) for (; e_it!=e_end; ++e_it)
if ( mesh.status(e_it).selected() ) if ( mesh.status(e_it).selected() )
{ {
if (noneSelected_) noneSelected = false;
noneSelected_ = false;
TriMesh::HalfedgeHandle hh = mesh.halfedge_handle( e_it, 0 ); TriMesh::HalfedgeHandle hh = mesh.halfedge_handle( e_it, 0 );
mesh.status( mesh.from_vertex_handle( hh ) ).set_tagged(true); mesh.status( mesh.from_vertex_handle( hh ) ).set_tagged(true);
...@@ -1026,8 +1036,7 @@ void MovePlugin::transformEdgeSelection( int _objectId , Matrix4x4 _matrix ){ ...@@ -1026,8 +1036,7 @@ void MovePlugin::transformEdgeSelection( int _objectId , Matrix4x4 _matrix ){
for (; e_it!=e_end; ++e_it) for (; e_it!=e_end; ++e_it)
if ( mesh.status(e_it).selected() ) if ( mesh.status(e_it).selected() )
{ {
if (noneSelected_) noneSelected = false;
noneSelected_ = false;
PolyMesh::HalfedgeHandle hh = mesh.halfedge_handle( e_it, 0 ); PolyMesh::HalfedgeHandle hh = mesh.halfedge_handle( e_it, 0 );
mesh.status( mesh.from_vertex_handle( hh ) ).set_tagged(true); mesh.status( mesh.from_vertex_handle( hh ) ).set_tagged(true);
...@@ -1055,8 +1064,7 @@ void MovePlugin::transformEdgeSelection( int _objectId , Matrix4x4 _matrix ){ ...@@ -1055,8 +1064,7 @@ void MovePlugin::transformEdgeSelection( int _objectId , Matrix4x4 _matrix ){
for (; e_it!=e_end; ++e_it) for (; e_it!=e_end; ++e_it)
if ( mesh.status(e_it).selected() ) if ( mesh.status(e_it).selected() )
{ {
if (noneSelected_) noneSelected = false;
noneSelected_ = false;
TSplineMesh::HalfedgeHandle hh = mesh.halfedge_handle( e_it, 0 ); TSplineMesh::HalfedgeHandle hh = mesh.halfedge_handle( e_it, 0 );
mesh.status( mesh.from_vertex_handle( hh ) ).set_tagged(true); mesh.status( mesh.from_vertex_handle( hh ) ).set_tagged(true);
...@@ -1082,6 +1090,9 @@ void MovePlugin::transformEdgeSelection( int _objectId , Matrix4x4 _matrix ){ ...@@ -1082,6 +1090,9 @@ void MovePlugin::transformEdgeSelection( int _objectId , Matrix4x4 _matrix ){
} }
#endif #endif
if (noneSelected)
return false;
emit updatedObject(_objectId, UPDATE_GEOMETRY); emit updatedObject(_objectId, UPDATE_GEOMETRY);
QString matString; QString matString;
...@@ -1095,8 +1106,10 @@ void MovePlugin::transformEdgeSelection( int _objectId , Matrix4x4 _matrix ){ ...@@ -1095,8 +1106,10 @@ void MovePlugin::transformEdgeSelection( int _objectId , Matrix4x4 _matrix ){
// Create backup if there was a change // Create backup if there was a change
// the backup is only created when the slot is called via scripting (sender == 0) // the backup is only created when the slot is called via scripting (sender == 0)
if ( !_matrix.is_identity() && (sender() == 0) && !noneSelected_) if ( !_matrix.is_identity() && (sender() == 0) )
emit createBackup(_objectId, "Transformation of Edge Selection"); emit createBackup(_objectId, "Transformation of Edge Selection");
return true;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
......
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