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 ...@@ -87,16 +87,16 @@ class FilePTSPlugin : public QObject, BaseInterface, FileInterface, LoadSaveInte
signals: signals:
// -- File Interface -- // -- File Interface --
void openedFile( int _id ); void openedFile( int _objectId );
// -- LoadSave Interface -- // -- LoadSave Interface --
void addEmptyObject( DataType _type, int &_id ); void addEmptyObject( DataType _type, int &_objectId );
void deleteObject( int _id ); void deleteObject( int _objectId );
void updatedObject( int _id, const UpdateType &_type ); void updatedObject( int _objectId, const UpdateType &_type );
//-- Logging Interface -- //-- Logging Interface --
void log( QString _message );
void log( Logtype _type, QString _message ); void log( Logtype _type, QString _message );
void log( QString _message );
private slots: private slots:
...@@ -110,7 +110,7 @@ public: ...@@ -110,7 +110,7 @@ public:
~FilePTSPlugin() { } ~FilePTSPlugin() { }
//-- Base Interface -- //-- Base Interface --
QString name() { return QString( "FilePTS" ); } QString name() { return QString( "FilePTS" ); }
QString description( ) { return QString( tr("Load/Save SplatCloud format files") ); } QString description( ) { return QString( tr("Load/Save SplatCloud format files") ); }
// -- File Interface -- // -- File Interface --
...@@ -129,7 +129,7 @@ public slots: ...@@ -129,7 +129,7 @@ public slots:
// -- File Interface -- // -- File Interface --
int loadObject( QString _filename ); int loadObject( QString _filename );
bool saveObject( int _id, QString _filename ); bool saveObject( int _objectId, QString _filename );
private: private:
...@@ -152,7 +152,6 @@ private: ...@@ -152,7 +152,6 @@ private:
QCheckBox *loadColors_; QCheckBox *loadColors_;
QComboBox *loadColorRange_; QComboBox *loadColorRange_;
QCheckBox *loadIndices_; QCheckBox *loadIndices_;
QCheckBox *loadNormalizeSize_;
// options in the saving menu // options in the saving menu
QCheckBox *saveBinaryFile_; QCheckBox *saveBinaryFile_;
......
...@@ -77,184 +77,183 @@ ...@@ -77,184 +77,183 @@
class SplatCloudObjectSelectionPlugin : public QObject, BaseInterface, BackupInterface, LoggingInterface, SelectionInterface, LoadSaveInterface, INIInterface, KeyInterface, ScriptInterface class SplatCloudObjectSelectionPlugin : public QObject, BaseInterface, BackupInterface, LoggingInterface, SelectionInterface, LoadSaveInterface, INIInterface, KeyInterface, ScriptInterface
{ {
Q_OBJECT Q_OBJECT
Q_INTERFACES( BaseInterface ) Q_INTERFACES( BaseInterface )
Q_INTERFACES( BackupInterface ) Q_INTERFACES( BackupInterface )
Q_INTERFACES( LoggingInterface ) Q_INTERFACES( LoggingInterface )
Q_INTERFACES( SelectionInterface ) Q_INTERFACES( SelectionInterface )
Q_INTERFACES( LoadSaveInterface ) Q_INTERFACES( LoadSaveInterface )
Q_INTERFACES( INIInterface ) Q_INTERFACES( INIInterface )
Q_INTERFACES( KeyInterface ) Q_INTERFACES( KeyInterface )
Q_INTERFACES( ScriptInterface ) Q_INTERFACES( ScriptInterface )
public: public:
/// Default constructor /// Default constructor
SplatCloudObjectSelectionPlugin() : vertexType_( 0 ), allSupportedTypes_( 0 ) { } SplatCloudObjectSelectionPlugin() : vertexType_( 0 ), allSupportedTypes_( 0 ) { }
friend class SelectVolumeAction; friend class SelectVolumeAction;
signals: signals:
//-- Base Interface -- //-- Base Interface --
void updateView(); void updateView();
void updatedObject( int _identifier, const UpdateType& _type ); void updatedObject( int _objectId, const UpdateType& _type );
void nodeVisibilityChanged( int _identifier ); void nodeVisibilityChanged( int _objectId );
void setSlotDescription( QString _slotName, QString _slotDescription, QStringList _parameters, QStringList _descriptions ); void setSlotDescription( QString _slotName, QString _slotDescription, QStringList _parameters, QStringList _descriptions );
//-- Backup Interface -- //-- Backup Interface --
void createBackup( int _objectId, QString _name, UpdateType _type = UPDATE_ALL ); void createBackup( int _objectId, QString _name, UpdateType _type = UPDATE_ALL );
//-- Logging Interface -- //-- Logging Interface --
void log( Logtype _type, QString _message ); void log( QString _message );
void log( QString _message ); void log( Logtype _type, QString _message );
//-- Selection Interface -- //-- Selection Interface --
void addSelectionEnvironment( QString _modeName, QString _description, QIcon _icon, QString &_handleName ); void addSelectionEnvironment( QString _modeName, QString _description, QIcon _icon, QString &_handleName );
void registerType( QString _handleName, DataType _type ); void registerType( QString _handleName, DataType _type );
void addPrimitiveType( QString _handleName, QString _name, QIcon _icon, SelectionInterface::PrimitiveType &_typeHandle ); void addPrimitiveType( QString _handleName, QString _name, QIcon _icon, SelectionInterface::PrimitiveType &_typeHandle );
void addSelectionOperations( QString _handleName, QStringList _operationsList, QString _category, SelectionInterface::PrimitiveType _type = 0u ); void addSelectionOperations( QString _handleName, QStringList _operationsList, QString _category, SelectionInterface::PrimitiveType _type = 0u );
void showToggleSelectionMode ( 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 showSphereSelectionMode ( QString _handleName, bool _show, SelectionInterface::PrimitiveType _associatedTypes );
void showLassoSelectionMode ( 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 showVolumeLassoSelectionMode( QString _handleName, bool _show, SelectionInterface::PrimitiveType _associatedTypes );
void getActiveDataTypes( SelectionInterface::TypeList &_types ); void getActiveDataTypes( SelectionInterface::TypeList &_types );
void getActivePrimitiveType( SelectionInterface::PrimitiveType &_type ); void getActivePrimitiveType( SelectionInterface::PrimitiveType &_type );
void targetObjectsOnly( bool &_targetsOnly ); void targetObjectsOnly( bool &_targetsOnly );
void registerKeyShortcut( int _key, Qt::KeyboardModifiers _modifiers = Qt::NoModifier ); void registerKeyShortcut( int _key, Qt::KeyboardModifiers _modifiers = Qt::NoModifier );
//-- LoadSave Interface -- //-- LoadSave Interface --
void deleteObject( int _objectId ); void deleteObject( int _objectId );
//-- Script Interface -- //-- Script Interface --
void scriptInfo( QString _functionName ); void scriptInfo( QString _functionName );
public slots: public slots:
//-- Selection Interface -- //-- Selection Interface --
void loadSelection( int _objId, const QString &_filename ); void loadSelection( int _objectId, const QString &_filename );
private slots: private slots:
//-- INI Interface -- //-- INI Interface --
void loadIniFile( INIFile &_ini, int _id ); void loadIniFile( INIFile &_ini, int _objectId );
void saveIniFile( INIFile &_ini, int _id ); void saveIniFile( INIFile &_ini, int _objectId );
//-- Base Interface -- //-- Base Interface --
void initializePlugin(); void initializePlugin();
void pluginsInitialized(); void pluginsInitialized();
void noguiSupported() { }; void noguiSupported() { };
//-- Selection Interface -- //-- Selection Interface --
void slotSelectionOperation( QString _operation ); void slotSelectionOperation( QString _operation );
void slotToggleSelection ( 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 slotSphereSelection ( QMouseEvent *_event, double _radius, SelectionInterface::PrimitiveType _currentType, bool _deselect );
void slotLassoSelection ( QMouseEvent *_event, SelectionInterface::PrimitiveType _currentType, bool _deselect ); void slotLassoSelection ( QMouseEvent *_event, SelectionInterface::PrimitiveType _currentType, bool _deselect );
void slotVolumeLassoSelection( QMouseEvent *_event, SelectionInterface::PrimitiveType _currentType, bool _deselect ); void slotVolumeLassoSelection( QMouseEvent *_event, SelectionInterface::PrimitiveType _currentType, bool _deselect );
void slotLoadSelection( const INIFile &_file ); void slotLoadSelection( const INIFile &_file );
void slotSaveSelection( INIFile &_file ); void slotSaveSelection( INIFile &_file );
void slotKeyShortcutEvent( int _key, Qt::KeyboardModifiers _modifiers ); void slotKeyShortcutEvent( int _key, Qt::KeyboardModifiers _modifiers );
public: public:
//-- Base Interface -- //-- Base Interface --
QString name() { return QString( tr("SplatCloud Object Selection") ); } 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: private:
/// Set descriptions for local public slots /// Set descriptions for local public slots
void updateSlotDescriptions(); void updateSlotDescriptions();
/// Set color for selection /// Set color for selection
void setColorForSelection( const int _objectId, const PrimitiveType _primitiveType ); void setColorForSelection( const int _objectId, const PrimitiveType _primitiveType );
/** @} */ /** @} */
//=========================================================================== //===========================================================================
/** @name Private slots /** @name Private slots
* @{ */ * @{ */
//=========================================================================== //===========================================================================
private slots: private slots:
/** @} */ /** @} */
public 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) // Is vertex type active? (for use in plugins that need SplatCloud selection)
bool vertexTypeActive() bool vertexTypeActive()
{ {
SelectionInterface::PrimitiveType t; SelectionInterface::PrimitiveType t;
emit getActivePrimitiveType( t ); emit getActivePrimitiveType( t );
return (t & vertexType_) > 0; return (t & vertexType_) > 0;
} }
//=========================================================================== //===========================================================================
/** @name Scriptable slots /** @name Scriptable slots
* @{ */ * @{ */
//=========================================================================== //===========================================================================
public slots: public slots:
//========================================== //==========================================
// VERTEX OPERATIONS // VERTEX OPERATIONS
//========================================== //==========================================
void selectVertices ( int _objectId, IdList _vertexList ); /// Select given vertices void selectVertices ( int _objectId, IdList _vertexList ); /// Select given vertices
void unselectVertices ( int _objectId, IdList _vertexList ); /// Unselect given vertices void unselectVertices ( int _objectId, IdList _vertexList ); /// Unselect given vertices
void selectAllVertices ( int _objectId ); /// Select all vertices void selectAllVertices ( int _objectId ); /// Select all vertices
void clearVertexSelection ( int _objectId ); /// Unselect all vertices void clearVertexSelection ( int _objectId ); /// Unselect all vertices
void invertVertexSelection ( int _objectId ); /// Invert the current vertex selection void invertVertexSelection ( int _objectId ); /// Invert the current vertex selection
IdList getVertexSelection ( int _objectId ); /// Return a list of all selected vertices IdList getVertexSelection ( int _objectId ); /// Return a list of all selected vertices
void deleteVertexSelection ( int _objectId ); /// Delete vertices that are currently selected 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 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: private:
bool splatCloudDeleteSelection ( SplatCloud *_splatCloud, PrimitiveType _primitiveType ); /// Delete all selected elements of a SplatCloud 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 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 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 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 void splatCloudColorizeSelection ( SplatCloud *_splatCloud, PrimitiveType _primitiveTypes, int _r, int _g, int _b, int _a ); /// Colorize the selection
/** @} */ /** @} */
//=========================================================================== //===========================================================================
/** @name Member variables /** @name Member variables
* @{ */ * @{ */
//=========================================================================== //===========================================================================
private: private:
QString environmentHandle_; /// Handle to selection environment QString environmentHandle_; /// Handle to selection environment
SelectionInterface::PrimitiveType vertexType_; /// Primitive type handle SelectionInterface::PrimitiveType vertexType_; /// Primitive type handle
SelectionInterface::PrimitiveType allSupportedTypes_; /// Primitive type handle SelectionInterface::PrimitiveType allSupportedTypes_; /// Primitive type handle
QPolygon lasso_2Dpoints_; /// Used for lasso selection tool QPolygon lasso_2Dpoints_; /// Used for lasso selection tool
QVector<QPoint> volumeLassoPoints_; /// Used for volume lasso tool QVector<QPoint> volumeLassoPoints_; /// Used for volume lasso tool
/** @} */ /** @} */
}; };
...@@ -263,20 +262,20 @@ class SelectVolumeAction ...@@ -263,20 +262,20 @@ class SelectVolumeAction
{ {
public: public:
SelectVolumeAction( QRegion &_region, SplatCloudObjectSelectionPlugin *_plugin, unsigned int _type, bool _deselection, ACG::GLState &_state ) : SelectVolumeAction( QRegion &_region, SplatCloudObjectSelectionPlugin *_plugin, unsigned int _type, bool _deselection, ACG::GLState &_state ) :
state_(_state), region_(_region), plugin_(_plugin), type_(_type), deselection_(_deselection) { } state_(_state), region_(_region), plugin_(_plugin), type_(_type), deselection_(_deselection) { }
void enter( BaseNode * /*_node*/ ) { } void enter( BaseNode * /*_node*/ ) { }
void leave( BaseNode * /*_node*/ ) { } void leave( BaseNode * /*_node*/ ) { }
bool operator()( BaseNode *_node ); bool operator()( BaseNode *_node );
private: private:
ACG::GLState &state_; ACG::GLState &state_;
QRegion &region_; QRegion &region_;
SplatCloudObjectSelectionPlugin *plugin_; SplatCloudObjectSelectionPlugin *plugin_;
unsigned int type_; unsigned int type_;
bool deselection_; bool deselection_;
}; };
......
...@@ -68,13 +68,15 @@ ...@@ -68,13 +68,15 @@
*/ */
bool SplatCloudObjectSelectionPlugin::splatCloudDeleteSelection( SplatCloud *_splatCloud, PrimitiveType _primitiveType ) bool SplatCloudObjectSelectionPlugin::splatCloudDeleteSelection( SplatCloud *_splatCloud, PrimitiveType _primitiveType )
{ {
if( _primitiveType & vertexType_ ) if( (_primitiveType & vertexType_) == 0 )
{ return false; // done
_splatCloud->initSelections();
return _splatCloud->deleteSelected();
}
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 ...@@ -90,16 +92,31 @@ bool SplatCloudObjectSelectionPlugin::splatCloudDeleteSelection( SplatCloud *_sp
*/ */
void SplatCloudObjectSelectionPlugin::splatCloudToggleSelection( SplatCloud *_splatCloud, uint _index, ACG::Vec3d &_hit_point, PrimitiveType _primitiveType ) void SplatCloudObjectSelectionPlugin::splatCloudToggleSelection( SplatCloud *_splatCloud, uint _index, ACG::Vec3d &_hit_point, PrimitiveType _primitiveType )
{ {
if( _primitiveType & vertexType_ ) if( (_primitiveType & vertexType_) == 0 )
{ return; // done
_splatCloud->initSelections();
_splatCloud->selections()[ _index ] = !_splatCloud->selections()[ _index ]; if( _splatCloud == 0 )
return; // error
if( _splatCloud->selections()[ _index ] )
emit scriptInfo( "selectVertices(ObjectId , [" + QString::number( _index ) + "])" ); if( /*(_index < 0) ||*/ (_index >= _splatCloud->numSplats()) )
else return; // error
emit scriptInfo( "unselectVertices(ObjectId , [" + QString::number( _index ) + "])" );
} 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 ...@@ -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 ) void SplatCloudObjectSelectionPlugin::splatCloudSphereSelection( SplatCloud *_splatCloud, uint _index, ACG::Vec3d &_hit_point, double _radius, PrimitiveType _primitiveType, bool _deselection )
{ {
if( _primitiveType & vertexType_ ) if( (_primitiveType & vertexType_) == 0 )
{ return; // done
_splatCloud->initSelections();
_splatCloud->setSphereSelections( _splatCloud->points()[ _index ], _radius * _radius, !_deselection ); 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;
}