"0021179: EDF 1654 SMESH GEOM: better look'n'feel" issue.

Material Properties.
This commit is contained in:
ana 2012-05-03 14:15:15 +00:00
parent 956e89f015
commit 8ad1208104
6 changed files with 555 additions and 996 deletions

View File

@ -454,7 +454,6 @@ void GEOMToolsGUI_MaterialPropertiesDlg::onApply()
SUIT_OverrideCursor wc();
printf("material prop:%s\n", qPrintable(prop));
for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
Handle(GEOM_AISShape) aisShape = GEOMBase::ConvertIOinGEOMAISShape( It.Value(), true );
if ( !aisShape.IsNull() ) {

View File

@ -25,38 +25,25 @@
#include "GEOM_ToolsGUI.hxx"
#include <QListWidget>
#include <QtxDialog.h>
#include <QFrame>
#include <QMap>
#include "Material_Model.h"
#include "Material_ResourceMgr.h"
class QCheckBox;
class QGroupBox;
class QLabel;
class QListWidget;
class QListWidgetItem;
class QPushButton;
class QSpinBox;
class QTabWidget;
class QSlider;
class QtxColorButton;
class QtxDoubleSpinBox;
class Material_Model;
class Material_ResourceMgr;
class GEOMToolsGUI_MaterialList;
class GEOMTOOLSGUI_EXPORT GEOMToolsGUI_MaterialPropertiesDlg : public QtxDialog
{
Q_OBJECT
enum { Current, Default, Global, User };
enum { Current, Global, User };
enum { TypeRole = Qt::UserRole + 123, NameRole };
//! Enumeration of viewer types
typedef enum {
OCC, //!< OCC viewer
VTK //!< VTK viewer
} ViewerType;
public:
GEOMToolsGUI_MaterialPropertiesDlg( QWidget* = 0 );
~GEOMToolsGUI_MaterialPropertiesDlg();
@ -66,66 +53,56 @@ public:
bool eventFilter( QObject*, QEvent* );
private:
Material_ResourceMgr* resourceMgr();
void fromModel( Material_Model* );
void toModel( Material_Model* ) const;
void updateState();
void toModel( Material_Model& ) const;
void fromModel( const Material_Model& );
QString findUniqueName( const QString&,
QListWidgetItem* = 0,
bool = false );
QListWidgetItem* = 0,
bool = false );
signals:
void materialChanged();
void changed();
private slots:
void onChanged();
void onMaterialChanged();
void onItemChanged( QListWidgetItem* );
void onContextMenu( QContextMenuEvent* );
void onDeleteMaterial();
void onAddMaterial();
void onApply();
void onHelp();
void onMaterialChanged();
void onChanged();
void onItemChanged( QListWidgetItem* );
void onReflectionTypeToggled( bool );
private:
Material_ResourceMgr* myResMgr;
typedef struct
{
QLabel* label;
QtxColorButton* color;
QSlider* coef;
QCheckBox* enabled;
} Reflection;
QCheckBox* myMaterialPhysicalCheck;
GEOMToolsGUI_MaterialList* myMaterials;
QCheckBox* myPhysical;
QList<Reflection> myReflection;
QSlider* myShininess;
QLabel* myColorLab;
QtxColorButton* myColor;
QPushButton* myAddButton;
QPushButton* myDelButton;
Material_ResourceMgr myResourceMgr;
Material_Model myCurrentModel;
};
//! Current material model for material
Material_Model* myCurrentModelF;
QListWidget* myMaterialList;
int myMaterialListFId;
QTabWidget* myMaterialTab;
//! Controls defining material properties
QGroupBox* myAmbientGroupF;
QtxColorButton* myAmbientColorF;
QtxDoubleSpinBox* myAmbientCoefntF;
QGroupBox* myDiffuseGroupF;
QtxColorButton* myDiffuseColorF;
QtxDoubleSpinBox* myDiffuseCoefntF;
QGroupBox* mySpecularGroupF;
QtxColorButton* mySpecularColorF;
QtxDoubleSpinBox* mySpecularCoefntF;
QGroupBox* myEmissionGroupF;
QtxColorButton* myEmissionColorF;
QtxDoubleSpinBox* myEmissionCoefntF;
QtxDoubleSpinBox* myShininessF;
QString myHelpFileName;
ViewerType myViewerType;
class GEOMToolsGUI_MaterialList : public QListWidget
{
Q_OBJECT
public:
GEOMToolsGUI_MaterialList( QWidget* parent );
protected:
void contextMenuEvent( QContextMenuEvent* e );
signals:
void contextMenu( QContextMenuEvent* );
};
#endif // GEOMTOOLSGUI_MATERIALPROPERTIESDLG_H

