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

Completly rewrite texturecontrol.

Not yet complete.

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@5634 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 0cf983ae
This diff is collapsed.
......@@ -44,12 +44,15 @@
#include <OpenFlipper/BasePlugin/TextureInterface.hh>
#include <OpenFlipper/BasePlugin/LoggingInterface.hh>
#include <OpenFlipper/BasePlugin/MenuInterface.hh>
#include <OpenFlipper/BasePlugin/LoadSaveInterface.hh>
#include <ObjectTypes/PolyMesh/PolyMesh.hh>
#include <ObjectTypes/TriangleMesh/TriangleMesh.hh>
#include <OpenFlipper/common/Types.hh>
#include "textureProperties.hh"
#include "TextureData.hh"
/*
struct Texture {
QString name;
QString filename;
......@@ -70,15 +73,16 @@ struct Texture {
bool scale;
uint type;
};
};*/
class TextureControlPlugin : public QObject, BaseInterface, TextureInterface, MenuInterface, LoggingInterface
class TextureControlPlugin : public QObject, BaseInterface, TextureInterface, MenuInterface, LoggingInterface, LoadSaveInterface
{
Q_OBJECT
Q_INTERFACES(BaseInterface)
Q_INTERFACES(TextureInterface)
Q_INTERFACES(MenuInterface)
Q_INTERFACES(LoggingInterface)
Q_INTERFACES(LoadSaveInterface)
public:
enum TextureType { VERTEXBASED = 1 << 0, HALFEDGEBASED = 1 << 1};
......@@ -94,6 +98,8 @@ class TextureControlPlugin : public QObject, BaseInterface, TextureInterface, Me
// MenuInterface
void addMenubarAction(QAction* _action, MenuActionType _type );
private slots:
// BaseInterface
void pluginsInitialized();
......@@ -105,6 +111,9 @@ class TextureControlPlugin : public QObject, BaseInterface, TextureInterface, Me
void slotSetTextureMode(QString _textureName ,QString _mode);
void slotSwitchTexture( QString _textureName );
// LoadSaveInterface
void fileOpened( int _id );
private slots:
/// Called when an action in the TextureMenu is triggered
void slotTextureMenu(QAction* _action);
......@@ -136,7 +145,7 @@ class TextureControlPlugin : public QObject, BaseInterface, TextureInterface, Me
QString activeTexture_;
std::vector< Texture > textures_;
TextureData globalTextures_;
std::vector<QAction*> textureActions_;
......@@ -151,11 +160,11 @@ class TextureControlPlugin : public QObject, BaseInterface, TextureInterface, Me
/// Take a scalar value and return a clamped,... depending on texture settings
inline
void computeValue(int _textureid, double _min, double _max, double& _value);
void computeValue(Texture& _texture, double _min, double _max, double& _value);
/// Calls the correct \a copyTexture() function to copy the texture property into the displayed OM property
template< typename MeshT >
void doUpdateTexture ( int _textureid, MeshT& _mesh);
void doUpdateTexture ( Texture& _texture , MeshT& _mesh);
template< typename MeshT >
void getOriginalHistogram(std::vector< double>& _x, std::vector< double>& _y,
......@@ -169,22 +178,22 @@ class TextureControlPlugin : public QObject, BaseInterface, TextureInterface, Me
/// Copy the supplied 1D vertex property to both coordinates of the 2D vertex OM texture property
template< typename MeshT >
void copyTexture(int _textureid, MeshT& _mesh, OpenMesh::VPropHandleT< double > _texProp );
void copyTexture(Texture& _texture , MeshT& _mesh, OpenMesh::VPropHandleT< double > _texProp );
/// Copy the supplied 1D halfedge property to both coordinates of the 2D halfedge OM texture property
template< typename MeshT >
void copyTexture(int _textureid, MeshT& _mesh, OpenMesh::HPropHandleT< double > _texProp );
void copyTexture(Texture& _texture , MeshT& _mesh, OpenMesh::HPropHandleT< double > _texProp );
/// For a given mesh compute the minimum and maximum values depending on texture settings (vertex based)
template< typename MeshT >
inline
void computeMinMaxScalar(int _textureid, MeshT& _mesh,OpenMesh::VPropHandleT< double > _texture,double& _min , double& _max);
void computeMinMaxScalar(Texture& _textureData , MeshT& _mesh ,OpenMesh::VPropHandleT< double > _texture,double& _min , double& _max);
/// For a given mesh compute the minimum and maximum values depending on texture settings (halfedge based)
template< typename MeshT >
inline
void computeMinMaxScalar(int _textureid, MeshT& _mesh,OpenMesh::HPropHandleT< double > _texture,double& _min , double& _max);
void computeMinMaxScalar(Texture& _textureData , MeshT& _mesh,OpenMesh::HPropHandleT< double > _texture,double& _min , double& _max);
/** @} */
......@@ -196,10 +205,10 @@ class TextureControlPlugin : public QObject, BaseInterface, TextureInterface, Me
/// Copy the supplied 2D vertex property to the 2D vertex OM property
template< typename MeshT >
void copyTexture(int _textureid, MeshT& _mesh, OpenMesh::VPropHandleT< ACG::Vec2d > _texProp );
void copyTexture(Texture& _texture, MeshT& _mesh, OpenMesh::VPropHandleT< ACG::Vec2d > _texProp );
/// Copy the supplied 2D halfedge property to the 2D halfedge OM property
template< typename MeshT >
void copyTexture(int _textureid, MeshT& _mesh, OpenMesh::HPropHandleT< ACG::Vec2d > _texProp );
void copyTexture(Texture& _texture, MeshT& _mesh, OpenMesh::HPropHandleT< ACG::Vec2d > _texProp );
/** @} */
......
......@@ -34,12 +34,15 @@
#include "TextureControl.hh"
template< typename MeshT >
void TextureControlPlugin::computeMinMaxScalar(int _textureid, MeshT& _mesh,OpenMesh::VPropHandleT< double > _texture,
double& _min , double& _max) {
const bool abs = textures_[_textureid].abs;
const bool clamp = textures_[_textureid].clamp ;
const double clamp_max = textures_[_textureid].clamp_max;
const double clamp_min = textures_[_textureid].clamp_min;
void TextureControlPlugin::computeMinMaxScalar(Texture& _textureData ,
MeshT& _mesh,
OpenMesh::VPropHandleT< double > _texture,
double& _min , double& _max) {
const bool abs = _textureData.parameters.abs;
const bool clamp = _textureData.parameters.clamp ;
const double clamp_max = _textureData.parameters.clamp_max;
const double clamp_min = _textureData.parameters.clamp_min;
_max = FLT_MIN;
_min = FLT_MAX;
......@@ -63,12 +66,15 @@ void TextureControlPlugin::computeMinMaxScalar(int _textureid, MeshT& _mesh,Open
}
template< typename MeshT >
void TextureControlPlugin::computeMinMaxScalar(int _textureid, MeshT& _mesh,OpenMesh::HPropHandleT< double > _texture,
double& _min , double& _max) {
const bool abs = textures_[_textureid].abs;
const bool clamp = textures_[_textureid].clamp ;
const double clamp_max = textures_[_textureid].clamp_max;
const double clamp_min = textures_[_textureid].clamp_min;
void TextureControlPlugin::computeMinMaxScalar(Texture& _textureData ,
MeshT& _mesh,
OpenMesh::HPropHandleT< double > _texture,
double& _min , double& _max) {
const bool abs = _textureData.parameters.abs;
const bool clamp = _textureData.parameters.clamp ;
const double clamp_max = _textureData.parameters.clamp_max;
const double clamp_min = _textureData.parameters.clamp_min;
_max = FLT_MIN;
_min = FLT_MAX;
......@@ -92,18 +98,18 @@ void TextureControlPlugin::computeMinMaxScalar(int _textureid, MeshT& _mesh,Open
}
template< typename MeshT >
void TextureControlPlugin::copyTexture ( int _textureid, MeshT& _mesh, OpenMesh::VPropHandleT< double > _texProp )
void TextureControlPlugin::copyTexture ( Texture& _texture , MeshT& _mesh, OpenMesh::VPropHandleT< double > _texProp )
{
// Compute some basic values for this texture
double max,min;
computeMinMaxScalar(_textureid, _mesh, _texProp, min, max);
computeMinMaxScalar(_texture, _mesh, _texProp, min, max);
for ( typename MeshT::VertexIter v_it = _mesh.vertices_begin(); v_it != _mesh.vertices_end(); ++v_it) {
// Get the value of the property
double value = _mesh.property(_texProp, v_it);
// Mangle it with the predefined user options
computeValue(_textureid, min, max, value);
computeValue(_texture, min, max, value);
// Write result to the openmesh texture coordinates ( 2d accessing the diagonal of a 2d texture)
_mesh.set_texcoord2D( v_it, ACG::Vec2f(float(value), float(value) ) );
......@@ -111,11 +117,11 @@ void TextureControlPlugin::copyTexture ( int _textureid, MeshT& _mesh, OpenMesh:
}
template< typename MeshT >
void TextureControlPlugin::copyTexture ( int _textureid, MeshT& _mesh, OpenMesh::HPropHandleT< double > _texProp )
void TextureControlPlugin::copyTexture ( Texture& _texture , MeshT& _mesh, OpenMesh::HPropHandleT< double > _texProp )
{
// Compute some basic values for this texture
double max,min;
computeMinMaxScalar(_textureid, _mesh, _texProp, min, max);
computeMinMaxScalar(_texture, _mesh, _texProp, min, max);
for ( typename MeshT::HalfedgeIter h_it = _mesh.halfedges_begin(); h_it != _mesh.halfedges_end(); ++h_it) {
......@@ -123,7 +129,7 @@ void TextureControlPlugin::copyTexture ( int _textureid, MeshT& _mesh, OpenMesh:
double value = _mesh.property(_texProp, h_it);
// Mangle it with the predefined user options
computeValue(_textureid, min, max, value);
computeValue(_texture, min, max, value);
// Write result to the openmesh texture coordinates ( 2d accessing the diagonal of a 2d texture)
_mesh.set_texcoord2D( h_it, ACG::Vec2f(float(value), float(value) ) );
......
......@@ -34,7 +34,7 @@
#include "TextureControl.hh"
template< typename MeshT >
void TextureControlPlugin::copyTexture ( int /*_textureid*/, MeshT& _mesh, OpenMesh::VPropHandleT< OpenMesh::Vec2d > _texProp )
void TextureControlPlugin::copyTexture ( Texture& /*_texture*/, MeshT& _mesh, OpenMesh::VPropHandleT< OpenMesh::Vec2d > _texProp )
{
for ( typename MeshT::VertexIter v_it = _mesh.vertices_begin(); v_it != _mesh.vertices_end(); ++v_it) {
......@@ -47,7 +47,7 @@ void TextureControlPlugin::copyTexture ( int /*_textureid*/, MeshT& _mesh, OpenM
}
template< typename MeshT >
void TextureControlPlugin::copyTexture ( int /*_textureid*/, MeshT& _mesh, OpenMesh::HPropHandleT< OpenMesh::Vec2d > _texProp )
void TextureControlPlugin::copyTexture ( Texture& /*_texture*/, MeshT& _mesh, OpenMesh::HPropHandleT< OpenMesh::Vec2d > _texProp )
{
for ( typename MeshT::HalfedgeIter h_it = _mesh.halfedges_begin(); h_it != _mesh.halfedges_end(); ++h_it) {
......
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