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

Merge branch 'track_image_usage' into 'master'

keep tracking image usage for drawing(do not tracking usage

See merge request !4
parents c0787ef8 7ab5c068
...@@ -118,6 +118,10 @@ QwtFunctionPlot::QwtFunctionPlot(QWidget* _parent) : ...@@ -118,6 +118,10 @@ QwtFunctionPlot::QwtFunctionPlot(QWidget* _parent) :
image_ = 0; image_ = 0;
} }
QwtFunctionPlot::~QwtFunctionPlot()
{
delete histogram_;
}
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void QwtFunctionPlot::setFunction( std::vector<double>& _values) void QwtFunctionPlot::setFunction( std::vector<double>& _values)
......
...@@ -105,7 +105,7 @@ public: ...@@ -105,7 +105,7 @@ public:
explicit QwtFunctionPlot( QWidget* _parent = 0 ); explicit QwtFunctionPlot( QWidget* _parent = 0 );
/// Destructor /// Destructor
~QwtFunctionPlot() {} ~QwtFunctionPlot();
// set the function to plot // set the function to plot
void setFunction( std::vector<double>& _values ); void setFunction( std::vector<double>& _values );
......
...@@ -426,8 +426,9 @@ void texturePropertiesWidget::slotButtonBoxClicked(QAbstractButton* _button){ ...@@ -426,8 +426,9 @@ void texturePropertiesWidget::slotButtonBoxClicked(QAbstractButton* _button){
texture.filename( currentImage_ ); texture.filename( currentImage_ );
// Add it to the imagestore and set the index in the texture description // Add it to the imagestore and set the index in the texture description
texture.textureImageId( imageStore().addImageFile(currentImage_) ); int newImageId = imageStore().addImageFile(currentImage_);
texture.textureImageId( newImageId );
texData_->addManagedImageId( newImageId );
changed = true; changed = true;
} }
......
...@@ -66,6 +66,11 @@ class ImageStore { ...@@ -66,6 +66,11 @@ class ImageStore {
void removeImage(int _id); void removeImage(int _id);
inline const QMap<int,QImage>& imageMap() const{return imageMap_;}
inline const QMap< QString,QPair<int,QDateTime> >& filenameMap() const {return filenameMap_;}
inline const QMap<int,QString>& reverseFilenameMap() const {return reverseFilenameMap_;}
inline const QMap<int,unsigned int>& refCount() const {return refCount_;}
private: private:
QMap<int,QImage> imageMap_; QMap<int,QImage> imageMap_;
QMap< QString,QPair<int,QDateTime> > filenameMap_; QMap< QString,QPair<int,QDateTime> > filenameMap_;
......
...@@ -96,6 +96,7 @@ void TextureControlPlugin::slotTextureAdded(QString _textureName , QString _file ...@@ -96,6 +96,7 @@ void TextureControlPlugin::slotTextureAdded(QString _textureName , QString _file
newId = imageStore().addImage(_image); newId = imageStore().addImage(_image);
else else
newId = imageStore().addImageFile(_fileName); newId = imageStore().addImageFile(_fileName);
texData->addManagedImageId(newId);
if ( newId == -1 ) { if ( newId == -1 ) {
emit log(LOGERR,imageStore().error()); emit log(LOGERR,imageStore().error());
...@@ -163,6 +164,7 @@ void TextureControlPlugin::slotTextureAdded( QString _textureName , QString _fil ...@@ -163,6 +164,7 @@ void TextureControlPlugin::slotTextureAdded( QString _textureName , QString _fil
newImageId = imageStore().addImage(_image); newImageId = imageStore().addImage(_image);
else else
newImageId = imageStore().addImageFile(_filename); newImageId = imageStore().addImageFile(_filename);
globalTextures_.addManagedImageId(newImageId);
if ( newImageId == -1 ) { if ( newImageId == -1 ) {
emit log(LOGERR,imageStore().error()); emit log(LOGERR,imageStore().error());
...@@ -221,21 +223,21 @@ void TextureControlPlugin::slotMultiTextureAdded( QString _textureGroup , QStrin ...@@ -221,21 +223,21 @@ void TextureControlPlugin::slotMultiTextureAdded( QString _textureGroup , QStrin
//hide the texture (its accessible through the multiTexture) //hide the texture (its accessible through the multiTexture)
texData->texture(_name).hidden( true ); texData->texture(_name).hidden( true );
//
// Add to image store // // Add to image store
int newImageId; // int newImageId;
if(_filename.isEmpty()) // if(_filename.isEmpty())
newImageId = imageStore().addImage(_image); // newImageId = imageStore().addImage(_image);
else // else
newImageId = imageStore().addImageFile(_filename); // newImageId = imageStore().addImageFile(_filename);
//
if ( newImageId == -1 ) { // if ( newImageId == -1 ) {
emit log(LOGERR,imageStore().error()); // emit log(LOGERR,imageStore().error());
return; // return;
} // }
//
// Add to texture description // // Add to texture description
texData->texture(_name).textureImageId(newImageId); // texData->texture(_name).textureImageId(newImageId);
// Store the new texture in the list of this textureGroup // Store the new texture in the list of this textureGroup
if ( _textureId != -1 ) { if ( _textureId != -1 ) {
...@@ -283,7 +285,7 @@ void TextureControlPlugin::addedEmptyObject( int _id ) { ...@@ -283,7 +285,7 @@ void TextureControlPlugin::addedEmptyObject( int _id ) {
// Add to image store // Add to image store
int newImageId = imageStore().addImageFile(globalTextures_.textures()[i].filename()); int newImageId = imageStore().addImageFile(globalTextures_.textures()[i].filename());
texData->addManagedImageId(newImageId);
if ( newImageId == -1 ) { if ( newImageId == -1 ) {
emit log(LOGERR,imageStore().error()); emit log(LOGERR,imageStore().error());
continue; continue;
...@@ -1390,7 +1392,7 @@ void TextureControlPlugin::pluginsInitialized() { ...@@ -1390,7 +1392,7 @@ void TextureControlPlugin::pluginsInitialized() {
// ================================================================================ // ================================================================================
// Create action group and menu for global textures // Create action group and menu for global textures
// ================================================================================ // ================================================================================
actionGroup_ = new QActionGroup( 0 ); actionGroup_ = new QActionGroup(this);
actionGroup_->setExclusive( true ); actionGroup_->setExclusive( true );
connect( actionGroup_, SIGNAL( triggered( QAction * ) ), connect( actionGroup_, SIGNAL( triggered( QAction * ) ),
this, SLOT( slotTextureMenu( QAction * ) ) ); this, SLOT( slotTextureMenu( QAction * ) ) );
...@@ -1400,6 +1402,11 @@ void TextureControlPlugin::pluginsInitialized() { ...@@ -1400,6 +1402,11 @@ void TextureControlPlugin::pluginsInitialized() {
connect(AC_Texture_Settings, SIGNAL(triggered()), this, SLOT(slotSetTextureProperties())); connect(AC_Texture_Settings, SIGNAL(triggered()), this, SLOT(slotSetTextureProperties()));
textureMenu_->addAction(AC_Texture_Settings); textureMenu_->addAction(AC_Texture_Settings);
QAction *AC_Print_Pool_Info = new QAction(tr("&Print Image Pool Info"), this);
AC_Print_Pool_Info->setStatusTip(tr("Print stats info of image pool"));
connect(AC_Print_Pool_Info, SIGNAL(triggered()), this, SLOT(slotPrintImagePoolInfo()));
textureMenu_->addAction(AC_Print_Pool_Info);
textureMenu_->addSeparator(); textureMenu_->addSeparator();
textureMenu_->addActions(actionGroup_->actions()); textureMenu_->addActions(actionGroup_->actions());
...@@ -1431,7 +1438,32 @@ void TextureControlPlugin::slotSetTextureProperties() { ...@@ -1431,7 +1438,32 @@ void TextureControlPlugin::slotSetTextureProperties() {
settingsDialog_->show( &globalTextures_, -1); settingsDialog_->show( &globalTextures_, -1);
} }
void TextureControlPlugin::applyDialogSettings(TextureData* _texData, QString _textureName, int _id) { void TextureControlPlugin::slotPrintImagePoolInfo() {
size_t sumRefCount=0;
for(auto it=imageStore().refCount().begin(),end=imageStore().refCount().end();it!=end;++it)
{
sumRefCount+=it.value();
}
size_t sumBytes = 0;
for(auto it=imageStore().imageMap().begin(),end=imageStore().imageMap().end();it!=end;++it)
{
sumBytes+=it.value().byteCount();
}
QString poolInfo = tr("PoolInfo:[%1 images][%2 files][%3 refs][%4 KB]").arg(imageStore().imageMap().size())
.arg(imageStore().filenameMap().size()).arg(sumRefCount).arg(sumBytes/1024);
for(auto it=imageStore().refCount().begin(),end=imageStore().refCount().end();it!=end;++it)
{
emit log(LOGSTATUS,tr("%1 %2").arg(imageStore().reverseFilenameMap()[it.key()]).arg(it.value()));
}
emit log(LOGINFO, poolInfo);
}
void TextureControlPlugin::applyDialogSettings(TextureData *_texData, QString _textureName, int _id) {
if (_id != -1) if (_id != -1)
{ {
...@@ -1843,7 +1875,7 @@ void TextureControlPlugin::slotUpdateContextMenu( int _objectId ) { ...@@ -1843,7 +1875,7 @@ void TextureControlPlugin::slotUpdateContextMenu( int _objectId ) {
// Prepare Texture menu // Prepare Texture menu
// ================================================================================ // ================================================================================
contextMenu_->clear(); contextMenu_->clear();
QActionGroup* actionGroup = new QActionGroup(0); QActionGroup* actionGroup = new QActionGroup(this);
actionGroup->setExclusive( true ); actionGroup->setExclusive( true );
connect( actionGroup, SIGNAL( triggered( QAction * ) ), connect( actionGroup, SIGNAL( triggered( QAction * ) ),
this, SLOT( slotTextureContextMenu( QAction * ) ) ); this, SLOT( slotTextureContextMenu( QAction * ) ) );
......
...@@ -163,6 +163,9 @@ class TextureControlPlugin : public QObject, BaseInterface, BackupInterface, Tex ...@@ -163,6 +163,9 @@ class TextureControlPlugin : public QObject, BaseInterface, BackupInterface, Tex
/// Slot for showing the TextureProperties Dialog /// Slot for showing the TextureProperties Dialog
void slotSetTextureProperties(); void slotSetTextureProperties();
/// Print Pool Info
void slotPrintImagePoolInfo();
public : public :
/// Constructor /// Constructor
TextureControlPlugin(); TextureControlPlugin();
......
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
#include "TextureData.hh" #include "TextureData.hh"
#include "ImageStorage.hh"
#include <iostream> #include <iostream>
//----------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------
...@@ -74,7 +75,10 @@ TextureData::TextureData() : ...@@ -74,7 +75,10 @@ TextureData::TextureData() :
//----------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------
TextureData::~TextureData() { TextureData::~TextureData() {
for(const int& id:managedImageId_)
{
imageStore().removeImage(id);
}
} }
//----------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------
...@@ -331,3 +335,6 @@ std::map< int, std::string>* TextureData::propertyMap(){ ...@@ -331,3 +335,6 @@ std::map< int, std::string>* TextureData::propertyMap(){
return &propertyMap_; return &propertyMap_;
} }
void TextureData::addManagedImageId(int _imageId){
managedImageId_.push_back(_imageId);
}
\ No newline at end of file
...@@ -52,9 +52,9 @@ ...@@ -52,9 +52,9 @@
#include <ACG/GL/gl.hh> #include <ACG/GL/gl.hh>
#include <vector> #include <vector>
#include <map> #include <map>
#include <set>
#include <cfloat> #include <cfloat>
enum TextureType { UNSET = 1 << 0, enum TextureType { UNSET = 1 << 0,
/// Texture Coordinates are stored on a per Vertex basis /// Texture Coordinates are stored on a per Vertex basis
VERTEXBASED = 1 << 1, VERTEXBASED = 1 << 1,
...@@ -265,8 +265,9 @@ class TextureData : public PerObjectData ...@@ -265,8 +265,9 @@ class TextureData : public PerObjectData
*/ */
std::map< int, std::string >* propertyMap(); std::map< int, std::string >* propertyMap();
void addManagedImageId(int _imageId);
private : private :
std::vector<int> managedImageId_;
std::map< int, GLuint> textureMap_; std::map< int, GLuint> textureMap_;
std::map< int, std::string> propertyMap_; std::map< int, std::string> propertyMap_;
......
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