File diff suppressed because it is too large Load Diff

View File

@ -28,86 +28,69 @@
#include <QColor>
#include <QMap>
#include <QString>
#include <QVector>
class Graphic3d_MaterialAspect;
class GEOM_VTKPropertyMaterial;
#include <Graphic3d_MaterialAspect.hxx>
class QtxResourceMgr;
class GEOM_VTKPropertyMaterial;
class MATERIAL_SALOME_EXPORT Material_Model
{
public:
//! Enumeration of reflection types of material
//! Reflection type
typedef enum {
Ambient, //!< Ambient
Diffuse, //!< Diffuse
Specular, //!< Specular
Emission //!< Emission
Emissive //!< Emissive
} ReflectionType;
Material_Model();
virtual ~Material_Model();
static Material_Model* getMaterialModel( QStringList );
QString getMaterialProperty();
Graphic3d_MaterialAspect getMaterialOCCAspect();
GEOM_VTKPropertyMaterial* getMaterialVTKProperty();
void initDefaults();
void fromResources( QtxResourceMgr*, const QString& = QString());
void save( QtxResourceMgr* = 0, const QString& = QString() );
QtxResourceMgr* resourceMgr() const;
QString resourceSection() const;
bool hasAmbientReflection();
bool hasDiffuseReflection();
bool hasSpecularReflection();
bool hasEmissionReflection();
QColor color( ReflectionType ) const;
void setColor( ReflectionType, const QColor& );
void setColor( QString,
QString,
ReflectionType );
void removeColor( ReflectionType );
double coefficient( ReflectionType ) const;
void setCoefficient( ReflectionType, double );
void setCoefficient( QString,
QString,
ReflectionType );
void removeCoefficient( ReflectionType );
double shininess() const;
void setShininess( double );
void fromProperties( const QString& );
QString toProperties();
void fromResources( const QString& = QString(), QtxResourceMgr* = 0 );
void toResources( const QString&, QtxResourceMgr* );
bool isPhysical() const;
void setPhysical( bool );
private:
void clearModel();
bool hasReflection( ReflectionType ) const;
void setReflection( ReflectionType, bool );
QColor color( ReflectionType ) const;
void setColor( ReflectionType, const QColor& );
double reflection( ReflectionType ) const;
void setReflection( ReflectionType, double );
double shininess() const;
void setShininess( double );
double transparency() const;
void setTransparency( double );
Graphic3d_MaterialAspect getMaterialOCCAspect();
GEOM_VTKPropertyMaterial* getMaterialVTKProperty();
private:
typedef QMap<ReflectionType, QColor> ColorMap;
typedef QMap<ReflectionType, double> CoefficientMap;
void init();
QtxResourceMgr* myResourceMgr;
QString myResourceSection;
private:
typedef struct {
QColor color;
double coef;
bool enabled;
} ReflectionData;
ColorMap myColors;
CoefficientMap myCoefficients;
double myShininess;
typedef QVector<ReflectionData> ReflectionList;
bool myIsPhysical;
double myShininess;
double myTransparency;
ReflectionList myReflection;
};
#endif // MATERIAL_MODEL_H

