Commit 7ab5c068 authored by Johannes Lenzen's avatar Johannes Lenzen

keep tracking image usage for drawing(do not tracking usage

 beyond TextureControl) safe for change image in TextureSetting Share texture
 if open multiple images. Remove while removing object from sceneTree.

Patch by: Shaun Song <sxsong1207@qq.com>
parent c0787ef8
......@@ -102,10 +102,10 @@ QwtFunctionPlot::QwtFunctionPlot(QWidget* _parent) :
connect(zoomInButton, SIGNAL( clicked() ), this,SLOT( zoomIn() ) );
connect(zoomOutButton,SIGNAL( clicked() ), this,SLOT( zoomOut() ) );
connect(clampButton, SIGNAL( clicked() ), this,SLOT( clamp() ) );
QwtPlotPanner *panner = new QwtPlotPanner( qwtPlot->canvas() );
panner->setMouseButton( Qt::MidButton );
// delete widget on close
setAttribute(Qt::WA_DeleteOnClose, true);
......@@ -118,6 +118,10 @@ QwtFunctionPlot::QwtFunctionPlot(QWidget* _parent) :
image_ = 0;
}
QwtFunctionPlot::~QwtFunctionPlot()
{
delete histogram_;
}
//------------------------------------------------------------------------------
void QwtFunctionPlot::setFunction( std::vector<double>& _values)
......
......@@ -105,7 +105,7 @@ public:
explicit QwtFunctionPlot( QWidget* _parent = 0 );
/// Destructor
~QwtFunctionPlot() {}
~QwtFunctionPlot();
// set the function to plot
void setFunction( std::vector<double>& _values );
......@@ -131,7 +131,7 @@ public slots:
void zoomIn();
void zoomOut();
void clamp();
void replot();
private:
......
......@@ -426,8 +426,9 @@ void texturePropertiesWidget::slotButtonBoxClicked(QAbstractButton* _button){
texture.filename( currentImage_ );
// 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;
}
......
......@@ -66,6 +66,11 @@ class ImageStore {
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:
QMap<int,QImage> imageMap_;
QMap< QString,QPair<int,QDateTime> > filenameMap_;
......
This diff is collapsed.
......@@ -163,6 +163,9 @@ class TextureControlPlugin : public QObject, BaseInterface, BackupInterface, Tex
/// Slot for showing the TextureProperties Dialog
void slotSetTextureProperties();
/// Print Pool Info
void slotPrintImagePoolInfo();
public :
/// Constructor
TextureControlPlugin();
......
......@@ -42,6 +42,7 @@
#include "TextureData.hh"
#include "ImageStorage.hh"
#include <iostream>
//-----------------------------------------------------------------------------------
......@@ -74,7 +75,10 @@ TextureData::TextureData() :
//-----------------------------------------------------------------------------------
TextureData::~TextureData() {
for(const int& id:managedImageId_)
{
imageStore().removeImage(id);
}
}
//-----------------------------------------------------------------------------------
......@@ -331,3 +335,6 @@ std::map< int, std::string>* TextureData::propertyMap(){
return &propertyMap_;
}
void TextureData::addManagedImageId(int _imageId){
managedImageId_.push_back(_imageId);
}
\ No newline at end of file
......@@ -52,9 +52,9 @@
#include <ACG/GL/gl.hh>
#include <vector>
#include <map>
#include <set>
#include <cfloat>
enum TextureType { UNSET = 1 << 0,
/// Texture Coordinates are stored on a per Vertex basis
VERTEXBASED = 1 << 1,
......@@ -68,7 +68,7 @@ enum TextureType { UNSET = 1 << 0,
class Texture {
public :
Texture();
// copy constructor
Texture( const Texture& _tex)
: parameters(_tex.parameters),
......@@ -195,13 +195,13 @@ class TextureData : public PerObjectData
TextureData();
/// Destructor
~TextureData();
// copy Operator returning an exact copy of this Object
virtual PerObjectData* copyPerObjectData( ) {
// Create an object copy (This will call all copy constructors of the included data objects! )
TextureData* copy = new TextureData(*this);
return copy;
}
......@@ -222,7 +222,7 @@ class TextureData : public PerObjectData
/// Add a Texture without file backing
int addTexture ( QString _textureName , uint _dimension, GLuint _glName ){return addTexture ( _textureName , QString("Invalid") , _dimension, _glName );}
/// Add a Texture
int addTexture ( QString _textureName , QString _filename , uint _dimension, GLuint _glName );
......@@ -265,8 +265,9 @@ class TextureData : public PerObjectData
*/
std::map< int, std::string >* propertyMap();
void addManagedImageId(int _imageId);
private :
std::vector<int> managedImageId_;
std::map< int, GLuint> textureMap_;
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