50 #include "MovePlugin.hh"
52 #ifdef ENABLE_POLYLINE_SUPPORT
55 #ifdef ENABLE_TSPLINEMESH_SUPPORT
56 #include <ObjectTypes/TSplineMesh/TSplineMesh.hh>
60 #ifdef ENABLE_OPENVOLUMEMESH_HEXAHEDRAL_SUPPORT
63 #ifdef ENABLE_OPENVOLUMEMESH_POLYHEDRAL_SUPPORT
72 emit setSlotDescription(
"translate(int,Vector)",tr(
"Translate object by given vector."),
73 QString(tr(
"objectId,Vector")).split(
","), QString(tr(
"ID of an object, translation vector")).split(
","));
75 emit setSlotDescription(
"translate(int,idList,Vector)",tr(
"Translate vertices by given vector."),
76 QString(tr(
"objectId,VertexHandles,Vector")).split(
","),
77 QString(tr(
"ID of an object, List of vertex handles, translation vector")).split(
","));
79 emit setSlotDescription(
"translateVertexSelection(int,Vector)",tr(
"Translate current vertex selection of an object by given vector."),
80 QString(tr(
"objectId,Vector")).split(
","), QString(tr(
"ID of an object, translation vector")).split(
","));
82 emit setSlotDescription(
"translateFaceSelection(int,Vector)",tr(
"Translate current face selection of an object by given vector."),
83 QString(tr(
"objectId,Vector")).split(
","), QString(tr(
"ID of an object, translation vector")).split(
","));
85 emit setSlotDescription(
"translateEdgeSelection(int,Vector)",tr(
"Translate current edge selection of an object by given vector."),
86 QString(tr(
"objectId,Vector")).split(
","), QString(tr(
"ID of an object, translation vector")).split(
","));
88 emit setSlotDescription(
"transformHandleRegion(int,Matrix4x4)",tr(
"Transform handle region using the specified matrix."),
89 QString(tr(
"objectId,Matrix")).split(
","), QString(tr(
"ID of an object, transformation matrix")).split(
","));
91 emit setSlotDescription(
"transform(int,Matrix4x4)",tr(
"transform object by given matrix."),
92 QString(tr(
"objectId,Matrix")).split(
","), QString(tr(
"ID of an object, transformation matrix")).split(
","));
94 emit setSlotDescription(
"transform(int,IdList,Matrix4x4)",tr(
"transform vertices by given matrix."),
95 QString(tr(
"objectId,VertexHandles,Matrix")).split(
","),
96 QString(tr(
"ID of an object, List of vertex handles, transformation matrix")).split(
","));
98 emit setSlotDescription(
"transformSelection(int,Matrix4x4)",tr(
"transform current selection of an object by given matrix."),
99 QString(tr(
"objectId,Matrix")).split(
","), QString(tr(
"ID of an object, transformation matrix")).split(
","));
101 emit setSlotDescription(
"transformCellSelection(int,Matrix4x4)",tr(
"transform selected cells by given matrix."),
102 QString(tr(
"objectId,Matrix")).split(
","),
103 QString(tr(
"ID of an object, transformation matrix")).split(
","));
105 emit setSlotDescription(
"transformVertexSelection(int,Matrix4x4)",tr(
"transform selected vertices by given matrix."),
106 QString(tr(
"objectId,Matrix")).split(
","),
107 QString(tr(
"ID of an object, transformation matrix")).split(
","));
109 emit setSlotDescription(
"transformFaceSelection(int,Matrix4x4)",tr(
"transform selected faces by given matrix."),
110 QString(tr(
"objectId,Matrix")).split(
","),
111 QString(tr(
"ID of an object, transformation matrix")).split(
","));
113 emit setSlotDescription(
"transformEdgeSelection(int,Matrix4x4)",tr(
"transform selected edges by given matrix."),
114 QString(tr(
"objectId,Matrix")).split(
","),
115 QString(tr(
"ID of an object, transformation matrix")).split(
","));
117 emit setSlotDescription(
"setManipulatorPosition(int,Vector)",tr(
"Set the position of the manipulator."),
118 QString(tr(
"objectId,Position")).split(
","), QString(tr(
"ID of an object, 3D point")).split(
","));
120 emit setSlotDescription(
"setManipulatorDirection(int,Vector, Vector)",tr(
"Set the direction of the manipulator."),
121 QString(tr(
"objectId,Direction, Direction")).split(
","), QString(tr(
"ID of an object, x-direction, y-direction")).split(
","));
123 emit setSlotDescription(
"manipulatorPosition(int)",tr(
"Returns the position of an object's manipulator."),
124 QStringList(tr(
"objectId")), QStringList(tr(
"ID of an object")));
126 emit setSlotDescription(
"manipulatorDirectionX(int)",tr(
"Returns the x-direction of an object's manipulator."),
127 QStringList(tr(
"objectId")), QStringList(tr(
"ID of an object")));
129 emit setSlotDescription(
"manipulatorDirectionY(int)",tr(
"Returns the y-direction of an object's manipulator."),
130 QStringList(tr(
"objectId")), QStringList(tr(
"ID of an object")));
132 emit setSlotDescription(
"manipulatorDirectionZ(int)",tr(
"Returns the z-direction of an object's manipulator."),
133 QStringList(tr(
"objectId")), QStringList(tr(
"ID of an object")));
136 emit setSlotDescription(
"objectRenderingMatrixIdentity(int)",tr(
"Resets the objects rendering matrix to identity."),
137 QStringList(tr(
"objectId")), QStringList(tr(
"ID of an object")));
140 emit setSlotDescription(
"objectRenderingMatrixScale(int,double)",tr(
"Adds a scaling factor to the Object rendering Matrix in the scenegraph."),
141 QStringList(tr(
"objectId;Scaling Factor").split(
";")), QStringList(tr(
"ID of an object; Scaling factor").split(
";")));
143 emit setSlotDescription(
"objectRenderingMatrixTranslate(int,Vector)",tr(
"Adds a translation to the Object rendering Matrix in the scenegraph."),
144 QStringList(tr(
"objectId;translation vector").split(
";")), QStringList(tr(
"ID of an object;Translation vector").split(
";")));
146 emit setSlotDescription(
"objectRenderingMatrixRotate(int,Vector,double)",tr(
"Adds a Rotation to the Object rendering Matrix in the scenegraph."),
147 QStringList(tr(
"objectId;rotation axis;angle").split(
";")), QStringList(tr(
"ID of an object;Rotation axis;angle").split(
";")));
149 emit setSlotDescription(
"getObjectRenderingMatrix(int)",tr(
"Returns the current object transformation matrix from the scenegraph."),
150 QStringList(tr(
"objectId").split(
";")), QStringList(tr(
"ID of an object").split(
";")));
167 emit log(
LOGERR,tr(
"translate : unable to get object") );
174 TriMesh::VertexIter v_it = mesh.vertices_begin();
175 TriMesh::VertexIter v_end = mesh.vertices_end();
176 for (; v_it!=v_end; ++v_it)
177 mesh.set_point(*v_it,mesh.point(*v_it) + _vector );
182 PolyMesh::VertexIter v_it = mesh.vertices_begin();
183 PolyMesh::VertexIter v_end = mesh.vertices_end();
184 for (; v_it!=v_end; ++v_it)
185 mesh.set_point(*v_it,mesh.point(*v_it) + _vector );
188 #ifdef ENABLE_TSPLINEMESH_SUPPORT
189 else if ( object->
dataType( DATA_TSPLINE_MESH ) ) {
191 TSplineMesh& mesh = (*PluginFunctions::tsplineMesh(
object));
192 TSplineMesh::VertexIter v_it = mesh.vertices_begin();
193 TSplineMesh::VertexIter v_end = mesh.vertices_end();
194 for (; v_it!=v_end; ++v_it)
195 mesh.set_point(v_it,mesh.point(v_it) + _vector );
199 #ifdef ENABLE_POLYLINE_SUPPORT
204 for (
int i = 0 ; i < (int)line.
n_vertices(); ++i )
208 #ifdef ENABLE_OPENVOLUMEMESH_HEXAHEDRAL_SUPPORT
214 for (; v_it != v_end; ++v_it)
218 #ifdef ENABLE_OPENVOLUMEMESH_POLYHEDRAL_SUPPORT
224 for (; v_it != v_end; ++v_it)
228 #ifdef ENABLE_BSPLINE_CURVE_SUPPORT
230 std::cerr <<
"Todo : translate BSplineCurve" << std::endl;
236 emit scriptInfo(
"translate( ObjectId , Vector(" +
237 QString::number( _vector[0] ) +
" , " +
238 QString::number( _vector[1] ) +
" , " +
239 QString::number( _vector[2] ) +
" ) )" );
254 emit log(
LOGERR,tr(
"translate : unable to get object") );
262 for (uint i=0; i < _vHandles.size(); i++){
263 TriMesh::VertexHandle vh( _vHandles[i] );
264 mesh.set_point(vh ,mesh.point( vh ) + _vector );
271 for (uint i=0; i < _vHandles.size(); i++){
273 mesh.set_point(vh ,mesh.point( vh ) + _vector );
276 #ifdef ENABLE_TSPLINEMESH_SUPPORT
277 else if ( object->
dataType( DATA_TSPLINE_MESH ) ) {
279 TSplineMesh& mesh = (*PluginFunctions::tsplineMesh(
object));
281 for (uint i=0; i < _vHandles.size(); i++){
282 TSplineMesh::VertexHandle vh( _vHandles[i] );
283 mesh.set_point(vh ,mesh.point( vh ) + _vector );
287 #ifdef ENABLE_POLYLINE_SUPPORT
294 for (
unsigned int i = 0 ; i < _vHandles.size(); ++i )
295 if ( (_vHandles[i] > 0) && ( _vHandles[i] < max ) )
296 line.
point( _vHandles[i] ) = line.
point( _vHandles[i] ) + _vector;
299 #ifdef ENABLE_OPENVOLUMEMESH_HEXAHEDRAL_SUPPORT
303 for (
unsigned int i = 0; i < _vHandles.size(); ++i) {
309 #ifdef ENABLE_OPENVOLUMEMESH_POLYHEDRAL_SUPPORT
313 for (
unsigned int i = 0; i < _vHandles.size(); ++i) {
319 #ifdef ENABLE_BSPLINE_CURVE_SUPPORT
321 std::cerr <<
"Todo : translate BSplineCurve" << std::endl;
327 emit scriptInfo(
"translate( ObjectId , Vector(" +
328 QString::number( _vector[0] ) +
" , " +
329 QString::number( _vector[1] ) +
" , " +
330 QString::number( _vector[2] ) +
" ) )" );
346 emit log(
LOGERR,tr(
"translate : unable to get object" ));
350 bool noneSelected =
true;
355 TriMesh::VertexIter v_it = mesh.vertices_begin();
356 TriMesh::VertexIter v_end = mesh.vertices_end();
357 for (; v_it!=v_end; ++v_it)
358 if ( mesh.status(*v_it).selected() ) {
359 noneSelected =
false;
360 mesh.set_point(*v_it,mesh.point(*v_it) + _vector );
366 PolyMesh::VertexIter v_it = mesh.vertices_begin();
367 PolyMesh::VertexIter v_end = mesh.vertices_end();
368 for (; v_it!=v_end; ++v_it)
369 if ( mesh.status(*v_it).selected() ) {
370 noneSelected =
false;
371 mesh.set_point(*v_it,mesh.point(*v_it) + _vector );
374 #ifdef ENABLE_TSPLINEMESH_SUPPORT
375 else if ( object->
dataType( DATA_TSPLINE_MESH ) ) {
377 TSplineMesh& mesh = (*PluginFunctions::tsplineMesh(
object));
378 TSplineMesh::VertexIter v_it = mesh.vertices_begin();
379 TSplineMesh::VertexIter v_end = mesh.vertices_end();
380 for (; v_it!=v_end; ++v_it)
381 if ( mesh.status(v_it).selected() ) {
382 noneSelected =
false;
383 mesh.set_point(v_it,mesh.point(v_it) + _vector );
387 #ifdef ENABLE_POLYLINE_SUPPORT
392 for (
int i = 0 ; i < (int)line.
n_vertices(); ++i )
393 if ( line.vertex_selection(i) ) {
394 noneSelected =
false;
399 #ifdef ENABLE_OPENVOLUMEMESH_HEXAHEDRAL_SUPPORT
406 for (; v_it != v_end; ++v_it)
407 if (statusAttrib[*v_it].selected()) {
408 noneSelected =
false;
413 #ifdef ENABLE_OPENVOLUMEMESH_POLYHEDRAL_SUPPORT
420 for (; v_it != v_end; ++v_it)
421 if (statusAttrib[*v_it].selected()) {
422 noneSelected =
false;
427 #ifdef ENABLE_BSPLINE_CURVE_SUPPORT
429 std::cerr <<
"Todo : translate BSplineCurve" << std::endl;
438 emit scriptInfo(
"translate( ObjectId , Vector(" +
439 QString::number( _vector[0] ) +
" , " +
440 QString::number( _vector[1] ) +
" , " +
441 QString::number( _vector[2] ) +
" ) )" );
456 emit log(
LOGERR,tr(
"translate : unable to get object" ));
460 bool noneSelected =
true;
467 TriMesh::VertexIter v_it, v_end( mesh.vertices_end() );
468 for (v_it=mesh.vertices_begin(); v_it!=v_end; ++v_it)
469 mesh.status(*v_it).set_tagged(
false);
471 TriMesh::FaceIter f_it = mesh.faces_begin();
472 TriMesh::FaceIter f_end = mesh.faces_end();
473 for (; f_it!=f_end; ++f_it)
474 if ( mesh.status(*f_it).selected() )
476 for(TriMesh::FVIter fv_it = mesh.fv_iter(*f_it); fv_it.is_valid(); ++fv_it) {
477 noneSelected =
false;
478 mesh.status(*fv_it).set_tagged(
true);
485 for (v_it=mesh.vertices_begin(); v_it!=v_end; ++v_it)
486 if ( mesh.status(*v_it).tagged() )
487 mesh.set_point(*v_it,mesh.point(*v_it) + _vector );
494 PolyMesh::VertexIter v_it, v_end( mesh.vertices_end() );
495 for (v_it=mesh.vertices_begin(); v_it!=v_end; ++v_it)
496 mesh.status(*v_it).set_tagged(
false);
498 PolyMesh::FaceIter f_it = mesh.faces_begin();
499 PolyMesh::FaceIter f_end = mesh.faces_end();
500 for (; f_it!=f_end; ++f_it)
501 if ( mesh.status(*f_it).selected() )
503 for(TriMesh::FVIter fv_it = mesh.fv_iter(*f_it); fv_it.is_valid(); ++fv_it) {
504 noneSelected =
false;
505 mesh.status(*fv_it).set_tagged(
true);
512 for (v_it=mesh.vertices_begin(); v_it!=v_end; ++v_it)
513 if ( mesh.status(*v_it).tagged() )
514 mesh.set_point(*v_it,mesh.point(*v_it) + _vector );
516 #ifdef ENABLE_TSPLINEMESH_SUPPORT
517 else if ( object->
dataType( DATA_TSPLINE_MESH ) ) {
519 TSplineMesh& mesh = (*PluginFunctions::tsplineMesh(
object));
522 TSplineMesh::VertexIter v_it, v_end( mesh.vertices_end() );
523 for (v_it=mesh.vertices_begin(); v_it!=v_end; ++v_it)
524 mesh.status(*v_it).set_tagged(
false);
526 TSplineMesh::FaceIter f_it = mesh.faces_begin();
527 TSplineMesh::FaceIter f_end = mesh.faces_end();
528 for (; f_it!=f_end; ++f_it)
529 if ( mesh.status(f_it).selected() )
531 for(TriMesh::FVIter fv_it = mesh.fv_iter(f_it); fv_it; ++fv_it) {
532 noneSelected =
false;
533 mesh.status(fv_it).set_tagged(
true);
540 for (v_it=mesh.vertices_begin(); v_it!=v_end; ++v_it)
541 if ( mesh.status(v_it).tagged() )
542 mesh.set_point(v_it,mesh.point(v_it) + _vector );
546 #ifdef ENABLE_POLYLINE_SUPPORT
551 for (
int i = 0 ; i < (int)line.
n_vertices(); ++i )
552 if ( line.vertex_selection(i) ) {
553 noneSelected =
false;
561 #ifdef ENABLE_BSPLINE_CURVE_SUPPORT
563 std::cerr <<
"Todo : translate BSplineCurve" << std::endl;
569 emit scriptInfo(
"translate( ObjectId , Vector(" +
570 QString::number( _vector[0] ) +
" , " +
571 QString::number( _vector[1] ) +
" , " +
572 QString::number( _vector[2] ) +
" ) )" );
588 emit log(
LOGERR,tr(
"translate : unable to get object" ));
592 bool noneSelected =
true;
599 TriMesh::VertexIter v_it, v_end( mesh.vertices_end() );
600 for (v_it=mesh.vertices_begin(); v_it!=v_end; ++v_it)
601 mesh.status(*v_it).set_tagged(
false);
603 TriMesh::EdgeIter e_it = mesh.edges_begin();
604 TriMesh::EdgeIter e_end = mesh.edges_end();
605 for (; e_it!=e_end; ++e_it)
606 if ( mesh.status(*e_it).selected() )
608 noneSelected =
false;
609 TriMesh::HalfedgeHandle hh = mesh.halfedge_handle( *e_it, 0 );
611 mesh.status( mesh.from_vertex_handle( hh ) ).set_tagged(
true);
612 mesh.status( mesh.to_vertex_handle( hh ) ).set_tagged(
true);
618 for (v_it=mesh.vertices_begin(); v_it!=v_end; ++v_it)
619 if ( mesh.status(*v_it).tagged() ){
620 mesh.set_point(*v_it,mesh.point(*v_it) + _vector );
628 PolyMesh::VertexIter v_it, v_end( mesh.vertices_end() );
629 for (v_it=mesh.vertices_begin(); v_it!=v_end; ++v_it)
630 mesh.status(*v_it).set_tagged(
false);
632 PolyMesh::EdgeIter e_it = mesh.edges_begin();
633 PolyMesh::EdgeIter e_end = mesh.edges_end();
634 for (; e_it!=e_end; ++e_it)
635 if ( mesh.status(*e_it).selected() )
637 noneSelected =
false;
638 PolyMesh::HalfedgeHandle hh = mesh.halfedge_handle( *e_it, 0 );
640 mesh.status( mesh.from_vertex_handle( hh ) ).set_tagged(
true);
641 mesh.status( mesh.to_vertex_handle( hh ) ).set_tagged(
true);
647 for (v_it=mesh.vertices_begin(); v_it!=v_end; ++v_it)
648 if ( mesh.status(*v_it).tagged() ){
649 mesh.set_point(*v_it,mesh.point(*v_it) + _vector );
652 #ifdef ENABLE_TSPLINEMESH_SUPPORT
653 else if ( object->
dataType( DATA_TSPLINE_MESH ) ) {
655 TSplineMesh& mesh = (*PluginFunctions::tsplineMesh(
object));
658 TSplineMesh::VertexIter v_it, v_end( mesh.vertices_end() );
659 for (v_it=mesh.vertices_begin(); v_it!=v_end; ++v_it)
660 mesh.status(v_it).set_tagged(
false);
662 TSplineMesh::EdgeIter e_it = mesh.edges_begin();
663 TSplineMesh::EdgeIter e_end = mesh.edges_end();
664 for (; e_it!=e_end; ++e_it)
665 if ( mesh.status(e_it).selected() )
667 noneSelected =
false;
668 PolyMesh::HalfedgeHandle hh = mesh.halfedge_handle( e_it, 0 );
670 mesh.status( mesh.from_vertex_handle( hh ) ).set_tagged(
true);
671 mesh.status( mesh.to_vertex_handle( hh ) ).set_tagged(
true);
677 for (v_it=mesh.vertices_begin(); v_it!=v_end; ++v_it)
678 if ( mesh.status(v_it).tagged() ){
679 mesh.set_point(v_it,mesh.point(v_it) + _vector );
684 #ifdef ENABLE_POLYLINE_SUPPORT
689 for (
int i = 0 ; i < (int)line.
n_vertices(); ++i )
690 if ( line.vertex_selection(i) ) {
691 noneSelected =
false;
699 #ifdef ENABLE_BSPLINE_CURVE_SUPPORT
701 std::cerr <<
"Todo : translate BSplineCurve" << std::endl;
707 emit scriptInfo(
"translate( ObjectId , Vector(" +
708 QString::number( _vector[0] ) +
" , " +
709 QString::number( _vector[1] ) +
" , " +
710 QString::number( _vector[2] ) +
" ) )" );
719 emit log(
LOGERR, tr(
"transformHandleRegion: Unable to get object!"));
750 emit log(
LOGERR,tr(
"transform : unable to get object" ));
761 TriMesh::VertexIter v_it = mesh.vertices_begin();
762 TriMesh::VertexIter v_end = mesh.vertices_end();
763 for (; v_it!=v_end; ++v_it){
764 mesh.set_point (*v_it, _matrix.
transform_point ( mesh.point(*v_it) ) );
765 mesh.set_normal(*v_it, normalMatrix.
transform_vector( mesh.normal(*v_it) ) );
771 PolyMesh::VertexIter v_it = mesh.vertices_begin();
772 PolyMesh::VertexIter v_end = mesh.vertices_end();
773 for (; v_it!=v_end; ++v_it){
774 mesh.set_point (*v_it, _matrix.
transform_point ( mesh.point(*v_it) ) );
775 mesh.set_normal(*v_it, normalMatrix.
transform_vector( mesh.normal(*v_it) ) );
778 #ifdef ENABLE_TSPLINEMESH_SUPPORT
779 else if ( object->
dataType( DATA_TSPLINE_MESH ) ) {
781 TSplineMesh& mesh = (*PluginFunctions::tsplineMesh(
object));
782 TSplineMesh::VertexIter v_it = mesh.vertices_begin();
783 TSplineMesh::VertexIter v_end = mesh.vertices_end();
784 for (; v_it!=v_end; ++v_it){
790 #ifdef ENABLE_POLYLINE_SUPPORT
795 for (
int i = 0 ; i < (int)line.
n_vertices(); ++i )
799 #ifdef ENABLE_OPENVOLUMEMESH_HEXAHEDRAL_SUPPORT
806 for (; v_it != v_end; ++v_it) {
812 #ifdef ENABLE_OPENVOLUMEMESH_POLYHEDRAL_SUPPORT
819 for (; v_it != v_end; ++v_it) {
825 #ifdef ENABLE_BSPLINE_CURVE_SUPPORT
827 std::cerr <<
"Todo : transform BSplineCurve" << std::endl;
834 for (
int i=0; i < 4; i++)
835 for (
int j=0; j < 4; j++)
836 matString +=
" , " + QString::number( _matrix(i,j) );
838 matString = matString.right( matString.length()-3 );
840 emit scriptInfo(
"transform( ObjectId , Matrix4x4(" + matString +
" ) )" );
856 emit log(
LOGERR,tr(
"transform : unable to get object" ));
868 for (uint i=0; i < _vHandles.size(); i++){
869 TriMesh::VertexHandle vh( _vHandles[i] );
878 for (uint i=0; i < _vHandles.size(); i++){
884 #ifdef ENABLE_TSPLINEMESH_SUPPORT
885 else if ( object->
dataType( DATA_TSPLINE_MESH ) ) {
887 TSplineMesh& mesh = (*PluginFunctions::tsplineMesh(
object));
889 for (uint i=0; i < _vHandles.size(); i++){
890 TSplineMesh::VertexHandle vh( _vHandles[i] );
896 #ifdef ENABLE_POLYLINE_SUPPORT
903 for (
unsigned int i = 0 ; i < _vHandles.size(); ++i )
904 if ( (_vHandles[i] > 0) && ( _vHandles[i] < max ) )
909 #ifdef ENABLE_OPENVOLUMEMESH_HEXAHEDRAL_SUPPORT
914 for (
unsigned int i = 0; i < _vHandles.size(); ++i) {
921 #ifdef ENABLE_OPENVOLUMEMESH_POLYHEDRAL_SUPPORT
926 for (
unsigned int i = 0; i < _vHandles.size(); ++i) {
933 #ifdef ENABLE_BSPLINE_CURVE_SUPPORT
935 std::cerr <<
"Todo : transform BSplineCurve" << std::endl;
942 for (
int i=0; i < 4; i++)
943 for (
int j=0; j < 4; j++)
944 matString +=
" , " + QString::number( _matrix(i,j) );
946 matString = matString.right( matString.length()-3 );
948 emit scriptInfo(
"transform( ObjectId , Matrix4x4(" + matString +
" ) )" );
965 emit log(
LOGERR,tr(
"transform : unable to get object") );
973 bool noneSelected =
true;
977 TriMesh::VertexIter v_it = mesh.vertices_begin();
978 TriMesh::VertexIter v_end = mesh.vertices_end();
979 for (; v_it!=v_end; ++v_it)
980 if ( mesh.status(*v_it).selected() )
982 noneSelected =
false;
983 mesh.set_point (*v_it, _matrix.
transform_point ( mesh.point(*v_it) ) );
984 mesh.set_normal(*v_it, normalMatrix.
transform_vector( mesh.normal(*v_it) ) );
990 PolyMesh::VertexIter v_it = mesh.vertices_begin();
991 PolyMesh::VertexIter v_end = mesh.vertices_end();
992 for (; v_it!=v_end; ++v_it)
993 if ( mesh.status(*v_it).selected() )
995 noneSelected =
false;
996 mesh.set_point (*v_it, _matrix.
transform_point ( mesh.point(*v_it) ) );
997 mesh.set_normal(*v_it, normalMatrix.
transform_vector( mesh.normal(*v_it) ) );
1000 #ifdef ENABLE_TSPLINEMESH_SUPPORT
1001 else if ( object->
dataType( DATA_TSPLINE_MESH ) ) {
1003 TSplineMesh& mesh = (*PluginFunctions::tsplineMesh(
object));
1004 TSplineMesh::VertexIter v_it = mesh.vertices_begin();
1005 TSplineMesh::VertexIter v_end = mesh.vertices_end();
1006 for (; v_it!=v_end; ++v_it)
1007 if ( mesh.status(v_it).selected() )
1009 noneSelected =
false;
1011 mesh.set_normal(v_it, normalMatrix.
transform_vector( mesh.normal(v_it) ) );
1015 #ifdef ENABLE_POLYLINE_SUPPORT
1020 for (
int i = 0 ; i < (int)line.
n_vertices(); ++i )
1021 if ( line.vertex_selection(i) ) {
1022 noneSelected =
false;
1027 #ifdef ENABLE_BSPLINE_CURVE_SUPPORT
1029 std::cerr <<
"Todo : transform BSplineCurve" << std::endl;
1032 #ifdef ENABLE_OPENVOLUMEMESH_HEXAHEDRAL_SUPPORT
1039 for (; v_it!=v_end; ++v_it)
1040 if ( statusAttrib[*v_it].selected() )
1042 noneSelected =
false;
1044 normalAttrib[*v_it] = normalMatrix.
transform_vector( normalAttrib[*v_it] );
1048 #ifdef ENABLE_OPENVOLUMEMESH_POLYHEDRAL_SUPPORT
1055 for (; v_it!=v_end; ++v_it)
1056 if ( statusAttrib[*v_it].selected() )
1058 noneSelected =
false;
1060 normalAttrib[*v_it] = normalMatrix.
transform_vector( normalAttrib[*v_it] );
1071 for (
int i=0; i < 4; i++)
1072 for (
int j=0; j < 4; j++)
1073 matString +=
" , " + QString::number( _matrix(i,j) );
1075 matString = matString.right( matString.length()-3 );
1077 emit scriptInfo(
"transformVertexSelection( ObjectId , Matrix4x4(" + matString +
" ) )" );
1095 emit log(
LOGERR,tr(
"transform : unable to get object") );
1103 bool noneSelected =
true;
1109 TriMesh::VertexIter v_it, v_end( mesh.vertices_end() );
1110 for (v_it=mesh.vertices_begin(); v_it!=v_end; ++v_it)
1111 mesh.status(*v_it).set_tagged(
false);
1113 TriMesh::FaceIter f_it = mesh.faces_begin();
1114 TriMesh::FaceIter f_end = mesh.faces_end();
1115 for (; f_it!=f_end; ++f_it)
1116 if ( mesh.status(*f_it).selected() )
1118 noneSelected =
false;
1119 for(TriMesh::FVIter fv_it = mesh.fv_iter(*f_it); fv_it.is_valid(); ++fv_it)
1120 mesh.status(*fv_it).set_tagged(
true);
1123 for (v_it=mesh.vertices_begin(); v_it!=v_end; ++v_it)
1124 if ( mesh.status(*v_it).tagged() ){
1125 mesh.set_point (*v_it, _matrix.
transform_point ( mesh.point(*v_it) ) );
1126 mesh.set_normal(*v_it, normalMatrix.
transform_vector( mesh.normal(*v_it) ) );
1134 PolyMesh::VertexIter v_it, v_end( mesh.vertices_end() );
1135 for (v_it=mesh.vertices_begin(); v_it!=v_end; ++v_it)
1136 mesh.status(*v_it).set_tagged(
false);
1138 PolyMesh::FaceIter f_it = mesh.faces_begin();
1139 PolyMesh::FaceIter f_end = mesh.faces_end();
1140 for (; f_it!=f_end; ++f_it)
1141 if ( mesh.status(*f_it).selected() )
1143 noneSelected =
false;
1144 for(PolyMesh::FVIter fv_it = mesh.fv_iter(*f_it); fv_it.is_valid(); ++fv_it)
1145 mesh.status(*fv_it).set_tagged(
true);
1148 for (v_it=mesh.vertices_begin(); v_it!=v_end; ++v_it)
1149 if ( mesh.status(*v_it).tagged() ){
1150 mesh.set_point (*v_it, _matrix.
transform_point ( mesh.point(*v_it) ) );
1151 mesh.set_normal(*v_it, normalMatrix.
transform_vector( mesh.normal(*v_it) ) );
1154 #ifdef ENABLE_TSPLINEMESH_SUPPORT
1155 else if ( object->
dataType( DATA_TSPLINE_MESH ) ) {
1157 TSplineMesh& mesh = (*PluginFunctions::tsplineMesh(
object));
1160 TSplineMesh::VertexIter v_it, v_end( mesh.vertices_end() );
1161 for (v_it=mesh.vertices_begin(); v_it!=v_end; ++v_it)
1162 mesh.status(v_it).set_tagged(
false);
1164 TSplineMesh::FaceIter f_it = mesh.faces_begin();
1165 TSplineMesh::FaceIter f_end = mesh.faces_end();
1166 for (; f_it!=f_end; ++f_it)
1167 if ( mesh.status(f_it).selected() )
1169 noneSelected =
false;
1170 for(TSplineMesh::FVIter fv_it = mesh.fv_iter(f_it); fv_it; ++fv_it)
1171 mesh.status(fv_it).set_tagged(
true);
1174 for (v_it=mesh.vertices_begin(); v_it!=v_end; ++v_it)
1175 if ( mesh.status(v_it).tagged() ){
1177 mesh.set_normal(v_it, normalMatrix.
transform_vector( mesh.normal(v_it) ) );
1181 #ifdef ENABLE_OPENVOLUMEMESH_HEXAHEDRAL_SUPPORT
1192 statusAttrib[*v_it].set_tagged(
false);
1196 for (; f_it!=f_end; ++f_it)
1197 if ( statusAttrib[*f_it].selected() )
1199 noneSelected =
false;
1201 statusAttrib[*hfv_it].set_tagged(
true);
1205 if ( statusAttrib[*v_it].tagged() )
1208 normalAttrib[*v_it] = normalMatrix.
transform_vector( normalAttrib[*v_it] );
1213 #ifdef ENABLE_OPENVOLUMEMESH_POLYHEDRAL_SUPPORT
1224 statusAttrib[*v_it].set_tagged(
false);
1228 for (; f_it!=f_end; ++f_it)
1229 if ( statusAttrib[*f_it].selected() )
1231 noneSelected =
false;
1233 statusAttrib[*hfv_it].set_tagged(
true);
1237 if ( statusAttrib[*v_it].tagged() )
1240 normalAttrib[*v_it] = normalMatrix.
transform_vector( normalAttrib[*v_it] );
1251 for (
int i=0; i < 4; i++)
1252 for (
int j=0; j < 4; j++)
1253 matString +=
" , " + QString::number( _matrix(i,j) );
1255 matString = matString.right( matString.length()-3 );
1257 emit scriptInfo(
"transformFaceSelection( ObjectId , Matrix4x4(" + matString +
" ) )" );
1275 emit log(
LOGERR,tr(
"transform : unable to get object" ) );
1283 bool noneSelected =
true;
1289 TriMesh::VertexIter v_it, v_end( mesh.vertices_end() );
1290 for (v_it=mesh.vertices_begin(); v_it!=v_end; ++v_it)
1291 mesh.status(*v_it).set_tagged(
false);
1293 TriMesh::EdgeIter e_it = mesh.edges_begin();
1294 TriMesh::EdgeIter e_end = mesh.edges_end();
1295 for (; e_it!=e_end; ++e_it)
1296 if ( mesh.status(*e_it).selected() )
1298 noneSelected =
false;
1299 TriMesh::HalfedgeHandle hh = mesh.halfedge_handle( *e_it, 0 );
1301 mesh.status( mesh.from_vertex_handle( hh ) ).set_tagged(
true);
1302 mesh.status( mesh.to_vertex_handle( hh ) ).set_tagged(
true);
1305 for (v_it=mesh.vertices_begin(); v_it!=v_end; ++v_it)
1306 if ( mesh.status(*v_it).tagged() ){
1307 mesh.set_point (*v_it, _matrix.
transform_point ( mesh.point(*v_it) ) );
1308 mesh.set_normal(*v_it, normalMatrix.
transform_vector( mesh.normal(*v_it) ) );
1316 PolyMesh::VertexIter v_it, v_end( mesh.vertices_end() );
1317 for (v_it=mesh.vertices_begin(); v_it!=v_end; ++v_it)
1318 mesh.status(*v_it).set_tagged(
false);
1320 PolyMesh::EdgeIter e_it = mesh.edges_begin();
1321 PolyMesh::EdgeIter e_end = mesh.edges_end();
1322 for (; e_it!=e_end; ++e_it)
1323 if ( mesh.status(*e_it).selected() )
1325 noneSelected =
false;
1326 PolyMesh::HalfedgeHandle hh = mesh.halfedge_handle( *e_it, 0 );
1328 mesh.status( mesh.from_vertex_handle( hh ) ).set_tagged(
true);
1329 mesh.status( mesh.to_vertex_handle( hh ) ).set_tagged(
true);
1332 for (v_it=mesh.vertices_begin(); v_it!=v_end; ++v_it)
1333 if ( mesh.status(*v_it).tagged() ){
1334 mesh.set_point (*v_it, _matrix.
transform_point ( mesh.point(*v_it) ) );
1335 mesh.set_normal(*v_it, normalMatrix.
transform_vector( mesh.normal(*v_it) ) );
1338 #ifdef ENABLE_TSPLINEMESH_SUPPORT
1339 else if ( object->
dataType( DATA_TSPLINE_MESH ) ) {
1341 TSplineMesh& mesh = (*PluginFunctions::tsplineMesh(
object));
1344 TSplineMesh::VertexIter v_it, v_end( mesh.vertices_end() );
1345 for (v_it=mesh.vertices_begin(); v_it!=v_end; ++v_it)
1346 mesh.status(v_it).set_tagged(
false);
1348 TSplineMesh::EdgeIter e_it = mesh.edges_begin();
1349 TSplineMesh::EdgeIter e_end = mesh.edges_end();
1350 for (; e_it!=e_end; ++e_it)
1351 if ( mesh.status(e_it).selected() )
1353 noneSelected =
false;
1354 TSplineMesh::HalfedgeHandle hh = mesh.halfedge_handle( e_it, 0 );
1356 mesh.status( mesh.from_vertex_handle( hh ) ).set_tagged(
true);
1357 mesh.status( mesh.to_vertex_handle( hh ) ).set_tagged(
true);
1360 for (v_it=mesh.vertices_begin(); v_it!=v_end; ++v_it)
1361 if ( mesh.status(v_it).tagged() ){
1363 mesh.set_normal(v_it, normalMatrix.
transform_vector( mesh.normal(v_it) ) );
1367 #ifdef ENABLE_OPENVOLUMEMESH_HEXAHEDRAL_SUPPORT
1378 statusAttrib[*v_it].set_tagged(
false);
1382 for (; e_it!=e_end; ++e_it)
1383 if ( statusAttrib[*e_it].selected() )
1385 noneSelected =
false;
1387 statusAttrib[e.from_vertex()].set_tagged(
true);
1388 statusAttrib[e.to_vertex()].set_tagged(
true);
1392 if ( statusAttrib[*v_it].tagged() )
1395 normalAttrib[*v_it] = normalMatrix.
transform_vector( normalAttrib[*v_it] );
1400 #ifdef ENABLE_OPENVOLUMEMESH_POLYHEDRAL_SUPPORT
1411 statusAttrib[*v_it].set_tagged(
false);
1415 for (; e_it!=e_end; ++e_it)
1416 if ( statusAttrib[*e_it].selected() )
1418 noneSelected =
false;
1420 statusAttrib[e.from_vertex()].set_tagged(
true);
1421 statusAttrib[e.to_vertex()].set_tagged(
true);
1425 if ( statusAttrib[*v_it].tagged() )
1428 normalAttrib[*v_it] = normalMatrix.
transform_vector( normalAttrib[*v_it] );
1434 #ifdef ENABLE_POLYLINE_SUPPORT
1436 std::cerr <<
"Todo : transform PolyLine" << std::endl;
1439 #ifdef ENABLE_BSPLINE_CURVE_SUPPORT
1441 std::cerr <<
"Todo : transform BSplineCurve" << std::endl;
1451 for (
int i=0; i < 4; i++)
1452 for (
int j=0; j < 4; j++)
1453 matString +=
" , " + QString::number( _matrix(i,j) );
1455 matString = matString.right( matString.length()-3 );
1457 emit scriptInfo(
"transformEdgeSelection( ObjectId , Matrix4x4(" + matString +
" ) )" );
1474 emit log(
LOGERR,tr(
"transform : unable to get object") );
1482 bool noneSelected =
true;
1484 #ifdef ENABLE_OPENVOLUMEMESH_HEXAHEDRAL_SUPPORT
1495 statusAttrib[*v_it].set_tagged(
false);
1499 for (; c_it!=c_end; ++c_it)
1500 if ( statusAttrib[*c_it].selected() )
1502 noneSelected =
false;
1504 statusAttrib[*cv_it].set_tagged(
true);
1508 if ( statusAttrib[*v_it].tagged() )
1511 normalAttrib[*v_it] = normalMatrix.
transform_vector( normalAttrib[*v_it] );
1516 #ifdef ENABLE_OPENVOLUMEMESH_POLYHEDRAL_SUPPORT
1527 statusAttrib[*v_it].set_tagged(
false);
1531 for (; c_it!=c_end; ++c_it)
1532 if ( statusAttrib[*c_it].selected() )
1534 noneSelected =
false;
1536 statusAttrib[*cv_it].set_tagged(
true);
1540 if ( statusAttrib[*v_it].tagged() )
1543 normalAttrib[*v_it] = normalMatrix.
transform_vector( normalAttrib[*v_it] );
1554 for (
int i=0; i < 4; i++)
1555 for (
int j=0; j < 4; j++)
1556 matString +=
" , " + QString::number( _matrix(i,j) );
1558 matString = matString.right( matString.length()-3 );
1560 emit scriptInfo(
"transformCellSelection( ObjectId , Matrix4x4(" + matString +
" ) )" );
1577 emit log(
LOGERR,tr(
"setManipulatorPosition : unable to get object") );
1585 object->manipPlaced(
true );
1587 object->manipulatorNode()->loadIdentity();
1588 object->manipulatorNode()->set_center(_position);
1589 object->manipulatorNode()->set_draw_cylinder(
true);
1591 object->manipulatorNode()->show();
1603 emit scriptInfo(
"setManipulatorPosition( ObjectId , Vector(" +
1604 QString::number( _position[0] ) +
" , " +
1605 QString::number( _position[1] ) +
" , " +
1606 QString::number( _position[2] ) +
" ) )" );
1621 emit log(
LOGERR,tr(
"manipulatorPosition : unable to get object" ));
1625 return (
Vector)
object->manipulatorNode()->center();
1641 emit log(
LOGERR,tr(
"setManipulatorDirection : unable to get object") );
1646 emit log(
LOGERR,tr(
"setManipulatorDirection : manipulator position has to be set first" ));
1650 object->manipulatorNode()->set_direction(_directionX, _directionY);
1652 emit scriptInfo(
"setManipulatorDirection( ObjectId , Vector(" +
1653 QString::number( _directionX[0] ) +
" , " +
1654 QString::number( _directionX[1] ) +
" , " +
1655 QString::number( _directionX[2] ) +
" ), Vector(" +
1656 QString::number( _directionY[0] ) +
" , " +
1657 QString::number( _directionY[1] ) +
" , " +
1658 QString::number( _directionY[2] ) +
" ) )" );
1673 emit log(
LOGERR,tr(
"manipulatorDirection : unable to get object" ));
1677 return (
Vector)
object->manipulatorNode()->directionX();
1692 emit log(
LOGERR,tr(
"manipulatorDirection : unable to get object" ));
1696 return (
Vector)
object->manipulatorNode()->directionY();
1711 emit log(
LOGERR,tr(
"manipulatorDirection : unable to get object" ));
1715 return (
Vector)
object->manipulatorNode()->directionZ();
1724 emit log(
LOGERR,tr(
"objectRenderingMatrixIdentity : unable to get object" ));
1728 object->manipulatorNode()->loadIdentity();
1739 emit log(
LOGERR,tr(
"objectRenderingMatrixScale : unable to get object" ));
1743 object->manipulatorNode()->scale(_s);
1754 emit log(
LOGERR,tr(
"objectRenderingMatrixTranslate : unable to get object" ));
1758 object->manipulatorNode()->translate(_translation);
1769 emit log(
LOGERR,tr(
"objectRenderingMatrixRotate : unable to get object" ));
1773 object->manipulatorNode()->rotate(_angle,_axis);
1784 emit log(
LOGERR,tr(
"getObjectRenderingMatrix : unable to get object" ));
1788 return object->manipulatorNode()->matrix();
size_t n_vertices() const
Get number of vertices.
void setManipulatorDirection(int _objectId, Vector _directionX, Vector _directionY)
Set the direction of the manipulator.
const UpdateType UPDATE_GEOMETRY(UpdateTypeSet(1)<< 2)
Geometry updated.
void transformHandleVertices(ACG::Matrix4x4d _matrix, MeshT &_mesh)
Matrix4x4 getObjectRenderingMatrix(int _objectId)
Gets the Object Matrix in the scenegraph.
bool manipPlaced()
Check if the manipulator has been placed.
void translateEdgeSelection(int _objectId, Vector _vector)
translate current edge selection of an Object by a given vector
PolyLine * polyLine(BaseObjectData *_object)
Get a poly Line from an object.
bool transformFaceSelection(int _objectId, Matrix4x4 _matrix)
transform current selection of an Object by a given matrix
QtTranslationManipulatorNode * manipulatorNode()
#define DATA_POLYHEDRAL_MESH
bool getObject(int _identifier, BSplineCurveObject *&_object)
PolyMesh * polyMesh(BaseObjectData *_object)
Get a poly mesh from an object.
ACG::Matrix4x4d Matrix4x4
Standard Type for a 4x4 Matrix used for scripting.
#define DATA_BSPLINE_CURVE
bool transformEdgeSelection(int _objectId, Matrix4x4 _matrix)
transform current selection of an Object by a given matrix
void setManipulatorPosition(int _objectId, Vector _position)
Set the position of the manipulator.
void objectRenderingMatrixScale(int _objectId, double _s)
Adds a scaling factor to the Object rendering Matrix in the scenegraph.
VectorT< T, 3 > transform_vector(const VectorT< T, 3 > &_v) const
transform vector (x',y',z',0) = A * (x,y,z,0)
void ManipulatorPositionChanged(QtTranslationManipulatorNode *_node)
update object when its manipulator changes position
Vector manipulatorPosition(int _objectId)
Get the position of the manipulator.
bool dataType(DataType _type) const
Vector manipulatorDirectionZ(int _objectId)
Get the z-direction of the manipulator.
void objectRenderingMatrixIdentity(int _objectId)
Sets the Object Matrix in the scenegraph to identity.
TriMesh * triMesh(BaseObjectData *_object)
Get a triangle mesh from an object.
ACG::Vec3d Vector
Standard Type for 3d Vector used for scripting.
int lastActiveManipulator_
Stores the last manipulator which has been clicked ( used for the toolbox dialog) ...
const VecT & vertex(const VertexHandle &_vh) const
Get point _vh's coordinates.
void translateFaceSelection(int _objectId, Vector _vector)
translate current face selection of an Object by a given vector
Functions for modifying a Mesh.
std::vector< int > IdList
Standard Type for id Lists used for scripting.
void transformHandleRegion(int _objectId, Matrix4x4 _matrix)
Transform handle region using the given transformation matrix.
bool transformVertexSelection(int _objectId, Matrix4x4 _matrix)
transform current selection of an Object by a given matrix
void objectRenderingMatrixRotate(int _objectId, Vector _axis, double _angle)
Adds a scaling factor to the Object rendering Matrix in the scenegraph.
Vector manipulatorDirectionX(int _objectId)
Get the x-direction of the manipulator.
double sceneRadius()
Returns the current scene radius from the active examiner widget.
void transform(int _objectId, Matrix4x4 _matrix)
transform an Object by a given matrix
void translateVertexSelection(int _objectId, Vector _vector)
translate current vertex selection of an Object by a given vector
Kernel::VertexHandle VertexHandle
Handle for referencing the corresponding item.
VectorT< T, 3 > transform_point(const VectorT< T, 3 > &_v) const
transform point (x',y',z',1) = M * (x,y,z,1)
void objectRenderingMatrixTranslate(int _objectId, Vector _translation)
Adds a scaling factor to the Object rendering Matrix in the scenegraph.
Point & point(unsigned int _i)
Get a point of the polyline.
void manipulatorMoved(QtTranslationManipulatorNode *_node, QMouseEvent *_event)
move the object when its manipulator moves
#define DATA_HEXAHEDRAL_MESH
double manip_size_modifier_
Modifier for the Size (changed by Mousewheel Events)
void transpose()
transpose matrix
double manip_size_
Size for the manipulators.
Vector manipulatorDirectionY(int _objectId)
Get the y-direction of the manipulator.
const UpdateType UPDATE_VISIBILITY(UpdateTypeSet(1)<< 1)
This is the update identifier for global Object visibility ( show/hide )
bool transformCellSelection(int _objectId, Matrix4x4 _matrix)
transform current selection of an Object by a given matrix
void setDescriptions()
Set Descriptions for scriptable functions.
bool invert()
matrix inversion (returns true on success)
#define DATA_TRIANGLE_MESH
HexahedralMesh * hexahedralMesh(BaseObjectData *_object)
Get an HexahedralMesh from an object.
void translate(int _objectId, Vector _vector)
translate an Object by a given vector
PolyhedralMesh * polyhedralMesh(BaseObjectData *_object)
Get an PolyhedralMesh from an object.
void set_vertex(const VertexHandle &_vh, const VecT &_p)
Set the coordinates of point _vh.