Developer Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
MovePluginScript.cc
1 /*===========================================================================*\
2 * *
3 * OpenFlipper *
4  * Copyright (c) 2001-2015, RWTH-Aachen University *
5  * Department of Computer Graphics and Multimedia *
6  * All rights reserved. *
7  * www.openflipper.org *
8  * *
9  *---------------------------------------------------------------------------*
10  * This file is part of OpenFlipper. *
11  *---------------------------------------------------------------------------*
12  * *
13  * Redistribution and use in source and binary forms, with or without *
14  * modification, are permitted provided that the following conditions *
15  * are met: *
16  * *
17  * 1. Redistributions of source code must retain the above copyright notice, *
18  * this list of conditions and the following disclaimer. *
19  * *
20  * 2. Redistributions in binary form must reproduce the above copyright *
21  * notice, this list of conditions and the following disclaimer in the *
22  * documentation and/or other materials provided with the distribution. *
23  * *
24  * 3. Neither the name of the copyright holder nor the names of its *
25  * contributors may be used to endorse or promote products derived from *
26  * this software without specific prior written permission. *
27  * *
28  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
29  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
30  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
31  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
32  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
33  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
34  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
35  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
36  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
37  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
38  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
39 * *
40 \*===========================================================================*/
41 
42 /*===========================================================================*\
43 * *
44 * $Revision$ *
45 * $LastChangedBy$ *
46 * $Date$ *
47 * *
48 \*===========================================================================*/
49 
50 #include "MovePlugin.hh"
51 
52 #ifdef ENABLE_POLYLINE_SUPPORT
54 #endif
55 #ifdef ENABLE_TSPLINEMESH_SUPPORT
56 #include <ObjectTypes/TSplineMesh/TSplineMesh.hh>
57 #endif
59 
60 #ifdef ENABLE_OPENVOLUMEMESH_HEXAHEDRAL_SUPPORT
62 #endif
63 #ifdef ENABLE_OPENVOLUMEMESH_POLYHEDRAL_SUPPORT
65 #endif
66 
71 
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(","));
74 
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(","));
78 
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(","));
81 
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(","));
84 
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(","));
87 
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(","));
90 
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(","));
93 
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(","));
97 
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(","));
100 
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(","));
104 
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(","));
108 
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(","));
112 
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(","));
116 
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(","));
119 
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(","));
122 
123  emit setSlotDescription("manipulatorPosition(int)",tr("Returns the position of an object's manipulator."),
124  QStringList(tr("objectId")), QStringList(tr("ID of an object")));
125 
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")));
128 
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")));
131 
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")));
134 
135 
136  emit setSlotDescription("objectRenderingMatrixIdentity(int)",tr("Resets the objects rendering matrix to identity."),
137  QStringList(tr("objectId")), QStringList(tr("ID of an object")));
138 
139 
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(";")));
142 
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(";")));
145 
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(";")));
148 
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(";")));
151 
152 
153 }
154 
155 
156 //------------------------------------------------------------------------------
157 
163 void MovePlugin::translate( int _objectId , Vector _vector) {
164 
165  BaseObjectData* object;
166  if ( ! PluginFunctions::getObject(_objectId,object) ) {
167  emit log(LOGERR,tr("translate : unable to get object") );
168  return;
169  }
170 
171  if ( object->dataType( DATA_TRIANGLE_MESH ) ) {
172 
173  TriMesh& mesh = (*PluginFunctions::triMesh(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 );
178 
179  } else if ( object->dataType( DATA_POLY_MESH ) ) {
180 
181  PolyMesh& mesh = (*PluginFunctions::polyMesh(object));
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 );
186 
187  }
188 #ifdef ENABLE_TSPLINEMESH_SUPPORT
189  else if ( object->dataType( DATA_TSPLINE_MESH ) ) {
190 
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 );
196 
197  }
198 #endif
199 #ifdef ENABLE_POLYLINE_SUPPORT
200  else if ( object->dataType(DATA_POLY_LINE) ) {
201 
202  PolyLine& line = (* PluginFunctions::polyLine(object) );
203 
204  for ( int i = 0 ; i < (int)line.n_vertices(); ++i )
205  line.point(i) = line.point(i) + _vector;
206  }
207 #endif
208 #ifdef ENABLE_OPENVOLUMEMESH_HEXAHEDRAL_SUPPORT
209  else if ( object->dataType(DATA_HEXAHEDRAL_MESH) ) {
210 
212  OpenVolumeMesh::VertexIter v_it = mesh.vertices_begin();
213  OpenVolumeMesh::VertexIter v_end = mesh.vertices_end();
214  for (; v_it != v_end; ++v_it)
215  mesh.set_vertex(*v_it, mesh.vertex(*v_it) + _vector );
216  }
217 #endif
218 #ifdef ENABLE_OPENVOLUMEMESH_POLYHEDRAL_SUPPORT
219  else if ( object->dataType(DATA_POLYHEDRAL_MESH) ) {
220 
222  OpenVolumeMesh::VertexIter v_it = mesh.vertices_begin();
223  OpenVolumeMesh::VertexIter v_end = mesh.vertices_end();
224  for (; v_it != v_end; ++v_it)
225  mesh.set_vertex(*v_it, mesh.vertex(*v_it) + _vector );
226  }
227 #endif
228 #ifdef ENABLE_BSPLINE_CURVE_SUPPORT
229  else if ( object->dataType(DATA_BSPLINE_CURVE) ) {
230  std::cerr << "Todo : translate BSplineCurve" << std::endl;
231  }
232 #endif
233 
234  emit updatedObject(_objectId, UPDATE_GEOMETRY);
235 
236  emit scriptInfo( "translate( ObjectId , Vector(" +
237  QString::number( _vector[0] ) + " , " +
238  QString::number( _vector[1] ) + " , " +
239  QString::number( _vector[2] ) + " ) )" );
240 }
241 
242 
243 //------------------------------------------------------------------------------
244 
251 void MovePlugin::translate( int _objectId , IdList _vHandles, Vector _vector ){
252  BaseObjectData* object;
253  if ( ! PluginFunctions::getObject(_objectId,object) ) {
254  emit log(LOGERR,tr("translate : unable to get object") );
255  return;
256  }
257 
258  if ( object->dataType( DATA_TRIANGLE_MESH ) ) {
259 
260  TriMesh& mesh = (*PluginFunctions::triMesh(object));
261 
262  for (uint i=0; i < _vHandles.size(); i++){
263  TriMesh::VertexHandle vh( _vHandles[i] );
264  mesh.set_point(vh ,mesh.point( vh ) + _vector );
265  }
266 
267  } else if ( object->dataType( DATA_POLY_MESH ) ) {
268 
269  PolyMesh& mesh = (*PluginFunctions::polyMesh(object));
270 
271  for (uint i=0; i < _vHandles.size(); i++){
272  PolyMesh::VertexHandle vh( _vHandles[i] );
273  mesh.set_point(vh ,mesh.point( vh ) + _vector );
274  }
275  }
276 #ifdef ENABLE_TSPLINEMESH_SUPPORT
277  else if ( object->dataType( DATA_TSPLINE_MESH ) ) {
278 
279  TSplineMesh& mesh = (*PluginFunctions::tsplineMesh(object));
280 
281  for (uint i=0; i < _vHandles.size(); i++){
282  TSplineMesh::VertexHandle vh( _vHandles[i] );
283  mesh.set_point(vh ,mesh.point( vh ) + _vector );
284  }
285  }
286 #endif
287 #ifdef ENABLE_POLYLINE_SUPPORT
288  else if ( object->dataType(DATA_POLY_LINE) ) {
289 
290  PolyLine& line = (* PluginFunctions::polyLine(object) );
291 
292  const int max = line.n_vertices();
293 
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;
297  }
298 #endif
299 #ifdef ENABLE_OPENVOLUMEMESH_HEXAHEDRAL_SUPPORT
300  else if ( object->dataType(DATA_HEXAHEDRAL_MESH) ) {
301 
303  for (unsigned int i = 0; i < _vHandles.size(); ++i) {
304  OpenVolumeMesh::VertexHandle v(_vHandles[i]);
305  mesh.set_vertex(v, mesh.vertex(v) + _vector );
306  }
307  }
308 #endif
309 #ifdef ENABLE_OPENVOLUMEMESH_POLYHEDRAL_SUPPORT
310  else if ( object->dataType(DATA_POLYHEDRAL_MESH) ) {
311 
313  for (unsigned int i = 0; i < _vHandles.size(); ++i) {
314  OpenVolumeMesh::VertexHandle v(_vHandles[i]);
315  mesh.set_vertex(v, mesh.vertex(v) + _vector );
316  }
317  }
318 #endif
319 #ifdef ENABLE_BSPLINE_CURVE_SUPPORT
320  else if ( object->dataType(DATA_BSPLINE_CURVE) ) {
321  std::cerr << "Todo : translate BSplineCurve" << std::endl;
322  }
323 #endif
324 
325  emit updatedObject(_objectId, UPDATE_GEOMETRY);
326 
327  emit scriptInfo( "translate( ObjectId , Vector(" +
328  QString::number( _vector[0] ) + " , " +
329  QString::number( _vector[1] ) + " , " +
330  QString::number( _vector[2] ) + " ) )" );
331 
332 }
333 
334 
335 //------------------------------------------------------------------------------
336 
342 void MovePlugin::translateVertexSelection( int _objectId , Vector _vector) {
343 
344  BaseObjectData* object;
345  if ( ! PluginFunctions::getObject(_objectId,object) ) {
346  emit log(LOGERR,tr("translate : unable to get object" ));
347  return;
348  }
349 
350  bool noneSelected = true;
351 
352  if ( object->dataType( DATA_TRIANGLE_MESH ) ) {
353 
354  TriMesh& mesh = (*PluginFunctions::triMesh(object));
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 );
361  }
362 
363  } else if ( object->dataType( DATA_POLY_MESH ) ) {
364 
365  PolyMesh& mesh = (*PluginFunctions::polyMesh(object));
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 );
372  }
373  }
374 #ifdef ENABLE_TSPLINEMESH_SUPPORT
375  else if ( object->dataType( DATA_TSPLINE_MESH ) ) {
376 
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 );
384  }
385  }
386 #endif
387 #ifdef ENABLE_POLYLINE_SUPPORT
388  else if ( object->dataType(DATA_POLY_LINE) ) {
389 
390  PolyLine& line = (* PluginFunctions::polyLine(object) );
391 
392  for ( int i = 0 ; i < (int)line.n_vertices(); ++i )
393  if ( line.vertex_selection(i) ) {
394  noneSelected = false;
395  line.point(i) = line.point(i) + _vector;
396  }
397  }
398 #endif
399 #ifdef ENABLE_OPENVOLUMEMESH_HEXAHEDRAL_SUPPORT
400  else if ( object->dataType(DATA_HEXAHEDRAL_MESH) ) {
401 
403  OpenVolumeMesh::StatusAttrib& statusAttrib = ((HexahedralMeshObject*)object)->status();
404  OpenVolumeMesh::VertexIter v_it = mesh.vertices_begin();
405  OpenVolumeMesh::VertexIter v_end = mesh.vertices_end();
406  for (; v_it != v_end; ++v_it)
407  if (statusAttrib[*v_it].selected()) {
408  noneSelected = false;
409  mesh.set_vertex(*v_it, mesh.vertex(*v_it) + _vector );
410  }
411  }
412 #endif
413 #ifdef ENABLE_OPENVOLUMEMESH_POLYHEDRAL_SUPPORT
414  else if ( object->dataType(DATA_POLYHEDRAL_MESH) ) {
415 
417  OpenVolumeMesh::StatusAttrib& statusAttrib = ((PolyhedralMeshObject*)object)->status();
418  OpenVolumeMesh::VertexIter v_it = mesh.vertices_begin();
419  OpenVolumeMesh::VertexIter v_end = mesh.vertices_end();
420  for (; v_it != v_end; ++v_it)
421  if (statusAttrib[*v_it].selected()) {
422  noneSelected = false;
423  mesh.set_vertex(*v_it, mesh.vertex(*v_it) + _vector );
424  }
425  }
426 #endif
427 #ifdef ENABLE_BSPLINE_CURVE_SUPPORT
428  else if ( object->dataType(DATA_BSPLINE_CURVE) ) {
429  std::cerr << "Todo : translate BSplineCurve" << std::endl;
430  }
431 #endif
432 
433  if (noneSelected)
434  return;
435 
436  emit updatedObject(_objectId, UPDATE_GEOMETRY);
437 
438  emit scriptInfo( "translate( ObjectId , Vector(" +
439  QString::number( _vector[0] ) + " , " +
440  QString::number( _vector[1] ) + " , " +
441  QString::number( _vector[2] ) + " ) )" );
442 }
443 
444 
445 //------------------------------------------------------------------------------
446 
452 void MovePlugin::translateFaceSelection( int _objectId , Vector _vector) {
453 
454  BaseObjectData* object;
455  if ( ! PluginFunctions::getObject(_objectId,object) ) {
456  emit log(LOGERR,tr("translate : unable to get object" ));
457  return;
458  }
459 
460  bool noneSelected = true;
461 
462  if ( object->dataType( DATA_TRIANGLE_MESH ) ) {
463 
464  TriMesh& mesh = (*PluginFunctions::triMesh(object));
465 
466  // clear tags
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);
470 
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() )
475  {
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);
479  }
480  }
481 
482  if (noneSelected)
483  return;
484 
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 );
488 
489  } else if ( object->dataType( DATA_POLY_MESH ) ) {
490 
491  PolyMesh& mesh = (*PluginFunctions::polyMesh(object));
492 
493  // clear tags
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);
497 
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() )
502  {
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);
506  }
507  }
508 
509  if (noneSelected)
510  return;
511 
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 );
515  }
516 #ifdef ENABLE_TSPLINEMESH_SUPPORT
517  else if ( object->dataType( DATA_TSPLINE_MESH ) ) {
518 
519  TSplineMesh& mesh = (*PluginFunctions::tsplineMesh(object));
520 
521  // clear tags
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);
525 
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() )
530  {
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);
534  }
535  }
536 
537  if (noneSelected)
538  return;
539 
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 );
543  }
544 #endif
545 
546  #ifdef ENABLE_POLYLINE_SUPPORT
547  else if ( object->dataType(DATA_POLY_LINE) ) {
548 
549  PolyLine& line = (* PluginFunctions::polyLine(object) );
550 
551  for ( int i = 0 ; i < (int)line.n_vertices(); ++i )
552  if ( line.vertex_selection(i) ) {
553  noneSelected = false;
554  line.point(i) = line.point(i) + _vector;
555  }
556 
557  if (noneSelected)
558  return;
559  }
560  #endif
561  #ifdef ENABLE_BSPLINE_CURVE_SUPPORT
562  else if ( object->dataType(DATA_BSPLINE_CURVE) ) {
563  std::cerr << "Todo : translate BSplineCurve" << std::endl;
564  }
565  #endif
566 
567  emit updatedObject(_objectId, UPDATE_GEOMETRY);
568 
569  emit scriptInfo( "translate( ObjectId , Vector(" +
570  QString::number( _vector[0] ) + " , " +
571  QString::number( _vector[1] ) + " , " +
572  QString::number( _vector[2] ) + " ) )" );
573 
574 }
575 
576 
577 //------------------------------------------------------------------------------
578 
584 void MovePlugin::translateEdgeSelection( int _objectId , Vector _vector) {
585 
586  BaseObjectData* object;
587  if ( ! PluginFunctions::getObject(_objectId,object) ) {
588  emit log(LOGERR,tr("translate : unable to get object" ));
589  return;
590  }
591 
592  bool noneSelected = true;
593 
594  if ( object->dataType( DATA_TRIANGLE_MESH ) ) {
595 
596  TriMesh& mesh = (*PluginFunctions::triMesh(object));
597 
598  // clear tags
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);
602 
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() )
607  {
608  noneSelected = false;
609  TriMesh::HalfedgeHandle hh = mesh.halfedge_handle( *e_it, 0 );
610 
611  mesh.status( mesh.from_vertex_handle( hh ) ).set_tagged(true);
612  mesh.status( mesh.to_vertex_handle( hh ) ).set_tagged(true);
613  }
614 
615  if (noneSelected)
616  return;
617 
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 );
621  }
622 
623  } else if ( object->dataType( DATA_POLY_MESH ) ) {
624 
625  PolyMesh& mesh = (*PluginFunctions::polyMesh(object));
626 
627  // clear tags
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);
631 
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() )
636  {
637  noneSelected = false;
638  PolyMesh::HalfedgeHandle hh = mesh.halfedge_handle( *e_it, 0 );
639 
640  mesh.status( mesh.from_vertex_handle( hh ) ).set_tagged(true);
641  mesh.status( mesh.to_vertex_handle( hh ) ).set_tagged(true);
642  }
643 
644  if (noneSelected)
645  return;
646 
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 );
650  }
651  }
652 #ifdef ENABLE_TSPLINEMESH_SUPPORT
653  else if ( object->dataType( DATA_TSPLINE_MESH ) ) {
654 
655  TSplineMesh& mesh = (*PluginFunctions::tsplineMesh(object));
656 
657  // clear tags
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);
661 
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() )
666  {
667  noneSelected = false;
668  PolyMesh::HalfedgeHandle hh = mesh.halfedge_handle( e_it, 0 );
669 
670  mesh.status( mesh.from_vertex_handle( hh ) ).set_tagged(true);
671  mesh.status( mesh.to_vertex_handle( hh ) ).set_tagged(true);
672  }
673 
674  if (noneSelected)
675  return;
676 
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 );
680  }
681  }
682 #endif
683 
684  #ifdef ENABLE_POLYLINE_SUPPORT
685  else if ( object->dataType(DATA_POLY_LINE) ) {
686 
687  PolyLine& line = (* PluginFunctions::polyLine(object) );
688 
689  for ( int i = 0 ; i < (int)line.n_vertices(); ++i )
690  if ( line.vertex_selection(i) ) {
691  noneSelected = false;
692  line.point(i) = line.point(i) + _vector;
693  }
694 
695  if (noneSelected)
696  return;
697  }
698  #endif
699  #ifdef ENABLE_BSPLINE_CURVE_SUPPORT
700  else if ( object->dataType(DATA_BSPLINE_CURVE) ) {
701  std::cerr << "Todo : translate BSplineCurve" << std::endl;
702  }
703  #endif
704 
705  emit updatedObject(_objectId, UPDATE_GEOMETRY);
706 
707  emit scriptInfo( "translate( ObjectId , Vector(" +
708  QString::number( _vector[0] ) + " , " +
709  QString::number( _vector[1] ) + " , " +
710  QString::number( _vector[2] ) + " ) )" );
711 
712 }
713 //------------------------------------------------------------------------------
714 
715 void MovePlugin::transformHandleRegion(int _objectId, Matrix4x4 _matrix) {
716 
717  BaseObjectData* object = NULL;
718  if (!PluginFunctions::getObject(_objectId, object)) {
719  emit log(LOGERR, tr("transformHandleRegion: Unable to get object!"));
720  return;
721  }
722 
723  if(object->dataType(DATA_TRIANGLE_MESH)) {
724 
725  TriMesh& mesh = (*PluginFunctions::triMesh(object));
726 
728 
729  } else if(object->dataType(DATA_POLY_MESH)) {
730 
731  PolyMesh& mesh = (*PluginFunctions::polyMesh(object));
732 
734  }
735 
736  emit updatedObject(_objectId, UPDATE_GEOMETRY);
737 }
738 
739 //------------------------------------------------------------------------------
740 
746 void MovePlugin::transform( int _objectId , Matrix4x4 _matrix ){
747 
748  BaseObjectData* object;
749  if ( ! PluginFunctions::getObject(_objectId,object) ) {
750  emit log(LOGERR,tr("transform : unable to get object" ));
751  return;
752  }
753 
754  Matrix4x4 normalMatrix = _matrix;
755  normalMatrix.invert();
756  normalMatrix.transpose();
757 
758  if ( object->dataType( DATA_TRIANGLE_MESH ) ) {
759 
760  TriMesh& mesh = (*PluginFunctions::triMesh(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) ) );
766  }
767 
768  } else if ( object->dataType( DATA_POLY_MESH ) ) {
769 
770  PolyMesh& mesh = (*PluginFunctions::polyMesh(object));
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) ) );
776  }
777  }
778 #ifdef ENABLE_TSPLINEMESH_SUPPORT
779  else if ( object->dataType( DATA_TSPLINE_MESH ) ) {
780 
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){
785  mesh.set_point (v_it, _matrix.transform_point ( mesh.point(v_it) ) );
786  mesh.set_normal(v_it, normalMatrix.transform_vector( mesh.normal(v_it) ) );
787  }
788  }
789 #endif
790 #ifdef ENABLE_POLYLINE_SUPPORT
791  else if ( object->dataType(DATA_POLY_LINE) ) {
792 
793  PolyLine& line = (* PluginFunctions::polyLine(object) );
794 
795  for ( int i = 0 ; i < (int)line.n_vertices(); ++i )
796  line.point(i) = _matrix.transform_point( line.point(i) );
797  }
798 #endif
799 #ifdef ENABLE_OPENVOLUMEMESH_HEXAHEDRAL_SUPPORT
800  else if ( object->dataType(DATA_HEXAHEDRAL_MESH) ) {
801 
803  OpenVolumeMesh::NormalAttrib<HexahedralMesh>& normalAttrib = ((HexahedralMeshObject*)object)->normals();
804  OpenVolumeMesh::VertexIter v_it = mesh.vertices_begin();
805  OpenVolumeMesh::VertexIter v_end = mesh.vertices_end();
806  for (; v_it != v_end; ++v_it) {
807  mesh.set_vertex(*v_it, _matrix.transform_point ( mesh.vertex(*v_it) ) );
808  normalAttrib[*v_it] = normalMatrix.transform_vector( normalAttrib[*v_it] );
809  }
810  }
811 #endif
812 #ifdef ENABLE_OPENVOLUMEMESH_POLYHEDRAL_SUPPORT
813  else if ( object->dataType(DATA_POLYHEDRAL_MESH) ) {
814 
816  OpenVolumeMesh::NormalAttrib<PolyhedralMesh>& normalAttrib = ((PolyhedralMeshObject*)object)->normals();
817  OpenVolumeMesh::VertexIter v_it = mesh.vertices_begin();
818  OpenVolumeMesh::VertexIter v_end = mesh.vertices_end();
819  for (; v_it != v_end; ++v_it) {
820  mesh.set_vertex(*v_it, _matrix.transform_point ( mesh.vertex(*v_it) ) );
821  normalAttrib[*v_it] = normalMatrix.transform_vector( normalAttrib[*v_it] );
822  }
823  }
824 #endif
825 #ifdef ENABLE_BSPLINE_CURVE_SUPPORT
826  else if ( object->dataType(DATA_BSPLINE_CURVE) ) {
827  std::cerr << "Todo : transform BSplineCurve" << std::endl;
828  }
829 #endif
830 
831  emit updatedObject(_objectId, UPDATE_GEOMETRY);
832 
833  QString matString;
834  for (int i=0; i < 4; i++)
835  for (int j=0; j < 4; j++)
836  matString += " , " + QString::number( _matrix(i,j) );
837 
838  matString = matString.right( matString.length()-3 );
839 
840  emit scriptInfo( "transform( ObjectId , Matrix4x4(" + matString + " ) )" );
841 }
842 
843 
844 //------------------------------------------------------------------------------
845 
852 void MovePlugin::transform( int _objectId , IdList _vHandles, Matrix4x4 _matrix ){
853 
854  BaseObjectData* object;
855  if ( ! PluginFunctions::getObject(_objectId,object) ) {
856  emit log(LOGERR,tr("transform : unable to get object" ));
857  return;
858  }
859 
860  Matrix4x4 normalMatrix = _matrix;
861  normalMatrix.invert();
862  normalMatrix.transpose();
863 
864  if ( object->dataType( DATA_TRIANGLE_MESH ) ) {
865 
866  TriMesh& mesh = (*PluginFunctions::triMesh(object));
867 
868  for (uint i=0; i < _vHandles.size(); i++){
869  TriMesh::VertexHandle vh( _vHandles[i] );
870  mesh.set_point (vh, _matrix.transform_point ( mesh.point(vh) ) );
871  mesh.set_normal(vh, normalMatrix.transform_vector( mesh.normal(vh) ) );
872  }
873 
874  } else if ( object->dataType( DATA_POLY_MESH ) ) {
875 
876  PolyMesh& mesh = (*PluginFunctions::polyMesh(object));
877 
878  for (uint i=0; i < _vHandles.size(); i++){
879  PolyMesh::VertexHandle vh( _vHandles[i] );
880  mesh.set_point (vh, _matrix.transform_point ( mesh.point(vh) ) );
881  mesh.set_normal(vh, normalMatrix.transform_vector( mesh.normal(vh) ) );
882  }
883  }
884 #ifdef ENABLE_TSPLINEMESH_SUPPORT
885  else if ( object->dataType( DATA_TSPLINE_MESH ) ) {
886 
887  TSplineMesh& mesh = (*PluginFunctions::tsplineMesh(object));
888 
889  for (uint i=0; i < _vHandles.size(); i++){
890  TSplineMesh::VertexHandle vh( _vHandles[i] );
891  mesh.set_point (vh, _matrix.transform_point ( mesh.point(vh) ) );
892  mesh.set_normal(vh, normalMatrix.transform_vector( mesh.normal(vh) ) );
893  }
894  }
895 #endif
896 #ifdef ENABLE_POLYLINE_SUPPORT
897  else if ( object->dataType(DATA_POLY_LINE) ) {
898 
899  PolyLine& line = (* PluginFunctions::polyLine(object) );
900 
901  const int max = line.n_vertices();
902 
903  for ( unsigned int i = 0 ; i < _vHandles.size(); ++i )
904  if ( (_vHandles[i] > 0) && ( _vHandles[i] < max ) )
905  line.point( _vHandles[i] ) = _matrix.transform_point( line.point( _vHandles[i] ) );
906 
907  }
908 #endif
909 #ifdef ENABLE_OPENVOLUMEMESH_HEXAHEDRAL_SUPPORT
910  else if ( object->dataType(DATA_HEXAHEDRAL_MESH) ) {
911 
913  OpenVolumeMesh::NormalAttrib<HexahedralMesh>& normalAttrib = ((HexahedralMeshObject*)object)->normals();
914  for (unsigned int i = 0; i < _vHandles.size(); ++i) {
915  OpenVolumeMesh::VertexHandle v(_vHandles[i]);
916  mesh.set_vertex(v, _matrix.transform_point ( mesh.vertex(v) ) );
917  normalAttrib[v] = normalMatrix.transform_vector( normalAttrib[v] );
918  }
919  }
920 #endif
921 #ifdef ENABLE_OPENVOLUMEMESH_POLYHEDRAL_SUPPORT
922  else if ( object->dataType(DATA_POLYHEDRAL_MESH) ) {
923 
925  OpenVolumeMesh::NormalAttrib<PolyhedralMesh>& normalAttrib = ((PolyhedralMeshObject*)object)->normals();
926  for (unsigned int i = 0; i < _vHandles.size(); ++i) {
927  OpenVolumeMesh::VertexHandle v(_vHandles[i]);
928  mesh.set_vertex(v, _matrix.transform_point ( mesh.vertex(v) ) );
929  normalAttrib[v] = normalMatrix.transform_vector( normalAttrib[v] );
930  }
931  }
932 #endif
933 #ifdef ENABLE_BSPLINE_CURVE_SUPPORT
934  else if ( object->dataType(DATA_BSPLINE_CURVE) ) {
935  std::cerr << "Todo : transform BSplineCurve" << std::endl;
936  }
937 #endif
938 
939  emit updatedObject(_objectId, UPDATE_GEOMETRY);
940 
941  QString matString;
942  for (int i=0; i < 4; i++)
943  for (int j=0; j < 4; j++)
944  matString += " , " + QString::number( _matrix(i,j) );
945 
946  matString = matString.right( matString.length()-3 );
947 
948  emit scriptInfo( "transform( ObjectId , Matrix4x4(" + matString + " ) )" );
949 
950 }
951 
952 
953 //------------------------------------------------------------------------------
954 
962 bool MovePlugin::transformVertexSelection( int _objectId , Matrix4x4 _matrix ){
963  BaseObjectData* object;
964  if ( ! PluginFunctions::getObject(_objectId,object) ) {
965  emit log(LOGERR,tr("transform : unable to get object") );
966  return false;
967  }
968 
969  Matrix4x4 normalMatrix = _matrix;
970  normalMatrix.invert();
971  normalMatrix.transpose();
972 
973  bool noneSelected = true;
974  if ( object->dataType( DATA_TRIANGLE_MESH ) ) {
975 
976  TriMesh& mesh = (*PluginFunctions::triMesh(object));
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() )
981  {
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) ) );
985  }
986 
987  } else if ( object->dataType( DATA_POLY_MESH ) ) {
988 
989  PolyMesh& mesh = (*PluginFunctions::polyMesh(object));
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() )
994  {
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) ) );
998  }
999  }
1000 #ifdef ENABLE_TSPLINEMESH_SUPPORT
1001  else if ( object->dataType( DATA_TSPLINE_MESH ) ) {
1002 
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() )
1008  {
1009  noneSelected = false;
1010  mesh.set_point (v_it, _matrix.transform_point ( mesh.point(v_it) ) );
1011  mesh.set_normal(v_it, normalMatrix.transform_vector( mesh.normal(v_it) ) );
1012  }
1013  }
1014 #endif
1015 #ifdef ENABLE_POLYLINE_SUPPORT
1016  else if ( object->dataType(DATA_POLY_LINE) ) {
1017 
1018  PolyLine& line = (* PluginFunctions::polyLine(object) );
1019 
1020  for ( int i = 0 ; i < (int)line.n_vertices(); ++i )
1021  if ( line.vertex_selection(i) ) {
1022  noneSelected = false;
1023  line.point(i) = _matrix.transform_point( line.point(i) );
1024  }
1025  }
1026 #endif
1027 #ifdef ENABLE_BSPLINE_CURVE_SUPPORT
1028  else if ( object->dataType(DATA_BSPLINE_CURVE) ) {
1029  std::cerr << "Todo : transform BSplineCurve" << std::endl;
1030  }
1031 #endif
1032 #ifdef ENABLE_OPENVOLUMEMESH_HEXAHEDRAL_SUPPORT
1033  else if ( object->dataType(DATA_HEXAHEDRAL_MESH) ) {
1035  OpenVolumeMesh::NormalAttrib<HexahedralMesh>& normalAttrib = ((HexahedralMeshObject*)object)->normals();
1036  OpenVolumeMesh::StatusAttrib& statusAttrib = ((HexahedralMeshObject*)object)->status();
1037  OpenVolumeMesh::VertexIter v_it = mesh.vertices_begin();
1038  OpenVolumeMesh::VertexIter v_end = mesh.vertices_end();
1039  for (; v_it!=v_end; ++v_it)
1040  if ( statusAttrib[*v_it].selected() )
1041  {
1042  noneSelected = false;
1043  mesh.set_vertex(*v_it, _matrix.transform_point ( mesh.vertex(*v_it) ) );
1044  normalAttrib[*v_it] = normalMatrix.transform_vector( normalAttrib[*v_it] );
1045  }
1046  }
1047 #endif
1048 #ifdef ENABLE_OPENVOLUMEMESH_POLYHEDRAL_SUPPORT
1049  else if ( object->dataType(DATA_POLYHEDRAL_MESH) ) {
1051  OpenVolumeMesh::NormalAttrib<PolyhedralMesh>& normalAttrib = ((PolyhedralMeshObject*)object)->normals();
1052  OpenVolumeMesh::StatusAttrib& statusAttrib = ((PolyhedralMeshObject*)object)->status();
1053  OpenVolumeMesh::VertexIter v_it = mesh.vertices_begin();
1054  OpenVolumeMesh::VertexIter v_end = mesh.vertices_end();
1055  for (; v_it!=v_end; ++v_it)
1056  if ( statusAttrib[*v_it].selected() )
1057  {
1058  noneSelected = false;
1059  mesh.set_vertex(*v_it, _matrix.transform_point ( mesh.vertex(*v_it) ) );
1060  normalAttrib[*v_it] = normalMatrix.transform_vector( normalAttrib[*v_it] );
1061  }
1062  }
1063 #endif
1064 
1065  if (noneSelected)
1066  return false;
1067 
1068  emit updatedObject(_objectId, UPDATE_GEOMETRY);
1069 
1070  QString matString;
1071  for (int i=0; i < 4; i++)
1072  for (int j=0; j < 4; j++)
1073  matString += " , " + QString::number( _matrix(i,j) );
1074 
1075  matString = matString.right( matString.length()-3 );
1076 
1077  emit scriptInfo( "transformVertexSelection( ObjectId , Matrix4x4(" + matString + " ) )" );
1078 
1079  return true;
1080 }
1081 
1082 
1083 //------------------------------------------------------------------------------
1084 
1092 bool MovePlugin::transformFaceSelection( int _objectId , Matrix4x4 _matrix ){
1093  BaseObjectData* object;
1094  if ( ! PluginFunctions::getObject(_objectId,object) ) {
1095  emit log(LOGERR,tr("transform : unable to get object") );
1096  return false;
1097  }
1098 
1099  Matrix4x4 normalMatrix = _matrix;
1100  normalMatrix.invert();
1101  normalMatrix.transpose();
1102 
1103  bool noneSelected = true;
1104  if ( object->dataType( DATA_TRIANGLE_MESH ) ) {
1105 
1106  TriMesh& mesh = (*PluginFunctions::triMesh(object));
1107 
1108  //init tags
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);
1112 
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() )
1117  {
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);
1121  }
1122 
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) ) );
1127  }
1128 
1129  } else if ( object->dataType( DATA_POLY_MESH ) ) {
1130 
1131  PolyMesh& mesh = (*PluginFunctions::polyMesh(object));
1132 
1133  //init tags
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);
1137 
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() )
1142  {
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);
1146  }
1147 
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) ) );
1152  }
1153  }
1154 #ifdef ENABLE_TSPLINEMESH_SUPPORT
1155  else if ( object->dataType( DATA_TSPLINE_MESH ) ) {
1156 
1157  TSplineMesh& mesh = (*PluginFunctions::tsplineMesh(object));
1158 
1159  //init tags
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);
1163 
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() )
1168  {
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);
1172  }
1173 
1174  for (v_it=mesh.vertices_begin(); v_it!=v_end; ++v_it)
1175  if ( mesh.status(v_it).tagged() ){
1176  mesh.set_point (v_it, _matrix.transform_point ( mesh.point(v_it) ) );
1177  mesh.set_normal(v_it, normalMatrix.transform_vector( mesh.normal(v_it) ) );
1178  }
1179  }
1180 #endif
1181 #ifdef ENABLE_OPENVOLUMEMESH_HEXAHEDRAL_SUPPORT
1182  if ( object->dataType( DATA_HEXAHEDRAL_MESH ) ) {
1183 
1185  OpenVolumeMesh::NormalAttrib<HexahedralMesh>& normalAttrib = ((HexahedralMeshObject*)object)->normals();
1186  OpenVolumeMesh::StatusAttrib& statusAttrib = ((HexahedralMeshObject*)object)->status();
1187  OpenVolumeMesh::VertexIter v_begin = mesh.vertices_begin();
1188  OpenVolumeMesh::VertexIter v_end = mesh.vertices_end();
1189 
1190  //init tags
1191  for (OpenVolumeMesh::VertexIter v_it = v_begin; v_it!=v_end; ++v_it)
1192  statusAttrib[*v_it].set_tagged(false);
1193 
1194  OpenVolumeMesh::FaceIter f_it = mesh.faces_begin();
1195  OpenVolumeMesh::FaceIter f_end = mesh.faces_end();
1196  for (; f_it!=f_end; ++f_it)
1197  if ( statusAttrib[*f_it].selected() )
1198  {
1199  noneSelected = false;
1200  for (OpenVolumeMesh::HalfFaceVertexIter hfv_it = mesh.hfv_iter(mesh.halfface_handle(*f_it,0)); hfv_it.valid(); ++hfv_it)
1201  statusAttrib[*hfv_it].set_tagged(true);
1202  }
1203 
1204  for (OpenVolumeMesh::VertexIter v_it = v_begin; v_it!=v_end; ++v_it)
1205  if ( statusAttrib[*v_it].tagged() )
1206  {
1207  mesh.set_vertex(*v_it, _matrix.transform_point ( mesh.vertex(*v_it) ) );
1208  normalAttrib[*v_it] = normalMatrix.transform_vector( normalAttrib[*v_it] );
1209  }
1210 
1211  }
1212 #endif
1213 #ifdef ENABLE_OPENVOLUMEMESH_POLYHEDRAL_SUPPORT
1214  else if ( object->dataType( DATA_POLYHEDRAL_MESH ) ) {
1215 
1217  OpenVolumeMesh::NormalAttrib<PolyhedralMesh>& normalAttrib = ((PolyhedralMeshObject*)object)->normals();
1218  OpenVolumeMesh::StatusAttrib& statusAttrib = ((PolyhedralMeshObject*)object)->status();
1219  OpenVolumeMesh::VertexIter v_begin = mesh.vertices_begin();
1220  OpenVolumeMesh::VertexIter v_end = mesh.vertices_end();
1221 
1222  //init tags
1223  for (OpenVolumeMesh::VertexIter v_it = v_begin; v_it!=v_end; ++v_it)
1224  statusAttrib[*v_it].set_tagged(false);
1225 
1226  OpenVolumeMesh::FaceIter f_it = mesh.faces_begin();
1227  OpenVolumeMesh::FaceIter f_end = mesh.faces_end();
1228  for (; f_it!=f_end; ++f_it)
1229  if ( statusAttrib[*f_it].selected() )
1230  {
1231  noneSelected = false;
1232  for (OpenVolumeMesh::HalfFaceVertexIter hfv_it = mesh.hfv_iter(mesh.halfface_handle(*f_it,0)); hfv_it.valid(); ++hfv_it)
1233  statusAttrib[*hfv_it].set_tagged(true);
1234  }
1235 
1236  for (OpenVolumeMesh::VertexIter v_it = v_begin; v_it!=v_end; ++v_it)
1237  if ( statusAttrib[*v_it].tagged() )
1238  {
1239  mesh.set_vertex(*v_it, _matrix.transform_point ( mesh.vertex(*v_it) ) );
1240  normalAttrib[*v_it] = normalMatrix.transform_vector( normalAttrib[*v_it] );
1241  }
1242  }
1243 #endif
1244 
1245  if (noneSelected)
1246  return false;
1247 
1248  emit updatedObject(_objectId, UPDATE_GEOMETRY);
1249 
1250  QString matString;
1251  for (int i=0; i < 4; i++)
1252  for (int j=0; j < 4; j++)
1253  matString += " , " + QString::number( _matrix(i,j) );
1254 
1255  matString = matString.right( matString.length()-3 );
1256 
1257  emit scriptInfo( "transformFaceSelection( ObjectId , Matrix4x4(" + matString + " ) )" );
1258 
1259  return true;
1260 }
1261 
1262 
1263 //------------------------------------------------------------------------------
1264 
1272 bool MovePlugin::transformEdgeSelection( int _objectId , Matrix4x4 _matrix ){
1273  BaseObjectData* object;
1274  if ( ! PluginFunctions::getObject(_objectId,object) ) {
1275  emit log(LOGERR,tr("transform : unable to get object" ) );
1276  return false;
1277  }
1278 
1279  Matrix4x4 normalMatrix = _matrix;
1280  normalMatrix.invert();
1281  normalMatrix.transpose();
1282 
1283  bool noneSelected = true;
1284  if ( object->dataType( DATA_TRIANGLE_MESH ) ) {
1285 
1286  TriMesh& mesh = (*PluginFunctions::triMesh(object));
1287 
1288  //init tags
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);
1292 
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() )
1297  {
1298  noneSelected = false;
1299  TriMesh::HalfedgeHandle hh = mesh.halfedge_handle( *e_it, 0 );
1300 
1301  mesh.status( mesh.from_vertex_handle( hh ) ).set_tagged(true);
1302  mesh.status( mesh.to_vertex_handle( hh ) ).set_tagged(true);
1303  }
1304 
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) ) );
1309  }
1310 
1311  } else if ( object->dataType( DATA_POLY_MESH ) ) {
1312 
1313  PolyMesh& mesh = (*PluginFunctions::polyMesh(object));
1314 
1315  //init tags
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);
1319 
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() )
1324  {
1325  noneSelected = false;
1326  PolyMesh::HalfedgeHandle hh = mesh.halfedge_handle( *e_it, 0 );
1327 
1328  mesh.status( mesh.from_vertex_handle( hh ) ).set_tagged(true);
1329  mesh.status( mesh.to_vertex_handle( hh ) ).set_tagged(true);
1330  }
1331 
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) ) );
1336  }
1337  }
1338 #ifdef ENABLE_TSPLINEMESH_SUPPORT
1339  else if ( object->dataType( DATA_TSPLINE_MESH ) ) {
1340 
1341  TSplineMesh& mesh = (*PluginFunctions::tsplineMesh(object));
1342 
1343  //init tags
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);
1347 
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() )
1352  {
1353  noneSelected = false;
1354  TSplineMesh::HalfedgeHandle hh = mesh.halfedge_handle( e_it, 0 );
1355 
1356  mesh.status( mesh.from_vertex_handle( hh ) ).set_tagged(true);
1357  mesh.status( mesh.to_vertex_handle( hh ) ).set_tagged(true);
1358  }
1359 
1360  for (v_it=mesh.vertices_begin(); v_it!=v_end; ++v_it)
1361  if ( mesh.status(v_it).tagged() ){
1362  mesh.set_point (v_it, _matrix.transform_point ( mesh.point(v_it) ) );
1363  mesh.set_normal(v_it, normalMatrix.transform_vector( mesh.normal(v_it) ) );
1364  }
1365  }
1366 #endif
1367 #ifdef ENABLE_OPENVOLUMEMESH_HEXAHEDRAL_SUPPORT
1368  if ( object->dataType( DATA_HEXAHEDRAL_MESH ) ) {
1369 
1371  OpenVolumeMesh::NormalAttrib<HexahedralMesh>& normalAttrib = ((HexahedralMeshObject*)object)->normals();
1372  OpenVolumeMesh::StatusAttrib& statusAttrib = ((HexahedralMeshObject*)object)->status();
1373  OpenVolumeMesh::VertexIter v_begin = mesh.vertices_begin();
1374  OpenVolumeMesh::VertexIter v_end = mesh.vertices_end();
1375 
1376  //init tags
1377  for (OpenVolumeMesh::VertexIter v_it = v_begin; v_it!=v_end; ++v_it)
1378  statusAttrib[*v_it].set_tagged(false);
1379 
1380  OpenVolumeMesh::EdgeIter e_it = mesh.edges_begin();
1381  OpenVolumeMesh::EdgeIter e_end = mesh.edges_end();
1382  for (; e_it!=e_end; ++e_it)
1383  if ( statusAttrib[*e_it].selected() )
1384  {
1385  noneSelected = false;
1386  OpenVolumeMesh::OpenVolumeMeshEdge e(mesh.edge(*e_it));
1387  statusAttrib[e.from_vertex()].set_tagged(true);
1388  statusAttrib[e.to_vertex()].set_tagged(true);
1389  }
1390 
1391  for (OpenVolumeMesh::VertexIter v_it = v_begin; v_it!=v_end; ++v_it)
1392  if ( statusAttrib[*v_it].tagged() )
1393  {
1394  mesh.set_vertex(*v_it, _matrix.transform_point ( mesh.vertex(*v_it) ) );
1395  normalAttrib[*v_it] = normalMatrix.transform_vector( normalAttrib[*v_it] );
1396  }
1397 
1398  }
1399 #endif
1400 #ifdef ENABLE_OPENVOLUMEMESH_POLYHEDRAL_SUPPORT
1401  if ( object->dataType( DATA_POLYHEDRAL_MESH ) ) {
1402 
1404  OpenVolumeMesh::NormalAttrib<PolyhedralMesh>& normalAttrib = ((PolyhedralMeshObject*)object)->normals();
1405  OpenVolumeMesh::StatusAttrib& statusAttrib = ((PolyhedralMeshObject*)object)->status();
1406  OpenVolumeMesh::VertexIter v_begin = mesh.vertices_begin();
1407  OpenVolumeMesh::VertexIter v_end = mesh.vertices_end();
1408 
1409  //init tags
1410  for (OpenVolumeMesh::VertexIter v_it = v_begin; v_it!=v_end; ++v_it)
1411  statusAttrib[*v_it].set_tagged(false);
1412 
1413  OpenVolumeMesh::EdgeIter e_it = mesh.edges_begin();
1414  OpenVolumeMesh::EdgeIter e_end = mesh.edges_end();
1415  for (; e_it!=e_end; ++e_it)
1416  if ( statusAttrib[*e_it].selected() )
1417  {
1418  noneSelected = false;
1419  OpenVolumeMesh::OpenVolumeMeshEdge e(mesh.edge(*e_it));
1420  statusAttrib[e.from_vertex()].set_tagged(true);
1421  statusAttrib[e.to_vertex()].set_tagged(true);
1422  }
1423 
1424  for (OpenVolumeMesh::VertexIter v_it = v_begin; v_it!=v_end; ++v_it)
1425  if ( statusAttrib[*v_it].tagged() )
1426  {
1427  mesh.set_vertex(*v_it, _matrix.transform_point ( mesh.vertex(*v_it) ) );
1428  normalAttrib[*v_it] = normalMatrix.transform_vector( normalAttrib[*v_it] );
1429  }
1430 
1431  }
1432 #endif
1433 
1434  #ifdef ENABLE_POLYLINE_SUPPORT
1435  else if ( object->dataType(DATA_POLY_LINE) ) {
1436  std::cerr << "Todo : transform PolyLine" << std::endl;
1437  }
1438  #endif
1439  #ifdef ENABLE_BSPLINE_CURVE_SUPPORT
1440  else if ( object->dataType(DATA_BSPLINE_CURVE) ) {
1441  std::cerr << "Todo : transform BSplineCurve" << std::endl;
1442  }
1443  #endif
1444 
1445  if (noneSelected)
1446  return false;
1447 
1448  emit updatedObject(_objectId, UPDATE_GEOMETRY);
1449 
1450  QString matString;
1451  for (int i=0; i < 4; i++)
1452  for (int j=0; j < 4; j++)
1453  matString += " , " + QString::number( _matrix(i,j) );
1454 
1455  matString = matString.right( matString.length()-3 );
1456 
1457  emit scriptInfo( "transformEdgeSelection( ObjectId , Matrix4x4(" + matString + " ) )" );
1458 
1459  return true;
1460 }
1461 
1462 //------------------------------------------------------------------------------
1463 
1471 bool MovePlugin::transformCellSelection( int _objectId , Matrix4x4 _matrix ){
1472  BaseObjectData* object;
1473  if ( ! PluginFunctions::getObject(_objectId,object) ) {
1474  emit log(LOGERR,tr("transform : unable to get object") );
1475  return false;
1476  }
1477 
1478  Matrix4x4 normalMatrix = _matrix;
1479  normalMatrix.invert();
1480  normalMatrix.transpose();
1481 
1482  bool noneSelected = true;
1483 
1484 #ifdef ENABLE_OPENVOLUMEMESH_HEXAHEDRAL_SUPPORT
1485  if ( object->dataType( DATA_HEXAHEDRAL_MESH ) ) {
1486 
1488  OpenVolumeMesh::NormalAttrib<HexahedralMesh>& normalAttrib = ((HexahedralMeshObject*)object)->normals();
1489  OpenVolumeMesh::StatusAttrib& statusAttrib = ((HexahedralMeshObject*)object)->status();
1490  OpenVolumeMesh::VertexIter v_begin = mesh.vertices_begin();
1491  OpenVolumeMesh::VertexIter v_end = mesh.vertices_end();
1492 
1493  //init tags
1494  for (OpenVolumeMesh::VertexIter v_it = v_begin; v_it!=v_end; ++v_it)
1495  statusAttrib[*v_it].set_tagged(false);
1496 
1497  OpenVolumeMesh::CellIter c_it = mesh.cells_begin();
1498  OpenVolumeMesh::CellIter c_end = mesh.cells_end();
1499  for (; c_it!=c_end; ++c_it)
1500  if ( statusAttrib[*c_it].selected() )
1501  {
1502  noneSelected = false;
1503  for (OpenVolumeMesh::CellVertexIter cv_it = mesh.cv_iter(*c_it); cv_it.valid(); ++cv_it)
1504  statusAttrib[*cv_it].set_tagged(true);
1505  }
1506 
1507  for (OpenVolumeMesh::VertexIter v_it = v_begin; v_it!=v_end; ++v_it)
1508  if ( statusAttrib[*v_it].tagged() )
1509  {
1510  mesh.set_vertex(*v_it, _matrix.transform_point ( mesh.vertex(*v_it) ) );
1511  normalAttrib[*v_it] = normalMatrix.transform_vector( normalAttrib[*v_it] );
1512  }
1513 
1514  }
1515 #endif
1516 #ifdef ENABLE_OPENVOLUMEMESH_POLYHEDRAL_SUPPORT
1517  else if ( object->dataType( DATA_POLYHEDRAL_MESH ) ) {
1518 
1520  OpenVolumeMesh::NormalAttrib<PolyhedralMesh>& normalAttrib = ((PolyhedralMeshObject*)object)->normals();
1521  OpenVolumeMesh::StatusAttrib& statusAttrib = ((PolyhedralMeshObject*)object)->status();
1522  OpenVolumeMesh::VertexIter v_begin = mesh.vertices_begin();
1523  OpenVolumeMesh::VertexIter v_end = mesh.vertices_end();
1524 
1525  //init tags
1526  for (OpenVolumeMesh::VertexIter v_it = v_begin; v_it!=v_end; ++v_it)
1527  statusAttrib[*v_it].set_tagged(false);
1528 
1529  OpenVolumeMesh::CellIter c_it = mesh.cells_begin();
1530  OpenVolumeMesh::CellIter c_end = mesh.cells_end();
1531  for (; c_it!=c_end; ++c_it)
1532  if ( statusAttrib[*c_it].selected() )
1533  {
1534  noneSelected = false;
1535  for (OpenVolumeMesh::CellVertexIter cv_it = mesh.cv_iter(*c_it); cv_it.valid(); ++cv_it)
1536  statusAttrib[*cv_it].set_tagged(true);
1537  }
1538 
1539  for (OpenVolumeMesh::VertexIter v_it = v_begin; v_it!=v_end; ++v_it)
1540  if ( statusAttrib[*v_it].tagged() )
1541  {
1542  mesh.set_vertex(*v_it, _matrix.transform_point ( mesh.vertex(*v_it) ) );
1543  normalAttrib[*v_it] = normalMatrix.transform_vector( normalAttrib[*v_it] );
1544  }
1545  }
1546 #endif
1547 
1548  if (noneSelected)
1549  return false;
1550 
1551  emit updatedObject(_objectId, UPDATE_GEOMETRY);
1552 
1553  QString matString;
1554  for (int i=0; i < 4; i++)
1555  for (int j=0; j < 4; j++)
1556  matString += " , " + QString::number( _matrix(i,j) );
1557 
1558  matString = matString.right( matString.length()-3 );
1559 
1560  emit scriptInfo( "transformCellSelection( ObjectId , Matrix4x4(" + matString + " ) )" );
1561 
1562  return true;
1563 }
1564 
1565 
1566 //------------------------------------------------------------------------------
1567 
1573 void MovePlugin::setManipulatorPosition( int _objectId , Vector _position ){
1574 
1575  BaseObjectData* object;
1576  if ( ! PluginFunctions::getObject(_objectId,object) ) {
1577  emit log(LOGERR,tr("setManipulatorPosition : unable to get object") );
1578  return;
1579  }
1580 
1581 
1583 
1584 
1585  object->manipPlaced( true );
1586 
1587  object->manipulatorNode()->loadIdentity();
1588  object->manipulatorNode()->set_center(_position);
1589  object->manipulatorNode()->set_draw_cylinder(true);
1590  object->manipulatorNode()->set_size(manip_size_ * manip_size_modifier_);
1591  object->manipulatorNode()->show();
1592 
1593  connect(object->manipulatorNode() , SIGNAL(manipulatorMoved(QtTranslationManipulatorNode*,QMouseEvent*)),
1594  this , SLOT( manipulatorMoved(QtTranslationManipulatorNode*,QMouseEvent*)));
1595 
1596  connect(object->manipulatorNode() , SIGNAL(positionChanged(QtTranslationManipulatorNode*)),
1598 
1599  lastActiveManipulator_ = object->id();
1600 
1601  emit updateView();
1602 
1603  emit scriptInfo( "setManipulatorPosition( ObjectId , Vector(" +
1604  QString::number( _position[0] ) + " , " +
1605  QString::number( _position[1] ) + " , " +
1606  QString::number( _position[2] ) + " ) )" );
1607 }
1608 
1609 
1610 //------------------------------------------------------------------------------
1611 
1618 
1619  BaseObjectData* object;
1620  if ( ! PluginFunctions::getObject(_objectId,object) ) {
1621  emit log(LOGERR,tr("manipulatorPosition : unable to get object" ));
1622  return Vector();
1623  }
1624 
1625  return (Vector) object->manipulatorNode()->center();
1626 }
1627 
1628 
1629 //------------------------------------------------------------------------------
1630 
1637 void MovePlugin::setManipulatorDirection( int _objectId , Vector _directionX, Vector _directionY ){
1638 
1639  BaseObjectData* object;
1640  if ( ! PluginFunctions::getObject(_objectId,object) ) {
1641  emit log(LOGERR,tr("setManipulatorDirection : unable to get object") );
1642  return;
1643  }
1644 
1645  if ( !object->manipPlaced() ){
1646  emit log(LOGERR,tr("setManipulatorDirection : manipulator position has to be set first" ));
1647  return;
1648  }
1649 
1650  object->manipulatorNode()->set_direction(_directionX, _directionY);
1651 
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] ) + " ) )" );
1659 }
1660 
1661 
1662 //------------------------------------------------------------------------------
1663 
1670 
1671  BaseObjectData* object;
1672  if ( ! PluginFunctions::getObject(_objectId,object) ) {
1673  emit log(LOGERR,tr("manipulatorDirection : unable to get object" ));
1674  return Vector();
1675  }
1676 
1677  return (Vector) object->manipulatorNode()->directionX();
1678 }
1679 
1680 
1681 //------------------------------------------------------------------------------
1682 
1689 
1690  BaseObjectData* object;
1691  if ( ! PluginFunctions::getObject(_objectId,object) ) {
1692  emit log(LOGERR,tr("manipulatorDirection : unable to get object" ));
1693  return Vector();
1694  }
1695 
1696  return (Vector) object->manipulatorNode()->directionY();
1697 }
1698 
1699 
1700 //------------------------------------------------------------------------------
1701 
1708 
1709  BaseObjectData* object;
1710  if ( ! PluginFunctions::getObject(_objectId,object) ) {
1711  emit log(LOGERR,tr("manipulatorDirection : unable to get object" ));
1712  return Vector();
1713  }
1714 
1715  return (Vector) object->manipulatorNode()->directionZ();
1716 }
1717 
1718 //------------------------------------------------------------------------------
1719 
1721  BaseObjectData* object;
1722 
1723  if ( ! PluginFunctions::getObject(_objectId,object) ) {
1724  emit log(LOGERR,tr("objectRenderingMatrixIdentity : unable to get object" ));
1725  return ;
1726  }
1727 
1728  object->manipulatorNode()->loadIdentity();
1729 
1730  emit updatedObject(_objectId,UPDATE_VISIBILITY);
1731 }
1732 
1733 //------------------------------------------------------------------------------
1734 
1735 void MovePlugin::objectRenderingMatrixScale(int _objectId, double _s) {
1736  BaseObjectData* object;
1737 
1738  if ( ! PluginFunctions::getObject(_objectId,object) ) {
1739  emit log(LOGERR,tr("objectRenderingMatrixScale : unable to get object" ));
1740  return ;
1741  }
1742 
1743  object->manipulatorNode()->scale(_s);
1744 
1745  emit updatedObject(_objectId,UPDATE_VISIBILITY);
1746 }
1747 
1748 //------------------------------------------------------------------------------
1749 
1750 void MovePlugin::objectRenderingMatrixTranslate(int _objectId, Vector _translation) {
1751  BaseObjectData* object;
1752 
1753  if ( ! PluginFunctions::getObject(_objectId,object) ) {
1754  emit log(LOGERR,tr("objectRenderingMatrixTranslate : unable to get object" ));
1755  return ;
1756  }
1757 
1758  object->manipulatorNode()->translate(_translation);
1759 
1760  emit updatedObject(_objectId,UPDATE_VISIBILITY);
1761 }
1762 
1763 //------------------------------------------------------------------------------
1764 
1765 void MovePlugin::objectRenderingMatrixRotate(int _objectId, Vector _axis, double _angle) {
1766  BaseObjectData* object;
1767 
1768  if ( ! PluginFunctions::getObject(_objectId,object) ) {
1769  emit log(LOGERR,tr("objectRenderingMatrixRotate : unable to get object" ));
1770  return ;
1771  }
1772 
1773  object->manipulatorNode()->rotate(_angle,_axis);
1774 
1775  emit updatedObject(_objectId,UPDATE_VISIBILITY);
1776 }
1777 
1778 //------------------------------------------------------------------------------
1779 
1781  BaseObjectData* object;
1782 
1783  if ( ! PluginFunctions::getObject(_objectId,object) ) {
1784  emit log(LOGERR,tr("getObjectRenderingMatrix : unable to get object" ));
1785  return Matrix4x4();
1786  }
1787 
1788  return object->manipulatorNode()->matrix();
1789 }
1790 
size_t n_vertices() const
Get number of vertices.
Definition: PolyLineT.hh:122
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.
#define DATA_POLY_LINE
Definition: PolyLine.hh:70
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.
Definition: DataTypes.hh:194
#define DATA_BSPLINE_CURVE
Definition: BSplineCurve.hh:73
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)
Definition: Matrix4x4T.cc:225
void ManipulatorPositionChanged(QtTranslationManipulatorNode *_node)
update object when its manipulator changes position
Definition: MovePlugin.cc:825
Vector manipulatorPosition(int _objectId)
Get the position of the manipulator.
bool dataType(DataType _type) const
Definition: BaseObject.cc:232
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.
Definition: DataTypes.hh:187
int lastActiveManipulator_
Stores the last manipulator which has been clicked ( used for the toolbox dialog) ...
Definition: MovePlugin.hh:413
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.
Definition: DataTypes.hh:192
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
#define DATA_POLY_MESH
Definition: PolyMesh.hh:65
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.
Definition: PolyMeshT.hh:139
VectorT< T, 3 > transform_point(const VectorT< T, 3 > &_v) const
transform point (x',y',z',1) = M * (x,y,z,1)
Definition: Matrix4x4T.cc:202
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.
Definition: PolyLineT.hh:148
void manipulatorMoved(QtTranslationManipulatorNode *_node, QMouseEvent *_event)
move the object when its manipulator moves
Definition: MovePlugin.cc:767
#define DATA_HEXAHEDRAL_MESH
double manip_size_modifier_
Modifier for the Size (changed by Mousewheel Events)
Definition: MovePlugin.hh:410
void transpose()
transpose matrix
Definition: Matrix4x4T.cc:272
double manip_size_
Size for the manipulators.
Definition: MovePlugin.hh:407
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)
Definition: Matrix4x4T.cc:297
#define DATA_TRIANGLE_MESH
Definition: TriangleMesh.hh:66
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.