mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-01-27 12:30:33 +05:00
"0021179: EDF 1654 SMESH GEOM: better look'n'feel" issue.
Material Properties.
This commit is contained in:
parent
29505882a3
commit
956e89f015
@ -569,8 +569,9 @@ bool GEOMGUI_Selection::isPhysicalMaterial( const int idx ) const{
|
||||
bool found = false;
|
||||
QVariant v = visibleProperty( entry( idx ), MATERIAL_PROP );
|
||||
if ( v.canConvert<QString>() ) {
|
||||
Material_Model* aModel = Material_Model::getMaterialModel( v.toString().split(DIGIT_SEPARATOR) );
|
||||
res = aModel->isPhysical();
|
||||
Material_Model material;
|
||||
material.fromProperties( v.toString() );
|
||||
res = material.isPhysical();
|
||||
found = true;
|
||||
}
|
||||
|
||||
|
@ -961,31 +961,20 @@ void GEOM_Displayer::Update( SALOME_OCCPrs* prs )
|
||||
}
|
||||
|
||||
// get material properties, set material
|
||||
Material_Model* aModelF = 0;
|
||||
Material_Model material;
|
||||
if ( useStudy ) {
|
||||
// Get material property from study and construct material model
|
||||
QString aMaterialF = aPropMap.value(MATERIAL_PROP).toString();
|
||||
QStringList aProps = aMaterialF.split(DIGIT_SEPARATOR);
|
||||
aModelF = Material_Model::getMaterialModel( aProps );
|
||||
material.fromProperties( aPropMap.value(MATERIAL_PROP).toString() );
|
||||
} else {
|
||||
// Get material property from study and construct material model
|
||||
aModelF = new Material_Model();
|
||||
aModelF->fromResources( aResMgr, "Geometry" );
|
||||
QString mname = aResMgr->stringValue( "Geometry", "material", "Plastic" );
|
||||
material.fromResources( mname );
|
||||
}
|
||||
|
||||
// Set material property
|
||||
QString aMaterialPropF = aModelF->getMaterialProperty();
|
||||
aStudy->setObjectProperty( aMgrId, anIO->getEntry(), MATERIAL_PROP, aMaterialPropF );
|
||||
|
||||
// Get material properties from the model
|
||||
Graphic3d_MaterialAspect aMatF = aModelF->getMaterialOCCAspect();
|
||||
aStudy->setObjectProperty( aMgrId, anIO->getEntry(), MATERIAL_PROP, material.toProperties() );
|
||||
|
||||
// Set material for the selected shape
|
||||
AISShape->SetMaterial(aMatF);
|
||||
|
||||
// Release memory
|
||||
if ( aModelF )
|
||||
delete aModelF;
|
||||
AISShape->SetMaterial( material.getMaterialOCCAspect() );
|
||||
|
||||
if(HasWidth())
|
||||
aStudy->setObjectProperty( aMgrId, anIO->getEntry(), EDGE_WIDTH_PROP, GetWidth() );
|
||||
@ -1174,24 +1163,16 @@ void GEOM_Displayer::Update( SALOME_VTKPrs* prs )
|
||||
aGeomGActor->setDisplayMode(aDispModeId);
|
||||
aGeomGActor->SetDeflection(aPropMap.value(DEFLECTION_COEFF_PROP).toDouble());
|
||||
|
||||
// Get material property of the object stored in the study
|
||||
QString aMaterialF = aPropMap.value(MATERIAL_PROP).toString();
|
||||
QStringList aPropsF = aMaterialF.split(DIGIT_SEPARATOR);
|
||||
// Create material model
|
||||
Material_Model* aModelF = Material_Model::getMaterialModel( aPropsF );
|
||||
Material_Model material;
|
||||
material.fromProperties( aPropMap.value(MATERIAL_PROP).toString() );
|
||||
// Set material properties for the object
|
||||
QString aMaterialPropF = aModelF->getMaterialProperty();
|
||||
aStudy->setObjectProperty( aMgrId, anEntry, MATERIAL_PROP, aMaterialPropF );
|
||||
// Get material properties from the model
|
||||
GEOM_VTKPropertyMaterial* aMatPropF = aModelF->getMaterialVTKProperty();
|
||||
aStudy->setObjectProperty( aMgrId, anEntry, MATERIAL_PROP, material.toProperties() );
|
||||
// Set the same front and back materials for the selected shape
|
||||
std::vector<vtkProperty*> aProps;
|
||||
aProps.push_back( (vtkProperty*) aMatPropF );
|
||||
std::vector<vtkProperty*> aProps;
|
||||
aProps.push_back( material.getMaterialVTKProperty() );
|
||||
aGeomGActor->SetMaterial(aProps);
|
||||
|
||||
// Release memory
|
||||
delete aModelF;
|
||||
|
||||
vtkFloatingPointType aColor[3] = {1.,0.,0.};
|
||||
if(aPropMap.contains(COLOR_PROP)) {
|
||||
QColor c = aPropMap.value(COLOR_PROP).value<QColor>();
|
||||
@ -1222,26 +1203,24 @@ void GEOM_Displayer::Update( SALOME_VTKPrs* prs )
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( !aMatPropF->GetPhysical() )
|
||||
if ( !material.isPhysical() )
|
||||
aGeomGActor->SetColor(aColor[0],aColor[1],aColor[2]);
|
||||
}
|
||||
else {
|
||||
SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
|
||||
if ( aResMgr ) {
|
||||
// Create material model
|
||||
Material_Model aModelF;
|
||||
Material_Model material;
|
||||
// Get material name from resources
|
||||
aModelF.fromResources( aResMgr, "Geometry" );
|
||||
QString mname = aResMgr->stringValue( "Geometry", "material", "Plastic" );
|
||||
material.fromResources( mname );
|
||||
// Set material properties for the object
|
||||
QString aMaterialPropF = aModelF.getMaterialProperty();
|
||||
aStudy->setObjectProperty( aMgrId, anEntry, MATERIAL_PROP, aMaterialPropF );
|
||||
// Get material properties from the model
|
||||
GEOM_VTKPropertyMaterial* aMatPropF = aModelF.getMaterialVTKProperty();
|
||||
|
||||
aStudy->setObjectProperty( aMgrId, anEntry, MATERIAL_PROP, material.toProperties() );
|
||||
// Set material for the selected shape
|
||||
std::vector<vtkProperty*> aProps;
|
||||
aProps.push_back( (vtkProperty*) aMatPropF );
|
||||
aGeomGActor->SetMaterial(aProps); }
|
||||
std::vector<vtkProperty*> aProps;
|
||||
aProps.push_back( material.getMaterialVTKProperty() );
|
||||
aGeomGActor->SetMaterial(aProps);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1935,10 +1914,10 @@ PropMap GEOM_Displayer::getDefaultPropertyMap(const QString& viewer_type) {
|
||||
aDefaultMap.insert( DEFLECTION_COEFF_PROP , aDC);
|
||||
|
||||
//8. Material
|
||||
Material_Model aModelF;
|
||||
aModelF.fromResources( aResMgr, "Geometry" );
|
||||
QString aMaterialF = aModelF.getMaterialProperty();
|
||||
aDefaultMap.insert( MATERIAL_PROP , aMaterialF );
|
||||
Material_Model material;
|
||||
QString mname = aResMgr->stringValue( "Geometry", "material", "Plastic" );
|
||||
material.fromResources( mname );
|
||||
aDefaultMap.insert( MATERIAL_PROP, material.toProperties() );
|
||||
|
||||
//9. Width of the edges
|
||||
aDefaultMap.insert( EDGE_WIDTH_PROP , aResMgr->integerValue("Geometry", "edge_width", 1));
|
||||
|
@ -5228,35 +5228,27 @@ Would you like to continue?</translation>
|
||||
<name>GEOMToolsGUI_MaterialPropertiesDlg</name>
|
||||
<message>
|
||||
<source>MATERIAL_PROPERTIES_TLT</source>
|
||||
<translation>Set Material Properties</translation>
|
||||
<translation>Color and Material Properties</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>MATERIAL_BACK_CHK</source>
|
||||
<translation>Enable back material</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>AMBIENT_GRP</source>
|
||||
<source>REFLECTION_0</source>
|
||||
<translation>Ambient</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>DIFFUSE_GRP</source>
|
||||
<source>REFLECTION_1</source>
|
||||
<translation>Diffuse</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>SPECULAR_GRP</source>
|
||||
<source>REFLECTION_2</source>
|
||||
<translation>Specular</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>EMISSION_GRP</source>
|
||||
<translation>Emission</translation>
|
||||
<source>REFLECTION_3</source>
|
||||
<translation>Emissive</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>COLOR</source>
|
||||
<translation>Color:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>COEFFICIENT</source>
|
||||
<translation>Coefficient:</translation>
|
||||
<source>ENABLED</source>
|
||||
<translation>Enabled</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>SHININESS</source>
|
||||
@ -5264,12 +5256,41 @@ Would you like to continue?</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>PHYSICAL</source>
|
||||
<translation>Physical:</translation>
|
||||
<translation>Physical</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>ADD_MATERIAL</source>
|
||||
<translation>Add Material</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>DELETE_MATERIAL</source>
|
||||
<translation>Remove material</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>RENAME_MATERIAL</source>
|
||||
<translation>Rename material</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>CURRENT_MATERIAL</source>
|
||||
<translation>[ Current ]</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>CURRENT_COLOR</source>
|
||||
<translation>Color</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>CUSTOM_MATERIAL</source>
|
||||
<translation>Custom material</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>QUE_CREATE_NEW_MATERIAL</source>
|
||||
<translation>Changing properties of pre-defined material is not allowed.
|
||||
Do you want to create new material?</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>QUE_REMOVE_MATERIAL</source>
|
||||
<translation>Remove material %1?</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>OK_BTN</source>
|
||||
<translation>&OK</translation>
|
||||
|
@ -5228,47 +5228,68 @@ Voulez-vous continuer?</translation>
|
||||
<name>GEOMToolsGUI_MaterialPropertiesDlg</name>
|
||||
<message>
|
||||
<source>MATERIAL_PROPERTIES_TLT</source>
|
||||
<translation>Définir une propriétés des matériaux</translation>
|
||||
<translation>Color and Material Properties</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>MATERIAL_BACK_CHK</source>
|
||||
<translation>Activer l'arrière du matériau</translation>
|
||||
<source>REFLECTION_0</source>
|
||||
<translation>Ambient</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>AMBIENT_GRP</source>
|
||||
<translation>Ambiante</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>DIFFUSE_GRP</source>
|
||||
<source>REFLECTION_1</source>
|
||||
<translation>Diffuse</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>SPECULAR_GRP</source>
|
||||
<translation>Spéculaire</translation>
|
||||
<source>REFLECTION_2</source>
|
||||
<translation>Specular</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>EMISSION_GRP</source>
|
||||
<translation>Emission</translation>
|
||||
<source>REFLECTION_3</source>
|
||||
<translation>Emissive</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>COLOR</source>
|
||||
<translation>Couleurs:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>COEFFICIENT</source>
|
||||
<translation>Coefficient:</translation>
|
||||
<source>ENABLED</source>
|
||||
<translation>Enabled</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>SHININESS</source>
|
||||
<translation>Brillance:</translation>
|
||||
<translation>Shininess:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>PHYSICAL</source>
|
||||
<translation>Matériau physique (couleur imposée):</translation>
|
||||
<translation>Physical</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>ADD_MATERIAL</source>
|
||||
<translation>Add Material</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>DELETE_MATERIAL</source>
|
||||
<translation>Remove material</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>RENAME_MATERIAL</source>
|
||||
<translation>Rename material</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>CURRENT_MATERIAL</source>
|
||||
<translation>[ Current ]</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>CURRENT_COLOR</source>
|
||||
<translation>Color</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>CUSTOM_MATERIAL</source>
|
||||
<translation>Matériau personnalisé</translation>
|
||||
<translation>Custom material</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>QUE_CREATE_NEW_MATERIAL</source>
|
||||
<translation>Changing properties of pre-defined material is not allowed.
|
||||
Do you want to create new material?</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>QUE_REMOVE_MATERIAL</source>
|
||||
<translation>Remove material %1?</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>OK_BTN</source>
|
||||
|
@ -592,10 +592,9 @@ void GeometryGUI::OnGUIEvent( int id )
|
||||
LightApp_Preferences* pref = preferences();
|
||||
if ( pref ) {
|
||||
Material_ResourceMgr aMatResMgr;
|
||||
QStringList aPerfMatNames = aMatResMgr.getPreferenceMaterialsNames();
|
||||
setPreferenceProperty( pref->rootItem()->findItem( tr( "PREF_MATERIAL" ), true )->id(),
|
||||
"strings",
|
||||
aPerfMatNames );
|
||||
aMatResMgr.materials() );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1814,8 +1813,7 @@ void GeometryGUI::createPreferences()
|
||||
|
||||
// Set property for default material
|
||||
Material_ResourceMgr aMatResMgr;
|
||||
QStringList aPrefMatNames = aMatResMgr.getPreferenceMaterialsNames();
|
||||
setPreferenceProperty( material, "strings", aPrefMatNames );
|
||||
setPreferenceProperty( material, "strings", aMatResMgr.materials() );
|
||||
|
||||
// Set property vertex marker type
|
||||
QList<QVariant> aMarkerTypeIndicesList;
|
||||
|
@ -294,18 +294,11 @@ void GEOMToolsGUI::OnColor()
|
||||
if ( c.isValid() ) {
|
||||
SUIT_OverrideCursor();
|
||||
for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
|
||||
QString defMatProp;
|
||||
QVariant mp = appStudy->getObjectProperty(mgrId,It.Value()->getEntry(), MATERIAL_PROP, defMatProp);
|
||||
QString matProp = mp.value<QString>();
|
||||
QStringList aProps = matProp.split(DIGIT_SEPARATOR);
|
||||
Material_Model* aModelF = Material_Model::getMaterialModel( aProps );
|
||||
bool aPhys = false;
|
||||
if ( aModelF ) {
|
||||
aPhys = aModelF->isPhysical();
|
||||
// Release memory
|
||||
delete aModelF;
|
||||
}
|
||||
if ( !aPhys ) {
|
||||
QString matProp;
|
||||
matProp = appStudy->getObjectProperty(mgrId,It.Value()->getEntry(), MATERIAL_PROP, matProp).toString();
|
||||
Material_Model material;
|
||||
material.fromProperties( matProp );
|
||||
if ( !material.isPhysical() ) {
|
||||
aView->SetColor( It.Value(), c );
|
||||
appStudy->setObjectProperty(mgrId,It.Value()->getEntry(),COLOR_PROP, c);
|
||||
}
|
||||
@ -332,19 +325,12 @@ void GEOMToolsGUI::OnColor()
|
||||
OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*> ( window->getViewManager()->getViewModel() );
|
||||
Handle (AIS_InteractiveContext) ic = vm->getAISContext();
|
||||
for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
|
||||
QString defMatProp;
|
||||
QVariant mp = appStudy->getObjectProperty(mgrId,It.Value()->getEntry(), MATERIAL_PROP, defMatProp);
|
||||
QString matProp = mp.value<QString>();
|
||||
QStringList aProps = matProp.split(DIGIT_SEPARATOR);
|
||||
Material_Model* aModelF = Material_Model::getMaterialModel( aProps );
|
||||
bool aPhys = false;
|
||||
if ( aModelF ) {
|
||||
aPhys = aModelF->isPhysical();
|
||||
// Release memory
|
||||
delete aModelF;
|
||||
}
|
||||
QString matProp;
|
||||
matProp = appStudy->getObjectProperty(mgrId,It.Value()->getEntry(), MATERIAL_PROP, matProp).toString();
|
||||
Material_Model material;
|
||||
material.fromProperties( matProp );
|
||||
io = GEOMBase::GetAIS( It.Value(), true );
|
||||
if ( !io.IsNull() && !aPhys ) { // change color only for shapes with not physical type of material
|
||||
if ( !io.IsNull() && !material.isPhysical() ) { // change color only for shapes with not physical type of material
|
||||
|
||||
if ( io->IsKind( STANDARD_TYPE(AIS_Shape) ) ) {
|
||||
TopoDS_Shape theShape = Handle(AIS_Shape)::DownCast( io )->Shape();
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user