Commit 69aa9e6e authored by Matthias Möller's avatar Matthias Möller

fix: changing manipulator property effects on mesh or selection, depeding on the manipluator mode

refs #485 part 1

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@14171 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 3ec68c67
......@@ -928,12 +928,29 @@ void MovePlugin::slotSetPosition() {
ACG::GLMatrixd m;
m.identity();
m.translate(translation);
// ...and transform mesh
if(object->dataType() == DATA_TRIANGLE_MESH)
if (PluginFunctions::pickMode() == "Move")
{
// ...and transform mesh
if(object->dataType() == DATA_TRIANGLE_MESH)
transformMesh(m, *PluginFunctions::triMesh(object));
else if(object->dataType() == DATA_POLY_MESH)
else if(object->dataType() == DATA_POLY_MESH)
transformMesh(m, *PluginFunctions::polyMesh(object));
}
else if (PluginFunctions::pickMode() == "MoveSelection")
{
updateSelectionType();
if (selectionType_ & VERTEX) {
transformVertexSelection(object->id(), m);
}
if (selectionType_ & FACE) {
transformFaceSelection(object->id(), m);
}
if (selectionType_ & EDGE) {
transformEdgeSelection(object->id(), m);
}
}
emit updatedObject(object->id(), UPDATE_GEOMETRY);
}
updateManipulatorDialog();
......@@ -1125,22 +1142,40 @@ void MovePlugin::slotTranslation() {
//
// }
BaseObjectData* object = 0;
PluginFunctions::getObject(pW->getBaseObjectDataId(),object);
BaseObjectData* object = 0;
PluginFunctions::getObject(pW->getBaseObjectDataId(),object);
if (object != 0) {
if (object->manipulatorNode()->visible()) {
if (object != 0) {
if (object->manipulatorNode()->visible()) {
translate(object->id(), translation);
object->manipulatorNode()->set_center(
object->manipulatorNode()->center() + translation);
object->manipulatorNode()->set_center(
object->manipulatorNode()->center() + translation);
emit createBackup(object->id(), "Translation");
emit updatedObject(object->id(), UPDATE_GEOMETRY);
}
} else {
return;
}
if (PluginFunctions::pickMode() == "Move")
{
translate(object->id(), translation);
}
else if (PluginFunctions::pickMode() == "MoveSelection")
{
updateSelectionType();
if (selectionType_ & VERTEX) {
translateVertexSelection(object->id(), translation);
}
if (selectionType_ & FACE) {
translateFaceSelection(object->id(), translation);
}
if (selectionType_ & EDGE) {
translateEdgeSelection(object->id(), translation);
}
}
emit createBackup(object->id(), "Translation");
emit updatedObject(object->id(), UPDATE_GEOMETRY);
}
} else {
return;
}
updateManipulatorDialog();
......@@ -1275,18 +1310,33 @@ void MovePlugin::slotRotate() {
object->manipulatorNode()->rotate(angle, axis);
if (object->dataType(DATA_TRIANGLE_MESH))
transformMesh(getLastManipulatorMatrix(true),
(*PluginFunctions::triMesh(object)));
ACG::Matrix4x4d m = getLastManipulatorMatrix(true);
if (object->dataType(DATA_POLY_MESH))
transformMesh(getLastManipulatorMatrix(true),
(*PluginFunctions::polyMesh(object)));
if (PluginFunctions::pickMode() == "Move")
{
if (object->dataType(DATA_TRIANGLE_MESH))
transformMesh(m, (*PluginFunctions::triMesh(object)));
if (object->dataType(DATA_POLY_MESH))
transformMesh(m, (*PluginFunctions::polyMesh(object)));
#ifdef ENABLE_TSPLINEMESH_SUPPORT
if (object->dataType(DATA_TSPLINE_MESH))
transformMesh(getLastManipulatorMatrix(true),
(*PluginFunctions::tsplineMesh(object)));
if (object->dataType(DATA_TSPLINE_MESH))
transformMesh(m, (*PluginFunctions::tsplineMesh(object)));
#endif
}
else if (PluginFunctions::pickMode() == "MoveSelection")
{
updateSelectionType();
if (selectionType_ & VERTEX) {
transformVertexSelection(object->id(), m);
}
if (selectionType_ & FACE) {
transformFaceSelection(object->id(), m);
}
if (selectionType_ & EDGE) {
transformEdgeSelection(object->id(), m);
}
}
updateManipulatorDialog();
......@@ -1351,18 +1401,32 @@ void MovePlugin::slotScale() {
object->manipulatorNode()->scale(scale);
if (object->dataType(DATA_TRIANGLE_MESH))
transformMesh(getLastManipulatorMatrix(true),
(*PluginFunctions::triMesh(object)));
if (object->dataType(DATA_POLY_MESH))
transformMesh(getLastManipulatorMatrix(true),
(*PluginFunctions::polyMesh(object)));
#ifdef ENABLE_TSPLINEMESH_SUPPORT
if (object->dataType(DATA_TSPLINE_MESH))
transformMesh(getLastManipulatorMatrix(true),
(*PluginFunctions::tsplineMesh(object)));
#endif
ACG::Matrix4x4d m = getLastManipulatorMatrix(true);
if (PluginFunctions::pickMode() == "Move")
{
if (object->dataType(DATA_TRIANGLE_MESH))
transformMesh(m,(*PluginFunctions::triMesh(object)));
if (object->dataType(DATA_POLY_MESH))
transformMesh(m, (*PluginFunctions::polyMesh(object)));
#ifdef ENABLE_TSPLINEMESH_SUPPORT
if (object->dataType(DATA_TSPLINE_MESH))
transformMesh(m, (*PluginFunctions::tsplineMesh(object)));
#endif
}
else if (PluginFunctions::pickMode() == "MoveSelection")
{
updateSelectionType();
if (selectionType_ & VERTEX) {
transformVertexSelection(object->id(), m);
}
if (selectionType_ & FACE) {
transformFaceSelection(object->id(), m);
}
if (selectionType_ & EDGE) {
transformEdgeSelection(object->id(), m);
}
}
updateManipulatorDialog();
......
......@@ -458,8 +458,14 @@ public slots :
/// translate given vertices by a vector
void translate( int _objectId , IdList _vHandles, Vector _vector );
/// translate current selection of an Object by a given vector
void translateSelection( int _objectId , Vector _vector );
/// translate current vertex selection of an Object by a given vector
void translateVertexSelection( int _objectId , Vector _vector );
/// translate current face selection of an Object by a given vector
void translateFaceSelection( int _objectId , Vector _vector );
/// translate current edge selection of an Object by a given vector
void translateEdgeSelection( int _objectId , Vector _vector );
/// transform an Object by a given matrix
void transform( int _objectId , Matrix4x4 _matrix );
......
......@@ -256,7 +256,7 @@ void MovePlugin::translate( int _objectId , IdList _vHandles, Vector _vector ){
* @param _objectId id of an object
* @param _vector translation vector
*/
void MovePlugin::translateSelection( int _objectId , Vector _vector) {
void MovePlugin::translateVertexSelection( int _objectId , Vector _vector) {
BaseObjectData* object;
if ( ! PluginFunctions::getObject(_objectId,object) ) {
......@@ -324,6 +324,225 @@ void MovePlugin::translateSelection( int _objectId , Vector _vector) {
//------------------------------------------------------------------------------
/** \brief translate face selection
*
* @param _objectId id of an object
* @param _vector translation vector
*/
void MovePlugin::translateFaceSelection( int _objectId , Vector _vector) {
BaseObjectData* object;
if ( ! PluginFunctions::getObject(_objectId,object) ) {
emit log(LOGERR,tr("translate : unable to get object" ));
return;
}
if ( object->dataType( DATA_TRIANGLE_MESH ) ) {
TriMesh& mesh = (*PluginFunctions::triMesh(object));
TriMesh::FaceIter f_it = mesh.faces_begin();
TriMesh::FaceIter f_end = mesh.faces_end();
for (; f_it!=f_end; ++f_it)
if ( mesh.status(f_it).selected() )
{
for(TriMesh::FVIter fv_it = mesh.fv_iter(f_it); fv_it; ++fv_it)
mesh.status(fv_it).set_tagged(true);
}
TriMesh::VertexIter v_it = mesh.vertices_begin();
TriMesh::VertexIter v_end = mesh.vertices_end();
for (v_it=mesh.vertices_begin(); v_it!=v_end; ++v_it)
if ( mesh.status(v_it).tagged() )
mesh.set_point(v_it,mesh.point(v_it) + _vector );
} else if ( object->dataType( DATA_POLY_MESH ) ) {
PolyMesh& mesh = (*PluginFunctions::polyMesh(object));
PolyMesh::FaceIter f_it = mesh.faces_begin();
PolyMesh::FaceIter f_end = mesh.faces_end();
for (; f_it!=f_end; ++f_it)
if ( mesh.status(f_it).selected() )
{
for(TriMesh::FVIter fv_it = mesh.fv_iter(f_it); fv_it; ++fv_it)
mesh.status(fv_it).set_tagged(true);
}
PolyMesh::VertexIter v_it = mesh.vertices_begin();
PolyMesh::VertexIter v_end = mesh.vertices_end();
for (v_it=mesh.vertices_begin(); v_it!=v_end; ++v_it)
if ( mesh.status(v_it).tagged() )
mesh.set_point(v_it,mesh.point(v_it) + _vector );
}
#ifdef ENABLE_TSPLINEMESH_SUPPORT
else if ( object->dataType( DATA_TSPLINE_MESH ) ) {
TSplineMesh& mesh = (*PluginFunctions::tsplineMesh(object));
TSplineMesh::FaceIter f_it = mesh.faces_begin();
TSplineMesh::FaceIter f_end = mesh.faces_end();
for (; f_it!=f_end; ++f_it)
if ( mesh.status(f_it).selected() )
{
for(TriMesh::FVIter fv_it = mesh.fv_iter(f_it); fv_it; ++fv_it)
mesh.status(fv_it).set_tagged(true);
}
TSplineMesh::VertexIter v_it = mesh.vertices_begin();
TSplineMesh::VertexIter v_end = mesh.vertices_end();
for (v_it=mesh.vertices_begin(); v_it!=v_end; ++v_it)
if ( mesh.status(v_it).tagged() )
mesh.set_point(v_it,mesh.point(v_it) + _vector );
}
#endif
#ifdef ENABLE_POLYLINE_SUPPORT
else if ( object->dataType(DATA_POLY_LINE) ) {
PolyLine& line = (* PluginFunctions::polyLine(object) );
for ( int i = 0 ; i < (int)line.n_vertices(); ++i )
if ( line.vertex_selection(i) )
line.point(i) = line.point(i) + _vector;
}
#endif
#ifdef ENABLE_BSPLINE_CURVE_SUPPORT
else if ( object->dataType(DATA_BSPLINE_CURVE) ) {
std::cerr << "Todo : translate BSplineCurve" << std::endl;
}
#endif
emit updatedObject(_objectId, UPDATE_GEOMETRY);
emit scriptInfo( "translate( ObjectId , Vector(" +
QString::number( _vector[0] ) + " , " +
QString::number( _vector[1] ) + " , " +
QString::number( _vector[2] ) + " ) )" );
// Create backup
emit createBackup(_objectId, "Translation of Selection");
}
//------------------------------------------------------------------------------
/** \brief translate edge selection
*
* @param _objectId id of an object
* @param _vector translation vector
*/
void MovePlugin::translateEdgeSelection( int _objectId , Vector _vector) {
BaseObjectData* object;
if ( ! PluginFunctions::getObject(_objectId,object) ) {
emit log(LOGERR,tr("translate : unable to get object" ));
return;
}
if ( object->dataType( DATA_TRIANGLE_MESH ) ) {
TriMesh& mesh = (*PluginFunctions::triMesh(object));
//init tags
TriMesh::VertexIter v_it, v_end( mesh.vertices_end() );
for (v_it=mesh.vertices_begin(); v_it!=v_end; ++v_it)
mesh.status(v_it).set_tagged(false);
TriMesh::EdgeIter e_it = mesh.edges_begin();
TriMesh::EdgeIter e_end = mesh.edges_end();
for (; e_it!=e_end; ++e_it)
if ( mesh.status(e_it).selected() )
{
TriMesh::HalfedgeHandle hh = mesh.halfedge_handle( e_it, 0 );
mesh.status( mesh.from_vertex_handle( hh ) ).set_tagged(true);
mesh.status( mesh.to_vertex_handle( hh ) ).set_tagged(true);
}
for (v_it=mesh.vertices_begin(); v_it!=v_end; ++v_it)
if ( mesh.status(v_it).tagged() ){
mesh.set_point(v_it,mesh.point(v_it) + _vector );
}
} else if ( object->dataType( DATA_POLY_MESH ) ) {
PolyMesh& mesh = (*PluginFunctions::polyMesh(object));
//init tags
PolyMesh::VertexIter v_it, v_end( mesh.vertices_end() );
for (v_it=mesh.vertices_begin(); v_it!=v_end; ++v_it)
mesh.status(v_it).set_tagged(false);
PolyMesh::EdgeIter e_it = mesh.edges_begin();
PolyMesh::EdgeIter e_end = mesh.edges_end();
for (; e_it!=e_end; ++e_it)
if ( mesh.status(e_it).selected() )
{
PolyMesh::HalfedgeHandle hh = mesh.halfedge_handle( e_it, 0 );
mesh.status( mesh.from_vertex_handle( hh ) ).set_tagged(true);
mesh.status( mesh.to_vertex_handle( hh ) ).set_tagged(true);
}
for (v_it=mesh.vertices_begin(); v_it!=v_end; ++v_it)
if ( mesh.status(v_it).tagged() ){
mesh.set_point(v_it,mesh.point(v_it) + _vector );
}
}
#ifdef ENABLE_TSPLINEMESH_SUPPORT
else if ( object->dataType( DATA_TSPLINE_MESH ) ) {
TSplineMesh& mesh = (*PluginFunctions::tsplineMesh(object));
//init tags
TSplineMesh::VertexIter v_it, v_end( mesh.vertices_end() );
for (v_it=mesh.vertices_begin(); v_it!=v_end; ++v_it)
mesh.status(v_it).set_tagged(false);
TSplineMesh::EdgeIter e_it = mesh.edges_begin();
TSplineMesh::EdgeIter e_end = mesh.edges_end();
for (; e_it!=e_end; ++e_it)
if ( mesh.status(e_it).selected() )
{
PolyMesh::HalfedgeHandle hh = mesh.halfedge_handle( e_it, 0 );
mesh.status( mesh.from_vertex_handle( hh ) ).set_tagged(true);
mesh.status( mesh.to_vertex_handle( hh ) ).set_tagged(true);
}
for (v_it=mesh.vertices_begin(); v_it!=v_end; ++v_it)
if ( mesh.status(v_it).tagged() ){
mesh.set_point(v_it,mesh.point(v_it) + _vector );
}
}
#endif
#ifdef ENABLE_POLYLINE_SUPPORT
else if ( object->dataType(DATA_POLY_LINE) ) {
PolyLine& line = (* PluginFunctions::polyLine(object) );
for ( int i = 0 ; i < (int)line.n_vertices(); ++i )
if ( line.vertex_selection(i) )
line.point(i) = line.point(i) + _vector;
}
#endif
#ifdef ENABLE_BSPLINE_CURVE_SUPPORT
else if ( object->dataType(DATA_BSPLINE_CURVE) ) {
std::cerr << "Todo : translate BSplineCurve" << std::endl;
}
#endif
emit updatedObject(_objectId, UPDATE_GEOMETRY);
emit scriptInfo( "translate( ObjectId , Vector(" +
QString::number( _vector[0] ) + " , " +
QString::number( _vector[1] ) + " , " +
QString::number( _vector[2] ) + " ) )" );
// Create backup
emit createBackup(_objectId, "Translation of Selection");
}
//------------------------------------------------------------------------------
/** \brief tranform an object
*
* @param _objectId object id
......
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