Commit 6a8bb189 authored by Dirk Wilden's avatar Dirk Wilden

fixed showManipulators and implemented some PolyLine Move todos

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@8680 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 74d430cc
include (plugin)
if (EXISTS ${CMAKE_SOURCE_DIR}/ObjectTypes/PolyLine)
add_definitions (-DENABLE_POLYLINE_SUPPORT)
endif ()
if (EXISTS ${CMAKE_SOURCE_DIR}/ObjectTypes/TSplineMesh)
add_definitions (-DENABLE_TSPLINEMESH_SUPPORT)
endif ()
......
......@@ -449,6 +449,9 @@ void MovePlugin::moveObject(ACG::Matrix4x4d mat, int _id) {
} else {
emit log(LOGERR,tr("moveObject called for unsupported Object Type"));
std::cerr << "type was : " << object->dataType() << std::endl;
std::cerr << "polyline : " << DATA_POLY_LINE << std::endl;
return;
}
......@@ -754,6 +757,17 @@ void MovePlugin::placeManip(QMouseEvent * _event, bool _snap) {
lastActiveManipulator_ = object->id();
emit updateView();
bool found = false;
for (uint i=0; i < activeManipulators_.size(); i++)
if ( activeManipulators_[i] == object->id() ){
found = true;
break;
}
if ( !found )
activeManipulators_.push_back( object->id() );
} else {
//emit log(LOGWARN, tr("Picking failed"));
......@@ -769,25 +783,33 @@ void MovePlugin::placeManip(QMouseEvent * _event, bool _snap) {
void MovePlugin::showManipulators( )
{
#ifdef ENABLE_TSPLINEMESH_SUPPORT
DataType types = DataType( DATA_TRIANGLE_MESH | DATA_POLY_MESH | DATA_TSPLINE_MESH);
#else
DataType types = DataType( DATA_TRIANGLE_MESH | DATA_POLY_MESH);
#endif
if (!hide_ && (toolboxActive_ || (PluginFunctions::pickMode() == "Move") || (PluginFunctions::pickMode() == "MoveSelection"))) {
for (PluginFunctions::ObjectIterator o_it(PluginFunctions::ALL_OBJECTS, types); o_it != PluginFunctions::objectsEnd(); ++o_it)
if (o_it->manipPlaced()) {
o_it->manipulatorNode()->show();
o_it->manipulatorNode()->apply_transformation( PluginFunctions::pickMode() == "Move" );
emit nodeVisibilityChanged(o_it->id());
for (uint i=0; i < activeManipulators_.size(); i++){
BaseObjectData* obj = 0;
PluginFunctions::getObject( activeManipulators_[i], obj );
if (obj != 0 && obj->manipPlaced()) {
obj->manipulatorNode()->show();
obj->manipulatorNode()->apply_transformation( PluginFunctions::pickMode() == "Move" );
emit nodeVisibilityChanged(obj->id());
}
}
} else {
for (PluginFunctions::ObjectIterator o_it(PluginFunctions::ALL_OBJECTS, types); o_it != PluginFunctions::objectsEnd(); ++o_it) {
o_it->manipulatorNode()->hide();
emit nodeVisibilityChanged(o_it->id());
for (uint i=0; i < activeManipulators_.size(); i++){
BaseObjectData* obj = 0;
PluginFunctions::getObject( activeManipulators_[i], obj );
if ( obj != 0 ) {
obj->manipulatorNode()->hide();
emit nodeVisibilityChanged(obj->id());
}
}
}
......@@ -1945,5 +1967,18 @@ OpenMesh::Vec3d MovePlugin::getNearestFace(MeshType* _mesh, uint _fh, OpenMesh::
return (OpenMesh::Vec3d)cog/count;
}
void MovePlugin::slotAllCleared(){
activeManipulators_.clear();
}
void MovePlugin::objectDeleted( int _id ){
for (uint i=0; i < activeManipulators_.size(); i++)
if ( activeManipulators_[i] == _id ){
activeManipulators_.erase( activeManipulators_.begin() + i );
return;
}
}
Q_EXPORT_PLUGIN2( moveplugin , MovePlugin );
......@@ -56,6 +56,7 @@
#include <OpenFlipper/BasePlugin/ScriptInterface.hh>
#include <OpenFlipper/BasePlugin/ToolbarInterface.hh>
#include <OpenFlipper/BasePlugin/ContextMenuInterface.hh>
#include <OpenFlipper/BasePlugin/LoadSaveInterface.hh>
#include <OpenFlipper/common/Types.hh>
#include <ObjectTypes/PolyMesh/PolyMesh.hh>
#include <ObjectTypes/Plane/Plane.hh>
......@@ -69,7 +70,7 @@ enum SelectionType {VERTEX, EDGE, FACE };
/** Plugin for moving objects and selections
*/
class MovePlugin : public QObject, BaseInterface, MouseInterface, KeyInterface, PickingInterface, ToolboxInterface, BackupInterface, LoggingInterface, ScriptInterface,ToolbarInterface, ContextMenuInterface
class MovePlugin : public QObject, BaseInterface, MouseInterface, KeyInterface, PickingInterface, ToolboxInterface, BackupInterface, LoggingInterface, ScriptInterface,ToolbarInterface, ContextMenuInterface, LoadSaveInterface
{
Q_OBJECT
Q_INTERFACES(BaseInterface)
......@@ -82,6 +83,7 @@ class MovePlugin : public QObject, BaseInterface, MouseInterface, KeyInterface,
Q_INTERFACES(ContextMenuInterface)
Q_INTERFACES(ScriptInterface)
Q_INTERFACES(ToolbarInterface)
Q_INTERFACES(LoadSaveInterface)
signals:
// BaseInterface
......@@ -125,6 +127,11 @@ class MovePlugin : public QObject, BaseInterface, MouseInterface, KeyInterface,
// BaseInterface
void initializePlugin();
void pluginsInitialized();
void slotAllCleared();
// LoadSaveInterface
void objectDeleted( int _id );
// MouseInterface
void slotMouseWheelEvent(QWheelEvent * _event, const std::string & _mode);
......@@ -277,6 +284,10 @@ class MovePlugin : public QObject, BaseInterface, MouseInterface, KeyInterface,
* @{ */
//===========================================================================
private:
//object ids of all objects with active Manipulator
std::vector< int > activeManipulators_;
private slots:
/// move the object when its manipulator moves
......
......@@ -149,7 +149,11 @@ void MovePlugin::translate( int _objectId , Vector _vector) {
#endif
#ifdef ENABLE_POLYLINE_SUPPORT
else if ( object->dataType(DATA_POLY_LINE) ) {
std::cerr << "Todo : translate PolyLine" << std::endl;
PolyLine& line = (* PluginFunctions::polyLine(object) );
for ( int i = 0 ; i < (int)line.n_vertices(); ++i )
line.point(i) = line.point(i) + _vector;
}
#endif
#ifdef ENABLE_BSPLINE_CURVE_SUPPORT
......@@ -214,7 +218,14 @@ void MovePlugin::translate( int _objectId , IdList _vHandles, Vector _vector ){
#ifdef ENABLE_POLYLINE_SUPPORT
else if ( object->dataType(DATA_POLY_LINE) ) {
std::cerr << "Todo : translate PolyLine" << std::endl;
PolyLine& line = (* PluginFunctions::polyLine(object) );
const int max = line.n_vertices();
for ( unsigned int i = 0 ; i < _vHandles.size(); ++i )
if ( (_vHandles[i] > 0) && ( _vHandles[i] < max ) )
line.point( _vHandles[i] ) = line.point( _vHandles[i] ) + _vector;
}
#endif
#ifdef ENABLE_BSPLINE_CURVE_SUPPORT
......@@ -280,7 +291,12 @@ void MovePlugin::translateSelection( int _objectId , Vector _vector) {
#ifdef ENABLE_POLYLINE_SUPPORT
else if ( object->dataType(DATA_POLY_LINE) ) {
std::cerr << "Todo : translate PolyLine" << std::endl;
PolyLine& line = (* PluginFunctions::polyLine(object) );
for ( int i = 0 ; i < (int)line.n_vertices(); ++i )
if ( line.vertex_selection(i) )
line.point(i) = line.point(i) + _vector;
}
#endif
#ifdef ENABLE_BSPLINE_CURVE_SUPPORT
......@@ -348,7 +364,11 @@ void MovePlugin::transform( int _objectId , Matrix4x4 _matrix ){
#ifdef ENABLE_POLYLINE_SUPPORT
else if ( object->dataType(DATA_POLY_LINE) ) {
std::cerr << "Todo : transform PolyLine" << std::endl;
PolyLine& line = (* PluginFunctions::polyLine(object) );
for ( int i = 0 ; i < (int)line.n_vertices(); ++i )
line.point(i) = _matrix.transform_point( line.point(i) );
}
#endif
#ifdef ENABLE_BSPLINE_CURVE_SUPPORT
......@@ -427,7 +447,15 @@ void MovePlugin::transform( int _objectId , IdList _vHandles, Matrix4x4 _matrix
#ifdef ENABLE_POLYLINE_SUPPORT
else if ( object->dataType(DATA_POLY_LINE) ) {
std::cerr << "Todo : transform PolyLine" << std::endl;
PolyLine& line = (* PluginFunctions::polyLine(object) );
const int max = line.n_vertices();
for ( unsigned int i = 0 ; i < _vHandles.size(); ++i )
if ( (_vHandles[i] > 0) && ( _vHandles[i] < max ) )
line.point( _vHandles[i] ) = _matrix.transform_point( line.point( _vHandles[i] ) );
}
#endif
#ifdef ENABLE_BSPLINE_CURVE_SUPPORT
......@@ -505,7 +533,12 @@ void MovePlugin::transformVertexSelection( int _objectId , Matrix4x4 _matrix ){
#ifdef ENABLE_POLYLINE_SUPPORT
else if ( object->dataType(DATA_POLY_LINE) ) {
std::cerr << "Todo : transform PolyLine" << std::endl;
PolyLine& line = (* PluginFunctions::polyLine(object) );
for ( int i = 0 ; i < (int)line.n_vertices(); ++i )
if ( line.vertex_selection(i) )
line.point(i) = _matrix.transform_point( line.point(i) );
}
#endif
#ifdef ENABLE_BSPLINE_CURVE_SUPPORT
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment