Commit 0146b28a 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 396f2709
......@@ -77,7 +77,10 @@ void
QtManipulatorNode::mouseEvent(GLState& _state, QMouseEvent* _event)
{
ManipulatorNode::mouseEvent( _state, _event );
emit manipulatorMoved( this , _event);
if (touched())
emit manipulatorMoved( this , _event);
reset_touched();
}
QtManipulatorNode::~QtManipulatorNode() {
......
......@@ -78,7 +78,10 @@ void
QtTranslationManipulatorNode::mouseEvent(GLState& _state, QMouseEvent* _event)
{
TranslationManipulatorNode::mouseEvent( _state, _event );
emit manipulatorMoved( this , _event);
if (touched_)
emit manipulatorMoved( this , _event);
touched_ = false;
}
QtTranslationManipulatorNode::~QtTranslationManipulatorNode() {
......
......@@ -130,6 +130,7 @@ TranslationManipulatorNode::Element::Element () :
TranslationManipulatorNode::
TranslationManipulatorNode( BaseNode* _parent, const std::string& _name )
: TransformNode(_parent, _name),
touched_(false),
draw_manipulator_(false),
dirX_(1.0,0.0,0.0),
dirY_(0.0,1.0,0.0),
......@@ -1021,6 +1022,11 @@ TranslationManipulatorNode::mouseEvent(GLState& _state, QMouseEvent* _event)
oldPoint2D_ = newPoint2D;
currentScale_ = Vec3d(1.0, 1.0, 1.0);
ignoreTime_ = true;
touched_ = element_[Origin].clicked_
|| any_top_clicked_
|| any_axis_clicked_
|| outer_ring_clicked_;
break;
}
......@@ -1028,8 +1034,16 @@ TranslationManipulatorNode::mouseEvent(GLState& _state, QMouseEvent* _event)
case QEvent::MouseButtonRelease: {
for (i = 0; i < NumElements; i++) {
if (element_[i].clicked_)
touched_ = true;
element_[i].clicked_ = false;
}
touched_ = touched_
|| any_top_clicked_
|| any_axis_clicked_
|| outer_ring_clicked_;
any_axis_clicked_ = false;
any_top_clicked_ = false;
outer_ring_clicked_ = false;
......@@ -1045,8 +1059,10 @@ TranslationManipulatorNode::mouseEvent(GLState& _state, QMouseEvent* _event)
// All real manipulation is done here
case QEvent::MouseMove: {
if (!draw_manipulator_)
if (!draw_manipulator_) {
touched_ = false;
return; // Avoid manipulation if manipulator is invisible
}
// Get pressed modifiers
Qt::KeyboardModifiers mods = Qt::ShiftModifier | Qt::ControlModifier;
......@@ -1177,6 +1193,8 @@ TranslationManipulatorNode::mouseEvent(GLState& _state, QMouseEvent* _event)
scale(currentScale_);
}
touched_ = true;
}
// x axis clicked apply translation along axis
......@@ -1247,6 +1265,8 @@ TranslationManipulatorNode::mouseEvent(GLState& _state, QMouseEvent* _event)
} else
//translation
translate(ntrans);
touched_ = true;
}
// y axis clicked change translation along axis
......@@ -1318,6 +1338,8 @@ TranslationManipulatorNode::mouseEvent(GLState& _state, QMouseEvent* _event)
} else
//translation
translate(ntrans);
touched_ = true;
}
// z axis clicked change translation along axis
......@@ -1389,6 +1411,8 @@ TranslationManipulatorNode::mouseEvent(GLState& _state, QMouseEvent* _event)
} else
//translation
translate(ntrans);
touched_ = true;
}
// x top clicked: rotate around x axis
......@@ -1435,6 +1459,7 @@ TranslationManipulatorNode::mouseEvent(GLState& _state, QMouseEvent* _event)
_state.pop_modelview_matrix();
}
touched_ = true;
}
// y top clicked: rotate around y axis
......@@ -1477,6 +1502,8 @@ TranslationManipulatorNode::mouseEvent(GLState& _state, QMouseEvent* _event)
_state.pop_modelview_matrix();
}
touched_ = true;
}
// z top clicked: rotate around z axis
......@@ -1520,6 +1547,7 @@ TranslationManipulatorNode::mouseEvent(GLState& _state, QMouseEvent* _event)
_state.pop_modelview_matrix();
}
touched_ = true;
}
break;
......
......@@ -219,6 +219,10 @@ public:
ManipulatorMode getMode () const { return mode_; };
protected:
/// stores if this manipulator was used in order to avoid emitting manipulatorMoved unnecessarily
bool touched_;
private:
enum StateUpdates {
......
......@@ -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