Commit 62072674 authored by Jan Möbius's avatar Jan Möbius
Browse files

Tobias: Update for splatcloud with the new property system

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@14928 383ad7c9-94d9-4d36-a494-682f7c89f535
parent c5e70df0
This diff is collapsed.
......@@ -87,16 +87,16 @@ class FilePTSPlugin : public QObject, BaseInterface, FileInterface, LoadSaveInte
signals:
// -- File Interface --
void openedFile( int _id );
void openedFile( int _objectId );
// -- LoadSave Interface --
void addEmptyObject( DataType _type, int &_id );
void deleteObject( int _id );
void updatedObject( int _id, const UpdateType &_type );
void addEmptyObject( DataType _type, int &_objectId );
void deleteObject( int _objectId );
void updatedObject( int _objectId, const UpdateType &_type );
//-- Logging Interface --
void log( QString _message );
void log( Logtype _type, QString _message );
void log( QString _message );
private slots:
......@@ -110,7 +110,7 @@ public:
~FilePTSPlugin() { }
//-- Base Interface --
QString name() { return QString( "FilePTS" ); }
QString name() { return QString( "FilePTS" ); }
QString description( ) { return QString( tr("Load/Save SplatCloud format files") ); }
// -- File Interface --
......@@ -129,7 +129,7 @@ public slots:
// -- File Interface --
int loadObject( QString _filename );
bool saveObject( int _id, QString _filename );
bool saveObject( int _objectId, QString _filename );
private:
......@@ -152,7 +152,6 @@ private:
QCheckBox *loadColors_;
QComboBox *loadColorRange_;
QCheckBox *loadIndices_;
QCheckBox *loadNormalizeSize_;
// options in the saving menu
QCheckBox *saveBinaryFile_;
......
......@@ -77,184 +77,183 @@
class SplatCloudObjectSelectionPlugin : public QObject, BaseInterface, BackupInterface, LoggingInterface, SelectionInterface, LoadSaveInterface, INIInterface, KeyInterface, ScriptInterface
{
Q_OBJECT
Q_INTERFACES( BaseInterface )
Q_INTERFACES( BackupInterface )
Q_INTERFACES( LoggingInterface )
Q_INTERFACES( SelectionInterface )
Q_INTERFACES( LoadSaveInterface )
Q_INTERFACES( INIInterface )
Q_INTERFACES( KeyInterface )
Q_INTERFACES( ScriptInterface )
Q_OBJECT
Q_INTERFACES( BaseInterface )
Q_INTERFACES( BackupInterface )
Q_INTERFACES( LoggingInterface )
Q_INTERFACES( SelectionInterface )
Q_INTERFACES( LoadSaveInterface )
Q_INTERFACES( INIInterface )
Q_INTERFACES( KeyInterface )
Q_INTERFACES( ScriptInterface )
public:
/// Default constructor
SplatCloudObjectSelectionPlugin() : vertexType_( 0 ), allSupportedTypes_( 0 ) { }
/// Default constructor
SplatCloudObjectSelectionPlugin() : vertexType_( 0 ), allSupportedTypes_( 0 ) { }
friend class SelectVolumeAction;
friend class SelectVolumeAction;
signals:
//-- Base Interface --
void updateView();
void updatedObject( int _identifier, const UpdateType& _type );
void nodeVisibilityChanged( int _identifier );
void setSlotDescription( QString _slotName, QString _slotDescription, QStringList _parameters, QStringList _descriptions );
//-- Base Interface --
void updateView();
void updatedObject( int _objectId, const UpdateType& _type );
void nodeVisibilityChanged( int _objectId );
void setSlotDescription( QString _slotName, QString _slotDescription, QStringList _parameters, QStringList _descriptions );
//-- Backup Interface --
void createBackup( int _objectId, QString _name, UpdateType _type = UPDATE_ALL );
//-- Backup Interface --
void createBackup( int _objectId, QString _name, UpdateType _type = UPDATE_ALL );
//-- Logging Interface --
void log( Logtype _type, QString _message );
void log( QString _message );
//-- Logging Interface --
void log( QString _message );
void log( Logtype _type, QString _message );
//-- Selection Interface --
void addSelectionEnvironment( QString _modeName, QString _description, QIcon _icon, QString &_handleName );
void registerType( QString _handleName, DataType _type );
void addPrimitiveType( QString _handleName, QString _name, QIcon _icon, SelectionInterface::PrimitiveType &_typeHandle );
void addSelectionOperations( QString _handleName, QStringList _operationsList, QString _category, SelectionInterface::PrimitiveType _type = 0u );
//-- Selection Interface --
void addSelectionEnvironment( QString _modeName, QString _description, QIcon _icon, QString &_handleName );
void registerType( QString _handleName, DataType _type );
void addPrimitiveType( QString _handleName, QString _name, QIcon _icon, SelectionInterface::PrimitiveType &_typeHandle );
void addSelectionOperations( QString _handleName, QStringList _operationsList, QString _category, SelectionInterface::PrimitiveType _type = 0u );
void showToggleSelectionMode ( QString _handleName, bool _show, SelectionInterface::PrimitiveType _associatedTypes );
void showSphereSelectionMode ( QString _handleName, bool _show, SelectionInterface::PrimitiveType _associatedTypes );
void showLassoSelectionMode ( QString _handleName, bool _show, SelectionInterface::PrimitiveType _associatedTypes );
void showVolumeLassoSelectionMode( QString _handleName, bool _show, SelectionInterface::PrimitiveType _associatedTypes );
void showToggleSelectionMode ( QString _handleName, bool _show, SelectionInterface::PrimitiveType _associatedTypes );
void showSphereSelectionMode ( QString _handleName, bool _show, SelectionInterface::PrimitiveType _associatedTypes );
void showLassoSelectionMode ( QString _handleName, bool _show, SelectionInterface::PrimitiveType _associatedTypes );
void showVolumeLassoSelectionMode( QString _handleName, bool _show, SelectionInterface::PrimitiveType _associatedTypes );
void getActiveDataTypes( SelectionInterface::TypeList &_types );
void getActivePrimitiveType( SelectionInterface::PrimitiveType &_type );
void targetObjectsOnly( bool &_targetsOnly );
void getActiveDataTypes( SelectionInterface::TypeList &_types );
void getActivePrimitiveType( SelectionInterface::PrimitiveType &_type );
void targetObjectsOnly( bool &_targetsOnly );
void registerKeyShortcut( int _key, Qt::KeyboardModifiers _modifiers = Qt::NoModifier );
void registerKeyShortcut( int _key, Qt::KeyboardModifiers _modifiers = Qt::NoModifier );
//-- LoadSave Interface --
void deleteObject( int _objectId );
//-- LoadSave Interface --
void deleteObject( int _objectId );
//-- Script Interface --
void scriptInfo( QString _functionName );
//-- Script Interface --
void scriptInfo( QString _functionName );
public slots:
//-- Selection Interface --
void loadSelection( int _objId, const QString &_filename );
//-- Selection Interface --
void loadSelection( int _objectId, const QString &_filename );
private slots:
//-- INI Interface --
void loadIniFile( INIFile &_ini, int _id );
void saveIniFile( INIFile &_ini, int _id );
//-- INI Interface --
void loadIniFile( INIFile &_ini, int _objectId );
void saveIniFile( INIFile &_ini, int _objectId );
//-- Base Interface --
void initializePlugin();
void pluginsInitialized();
void noguiSupported() { };
//-- Base Interface --
void initializePlugin();
void pluginsInitialized();
void noguiSupported() { };
//-- Selection Interface --
void slotSelectionOperation( QString _operation );
//-- Selection Interface --
void slotSelectionOperation( QString _operation );
void slotToggleSelection ( QMouseEvent *_event, SelectionInterface::PrimitiveType _currentType, bool _deselect );
void slotSphereSelection ( QMouseEvent *_event, double _radius, SelectionInterface::PrimitiveType _currentType, bool _deselect );
void slotLassoSelection ( QMouseEvent *_event, SelectionInterface::PrimitiveType _currentType, bool _deselect );
void slotVolumeLassoSelection( QMouseEvent *_event, SelectionInterface::PrimitiveType _currentType, bool _deselect );
void slotToggleSelection ( QMouseEvent *_event, SelectionInterface::PrimitiveType _currentType, bool _deselect );
void slotSphereSelection ( QMouseEvent *_event, double _radius, SelectionInterface::PrimitiveType _currentType, bool _deselect );
void slotLassoSelection ( QMouseEvent *_event, SelectionInterface::PrimitiveType _currentType, bool _deselect );
void slotVolumeLassoSelection( QMouseEvent *_event, SelectionInterface::PrimitiveType _currentType, bool _deselect );
void slotLoadSelection( const INIFile &_file );
void slotSaveSelection( INIFile &_file );
void slotLoadSelection( const INIFile &_file );
void slotSaveSelection( INIFile &_file );
void slotKeyShortcutEvent( int _key, Qt::KeyboardModifiers _modifiers );
void slotKeyShortcutEvent( int _key, Qt::KeyboardModifiers _modifiers );
public:
//-- Base Interface --
QString name() { return QString( tr("SplatCloud Object Selection") ); }
//-- Base Interface --
QString name() { return QString( tr("SplatCloud Object Selection" ) ); }
QString description() { return QString( tr("Allows to select parts of SplatCloud Objects") ); }
QString description() { return QString( tr("Allows to select parts of SplatCloud Objects") ); }
//===========================================================================
/** @name Private methods
* @{ */
//===========================================================================
//===========================================================================
/** @name Private methods
* @{ */
//===========================================================================
private:
/// Set descriptions for local public slots
void updateSlotDescriptions();
/// Set descriptions for local public slots
void updateSlotDescriptions();
/// Set color for selection
void setColorForSelection( const int _objectId, const PrimitiveType _primitiveType );
/// Set color for selection
void setColorForSelection( const int _objectId, const PrimitiveType _primitiveType );
/** @} */
/** @} */
//===========================================================================
/** @name Private slots
* @{ */
//===========================================================================
//===========================================================================
/** @name Private slots
* @{ */
//===========================================================================
private slots:
/** @} */
/** @} */
public slots:
QString version() { return QString( "1.0" ); }
QString version() { return QString( "1.0" ); }
// Is vertex type active? (for use in plugins that need SplatCloud selection)
bool vertexTypeActive()
{
SelectionInterface::PrimitiveType t;
emit getActivePrimitiveType( t );
return (t & vertexType_) > 0;
}
// Is vertex type active? (for use in plugins that need SplatCloud selection)
bool vertexTypeActive()
{
SelectionInterface::PrimitiveType t;
emit getActivePrimitiveType( t );
return (t & vertexType_) > 0;
}
//===========================================================================
/** @name Scriptable slots
* @{ */
//===========================================================================
//===========================================================================
/** @name Scriptable slots
* @{ */
//===========================================================================
public slots:
//==========================================
// VERTEX OPERATIONS
//==========================================
//==========================================
// VERTEX OPERATIONS
//==========================================
void selectVertices ( int _objectId, IdList _vertexList ); /// Select given vertices
void unselectVertices ( int _objectId, IdList _vertexList ); /// Unselect given vertices
void selectAllVertices ( int _objectId ); /// Select all vertices
void clearVertexSelection ( int _objectId ); /// Unselect all vertices
void invertVertexSelection ( int _objectId ); /// Invert the current vertex selection
IdList getVertexSelection ( int _objectId ); /// Return a list of all selected vertices
void deleteVertexSelection ( int _objectId ); /// Delete vertices that are currently selected
void colorizeVertexSelection( int _objectId, int _r, int _g, int _b, int _a ); /// Colorize the vertex selection
void selectVertices ( int _objectId, IdList _vertexList ); /// Select given vertices
void unselectVertices ( int _objectId, IdList _vertexList ); /// Unselect given vertices
void selectAllVertices ( int _objectId ); /// Select all vertices
void clearVertexSelection ( int _objectId ); /// Unselect all vertices
void invertVertexSelection ( int _objectId ); /// Invert the current vertex selection
IdList getVertexSelection ( int _objectId ); /// Return a list of all selected vertices
void deleteVertexSelection ( int _objectId ); /// Delete vertices that are currently selected
void colorizeVertexSelection( int _objectId, int _r, int _g, int _b, int _a ); /// Colorize the vertex selection
//===========================================================================
//===========================================================================
void lassoSelect( QRegion &_region, PrimitiveType _primitiveType, bool _deselection ); /// Lasso selection tool
void lassoSelect( QRegion &_region, PrimitiveType _primitiveType, bool _deselection ); /// Lasso selection tool
/** @} */
/** @} */
//===========================================================================
/** @name Template Functions
* @{ */
//===========================================================================
//===========================================================================
/** @name Template Functions
* @{ */
//===========================================================================
private:
bool splatCloudDeleteSelection ( SplatCloud *_splatCloud, PrimitiveType _primitiveType ); /// Delete all selected elements of a SplatCloud
void splatCloudToggleSelection ( SplatCloud *_splatCloud, uint _index, ACG::Vec3d &_hit_point, PrimitiveType _primitiveType ); /// Toggle SplatCloud selection
void splatCloudSphereSelection ( SplatCloud *_splatCloud, uint _index, ACG::Vec3d &_hit_point, double _radius, PrimitiveType _primitiveTypes, bool _deselection ); /// Use the event to paint selection with a sphere
bool splatCloudVolumeSelection ( SplatCloud *_splatCloud, ACG::GLState &_state, QRegion *_region, PrimitiveType _primitiveTypes, bool _deselection ); /// Surface volume selection tool
void splatCloudColorizeSelection ( SplatCloud *_splatCloud, PrimitiveType _primitiveTypes, int _r, int _g, int _b, int _a ); /// Colorize the selection
bool splatCloudDeleteSelection ( SplatCloud *_splatCloud, PrimitiveType _primitiveType ); /// Delete all selected elements of a SplatCloud
void splatCloudToggleSelection ( SplatCloud *_splatCloud, uint _index, ACG::Vec3d &_hit_point, PrimitiveType _primitiveType ); /// Toggle SplatCloud selection
void splatCloudSphereSelection ( SplatCloud *_splatCloud, uint _index, ACG::Vec3d &_hit_point, double _radius, PrimitiveType _primitiveTypes, bool _deselection ); /// Use the event to paint selection with a sphere
bool splatCloudVolumeSelection ( SplatCloud *_splatCloud, ACG::GLState &_state, QRegion *_region, PrimitiveType _primitiveTypes, bool _deselection ); /// Surface volume selection tool
void splatCloudColorizeSelection ( SplatCloud *_splatCloud, PrimitiveType _primitiveTypes, int _r, int _g, int _b, int _a ); /// Colorize the selection
/** @} */
/** @} */
//===========================================================================
/** @name Member variables
* @{ */
//===========================================================================
//===========================================================================
/** @name Member variables
* @{ */
//===========================================================================
private:
QString environmentHandle_; /// Handle to selection environment
SelectionInterface::PrimitiveType vertexType_; /// Primitive type handle
SelectionInterface::PrimitiveType allSupportedTypes_; /// Primitive type handle
QPolygon lasso_2Dpoints_; /// Used for lasso selection tool
QVector<QPoint> volumeLassoPoints_; /// Used for volume lasso tool
QString environmentHandle_; /// Handle to selection environment
SelectionInterface::PrimitiveType vertexType_; /// Primitive type handle
SelectionInterface::PrimitiveType allSupportedTypes_; /// Primitive type handle
QPolygon lasso_2Dpoints_; /// Used for lasso selection tool
QVector<QPoint> volumeLassoPoints_; /// Used for volume lasso tool
/** @} */
/** @} */
};
......@@ -263,20 +262,20 @@ class SelectVolumeAction
{
public:
SelectVolumeAction( QRegion &_region, SplatCloudObjectSelectionPlugin *_plugin, unsigned int _type, bool _deselection, ACG::GLState &_state ) :
state_(_state), region_(_region), plugin_(_plugin), type_(_type), deselection_(_deselection) { }
SelectVolumeAction( QRegion &_region, SplatCloudObjectSelectionPlugin *_plugin, unsigned int _type, bool _deselection, ACG::GLState &_state ) :
state_(_state), region_(_region), plugin_(_plugin), type_(_type), deselection_(_deselection) { }
void enter( BaseNode * /*_node*/ ) { }
void leave( BaseNode * /*_node*/ ) { }
void enter( BaseNode * /*_node*/ ) { }
void leave( BaseNode * /*_node*/ ) { }
bool operator()( BaseNode *_node );
bool operator()( BaseNode *_node );
private:
ACG::GLState &state_;
QRegion &region_;
SplatCloudObjectSelectionPlugin *plugin_;
unsigned int type_;
bool deselection_;
ACG::GLState &state_;
QRegion &region_;
SplatCloudObjectSelectionPlugin *plugin_;
unsigned int type_;
bool deselection_;
};
......
......@@ -68,13 +68,15 @@
*/
bool SplatCloudObjectSelectionPlugin::splatCloudDeleteSelection( SplatCloud *_splatCloud, PrimitiveType _primitiveType )
{
if( _primitiveType & vertexType_ )
{
_splatCloud->initSelections();
return _splatCloud->deleteSelected();
}
if( (_primitiveType & vertexType_) == 0 )
return false; // done
return false;
if( _splatCloud == 0 )
return false; // error
unsigned int numDeleted = _splatCloud->eraseSplatsByIndex( SplatCloudSelection::getVertexSelection( _splatCloud ) );
return (numDeleted != 0);
}
......@@ -90,16 +92,31 @@ bool SplatCloudObjectSelectionPlugin::splatCloudDeleteSelection( SplatCloud *_sp
*/
void SplatCloudObjectSelectionPlugin::splatCloudToggleSelection( SplatCloud *_splatCloud, uint _index, ACG::Vec3d &_hit_point, PrimitiveType _primitiveType )
{
if( _primitiveType & vertexType_ )
{
_splatCloud->initSelections();
_splatCloud->selections()[ _index ] = !_splatCloud->selections()[ _index ];
if( _splatCloud->selections()[ _index ] )
emit scriptInfo( "selectVertices(ObjectId , [" + QString::number( _index ) + "])" );
else
emit scriptInfo( "unselectVertices(ObjectId , [" + QString::number( _index ) + "])" );
}
if( (_primitiveType & vertexType_) == 0 )
return; // done
if( _splatCloud == 0 )
return; // error
if( /*(_index < 0) ||*/ (_index >= _splatCloud->numSplats()) )
return; // error
if( !_splatCloud->hasSelections() )
{
if( !_splatCloud->requestSelections() )
return; // error
unsigned int i, num = _splatCloud->numSplats();
for( i=0; i<num; ++i )
_splatCloud->selections( i ) = false;
}
_splatCloud->selections( _index ) = !_splatCloud->selections( _index );
if( _splatCloud->selections( _index ) )
emit scriptInfo( "selectVertices(ObjectId , [" + QString::number( _index ) + "])" );
else
emit scriptInfo( "unselectVertices(ObjectId , [" + QString::number( _index ) + "])" );
}
......@@ -117,11 +134,52 @@ void SplatCloudObjectSelectionPlugin::splatCloudToggleSelection( SplatCloud *_sp
*/
void SplatCloudObjectSelectionPlugin::splatCloudSphereSelection( SplatCloud *_splatCloud, uint _index, ACG::Vec3d &_hit_point, double _radius, PrimitiveType _primitiveType, bool _deselection )
{
if( _primitiveType & vertexType_ )
{
_splatCloud->initSelections();
_splatCloud->setSphereSelections( _splatCloud->points()[ _index ], _radius * _radius, !_deselection );
}
if( (_primitiveType & vertexType_) == 0 )
return; // done
if( _splatCloud == 0 )
return; // error
if( /*(_index < 0) ||*/ (_index >= _splatCloud->numSplats()) )
return; // error
if( !_splatCloud->hasPositions() )
return; // error
if( !_splatCloud->hasSelections() )
{
if( _deselection )
return; // done
if( !_splatCloud->requestSelections() )
return; // error
unsigned int i, num = _splatCloud->numSplats();
for( i=0; i<num; ++i )
_splatCloud->selections( i ) = false;
}
if( _radius < 0.0 )
return; // done
double sqrRadius = _radius * _radius;
SplatCloud::Selection selection = !_deselection;
unsigned int i, num = _splatCloud->numSplats();
for( i=0; i<num; ++i )
{
const SplatCloud::Position &pos = _splatCloud->positions( i );
double dx = pos[0] - _hit_point[0];
double dy = pos[1] - _hit_point[1];
double dz = pos[2] - _hit_point[2];
double sqrDist = dx*dx + dy*dy + dz*dz;
if( sqrDist <= sqrRadius )
_splatCloud->selections( i ) = selection;
}
}
......@@ -139,27 +197,55 @@ void SplatCloudObjectSelectionPlugin::splatCloudSphereSelection( SplatCloud *_sp
*/
bool SplatCloudObjectSelectionPlugin::splatCloudVolumeSelection( SplatCloud *_splatCloud, ACG::GLState &_state, QRegion *_region, PrimitiveType _primitiveType, bool _deselection )
{
bool rv = false;
if( _primitiveType & vertexType_ )
{
_splatCloud->initSelections();
unsigned int i, num = _splatCloud->numPoints();
for( i=0; i<num; ++i )
{
const SplatCloud::Point &p = _splatCloud->points()[ i ];
ACG::Vec3d proj = _state.project( ACG::Vec3d( p[0], p[1], p[2] ) );
if( _region->contains( QPoint( (int) proj[0], _state.context_height() - (int) proj[1] ) ) )
{
_splatCloud->selections()[ i ] = !_deselection;
rv = true;
}
}
}
return rv;
if( (_primitiveType & vertexType_) == 0 )
return false; // done
if( _splatCloud == 0 )
return false; // error
if( !_splatCloud->hasPositions() )
return false; // error
bool modify = true;
if( !_splatCloud->hasSelections() )
{
if( _deselection )
{
modify = false;
}
else
{
if( !_splatCloud->requestSelections() )
return false; // error
unsigned int i, num = _splatCloud->numSplats();
for( i=0; i<num; ++i )
_splatCloud->selections( i ) = false;
}
}
bool rv = false;
SplatCloud::Selection selection = !_deselection;
unsigned int i, num = _splatCloud->numSplats();
for( i=0; i<num; ++i )
{
const SplatCloud::