View File

@ -19,11 +19,8 @@
// File : Material_ResourceMgr.cxx
// Author : Margarita KARPUNINA, Open CASCADE S.A.S. (margarita.karpunina@opencascade.com)
//
#include "Material_ResourceMgr.h"
//#include "Qtx.h" // used to print colors of global materials
//#include <iostream> // used to print colors of global materials
#include "Material_ResourceMgr.h"
/*!
\class Material_ResourceMgr
@ -49,299 +46,6 @@ Material_ResourceMgr::Material_ResourceMgr()
if ( dirList().isEmpty() && ::getenv( "GEOM_ROOT_DIR" ) )
setDirList( QStringList() << Qtx::addSlash( ::getenv( "GEOM_ROOT_DIR" ) ) + "share/salome/resources/geom" );
setCurrentFormat( "xml" );
/*
// Get string equivalent for colors of global materials ---->
QColor c;
QString s;
// 1. ============= Plastic
std::cout << "---- Plastic:" << std::endl;
// ambient
c.setRgbF(0.2, 0.2, 0.2);
s = Qtx::colorToString( c );
std::cout << " ambient color: " << s.toStdString().c_str() << std::endl;
// diffuse
c.setRgbF(0.0, 0.0, 0.0);
s = Qtx::colorToString( c );
std::cout << " diffuse color: " << s.toStdString().c_str() << std::endl;
// specular
c.setRgbF(1.0, 1.0, 1.0);
s = Qtx::colorToString( c );
std::cout << " specular color: " << s.toStdString().c_str() << std::endl;
// 2. ============= Shiny plastic
std::cout << "---- Shiny plastic:" << std::endl;
// ambient
c.setRgbF(0.2, 0.2, 0.2);
s = Qtx::colorToString( c );
std::cout << " ambient color: " << s.toStdString().c_str() << std::endl;
// diffuse
c.setRgbF(0.0, 0.0, 0.0);
s = Qtx::colorToString( c );
std::cout << " diffuse color: " << s.toStdString().c_str() << std::endl;
// specular
c.setRgbF(1.0, 1.0, 1.0);
s = Qtx::colorToString( c );
std::cout << " specular color: " << s.toStdString().c_str() << std::endl;
// 3. ============= Satin
std::cout << "---- Satin:" << std::endl;
// ambient
c.setRgbF(0.2, 0.2, 0.2);
s = Qtx::colorToString( c );
std::cout << " ambient color: " << s.toStdString().c_str() << std::endl;
// diffuse
c.setRgbF(0.0, 0.0, 0.0);
s = Qtx::colorToString( c );
std::cout << " diffuse color: " << s.toStdString().c_str() << std::endl;
// specular
c.setRgbF(1.0, 1.0, 1.0);
s = Qtx::colorToString( c );
std::cout << " specular color: " << s.toStdString().c_str() << std::endl;
// 4. ============= Metal
std::cout << "---- Metal:" << std::endl;
// diffuse
c.setRgbF(0.0, 0.0, 0.0);
s = Qtx::colorToString( c );
std::cout << " diffuse color: " << s.toStdString().c_str() << std::endl;
// specular
c.setRgbF(1.0, 1.0, 1.0);
s = Qtx::colorToString( c );
std::cout << " specular color: " << s.toStdString().c_str() << std::endl;
// 5. ============= Brass
std::cout << "---- Brass:" << std::endl;
// ambient
c.setRgbF(0.329412, 0.223529, 0.027451);
s = Qtx::colorToString( c );
std::cout << " ambient color: " << s.toStdString().c_str() << std::endl;
// diffuse
c.setRgbF(0.780392, 0.568627, 0.113725);
s = Qtx::colorToString( c );
std::cout << " diffuse color: " << s.toStdString().c_str() << std::endl;
// specular
c.setRgbF(0.992157, 0.941176, 0.807843);
s = Qtx::colorToString( c );
std::cout << " specular color: " << s.toStdString().c_str() << std::endl;
// 6. ============= Bronze
std::cout << "---- Bronze:" << std::endl;
// ambient
c.setRgbF(0.2125, 0.1275, 0.054);
s = Qtx::colorToString( c );
std::cout << " ambient color: " << s.toStdString().c_str() << std::endl;
// diffuse
c.setRgbF(0.714, 0.4284, 0.18144);
s = Qtx::colorToString( c );
std::cout << " diffuse color: " << s.toStdString().c_str() << std::endl;
// specular
c.setRgbF(0.393548, 0.271906, 0.166721);
s = Qtx::colorToString( c );
std::cout << " specular color: " << s.toStdString().c_str() << std::endl;
// 7. ============= Copper
std::cout << "---- Copper:" << std::endl;
// ambient
c.setRgbF(0.33, 0.26, 0.23);
s = Qtx::colorToString( c );
std::cout << " ambient color: " << s.toStdString().c_str() << std::endl;
// diffuse
c.setRgbF(0.50, 0.11, 0.0);
s = Qtx::colorToString( c );
std::cout << " diffuse color: " << s.toStdString().c_str() << std::endl;
// specular
c.setRgbF(0.95, 0.73, 0.0);
s = Qtx::colorToString( c );
std::cout << " specular color: " << s.toStdString().c_str() << std::endl;
// 8. ============= Gold
std::cout << "---- Gold:" << std::endl;
// ambient
c.setRgbF(1.0, 0.76862745, 0.31764706);
s = Qtx::colorToString( c );
std::cout << " ambient color: " << s.toStdString().c_str() << std::endl;
// diffuse
c.setRgbF(1.0, 0.69, 0.0);
s = Qtx::colorToString( c );
std::cout << " diffuse color: " << s.toStdString().c_str() << std::endl;
// specular
c.setRgbF(1.0, 0.98, 0.78);
s = Qtx::colorToString( c );
std::cout << " specular color: " << s.toStdString().c_str() << std::endl;
// 9. ============= Pewter
std::cout << "---- Pewter:" << std::endl;
// ambient
c.setRgbF(0.105882, 0.058824, 0.113725);
s = Qtx::colorToString( c );
std::cout << " ambient color: " << s.toStdString().c_str() << std::endl;
// diffuse
c.setRgbF(0.427451, 0.470588, 0.541176);
s = Qtx::colorToString( c );
std::cout << " diffuse color: " << s.toStdString().c_str() << std::endl;
// specular
c.setRgbF(0.333333, 0.333333, 0.521569);
s = Qtx::colorToString( c );
std::cout << " specular color: " << s.toStdString().c_str() << std::endl;
// 10. ============= Plaster
std::cout << "---- Plaster:" << std::endl;
// ambient
c.setRgbF(0.19225, 0.19225, 0.19225);
s = Qtx::colorToString( c );
std::cout << " ambient color: " << s.toStdString().c_str() << std::endl;
// diffuse
c.setRgbF(0.50754, 0.50754, 0.50754);
s = Qtx::colorToString( c );
std::cout << " diffuse color: " << s.toStdString().c_str() << std::endl;
// specular
c.setRgbF(0.508273, 0.508273, 0.508273);
s = Qtx::colorToString( c );
std::cout << " specular color: " << s.toStdString().c_str() << std::endl;
// 11. ============= Silver
std::cout << "---- Silver:" << std::endl;
// ambient
c.setRgbF(0.19225, 0.19225, 0.19225);
s = Qtx::colorToString( c );
std::cout << " ambient color: " << s.toStdString().c_str() << std::endl;
// diffuse
c.setRgbF(0.50754, 0.50754, 0.50754);
s = Qtx::colorToString( c );
std::cout << " diffuse color: " << s.toStdString().c_str() << std::endl;
// specular
c.setRgbF(0.508273, 0.508273, 0.508273);
s = Qtx::colorToString( c );
std::cout << " specular color: " << s.toStdString().c_str() << std::endl;
// 12. ============= Steel
std::cout << "---- Steel:" << std::endl;
// ambient
c.setRgbF(0.2, 0.2, 0.2);
s = Qtx::colorToString( c );
std::cout << " ambient color: " << s.toStdString().c_str() << std::endl;
// diffuse
c.setRgbF(0.0, 0.0, 0.0);
s = Qtx::colorToString( c );
std::cout << " diffuse color: " << s.toStdString().c_str() << std::endl;
// specular
c.setRgbF(1.0, 1.0, 1.0);
s = Qtx::colorToString( c );
std::cout << " specular color: " << s.toStdString().c_str() << std::endl;
// 13. ============= Stone
std::cout << "---- Stone:" << std::endl;
// ambient
c.setRgbF(1.0, 0.8, 0.62);
s = Qtx::colorToString( c );
std::cout << " ambient color: " << s.toStdString().c_str() << std::endl;
// diffuse
c.setRgbF(1.0, 0.8, 0.62);
s = Qtx::colorToString( c );
std::cout << " diffuse color: " << s.toStdString().c_str() << std::endl;
// specular
c.setRgbF(0.98, 1.0, 0.60);
s = Qtx::colorToString( c );
std::cout << " specular color: " << s.toStdString().c_str() << std::endl;
// 14. ============= Chrome
std::cout << "---- Chrome:" << std::endl;
// ambient
c.setRgbF(0.35, 0.35, 0.35);
s = Qtx::colorToString( c );
std::cout << " ambient color: " << s.toStdString().c_str() << std::endl;
// diffuse
c.setRgbF(0.4, 0.4, 0.4);
s = Qtx::colorToString( c );
std::cout << " diffuse color: " << s.toStdString().c_str() << std::endl;
// specular
c.setRgbF(0.974597, 0.974597, 0.974597);
s = Qtx::colorToString( c );
std::cout << " specular color: " << s.toStdString().c_str() << std::endl;
// 15. ============= Neon
std::cout << "---- Neon:" << std::endl;
// ambient
c.setRgbF(1.0, 1.0, 1.0);
s = Qtx::colorToString( c );
std::cout << " ambient color: " << s.toStdString().c_str() << std::endl;
// diffuse
c.setRgbF(1.0, 1.0, 1.0);
s = Qtx::colorToString( c );
std::cout << " diffuse color: " << s.toStdString().c_str() << std::endl;
// specular
c.setRgbF(1.0, 1.0, 1.0);
s = Qtx::colorToString( c );
std::cout << " specular color: " << s.toStdString().c_str() << std::endl;
// emissive
c.setRgbF(0.0, 1.0, 0.46);
s = Qtx::colorToString( c );
std::cout << " emissive color: " << s.toStdString().c_str() << std::endl;
// 16. ============= Aluminium
std::cout << "---- Aluminium:" << std::endl;
// ambient
c.setRgbF(0.30, 0.30, 0.30);
s = Qtx::colorToString( c );
std::cout << " ambient color: " << s.toStdString().c_str() << std::endl;
// diffuse
c.setRgbF(0.30, 0.30, 0.30);
s = Qtx::colorToString( c );
std::cout << " diffuse color: " << s.toStdString().c_str() << std::endl;
// specular
c.setRgbF(0.70, 0.70, 0.80);
s = Qtx::colorToString( c );
std::cout << " specular color: " << s.toStdString().c_str() << std::endl;
// 17. ============= Obsidian
std::cout << "---- Obsidian:" << std::endl;
// ambient
c.setRgbF(0.05375, 0.05, 0.06625);
s = Qtx::colorToString( c );
std::cout << " ambient color: " << s.toStdString().c_str() << std::endl;
// diffuse
c.setRgbF(0.18275, 0.17, 0.22525);
s = Qtx::colorToString( c );
std::cout << " diffuse color: " << s.toStdString().c_str() << std::endl;
// specular
c.setRgbF(0.332741, 0.328634, 0.346435);
s = Qtx::colorToString( c );
std::cout << " specular color: " << s.toStdString().c_str() << std::endl;
// 18. ============= Jade
std::cout << "---- Jade:" << std::endl;
// ambient
c.setRgbF(0.135, 0.2225, 0.1575);
s = Qtx::colorToString( c );
std::cout << " ambient color: " << s.toStdString().c_str() << std::endl;
// diffuse
c.setRgbF(0.54, 0.89, 0.63);
s = Qtx::colorToString( c );
std::cout << " diffuse color: " << s.toStdString().c_str() << std::endl;
// specular
c.setRgbF(0.316228, 0.316228, 0.316228);
s = Qtx::colorToString( c );
std::cout << " specular color: " << s.toStdString().c_str() << std::endl;
// 19. ============= Default material
std::cout << "---- Default material:" << std::endl;
// ambient
c.setRgbF(0.2, 0.2, 0.2);
s = Qtx::colorToString( c );
std::cout << " ambient color: " << s.toStdString().c_str() << std::endl;
// diffuse
c.setRgbF(0.0, 0.0, 0.0);
s = Qtx::colorToString( c );
std::cout << " diffuse color: " << s.toStdString().c_str() << std::endl;
// specular
c.setRgbF(1.0, 1.0, 1.0);
s = Qtx::colorToString( c );
std::cout << " specular color: " << s.toStdString().c_str() << std::endl;
// Get string equivalent for colors of global materials <----
*/
}
/*!
@ -359,49 +63,54 @@ Material_ResourceMgr::~Material_ResourceMgr()
*/
QStringList Material_ResourceMgr::materials( MaterialType theType, bool theSort )
{
QStringList sl;
// store original working mode
WorkingMode m = workingMode();
QStringList slglobal, sluser;
// retrieve all materials : global + user
setWorkingMode( AllowUserValues );
sluser = sections();
// retrieve only global materials
setWorkingMode( IgnoreUserValues );
slglobal = sections();
// remove global materials from user list to obtain only user materials
QMutableListIterator<QString> it( sluser );
while ( it.hasNext() ) {
QString s = it.next();
if ( slglobal.contains( s ) ) it.remove();
}
// remove 'common' material
slglobal.removeAll("[common]");
// restore original working mode
setWorkingMode( m );
// sort if necessary (separately global and user materials)
if ( theSort ) {
qSort( slglobal );
qSort( sluser );
}
// combine the materials to obtain result list
QStringList result;
switch ( theType ) {
case Global:
setWorkingMode( IgnoreUserValues );
sl = sections();
result = slglobal;
break;
case User:
{
setWorkingMode( AllowUserValues );
sl = sections();
setWorkingMode( IgnoreUserValues );
QMutableListIterator<QString> it( sl );
while ( it.hasNext() ) {
QString s = it.next();
if ( hasSection( s ) ) it.remove();
}
}
result = sluser;
break;
case All:
setWorkingMode( AllowUserValues );
sl = sections();
result = slglobal + sluser;
break;
default:
break;
}
setWorkingMode( m );
if ( theSort )
qSort( sl );
return sl;
}
/*!
\brief Get list of materials names for preferences dialog
\return list of materials names
*/
QStringList Material_ResourceMgr::getPreferenceMaterialsNames()
{
QStringList aMaterialsList = materials( Material_ResourceMgr::All );
return aMaterialsList;
return result;
}

View File

@ -41,8 +41,6 @@ public:
~Material_ResourceMgr();
QStringList materials( MaterialType = All, bool = true );
QStringList getPreferenceMaterialsNames();
};