<parameter name="marker_scale" value="1" />
<parameter name="geom_preview" value="false" />
<parameter name="material" value="Plastic" />
+ <parameter name="predef_materials" value="true" />
<parameter name="edge_width" value="1" />
<parameter name="isolines_width" value="1" />
<parameter name="preview_edge_width" value="1" />
{
}
+//=================================================================================
+// class : GEOMGUI::OnGUIEvent
+// purpose : Main/popup menu events processing
+//=================================================================================
+bool GEOMGUI::OnGUIEvent( int /*theCommandID*/, SUIT_Desktop* /*parent*/, const QVariant& /*theParam*/ )
+{
+ return TRUE;
+}
+
//=================================================================================
// class : GEOMGUI::OnGUIEvent
// purpose : Main/popup menu events processing
// Each of this methods can be redifined by descendants
virtual bool OnGUIEvent( int theCommandID, SUIT_Desktop* parent );
+ virtual bool OnGUIEvent( int theCommandID, SUIT_Desktop* parent, const QVariant& theParam );
virtual bool OnMousePress( QMouseEvent* pe, SUIT_Desktop* parent, SUIT_ViewWindow* );
virtual bool OnMouseMove( QMouseEvent* pe, SUIT_Desktop* parent, SUIT_ViewWindow* );
aStudy->setObjectProperty( aMgrId, anIO->getEntry(), MATERIAL_PROP, material.toProperties() );
// Set material for the selected shape
- AISShape->SetMaterial( material.getMaterialOCCAspect() );
+ // Set front material for the selected shape
+ AISShape->SetCurrentFacingModel(Aspect_TOFM_FRONT_SIDE);
+ AISShape->SetMaterial( material.getMaterialOCCAspect( true ) );
+ // Set back material for the selected shape
+ AISShape->SetCurrentFacingModel(Aspect_TOFM_BACK_SIDE);
+ AISShape->SetMaterial( material.getMaterialOCCAspect( false ) );
+ // Return to the default facing mode
+ AISShape->SetCurrentFacingModel(Aspect_TOFM_BOTH_SIDE);
+
if(HasWidth())
aStudy->setObjectProperty( aMgrId, anIO->getEntry(), EDGE_WIDTH_PROP, GetWidth() );
if(HasIsosWidth())
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( material.getMaterialVTKProperty() );
+ aProps.push_back( material.getMaterialVTKProperty( true ) );
+ aProps.push_back( material.getMaterialVTKProperty( false) );
aGeomGActor->SetMaterial(aProps);
vtkFloatingPointType aColor[3] = {1.,0.,0.};
aStudy->setObjectProperty( aMgrId, anEntry, MATERIAL_PROP, material.toProperties() );
// Set material for the selected shape
std::vector<vtkProperty*> aProps;
- aProps.push_back( material.getMaterialVTKProperty() );
+ aProps.push_back( material.getMaterialVTKProperty( true ) );
+ aProps.push_back( material.getMaterialVTKProperty( false ) );
aGeomGActor->SetMaterial(aProps);
}
}
<source>MEN_TOOLS</source>
<translation>Tools</translation>
</message>
+ <message>
+ <source>MEN_MATERIALS_LIBRARY</source>
+ <translation>Materials library</translation>
+ </message>
<message>
<source>MEN_TORUS</source>
<translation>Torus</translation>
<source>MEN_POP_MATERIAL_PROPERTIES</source>
<translation>Material Properties</translation>
</message>
+ <message>
+ <source>MEN_POP_PREDEF_MATER_CUSTOM</source>
+ <translation>Custom...</translation>
+ </message>
<message>
<source>NAME_LBL</source>
<translation>Name: </translation>
<source>PREF_MATERIAL</source>
<translation>Default material</translation>
</message>
+ <message>
+ <source>PREF_PREDEF_MATERIALS</source>
+ <translation>Show predefined materials in popup menu</translation>
+ </message>
<message>
<source>PREF_EDGE_WIDTH</source>
<translation>Edges width</translation>
<source>PROCESS_SHAPE_NEW_OBJ_NAME</source>
<translation>ProcessShape</translation>
</message>
+ <message>
+ <source>MATERIAL_LIBRARY_TLT</source>
+ <translation>Materials Library</translation>
+ </message>
<message>
<source>REMOVE_HOLES_NEW_OBJ_NAME</source>
<translation>SupressHoles</translation>
<source>STB_POP_WIREFRAME</source>
<translation>Wireframe</translation>
</message>
+ <message>
+ <source>STB_MATERIALS_LIBRARY</source>
+ <translation>Displays content of Materials library</translation>
+ </message>
+ <message>
+ <source>STB_POP_PREDEF_MATER_CUSTOM</source>
+ <translation>Custom...</translation>
+ </message>
<message>
<source>STB_PROPAGATE</source>
<translation>Propagate</translation>
<source>MATERIAL_PROPERTIES_TLT</source>
<translation>Color and Material Properties</translation>
</message>
+ <message>
+ <source>FRONT_FACE</source>
+ <translation>Front face</translation>
+ </message>
+ <message>
+ <source>BACK_FACE</source>
+ <translation>Back face</translation>
+ </message>
<message>
<source>REFLECTION_0</source>
<translation>Ambient</translation>
<source>REFLECTION_3</source>
<translation>Emissive</translation>
</message>
- <message>
- <source>ENABLED</source>
- <translation>Enabled</translation>
- </message>
<message>
<source>SHININESS</source>
<translation>Shininess:</translation>
<source>REFLECTION_3</source>
<translation>Emissive</translation>
</message>
- <message>
- <source>ENABLED</source>
- <translation>Activée</translation>
- </message>
<message>
<source>SHININESS</source>
<translation>Brillance:</translation>
#include "GEOM_Actor.h"
#include <Material_ResourceMgr.h>
+#include <Material_Model.h>
#include <SUIT_Desktop.h>
#include <SUIT_MessageBox.h>
#include <QFileInfo>
#include <QString>
#include <QPainter>
+#include <QSignalMapper>
#include <AIS_Drawer.hxx>
#include <AIS_ListOfInteractive.hxx>
// function : GeometryGUI::OnGUIEvent()
// purpose : manage all events on GUI [static]
//=======================================================================
-void GeometryGUI::OnGUIEvent( int id )
+void GeometryGUI::OnGUIEvent( int id, const QVariant& theParam )
{
SUIT_Application* anApp = application();
if (!anApp) return;
case GEOMOp::OpSelectAll: // POPUP MENU - SELECT ONLY - SELECT ALL
case GEOMOp::OpDelete: // MENU EDIT - DELETE
case GEOMOp::OpCheckGeom: // MENU TOOLS - CHECK GEOMETRY
+ case GEOMOp::OpMaterialsLibrary: // MENU TOOLS - MATERIALS LIBRARY
case GEOMOp::OpDeflection: // POPUP MENU - DEFLECTION COEFFICIENT
case GEOMOp::OpColor: // POPUP MENU - COLOR
case GEOMOp::OpSetTexture: // POPUP MENU - SETTEXTURE
case GEOMOp::OpPublishObject: // ROOT GEOM OBJECT - POPUP MENU - PUBLISH
case GEOMOp::OpPointMarker: // POPUP MENU - POINT MARKER
case GEOMOp::OpMaterialProperties: // POPUP MENU - MATERIAL PROPERTIES
+ case GEOMOp::OpPredefMaterial: // POPUP MENU - <SOME MATERIAL>
+ case GEOMOp::OpPredefMaterCustom: // POPUP MENU - MATERIAL PROPERTIES - CUSTOM...
case GEOMOp::OpEdgeWidth: // POPUP MENU - LINE WIDTH - EDGE WIDTH
case GEOMOp::OpIsosWidth: // POPUP MENU - LINE WIDTH - ISOS WIDTH
case GEOMOp::OpBringToFront: // POPUP MENU - BRING TO FRONT
// call method of corresponding GUI library
if ( library ) {
- library->OnGUIEvent( id, desk );
-
+ if( !theParam.isValid() )
+ library->OnGUIEvent( id, desk );
+ else
+ library->OnGUIEvent( id, desk, theParam);
// Update a list of materials for "Preferences" dialog
if ( id == GEOMOp::OpMaterialProperties ) {
LightApp_Preferences* pref = preferences();
createGeomAction( GEOMOp::OpCheckGeom, "CHECK_GEOMETRY" );
#endif
+ createGeomAction( GEOMOp::OpMaterialsLibrary, "MATERIALS_LIBRARY" );
createGeomAction( GEOMOp::OpDMWireframe, "WIREFRAME" );
createGeomAction( GEOMOp::OpDMShading, "SHADING" );
createGeomAction( GEOMOp::OpDMShadingWithEdges, "SHADING_WITH_EDGES" );
createGeomAction( GEOMOp::OpUnpublishObject, "POP_UNPUBLISH_OBJ" );
createGeomAction( GEOMOp::OpPublishObject, "POP_PUBLISH_OBJ" );
createGeomAction( GEOMOp::OpPointMarker, "POP_POINT_MARKER" );
- createGeomAction( GEOMOp::OpMaterialProperties, "POP_MATERIAL_PROPERTIES" );
+ createGeomAction( GEOMOp::OpMaterialProperties, "POP_MATERIAL_PROPERTIES" );
+ createGeomAction( GEOMOp::OpPredefMaterCustom, "POP_PREDEF_MATER_CUSTOM" );
createGeomAction( GEOMOp::OpPipeTShape, "PIPETSHAPE" );
createMenu( separator(), toolsId, -1 );
createMenu( GEOMOp::OpCheckGeom, toolsId, -1 );
#endif
+
+ int toolsId = createMenu( tr( "MEN_TOOLS" ), -1, -1 );
+ createMenu( separator(), toolsId, -1 );
+ createMenu( GEOMOp::OpMaterialsLibrary, toolsId, -1 );
+ createMenu( separator(), toolsId, -1 );
int viewId = createMenu( tr( "MEN_VIEW" ), -1, -1 );
createMenu( separator(), viewId, -1 );
mgr->setRule( action( GEOMOp::OpVectors ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule );
mgr->setRule( action( GEOMOp::OpVectors ), clientOCCorVTK + " and isVectorsMode", QtxPopupMgr::ToggleRule );
mgr->insert( separator(), -1, -1 ); // -----------
+
mgr->insert( action( GEOMOp::OpColor ), -1, -1 ); // color
mgr->setRule( action( GEOMOp::OpColor ), clientOCCorVTKorOB_AndSomeVisible + " and ($component={'GEOM'})" + "and isPhysicalMaterial=false", QtxPopupMgr::VisibleRule );
mgr->insert( action( GEOMOp::OpTransparency ), -1, -1 ); // transparency
mgr->insert( action( GEOMOp::OpPointMarker ), -1, -1 ); // point marker
//mgr->setRule( action( GEOMOp::OpPointMarker ), QString( "selcount>0 and $typeid in {%1}" ).arg(GEOM_POINT ), QtxPopupMgr::VisibleRule );
mgr->setRule( action( GEOMOp::OpPointMarker ), QString( "selcount>0 and ( $typeid in {%1} or compoundOfVertices=true ) " ).arg(GEOM::VERTEX).arg(GEOM::COMPOUND), QtxPopupMgr::VisibleRule );
- mgr->insert( action( GEOMOp::OpMaterialProperties ), -1, -1 ); // material properties
- mgr->setRule( action( GEOMOp::OpMaterialProperties ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'}) and selcount>0 and isVisible", QtxPopupMgr::VisibleRule );
- mgr->insert( action( GEOMOp::OpSetTexture ), -1, -1 ); // texture
+
+ // material properties
+ int MaterId = mgr->insert( action( GEOMOp::OpMaterialProperties ), -1, -1 );
+ mgr->setRule( action( GEOMOp::OpMaterialProperties ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
+
+ // texture
+ mgr->insert( action( GEOMOp::OpSetTexture ), -1, -1 );
mgr->setRule( action( GEOMOp::OpSetTexture ), clientOCCorOB_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
int lineW = mgr->insert( tr( "MEN_LINE_WIDTH" ), -1, -1 ); // line width menu
SalomeApp_Module::contextMenuPopup( client, menu, title );
SALOME_ListIO lst;
getApp()->selectionMgr()->selectedObjects( lst );
+
+ //Add submenu for predefined materials
+ bool isPredefMat = SUIT_Session::session()->resourceMgr()->booleanValue( "Geometry", "predef_materials" );
+ if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() > 0 ) {
+ QtxPopupMgr* mgr = popupMgr();
+ //get parrent for submenu
+ QAction* act = mgr->action( mgr->actionId( action( GEOMOp::OpMaterialProperties ) ) );
+ //Clear old menu
+ QMenu* oldMenu = act->menu() ;
+ if( oldMenu ) {
+ delete oldMenu;
+ }
+ if( isPredefMat ){
+ QMenu* matMenu = new QMenu();
+ QSignalMapper* signalMapper = new QSignalMapper( matMenu );
+
+ //Get current material model for the object
+ QVariant v;
+ LightApp_Application* anApp = dynamic_cast<LightApp_Application*>( getApp() );
+ if ( anApp && anApp->activeViewManager() ) {
+ LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( anApp->activeStudy() );
+ if( aStudy ) {
+ v = aStudy->getObjectProperty( anApp->activeViewManager()->getGlobalId(), lst.Last()->getEntry(), MATERIAL_PROP, QVariant() );
+ }
+ }
+ QString curModel = "";
+ if ( v.canConvert<QString>() ) curModel = v.toString();
+ // get list of all predefined materials
+ Material_ResourceMgr aMatResMgr;
+ QStringList matNameList = aMatResMgr.materials();
+ foreach ( QString name, matNameList )
+ {
+ QAction* menAct = matMenu->addAction( name );
+ connect(menAct, SIGNAL( toggled( bool ) ), signalMapper, SLOT( map() ) );
+ signalMapper->setMapping( menAct, name );
+ menAct->setCheckable( true );
+ // Set checked if this material is current
+ Material_Model aModel;
+ aModel.fromResources( name );
+ menAct->setChecked( aModel.toProperties() == curModel );
+ }
+ matMenu->insertAction( matMenu->addSeparator(), action( GEOMOp::OpPredefMaterCustom ) );
+ matMenu->insertSeparator( action( GEOMOp::OpPredefMaterCustom ) );
+ connect( signalMapper, SIGNAL( mapped( const QString & ) ),
+ this, SLOT( OnSetMaterial( const QString & ) ) );
+ act->setMenu( matMenu );
+ }
+ }
+ //Set name
if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
Handle(SALOME_InteractiveObject) io = lst.First();
SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
}
}
+void GeometryGUI::OnSetMaterial(const QString& theName)
+{
+ OnGUIEvent( GEOMOp::OpPredefMaterial, QVariant( theName ) );
+}
+
+
void GeometryGUI::createPreferences()
{
int tabId = addPreference( tr( "PREF_TAB_SETTINGS" ) );
int defl = addPreference( tr( "PREF_DEFLECTION" ), genGroup,
LightApp_Preferences::DblSpin, "Geometry", "deflection_coeff" );
+ int predef_materials = addPreference( tr( "PREF_PREDEF_MATERIALS" ), genGroup,
+ LightApp_Preferences::Bool, "Geometry", "predef_materials" );
+
int material = addPreference( tr( "PREF_MATERIAL" ), genGroup,
LightApp_Preferences::Selector,
"Geometry", "material" );
setPreferenceProperty( defl, "step", 1.0e-04 );
setPreferenceProperty( defl, "precision", 6 );
+ // Set property for 'Show predefined materials'
+ setPreferenceProperty( predef_materials, "eval", true);
// Set property for default material
Material_ResourceMgr aMatResMgr;
setPreferenceProperty( material, "strings", aMatResMgr.materials() );
void EmitSignalDefaultStepValueChanged( double newVal );
// Process action
- void OnGUIEvent( int id );
+ void OnGUIEvent( int id, const QVariant& theParam = QVariant( QVariant::Invalid ) );
// The Working Plane management
void SetWorkingPlane( gp_Ax3 wp ) { myWorkingPlane = wp; }
void OnGUIEvent();
void onWindowActivated( SUIT_ViewWindow* );
void onViewAboutToShow();
+ void OnSetMaterial( const QString& );
signals :
void SignalDeactivateActiveDialog();
OpExport = 1001, // MENU FILE - EXPORT
OpDelete = 1020, // MENU EDIT - DELETE
OpCheckGeom = 1030, // MENU TOOLS - CHECK GEOMETRY
+ OpMaterialsLibrary = 1040, // MENU TOOLS - MATERIALS LIBRARY
OpSelectVertex = 1100, // POPUP MENU - SELECT ONLY - VERTEX
OpSelectEdge = 1101, // POPUP MENU - SELECT ONLY - EDGE
OpSelectWire = 1102, // POPUP MENU - SELECT ONLY - WIRE
OpPointMarker = 1210, // POPUP MENU - POINT MARKER
OpSetTexture = 1211, // POPUP MENU - SETTEXTURE
OpMaterialProperties = 1212, // POPUP MENU - MATERIAL PROPERTIES
+ OpPredefMaterial = 1213, // POPUP MENU - MATERIAL PROPERTIES - <SOME MATERIAL>
+ OpPredefMaterCustom = 1214, // POPUP MENU - MATERIAL PROPERTIES - CUSTOM...
OpDiscloseChildren = 1250, // POPUP MENU - DISCLOSE CHILD ITEMS
OpConcealChildren = 1251, // POPUP MENU - CONCEAL CHILD ITEMS
OpUnpublishObject = 1253, // POPUP MENU - UNPUBLISH
case GEOMOp::OpColor: // POPUP - COLOR
OnColor();
break;
- case GEOMOp::OpSetTexture: // POPUP - TEXTURE
+ case GEOMOp::OpSetTexture: // POPUP - TEXTURE
OnTexture();
break;
case GEOMOp::OpTransparency: // POPUP - TRANSPARENCY
case GEOMOp::OpMaterialProperties: // POPUP - MATERIAL PROPERTIES
OnMaterialProperties();
break;
+ case GEOMOp::OpPredefMaterCustom: // POPUP - MATERIAL PROPERTIES - CUSTOM...
+ OnMaterialProperties();
+ break;
+ case GEOMOp::OpMaterialsLibrary: // POPUP MENU - MATERIAL PROPERTIES
+ OnMaterialsLibrary();
+ break;
case GEOMOp::OpAutoColor: // POPUP - AUTO COLOR
OnAutoColor();
break;
return true;
}
+//=======================================================================
+// function : OnGUIEvent()
+// purpose :
+//=======================================================================
+bool GEOMToolsGUI::OnGUIEvent(int theCommandID, SUIT_Desktop* parent, const QVariant& theParam )
+{
+ getGeometryGUI()->EmitSignalDeactivateDialog();
+
+ switch ( theCommandID ) {
+ case GEOMOp::OpPredefMaterial: // POPUP MENU - MATERIAL PROPERTIES - <SOME MATERIAL>
+ OnSetMaterial( theParam );
+ break;
+ default:
+ SUIT_Session::session()->activeApplication()->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID));
+ break;
+ }
+ return true;
+}
+
//===============================================================================
// function : OnEditDelete()
// purpose :
~GEOMToolsGUI();
bool OnGUIEvent( int, SUIT_Desktop* );
+ bool OnGUIEvent( int theCommandID, SUIT_Desktop*, const QVariant& );
+
virtual void deactivate();
enum ActionType { SHOWDLG, INCR, DECR };
void OnPublishObject() ;
void OnPointMarker();
void OnMaterialProperties();
+ void OnMaterialsLibrary();
+ void OnSetMaterial(const QVariant& );
void OnEdgeWidth();
void OnIsosWidth();
void OnBringToFront();
#include "GEOMToolsGUI_PublishDlg.h"
#include "GEOMToolsGUI_MaterialPropertiesDlg.h"
#include "GEOMToolsGUI_LineWidthDlg.h"
-#include "Material_Model.h"
+#include <Material_Model.h>
+
+#include <GEOM_VTKPropertyMaterial.hxx>
#include <GeometryGUI.h>
#include <GeometryGUI_Operations.h>
// VTK includes
#include <vtkRenderer.h>
+class QtxDialog;
// If the next macro is defined, autocolor feature works for all sub-shapes;
// if it is undefined, autocolor feature works for groups only
#define GENERAL_AUTOCOLOR
void GEOMToolsGUI::OnMaterialProperties()
{
- GEOMToolsGUI_MaterialPropertiesDlg dlg( SUIT_Session::session()->activeApplication()->desktop() );
+ GEOMToolsGUI_MaterialPropertiesDlg* dlg = new GEOMToolsGUI_MaterialPropertiesDlg( SUIT_Session::session()->activeApplication()->desktop(), true, false, QtxDialog::OK | QtxDialog::Close | QtxDialog::Apply | QtxDialog::Help );
+ dlg->show();
+}
+
+void GEOMToolsGUI::OnMaterialsLibrary()
+{
+ GEOMToolsGUI_MaterialPropertiesDlg dlg( SUIT_Session::session()->activeApplication()->desktop(), false, true, QtxDialog::Standard );
+ dlg.setWindowTitle( tr( "MATERIAL_LIBRARY_TLT" ) );
dlg.exec();
}
}
}
+void GEOMToolsGUI::OnSetMaterial( const QVariant& theParam )
+{
+ QString theName;
+ if ( theParam.canConvert<QString>() ) theName = theParam.toString();
+ SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
+ if ( !app )
+ return;
+ SalomeApp_Module* mod = dynamic_cast<SalomeApp_Module*>(app->activeModule());
+ if(!mod)
+ return;
+ GEOM_Displayer* disp = dynamic_cast<GEOM_Displayer*>(mod->displayer());
+ if(!disp)
+ return;
+ LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
+ SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
+ if ( !aSelMgr || !study )
+ return;
+ SALOME_ListIO selected;
+ aSelMgr->selectedObjects( selected );
+ if ( selected.IsEmpty() )
+ return;
+ SUIT_ViewWindow* window = app->desktop()->activeWindow();
+ int mgrId = window->getViewManager()->getGlobalId();
+
+ // convert needed material properties to the string representation
+ Material_Model aModel;
+ aModel.fromResources( theName );
+ QString prop = aModel.toProperties();
+
+ if ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() ) {
+ // for VTK viewer
+ SVTK_ViewWindow* vtkVW = dynamic_cast<SVTK_ViewWindow*>( window );
+ if ( !vtkVW )
+ return;
+
+ SVTK_View* aView = vtkVW->getView();
+
+ // get VTK material properties from the current model
+ GEOM_VTKPropertyMaterial* vtkPropF = aModel.getMaterialVTKProperty();
+ GEOM_VTKPropertyMaterial* vtkPropB = aModel.getMaterialVTKProperty( false );
+
+ SUIT_OverrideCursor wc();
+
+ for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
+ // set material property to the presentation
+ aView->SetMaterial( It.Value(), vtkPropF, vtkPropB );
+ // store chosen material in the property map
+ study->setObjectProperty( mgrId, It.Value()->getEntry(), MATERIAL_PROP, prop );
+ // set correct color for the non-physical material
+ }
+ aView->Repaint();
+ GeometryGUI::Modified();
+ }
+ else if ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() ) {
+ // for OCC viewer
+ OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*>( window->getViewManager()->getViewModel() );
+ if ( !vm )
+ return;
+
+ Handle(AIS_InteractiveContext) ic = vm->getAISContext();
+
+ // get OCC material aspect from the current model
+ Graphic3d_MaterialAspect front_occAspect = aModel.getMaterialOCCAspect( true );
+ Graphic3d_MaterialAspect back_occAspect = aModel.getMaterialOCCAspect( false );
+
+ SUIT_OverrideCursor wc();
+
+ for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
+ Handle(GEOM_AISShape) aisShape = GEOMBase::ConvertIOinGEOMAISShape( It.Value(), true );
+ if ( !aisShape.IsNull() ) {
+ // Set front material for the selected shape
+ aisShape->SetCurrentFacingModel(Aspect_TOFM_FRONT_SIDE);
+ aisShape->SetMaterial(front_occAspect);
+ // Set back material for the selected shape
+ aisShape->SetCurrentFacingModel(Aspect_TOFM_BACK_SIDE);
+ aisShape->SetMaterial(back_occAspect);
+ // Return to the default facing mode
+ aisShape->SetCurrentFacingModel(Aspect_TOFM_BOTH_SIDE);
+ // store chosen material in the property map
+ study->setObjectProperty( mgrId, It.Value()->getEntry(), MATERIAL_PROP, prop );
+ //if ( aisShape->DisplayMode() != AIS_Shaded)
+ ic->Redisplay( aisShape, Standard_False );
+ }
+ }
+ ic->UpdateCurrentViewer();
+ }
+}
#include "GEOM_Constants.h"
#include "GEOM_VTKPropertyMaterial.hxx"
#include "GEOMBase.h"
+#include "GEOM_Displayer.h"
#include <QtxColorButton.h>
#include <QtxDoubleSpinBox.h>
#include <QHBoxLayout>
#include <QKeyEvent>
#include <QLabel>
+#include <QLineEdit>
#include <QMap>
#include <QMenu>
#include <QPushButton>
/*!
\brief Constructor
\param parent parent widget
+ \param showSelWidget if \c true then objects can be selected by user
+ \param modal if \c true dialog box is modal
+ \param f specified control buttons for dialog box (QtxDialog::ButtonFlags)
*/
-GEOMToolsGUI_MaterialPropertiesDlg::GEOMToolsGUI_MaterialPropertiesDlg( QWidget* parent )
- : QtxDialog( parent, true, true, OK | Close | Apply | Help )
+GEOMToolsGUI_MaterialPropertiesDlg::GEOMToolsGUI_MaterialPropertiesDlg( QWidget* parent,bool showSelWidget, bool modal,const int f )
+ : QtxDialog( parent, modal, true, f )
{
+ myShowSelWidget = showSelWidget;
// Set title
setWindowTitle( tr( "MATERIAL_PROPERTIES_TLT" ) );
-
+
// main layout
QVBoxLayout* main = new QVBoxLayout( mainFrame() );
main->setMargin( 0 );
QFrame* fr = new QFrame( mainFrame() );
fr->setFrameStyle( QFrame::Box | QFrame::Sunken );
main->addWidget( fr );
+ // selection widget
+ myLineEditCurArg = new QLineEdit(fr);
+ myLineEditCurArg->setReadOnly(true);
+ myPushBtn = new QPushButton(fr);
+ QLabel* PushBtnLab = new QLabel( tr( "GEOM_OBJECTS" ), fr );
// materials list widget
myMaterials = new GEOMToolsGUI_MaterialList( fr );
// "physical" material type widgets
myPhysical = new QCheckBox( tr( "PHYSICAL" ), propWidget );
+ // Labels for front and back reflection components
+ QLabel* aFrontLabel = new QLabel( tr( "FRONT_FACE" ), propWidget );
+ QLabel* aBackLabel = new QLabel( tr( "BACK_FACE" ), propWidget );
+
// reflection components widgets
for ( int i = Material_Model::Ambient; i <= Material_Model::Emissive; i++ )
{
Reflection refl;
+
+ refl.enabled = new QCheckBox( propWidget );
refl.label = new QLabel( tr( QString( "REFLECTION_%1" ).arg( i ).toLatin1().data() ), propWidget );
refl.color = new QtxColorButton( propWidget );
//refl.color->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
- refl.coef = new QtxDoubleSpinBox( propWidget );
- refl.coef->setPrecision( 4 );
- refl.coef->setDecimals( 4 );
- refl.coef->setRange( 0., 1. );
- refl.coef->setSingleStep( 0.05 );
- refl.coef->setMinimumWidth( 80 );
-
- refl.enabled = new QCheckBox( tr( "ENABLED" ), propWidget );
+ refl.front_coef = new QtxDoubleSpinBox( propWidget );
+ refl.front_coef->setPrecision( 4 );
+ refl.front_coef->setDecimals( 4 );
+ refl.front_coef->setRange( 0., 1. );
+ refl.front_coef->setSingleStep( 0.05 );
+ refl.front_coef->setMinimumWidth( 80 );
+
+ refl.back_coef = new QtxDoubleSpinBox( propWidget );
+ refl.back_coef->setPrecision( 4 );
+ refl.back_coef->setDecimals( 4 );
+ refl.back_coef->setRange( 0., 1. );
+ refl.back_coef->setSingleStep( 0.05 );
+ refl.back_coef->setMinimumWidth( 80 );
myReflection << refl;
}
// shininess widgets
QLabel* shininessLab = new QLabel( tr( "SHININESS" ), propWidget );
- myShininess = new QtxDoubleSpinBox( propWidget );
- myShininess->setPrecision( 4 );
- myShininess->setDecimals( 4 );
- myShininess->setRange( 0., 1. );
- myShininess->setSingleStep( 0.05 );
+ myFrontShininess = new QtxDoubleSpinBox( propWidget );
+ myFrontShininess->setPrecision( 4 );
+ myFrontShininess->setDecimals( 4 );
+ myFrontShininess->setRange( 0., 1. );
+ myFrontShininess->setSingleStep( 0.05 );
+
+ myBackShininess = new QtxDoubleSpinBox( propWidget );
+ myBackShininess->setPrecision( 4 );
+ myBackShininess->setDecimals( 4 );
+ myBackShininess->setRange( 0., 1. );
+ myBackShininess->setSingleStep( 0.05 );
// separator widgets
QFrame* line1 = new QFrame( propWidget );
line1->setFrameStyle( QFrame::HLine | QFrame::Sunken );
QFrame* line2 = new QFrame( propWidget );
line2->setFrameStyle( QFrame::HLine | QFrame::Sunken );
+ QFrame* line3 = new QFrame( propWidget );
+ line3->setFrameStyle( QFrame::VLine | QFrame::Sunken );
+ QFrame* line4 = new QFrame( propWidget );
+ line4->setFrameStyle( QFrame::VLine | QFrame::Sunken );
+ QFrame* line5 = new QFrame( propWidget );
+ line5->setFrameStyle( QFrame::HLine | QFrame::Sunken );
// add / remove material buttons
myAddButton = new QPushButton( tr( "ADD_MATERIAL" ), propWidget );
btnLayout->addWidget( myDelButton );
// layout all properties widgets together
- propLayout->addWidget( myColorLab, 0, 0 );
- propLayout->addWidget( myColor, 0, 1 );
- propLayout->addWidget( line1, 1, 0, 1, 4 );
- propLayout->addWidget( myPhysical, 2, 0, 1, 2 );
+ propLayout->addWidget( PushBtnLab,0,0);
+ propLayout->addWidget( myPushBtn,0,1);
+ propLayout->addWidget( myLineEditCurArg, 0, 2, 1, 5 );
+ propLayout->addWidget( line1, 1, 0, 1, 7 );
+ propLayout->addWidget( myColorLab, 2, 1 );
+ propLayout->addWidget( myColor, 2, 2 );
+ propLayout->addWidget( myPhysical, 2, 0 );
+ propLayout->addWidget( line2, 3, 0, 1, 7 );
+ propLayout->addWidget( aFrontLabel, 4, 4);
+ propLayout->addWidget( aBackLabel, 4, 6);
+
+ propLayout->addWidget( line3, 4, 3, 6, 1 );
+ propLayout->addWidget( line4, 4, 5, 6, 1 );
+
+ if( !myShowSelWidget ) {
+ myColorLab->hide();
+ myColor->hide();
+ line1->hide();
+ myLineEditCurArg->hide();
+ myPushBtn->hide();
+ PushBtnLab->hide();
+ }
for ( int i = Material_Model::Ambient; i <= Material_Model::Emissive; i++ ) {
- propLayout->addWidget( myReflection[i].label, i+3, 0 );
- propLayout->addWidget( myReflection[i].color, i+3, 1 );
- propLayout->addWidget( myReflection[i].coef, i+3, 2 );
- propLayout->addWidget( myReflection[i].enabled, i+3, 3 );
+ propLayout->addWidget( myReflection[i].enabled, i+5, 0 );
+ propLayout->addWidget( myReflection[i].label, i+5, 1 );
+ propLayout->addWidget( myReflection[i].color, i+5, 2 );
+ propLayout->addWidget( myReflection[i].front_coef, i+5, 4 );
+ propLayout->addWidget( myReflection[i].back_coef, i+5, 6 );
}
- propLayout->addWidget( shininessLab, 7, 0 );
- propLayout->addWidget( myShininess, 7, 2 );
- propLayout->addWidget( line2, 8, 0, 1, 4 );
- propLayout->setRowStretch( 9, 5 );
- propLayout->addLayout( btnLayout, 10, 0, 1, 4 );
+
+ propLayout->addWidget( shininessLab, 9, 0 );
+ propLayout->addWidget( myFrontShininess, 9, 4 );
+ propLayout->addWidget( myBackShininess, 9, 6 );
+ propLayout->addWidget( line5, 10, 0, 1, 7 );
+ propLayout->setRowStretch( 11, 5 );
+ propLayout->addLayout( btnLayout, 12, 0, 1, 7 );
// initialize dialog box
setButtonPosition( Right, Close );
// install event filter to the materials list to process key press events
myMaterials->installEventFilter( this );
+ //Set image
+ myPushBtn->setIcon(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_SELECT")));
+
// connect signals
// note: all widgets, that change material properties, are connected to the common signal
// changed(), instead of connecting directly to the slot - this allows easy temporary blocking
connect( myPhysical, SIGNAL( toggled( bool ) ), this, SIGNAL( changed() ) );
for ( int i = Material_Model::Ambient; i <= Material_Model::Emissive; i++ ) {
connect( myReflection[i].color, SIGNAL( changed( QColor ) ), this, SIGNAL( changed() ) );
- connect( myReflection[i].coef, SIGNAL( valueChanged( double ) ), this, SIGNAL( changed() ) );
+ connect( myReflection[i].front_coef, SIGNAL( valueChanged( double ) ), this, SIGNAL( changed() ) );
+ connect( myReflection[i].back_coef, SIGNAL( valueChanged( double ) ), this, SIGNAL( changed() ) );
connect( myReflection[i].enabled, SIGNAL( toggled( bool ) ), this, SIGNAL( changed() ) );
}
- connect( myShininess, SIGNAL( valueChanged( double ) ), this, SIGNAL( changed() ) );
+ connect( myFrontShininess, SIGNAL( valueChanged( double ) ), this, SIGNAL( changed() ) );
+ connect( myBackShininess, SIGNAL( valueChanged( double ) ), this, SIGNAL( changed() ) );
connect( myMaterials, SIGNAL( itemSelectionChanged() ),
this, SLOT( onMaterialChanged() ) );
connect( myMaterials, SIGNAL( itemChanged( QListWidgetItem* ) ),
connect( this, SIGNAL( dlgApply() ), this, SLOT( onApply() ) );
connect( this, SIGNAL( dlgHelp() ), this, SLOT( onHelp() ) );
connect( this, SIGNAL( changed() ), this, SLOT( onChanged() ) );
+ connect(myPushBtn, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
+ connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(),
+ SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
// initialize current material model according to the selection
myColor->setColor( SUIT_Session::session()->resourceMgr()->colorValue( "Geometry", "shading_color", QColor( 255, 0, 0 ) ) );
}
}
}
-
+ myLineEditCurArg->setText("");
+ myPushBtn->click();
+ SelectionIntoArgument();
+
// finally activate current material properties
myMaterials->setCurrentRow( 0 );
}
for ( int i = Material_Model::Ambient; i <= Material_Model::Emissive; i++ )
{
myReflection[i].color->setColor( model.color( (Material_Model::ReflectionType)i ) );
- myReflection[i].coef->setValue( model.reflection( (Material_Model::ReflectionType)i ) );
+ myReflection[i].front_coef->setValue( model.reflection( (Material_Model::ReflectionType)i, true ) );
+ myReflection[i].back_coef->setValue( model.reflection( (Material_Model::ReflectionType)i, false ) );
myReflection[i].enabled->setChecked( model.hasReflection( (Material_Model::ReflectionType)i ) );
}
// shininess
- myShininess->setValue( model.shininess() );
+ myFrontShininess->setValue( model.shininess( true ) );
+ myBackShininess->setValue( model.shininess( false ) );
// type (physical or no)
myPhysical->setChecked( model.isPhysical() );
model.setPhysical( myPhysical->isChecked() );
// shininess
- model.setShininess( myShininess->value() );
+ model.setShininess( myFrontShininess->value(), true );
+ model.setShininess( myBackShininess->value(), false );
// reflection components
for ( int i = Material_Model::Ambient; i <= Material_Model::Emissive; i++ )
{
model.setColor ( (Material_Model::ReflectionType)i, myReflection[i].color->color() );
- model.setReflection( (Material_Model::ReflectionType)i, myReflection[i].coef->value() );
+ model.setReflection( (Material_Model::ReflectionType)i, myReflection[i].front_coef->value(), true );
+ model.setReflection( (Material_Model::ReflectionType)i, myReflection[i].back_coef->value(), false );
model.setReflection( (Material_Model::ReflectionType)i, myReflection[i].enabled->isChecked() );
}
}
{
// save user materials
myResourceMgr.save();
-
+ if( !myShowSelWidget ) return;
// store selected material properties in the current model
toModel( myCurrentModel );
SVTK_View* aView = vtkVW->getView();
// get VTK material properties from the current model
- GEOM_VTKPropertyMaterial* vtkProp = myCurrentModel.getMaterialVTKProperty();
+ GEOM_VTKPropertyMaterial* vtkPropF = myCurrentModel.getMaterialVTKProperty();
+ GEOM_VTKPropertyMaterial* vtkPropB = myCurrentModel.getMaterialVTKProperty( false );
SUIT_OverrideCursor wc();
for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
// set material property to the presentation
- aView->SetMaterial( It.Value(), vtkProp );
+ aView->SetMaterial( It.Value(), vtkPropF, vtkPropB );
// store chosen material in the property map
study->setObjectProperty( mgrId, It.Value()->getEntry(), MATERIAL_PROP, prop );
// set correct color for the non-physical material
if ( !myCurrentModel.isPhysical() ) {
aView->SetColor( It.Value(), myColor->color() );
- study->setObjectProperty( mgrId, It.Value()->getEntry(), COLOR_PROP, myColor->color() );
+ study->setObjectProperty( mgrId, It.Value()->getEntry(), COLOR_PROP, myColor->color() );
}
}
aView->Repaint();
Handle(AIS_InteractiveContext) ic = vm->getAISContext();
// get OCC material aspect from the current model
- Graphic3d_MaterialAspect occAspect = myCurrentModel.getMaterialOCCAspect();
+ Graphic3d_MaterialAspect front_occAspect = myCurrentModel.getMaterialOCCAspect( true );
+ Graphic3d_MaterialAspect back_occAspect = myCurrentModel.getMaterialOCCAspect( false );
SUIT_OverrideCursor wc();
for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
Handle(GEOM_AISShape) aisShape = GEOMBase::ConvertIOinGEOMAISShape( It.Value(), true );
if ( !aisShape.IsNull() ) {
- // set material property to the presentation
- aisShape->SetMaterial( occAspect );
- // store chosen material in the property map
- study->setObjectProperty( mgrId, It.Value()->getEntry(), MATERIAL_PROP, prop );
- // set correct color for the non-physical material
- if ( !myCurrentModel.isPhysical() ) {
- aisShape->SetShadingColor( SalomeApp_Tools::color( myColor->color() ) );
- study->setObjectProperty( mgrId, It.Value()->getEntry(), COLOR_PROP, myColor->color() );
- ic->RecomputePrsOnly( aisShape, Standard_False );
- }
- //if ( aisShape->DisplayMode() != AIS_Shaded/*aisShape->DisplayMode() == GEOM_AISShape::ShadingWithEdges*/)
- ic->Redisplay( aisShape, Standard_False );
+ // Set front material for the selected shape
+ aisShape->SetCurrentFacingModel(Aspect_TOFM_FRONT_SIDE);
+ aisShape->SetMaterial(front_occAspect);
+ // Set back material for the selected shape
+ aisShape->SetCurrentFacingModel(Aspect_TOFM_BACK_SIDE);
+ aisShape->SetMaterial(back_occAspect);
+ // Return to the default facing mode
+ aisShape->SetCurrentFacingModel(Aspect_TOFM_BOTH_SIDE);
+ // store chosen material in the property map
+ study->setObjectProperty( mgrId, It.Value()->getEntry(), MATERIAL_PROP, prop );
+ // set correct color for the non-physical material
+ if ( !myCurrentModel.isPhysical() ) {
+ aisShape->SetShadingColor( SalomeApp_Tools::color( myColor->color() ) );
+ study->setObjectProperty( mgrId, It.Value()->getEntry(), COLOR_PROP, myColor->color() );
+ ic->RecomputePrsOnly( aisShape, Standard_False );
+ }
+ //if ( aisShape->DisplayMode() != AIS_Shaded/*aisShape->DisplayMode() == GEOM_AISShape::ShadingWithEdges*/)
+ ic->Redisplay( aisShape, Standard_False );
}
}
ic->UpdateCurrentViewer();
myColor->setEnabled( !myPhysical->isChecked() );
myReflection[0].color->setEnabled( myPhysical->isChecked() );
}
+
+
+void GEOMToolsGUI_MaterialPropertiesDlg::SetEditCurrentArgument()
+{
+ QPushButton* send = (QPushButton*)sender();
+
+ if (send == myPushBtn) {
+ // enable line edit
+ myLineEditCurArg->setEnabled(true);
+ myLineEditCurArg->setFocus();
+ SelectionIntoArgument();
+ // after setFocus(), because it will be setDown(false) when loses focus
+ send->setDown(true);
+ }
+}
+
+/*!
+ \brief Called when selection as changed or other case
+*/
+void GEOMToolsGUI_MaterialPropertiesDlg::SelectionIntoArgument()
+{
+ myLineEditCurArg->setText( "" );
+ QString aString = "";
+
+ SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
+ SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
+ LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
+ if ( study ) {
+ SALOME_ListIO aSelList;
+ aSelMgr->selectedObjects(aSelList);
+ int nbSel = GEOMBase::GetNameOfSelectedIObjects(aSelList, aString, true);
+ }
+ myLineEditCurArg->setText( aString );
+}
enum { TypeRole = Qt::UserRole + 123, NameRole };
public:
- GEOMToolsGUI_MaterialPropertiesDlg( QWidget* = 0 );
+ GEOMToolsGUI_MaterialPropertiesDlg( QWidget* = 0 , bool = true, bool = false,const int = Standard );
~GEOMToolsGUI_MaterialPropertiesDlg();
void accept();
void onAddMaterial();
void onApply();
void onHelp();
+ void SetEditCurrentArgument();
+ void SelectionIntoArgument();
private:
typedef struct
{
+ QCheckBox* enabled;
QLabel* label;
QtxColorButton* color;
- QtxDoubleSpinBox* coef;
- QCheckBox* enabled;
+ QtxDoubleSpinBox* front_coef;
+ QtxDoubleSpinBox* back_coef;
} Reflection;
GEOMToolsGUI_MaterialList* myMaterials;
QCheckBox* myPhysical;
QList<Reflection> myReflection;
- QtxDoubleSpinBox* myShininess;
+ QtxDoubleSpinBox* myFrontShininess;
+ QtxDoubleSpinBox* myBackShininess;
QLabel* myColorLab;
QtxColorButton* myColor;
QPushButton* myAddButton;
QPushButton* myDelButton;
Material_ResourceMgr myResourceMgr;
Material_Model myCurrentModel;
+ bool myShowSelWidget;
+ QLineEdit* myLineEditCurArg;
+ QPushButton* myPushBtn;
};
class GEOMToolsGUI_MaterialList : public QListWidget
else if ( key == "emissivecolor" && Qtx::stringToColor( data, colorValue ) ) {
setColor( Emissive, colorValue );
}
- else if ( key == "ambientcoefficient" && dblOk ) {
+ else if ( key == "frontambientcoefficient" && dblOk ) {
setReflection( Ambient, dblValue );
}
- else if ( key == "diffusecoefficient" && dblOk ) {
+ else if ( key == "backambientcoefficient" && dblOk ) {
+ setReflection( Ambient, dblValue, false );
+ }
+ else if ( key == "frontdiffusecoefficient" && dblOk ) {
setReflection( Diffuse, dblValue );
}
- else if ( key == "specularcoefficient" && dblOk ) {
+ else if ( key == "backdiffusecoefficient" && dblOk ) {
+ setReflection( Diffuse, dblValue, false );
+ }
+ else if ( key == "frontspecularcoefficient" && dblOk ) {
setReflection( Specular, dblValue );
}
- else if ( key == "emissivecoefficient" && dblOk ) {
+ else if ( key == "backspecularcoefficient" && dblOk ) {
+ setReflection( Specular, dblValue, false );
+ }
+ else if ( key == "frontemissivecoefficient" && dblOk ) {
setReflection( Emissive, dblValue );
}
- else if ( key == "shininess" && dblOk ) {
+ else if ( key == "backemissivecoefficient" && dblOk ) {
+ setReflection( Emissive, dblValue, false );
+ }
+ else if ( key == "frontshininess" && dblOk ) {
setShininess( dblValue );
}
+ else if ( key == "backshininess" && dblOk ) {
+ setShininess( dblValue, false );
+ }
else if ( key == "transparency" && dblOk ) {
setTransparency( dblValue );
}
props << fmt.arg( "Physical" ).arg( isPhysical() );
// shininess
- props << fmt.arg( "Shininess" ).arg( shininess() );
+ props << fmt.arg( "FrontShininess" ).arg( QString::number ( shininess( true ), 'g', 4 ) ) << fmt.arg( "BackShininess" ).arg( QString::number ( shininess( false ), 'g', 4 ) );
//transparency
props << fmt.arg( "Transparency" ).arg( transparency() );
props << fmt.arg( "Ambient" ).arg( hasReflection( Ambient ) );
if ( color( Ambient ).isValid() )
props << fmt.arg( "AmbientColor" ).arg( Qtx::colorToString( color( Ambient ) ) );
- props << fmt.arg( "AmbientCoefficient" ).arg( reflection( Ambient ) );
+ props << fmt.arg( "FrontAmbientCoefficient" ).arg( QString::number ( reflection( Ambient, true ), 'g', 4 ) ) << fmt.arg( "BackAmbientCoefficient" ).arg( QString::number ( reflection( Ambient, false ), 'g', 4 ) );
// diffuse reflection
props << fmt.arg( "Diffuse" ).arg( hasReflection( Diffuse ) );
if ( color( Diffuse ).isValid() )
props << fmt.arg( "DiffuseColor" ).arg( Qtx::colorToString( color( Diffuse ) ) );
- props << fmt.arg( "DiffuseCoefficient" ).arg( reflection( Diffuse ) );
+ props << fmt.arg( "FrontDiffuseCoefficient" ).arg( QString::number ( reflection( Diffuse, true ), 'g', 4 ) ) << fmt.arg( "BackDiffuseCoefficient" ).arg( QString::number ( reflection( Diffuse, false ), 'g', 4 ) );
// specular reflection
props << fmt.arg( "Specular" ).arg( hasReflection( Specular ) );
if ( color( Specular ).isValid() )
props << fmt.arg( "SpecularColor" ).arg( Qtx::colorToString( color( Specular ) ) );
- props << fmt.arg( "SpecularCoefficient" ).arg( reflection( Specular ) );
+ props << fmt.arg( "FrontSpecularCoefficient" ).arg( QString::number ( reflection( Specular, true ), 'g', 4 ) ) << fmt.arg( "BackSpecularCoefficient" ).arg( QString::number ( reflection( Specular, false ), 'g', 4 ) );
// emissive reflection
props << fmt.arg( "Emissive" ).arg( hasReflection( Emissive ) );
if ( color( Emissive ).isValid() )
props << fmt.arg( "EmissiveColor" ).arg( Qtx::colorToString( color( Emissive ) ) );
- props << fmt.arg( "EmissiveCoefficient" ).arg( reflection( Emissive ) );
+ props << fmt.arg( "FrontEmissiveCoefficient" ).arg( QString::number ( reflection( Emissive, true ), 'g', 4 ) ) << fmt.arg( "BackEmissiveCoefficient" ).arg( QString::number ( reflection( Emissive, false ), 'g', 4 ) );
return props.join( ":" );
}
}
// shininess
- if ( resMgr->hasValue( material, "shininess" ) ) {
- setShininess( resMgr->doubleValue( material, "shininess" ) );
+ if ( resMgr->hasValue( material, "front_shininess" ) ) {
+ setShininess( resMgr->doubleValue( material, "front_shininess" ) );
+ }
+ if ( resMgr->hasValue( material, "back_shininess" ) ) {
+ setShininess( resMgr->doubleValue( material, "back_shininess" ), false );
}
// transparency
if ( resMgr->hasValue( material, "ambient-color" ) ) {
setColor( Ambient, resMgr->colorValue( material, "ambient-color" ) );
}
- if ( resMgr->hasValue( material, "ambient-coefficient" ) ) {
- setReflection( Ambient, resMgr->doubleValue( material, "ambient-coefficient" ) );
+ if ( resMgr->hasValue( material, "front_ambient-coefficient" ) ) {
+ setReflection( Ambient, resMgr->doubleValue( material, "front_ambient-coefficient" ) );
+ }
+ if ( resMgr->hasValue( material, "back_ambient-coefficient" ) ) {
+ setReflection( Ambient, resMgr->doubleValue( material, "back_ambient-coefficient" ), false );
}
if ( resMgr->hasValue( material, "ambient" ) ) {
setReflection( Ambient, resMgr->booleanValue( material, "ambient" ) );
if ( resMgr->hasValue( material, "diffuse-color" ) ) {
setColor( Diffuse, resMgr->colorValue( material, "diffuse-color" ) );
}
- if ( resMgr->hasValue( material, "diffuse-coefficient" ) ) {
- setReflection( Diffuse, resMgr->doubleValue( material, "diffuse-coefficient" ) );
+ if ( resMgr->hasValue( material, "front_diffuse-coefficient" ) ) {
+ setReflection( Diffuse, resMgr->doubleValue( material, "front_diffuse-coefficient" ) );
+ }
+ if ( resMgr->hasValue( material, "back_diffuse-coefficient" ) ) {
+ setReflection( Diffuse, resMgr->doubleValue( material, "back_diffuse-coefficient" ), false );
}
if ( resMgr->hasValue( material, "diffuse" ) ) {
setReflection( Diffuse, resMgr->booleanValue( material, "diffuse" ) );
if ( resMgr->hasValue( material, "specular-color" ) ) {
setColor( Specular, resMgr->colorValue( material, "specular-color" ) );
}
- if ( resMgr->hasValue( material, "specular-coefficient" ) ) {
- setReflection( Specular, resMgr->doubleValue( material, "specular-coefficient" ) );
+ if ( resMgr->hasValue( material, "front_specular-coefficient" ) ) {
+ setReflection( Specular, resMgr->doubleValue( material, "front_specular-coefficient" ) );
+ }
+ if ( resMgr->hasValue( material, "back_specular-coefficient" ) ) {
+ setReflection( Specular, resMgr->doubleValue( material, "back_specular-coefficient" ), false );
}
if ( resMgr->hasValue( material, "specular" ) ) {
setReflection( Specular, resMgr->booleanValue( material, "specular" ) );
if ( resMgr->hasValue( material, "emissive-color" ) ) {
setColor( Emissive, resMgr->colorValue( material, "emissive-color" ) );
}
- if ( resMgr->hasValue( material, "emissive-coefficient" ) ) {
- setReflection( Emissive, resMgr->doubleValue( material, "emissive-coefficient" ) );
+ if ( resMgr->hasValue( material, "front_emissive-coefficient" ) ) {
+ setReflection( Emissive, resMgr->doubleValue( material, "front_emissive-coefficient" ) );
+ }
+ if ( resMgr->hasValue( material, "back_emissive-coefficient" ) ) {
+ setReflection( Emissive, resMgr->doubleValue( material, "back_emissive-coefficient" ), false );
}
if ( resMgr->hasValue( material, "emissive" ) ) {
setReflection( Emissive, resMgr->booleanValue( material, "emissive" ) );
resMgr->setValue( material, "physical", isPhysical() );
// shininess
- resMgr->setValue( material, "shininess", shininess() );
+ resMgr->setValue( material, "front_shininess", shininess( true) );
+ resMgr->setValue( material, "back_shininess", shininess( false ) );
// transparency
resMgr->setValue( material, "transparency", transparency() );
// ambient reflection
if ( color( Ambient ).isValid() )
resMgr->setValue( material, "ambient-color", color( Ambient ) );
- resMgr->setValue( material, "ambient-coefficient", reflection( Ambient ) );
+ resMgr->setValue( material, "front_ambient-coefficient", reflection( Ambient ) );
+ resMgr->setValue( material, "back_ambient-coefficient", reflection( Ambient, false ) );
resMgr->setValue( material, "ambient", hasReflection( Ambient ) );
// diffuse reflection
if ( color( Diffuse ).isValid() )
resMgr->setValue( material, "diffuse-color", color( Diffuse ) );
- resMgr->setValue( material, "diffuse-coefficient", reflection( Diffuse ) );
+ resMgr->setValue( material, "front_diffuse-coefficient", reflection( Diffuse ) );
+ resMgr->setValue( material, "back_diffuse-coefficient", reflection( Diffuse, false ) );
resMgr->setValue( material, "diffuse", hasReflection( Diffuse ) );
// Specular reflection
if ( color( Specular ).isValid() )
resMgr->setValue( material, "specular-color", color( Specular ) );
- resMgr->setValue( material, "specular-coefficient", reflection( Specular ) );
+ resMgr->setValue( material, "front_specular-coefficient", reflection( Specular ) );
+ resMgr->setValue( material, "back_specular-coefficient", reflection( Specular, false ) );
resMgr->setValue( material, "specular", hasReflection( Specular ) );
// Emissive reflection
if ( color( Emissive ).isValid() )
resMgr->setValue( material, "emissive-color", color( Emissive ) );
- resMgr->setValue( material, "emissive-coefficient", reflection( Emissive ) );
+ resMgr->setValue( material, "front_emissive-coefficient", reflection( Emissive ) );
+ resMgr->setValue( material, "back_emissive-coefficient", reflection( Emissive, false ) );
resMgr->setValue( material, "emissive", hasReflection( Emissive ) );
}
}
-/*!
- \brief Initialize material model from the preferences
-
- The material name is retrieved from the "material" parameter of the "Geometry" section
- of the specified resources manager.
-
- \param resMgr resources manager
- \sa fromResources(), toResources()
-*/
-// void Material_Model::fromPreferences( QtxResourceMgr* resMgr )
-// {
-// if ( resMgr ) {
-// // default material is Plastic
-// fromResources( resMgr->stringValue( "Geometry", "material", "Plastic" ) );
-// }
-// }
-
/*!
\brief Get material type
\return \c true if material is physical or \c false otherwise
/*!
\brief Get coefficient value for the given reflection type
\param type reflection type
+ \param theIsFront boolean flag for choosing side
\return coefficient value for the specified reflection type
- \sa setReflection(ReflectionType, double)
+ \sa setReflection(ReflectionType, double, bool = true)
*/
-double Material_Model::reflection( ReflectionType type ) const
+double Material_Model::reflection( ReflectionType type, bool theIsFront ) const
{
double value = 0.0;
if ( type >= 0 && type < 4 )
- value = myReflection[ type ].coef;
+ if ( theIsFront )
+ value = myReflection[ type ].front_coef;
+ else
+ value = myReflection[ type ].back_coef;
return value;
}
\brief Set coefficient value for the given reflection type
\param type reflection type
\param value coefficient to be used by the given reflection type
- \sa reflection()
+ \param theIsFront boolean flag for choosing side
+ \sa reflection( bool = true)
*/
-void Material_Model::setReflection( ReflectionType type, double value )
+void Material_Model::setReflection( ReflectionType type, double value, bool theIsFront )
{
if ( type >= 0 && type < 4 )
- myReflection[ type ].coef = value;
+ if ( theIsFront )
+ myReflection[ type ].front_coef = value;
+ else
+ myReflection[ type ].back_coef = value;
}
/*!
\brief Get shininess value
+ \param theIsFront boolean flag for choosing side
\return shininess value of the material
- \sa setShininess()
+ \sa setShininess( double, bool = true )
*/
-double Material_Model::shininess() const
+double Material_Model::shininess( bool theIsFront ) const
{
- return myShininess;
+ if ( theIsFront )
+ return myFrontShininess;
+ else
+ return myBackShininess;
}
/*!
\brief Set shininess value
\param value new shininess value
- \sa shininess()
+ \param theIsFront boolean flag for choosing side
+ \sa shininess( bool = true )
*/
-void Material_Model::setShininess( double value )
+void Material_Model::setShininess( double value, bool theIsFront )
{
- myShininess = value;
+ if ( theIsFront )
+ myFrontShininess = value;
+ else
+ myBackShininess = value;
}
/*!
setPhysical( false );
// shininess
setShininess( 0.039 );
+ setShininess( 0.039, false );
// transparency
setTransparency( 0.0 );
// ambient reflection (enabled by default)
Qtx::stringToColor( "#333333", c );
setColor( Ambient, c );
- setReflection( Ambient, 0.3 );
+ setReflection( Ambient, 0.3, true );
+ setReflection( Ambient, 0.3, false );
setReflection( Ambient, true );
// diffuse reflection (enabled by default)
Qtx::stringToColor( "#000000", c );
setColor( Diffuse, c );
setReflection( Diffuse, 0.65 );
+ setReflection( Diffuse, 0.65, false );
setReflection( Diffuse, true );
// specular reflection (enabled by default)
Qtx::stringToColor( "#ffffff", c );
setColor( Specular, c );
- setReflection( Specular, 0.0 );
+ setReflection( Specular, 0.0 );
+ setReflection( Specular, 0.0, false );
setReflection( Specular, true );
// emissive reflection (disabled by default)
Qtx::stringToColor( "#000000", c );
setColor( Emissive, c );
- setReflection( Emissive, 0.0 );
+ setReflection( Emissive, 0.0 );
+ setReflection( Emissive, 0.0, false );
setReflection( Emissive, false );
}
/*!
\brief Construct OCCT material aspect from material model
+ \param theIsFront boolean flag for choosing side
\return material aspect object with corresponding properties
*/
-Graphic3d_MaterialAspect Material_Model::getMaterialOCCAspect()
+Graphic3d_MaterialAspect Material_Model::getMaterialOCCAspect( bool theIsFront )
{
// Get material aspect from the current model
Graphic3d_MaterialAspect aspect;
c = color( Ambient );
aspect.SetAmbientColor( Quantity_Color( c.redF(), c.greenF(), c.blueF(), Quantity_TOC_RGB ) );
}
- aspect.SetAmbient( reflection( Ambient ));
+ aspect.SetAmbient( reflection( Ambient, theIsFront ));
if ( hasReflection( Ambient ) )
aspect.SetReflectionModeOn( Graphic3d_TOR_AMBIENT );
else
c = color( Diffuse );
aspect.SetDiffuseColor( Quantity_Color( c.redF(), c.greenF(), c.blueF(), Quantity_TOC_RGB ) );
}
- aspect.SetDiffuse( reflection( Diffuse ));
+ aspect.SetDiffuse( reflection( Diffuse, theIsFront ));
if ( hasReflection( Diffuse ) )
aspect.SetReflectionModeOn( Graphic3d_TOR_DIFFUSE );
else
c = color( Specular );
aspect.SetSpecularColor( Quantity_Color( c.redF(), c.greenF(), c.blueF(), Quantity_TOC_RGB ) );
}
- aspect.SetSpecular( reflection( Specular ));
+ aspect.SetSpecular( reflection( Specular, theIsFront ));
if ( hasReflection( Specular ) )
aspect.SetReflectionModeOn( Graphic3d_TOR_SPECULAR );
else
c = color( Emissive );
aspect.SetEmissiveColor( Quantity_Color( c.redF(), c.greenF(), c.blueF(), Quantity_TOC_RGB ) );
}
- aspect.SetEmissive( reflection( Emissive ));
+ aspect.SetEmissive( reflection( Emissive, theIsFront ));
if ( hasReflection( Emissive ) )
aspect.SetReflectionModeOn( Graphic3d_TOR_EMISSION );
else
aspect.SetReflectionModeOff( Graphic3d_TOR_EMISSION );
// shininess
- aspect.SetShininess( shininess() );
+ aspect.SetShininess( shininess( theIsFront ) );
// transparency
aspect.SetTransparency( transparency() );
/*!
\brief Construct VTK property from material model
+ \param theIsFront boolean flag for choosing side
\return VTK property with correspondent material properties
*/
-GEOM_VTKPropertyMaterial* Material_Model::getMaterialVTKProperty()
+GEOM_VTKPropertyMaterial* Material_Model::getMaterialVTKProperty( bool theIsFront )
{
// NOTE: In VTK it's impossible to switch on/off specific reflection type
// NOTE: In VTK emissive reflection type is not supported
if ( color( Ambient ).isValid() && hasReflection( Ambient ) ) {
c = color( Ambient );
prop->SetAmbientColor( c.redF(), c.greenF(), c.blueF() );
- prop->SetAmbient( reflection( Ambient ) );
+ prop->SetAmbient( reflection( Ambient, theIsFront ) );
}
// diffuse reflection
if ( color( Diffuse ).isValid() && hasReflection( Diffuse ) ) {
c = color( Diffuse );
prop->SetDiffuseColor( c.redF(), c.greenF(), c.blueF() );
- prop->SetDiffuse( reflection( Diffuse ) );
+ prop->SetDiffuse( reflection( Diffuse, theIsFront ) );
}
// specular reflection
if ( color( Specular ).isValid() && hasReflection( Specular ) ) {
c = color( Specular );
prop->SetSpecularColor( c.redF(), c.greenF(), c.blueF() );
- prop->SetSpecular( reflection( Specular ) );
+ prop->SetSpecular( reflection( Specular, theIsFront ) );
}
// shininess
- prop->SetSpecularPower( shininess()*100.0 );
+ prop->SetSpecularPower( shininess( theIsFront )*100.0 );
// transparency
prop->SetOpacity( 1 - transparency() );
QColor color( ReflectionType ) const;
void setColor( ReflectionType, const QColor& );
- double reflection( ReflectionType ) const;
- void setReflection( ReflectionType, double );
+ double reflection( ReflectionType, bool = true ) const;
+ void setReflection( ReflectionType, double, bool = true );
- double shininess() const;
- void setShininess( double );
+ double shininess( bool = true) const;
+ void setShininess( double, bool = true );
double transparency() const;
void setTransparency( double );
- Graphic3d_MaterialAspect getMaterialOCCAspect();
- GEOM_VTKPropertyMaterial* getMaterialVTKProperty();
+ Graphic3d_MaterialAspect getMaterialOCCAspect( bool = true );
+ GEOM_VTKPropertyMaterial* getMaterialVTKProperty( bool = true );
private:
void init();
private:
typedef struct {
QColor color;
- double coef;
+ double front_coef;
+ double back_coef;
bool enabled;
} ReflectionData;
typedef QVector<ReflectionData> ReflectionList;
bool myIsPhysical;
- double myShininess;
+ double myFrontShininess;
+ double myBackShininess;
double myTransparency;
ReflectionList myReflection;
};
-->
<document>
<section name="[common]" >
- <parameter name="physical" value="false" />
- <parameter name="shininess" value="0.039" />
- <parameter name="ambient" value="true" />
- <parameter name="ambient-coefficient" value="0.3" />
- <parameter name="ambient-color" value="#333333" />
- <parameter name="diffuse" value="true" />
- <parameter name="diffuse-coefficient" value="0.65" />
- <parameter name="diffuse-color" value="#000000" />
- <parameter name="specular" value="true" />
- <parameter name="specular-coefficient" value="0.0" />
- <parameter name="specular-color" value="#ffffff" />
- <parameter name="emissive" value="false" />
- <parameter name="emissive-coefficient" value="0.0" />
- <parameter name="emissive-color" value="#000000" />
- <parameter name="transparency" value="0.0" />
+ <parameter name="physical" value="false" />
+ <parameter name="front_shininess" value="0.039" />
+ <parameter name="back_shininess" value="0.039" />
+ <parameter name="ambient" value="true" />
+ <parameter name="front_ambient-coefficient" value="0.3" />
+ <parameter name="back_ambient-coefficient" value="0.3" />
+ <parameter name="ambient-color" value="#333333" />
+ <parameter name="diffuse" value="true" />
+ <parameter name="front_diffuse-coefficient" value="0.65" />
+ <parameter name="back_diffuse-coefficient" value="0.65" />
+ <parameter name="diffuse-color" value="#000000" />
+ <parameter name="specular" value="true" />
+ <parameter name="front_specular-coefficient" value="0.0" />
+ <parameter name="back_specular-coefficient" value="0.0" />
+ <parameter name="specular-color" value="#ffffff" />
+ <parameter name="emissive" value="false" />
+ <parameter name="front_emissive-coefficient" value="0.0" />
+ <parameter name="back_emissive-coefficient" value="0.0" />
+ <parameter name="emissive-color" value="#000000" />
+ <parameter name="transparency" value="0.0" />
</section>
<section name="Plastic" >
- <parameter name="shininess" value="0.0078125" />
- <parameter name="ambient-coefficient" value="0.5" />
- <parameter name="diffuse-coefficient" value="0.24" />
- <parameter name="specular-coefficient" value="0.06" />
+ <parameter name="front_shininess" value="0.0078125" />
+ <parameter name="back_shininess" value="0.0078125" />
+ <parameter name="front_ambient-coefficient" value="0.5" />
+ <parameter name="back_ambient-coefficient" value="0.35" />
+ <parameter name="front_diffuse-coefficient" value="0.24" />
+ <parameter name="back_diffuse-coefficient" value="0.24" />
+ <parameter name="front_specular-coefficient" value="0.06" />
+ <parameter name="back_specular-coefficient" value="0.06" />
</section>
<section name="Shiny plastic" >
- <parameter name="shininess" value="1.0" />
- <parameter name="ambient-coefficient" value="0.44" />
- <parameter name="diffuse-coefficient" value="0.5" />
- <parameter name="specular-coefficient" value="1.0" />
+ <parameter name="front_shininess" value="1.0" />
+ <parameter name="back_shininess" value="1.0" />
+ <parameter name="front_ambient-coefficient" value="0.44" />
+ <parameter name="back_ambient-coefficient" value="0.36" />
+ <parameter name="front_diffuse-coefficient" value="0.5" />
+ <parameter name="back_diffuse-coefficient" value="0.4" />
+ <parameter name="front_specular-coefficient" value="1.0" />
+ <parameter name="back_specular-coefficient" value="1.0" />
</section>
<section name="Satin" >
- <parameter name="shininess" value="0.09375" />
- <parameter name="ambient-coefficient" value="0.33" />
- <parameter name="diffuse-coefficient" value="0.4" />
- <parameter name="specular-coefficient" value="0.44" />
+ <parameter name="front_shininess" value="0.09375" />
+ <parameter name="back_shininess" value="0.09375" />
+ <parameter name="front_ambient-coefficient" value="0.33" />
+ <parameter name="back_ambient-coefficient" value="0.28" />
+ <parameter name="front_diffuse-coefficient" value="0.4" />
+ <parameter name="back_diffuse-coefficient" value="0.35" />
+ <parameter name="front_specular-coefficient" value="0.44" />
+ <parameter name="back_specular-coefficient" value="0.44" />
</section>
<section name="Neon" >
- <parameter name="shininess" value="0.05" />
- <parameter name="ambient-coefficient" value="1.0" />
- <parameter name="diffuse-coefficient" value="1.0" />
- <parameter name="specular-coefficient" value="0.62" />
- <parameter name="emissive-coefficient" value="1.0" />
- <parameter name="ambient" value="false" />
- <parameter name="emissive" value="true" />
+ <parameter name="front_shininess" value="0.05" />
+ <parameter name="back_shininess" value="0.05" />
+ <parameter name="front_ambient-coefficient" value="1.0" />
+ <parameter name="back_ambient-coefficient" value="0.6" />
+ <parameter name="front_diffuse-coefficient" value="1.0" />
+ <parameter name="back_diffuse-coefficient" value="0.6" />
+ <parameter name="front_specular-coefficient" value="0.62" />
+ <parameter name="back_specular-coefficient" value="0.27" />
+ <parameter name="front_emissive-coefficient" value="1.0" />
+ <parameter name="back_emissive-coefficient" value="0.5" />
+ <parameter name="ambient" value="false" />
+ <parameter name="emissive" value="true" />
</section>
<section name="Metalized" >
- <parameter name="shininess" value="0.13" />
- <parameter name="ambient" value="false" />
- <parameter name="ambient-coefficient" value="0.9" />
- <parameter name="diffuse-coefficient" value="0.47" />
- <parameter name="specular-coefficient" value="0.45" />
+ <parameter name="front_shininess" value="0.08" />
+ <parameter name="back_shininess" value="0.13" />
+ <parameter name="ambient" value="false" />
+ <parameter name="front_ambient-coefficient" value="0.9" />
+ <parameter name="back_ambient-coefficient" value="0.7" />
+ <parameter name="front_diffuse-coefficient" value="0.57" />
+ <parameter name="back_diffuse-coefficient" value="0.42" />
+ <parameter name="front_specular-coefficient" value="0.45" />
+ <parameter name="back_specular-coefficient" value="0.45" />
</section>
<section name="Brass">
- <parameter name="physical" value="true" />
- <parameter name="shininess" value="0.21794844" />
- <parameter name="ambient-coefficient" value="1.0" />
- <parameter name="ambient-color" value="#543907" />
- <parameter name="diffuse-coefficient" value="1.0" />
- <parameter name="diffuse-color" value="#c7911d" />
- <parameter name="specular-coefficient" value="1.0" />
- <parameter name="specular-color" value="#fdf0ce" />
+ <parameter name="physical" value="true" />
+ <parameter name="front_shininess" value="0.21794844" />
+ <parameter name="back_shininess" value="0.21794844" />
+ <parameter name="front_ambient-coefficient" value="1.0" />
+ <parameter name="back_ambient-coefficient" value="0.6" />
+ <parameter name="ambient-color" value="#543907" />
+ <parameter name="front_diffuse-coefficient" value="1.0" />
+ <parameter name="back_diffuse-coefficient" value="0.9" />
+ <parameter name="diffuse-color" value="#c7911d" />
+ <parameter name="front_specular-coefficient" value="1.0" />
+ <parameter name="back_specular-coefficient" value="1.0" />
+ <parameter name="specular-color" value="#fdf0ce" />
</section>
<section name="Bronze">
- <parameter name="physical" value="true" />
- <parameter name="shininess" value="0.2" />
- <parameter name="ambient-coefficient" value="1.0" />
- <parameter name="ambient-color" value="#36200d" />
- <parameter name="diffuse-coefficient" value="1.0" />
- <parameter name="diffuse-color" value="#b66d2e" />
- <parameter name="specular-coefficient" value="1.0" />
- <parameter name="specular-color" value="#64452a" />
+ <parameter name="physical" value="true" />
+ <parameter name="front_shininess" value="0.2" />
+ <parameter name="back_shininess" value="0.2" />
+ <parameter name="front_ambient-coefficient" value="1.0" />
+ <parameter name="back_ambient-coefficient" value="0.6" />
+ <parameter name="ambient-color" value="#36200d" />
+ <parameter name="front_diffuse-coefficient" value="1.0" />
+ <parameter name="back_diffuse-coefficient" value="0.9" />
+ <parameter name="diffuse-color" value="#b66d2e" />
+ <parameter name="front_specular-coefficient" value="1.0" />
+ <parameter name="back_specular-coefficient" value="0.95" />
+ <parameter name="specular-color" value="#64452a" />
</section>
<section name="Copper" >
- <parameter name="physical" value="true" />
- <parameter name="shininess" value="0.93" />
- <parameter name="ambient-coefficient" value="1.0" />
- <parameter name="ambient-color" value="#54423a" />
- <parameter name="diffuse-coefficient" value="1.0" />
- <parameter name="diffuse-color" value="#801c00" />
- <parameter name="specular-coefficient" value="1.0" />
- <parameter name="specular-color" value="#f3ba00" />
+ <parameter name="physical" value="true" />
+ <parameter name="front_shininess" value="0.93" />
+ <parameter name="back_shininess" value="0.93" />
+ <parameter name="front_ambient-coefficient" value="1.0" />
+ <parameter name="back_ambient-coefficient" value="0.6" />
+ <parameter name="ambient-color" value="#54423a" />
+ <parameter name="front_diffuse-coefficient" value="1.0" />
+ <parameter name="back_diffuse-coefficient" value="1.0" />
+ <parameter name="diffuse-color" value="#801c00" />
+ <parameter name="front_specular-coefficient" value="1.0" />
+ <parameter name="back_specular-coefficient" value="1.0" />
+ <parameter name="specular-color" value="#f3ba00" />
</section>
<section name="Gold" >
- <parameter name="physical" value="true" />
- <parameter name="shininess" value="0.0625" />
- <parameter name="ambient-coefficient" value="0.3" />
- <parameter name="ambient-color" value="#ffc451" />
- <parameter name="diffuse-coefficient" value="0.4" />
- <parameter name="diffuse-color" value="#ffb000" />
- <parameter name="specular-coefficient" value="0.9" />
- <parameter name="specular-color" value="#fffac7" />
+ <parameter name="physical" value="true" />
+ <parameter name="front_shininess" value="0.0625" />
+ <parameter name="back_shininess" value="0.0625" />
+ <parameter name="front_ambient-coefficient" value="0.3" />
+ <parameter name="back_ambient-coefficient" value="0.25" />
+ <parameter name="ambient-color" value="#ffc451" />
+ <parameter name="front_diffuse-coefficient" value="0.4" />
+ <parameter name="back_diffuse-coefficient" value="0.3" />
+ <parameter name="diffuse-color" value="#ffb000" />
+ <parameter name="front_specular-coefficient" value="0.9" />
+ <parameter name="back_specular-coefficient" value="0.9" />
+ <parameter name="specular-color" value="#fffac7" />
</section>
<section name="Pewter" >
- <parameter name="physical" value="true" />
- <parameter name="shininess" value="0.076923047" />
- <parameter name="ambient-coefficient" value="1.0" />
- <parameter name="ambient-color" value="#1b0f1d" />
- <parameter name="diffuse-coefficient" value="1.0" />
- <parameter name="diffuse-color" value="#6d788a" />
- <parameter name="specular-coefficient" value="1.0" />
- <parameter name="specular-color" value="#555585" />
+ <parameter name="physical" value="true" />
+ <parameter name="front_shininess" value="0.076923047" />
+ <parameter name="back_shininess" value="0.076923047" />
+ <parameter name="front_ambient-coefficient" value="1.0" />
+ <parameter name="back_ambient-coefficient" value="0.6" />
+ <parameter name="ambient-color" value="#1b0f1d" />
+ <parameter name="front_diffuse-coefficient" value="1.0" />
+ <parameter name="back_diffuse-coefficient" value="0.9" />
+ <parameter name="diffuse-color" value="#6d788a" />
+ <parameter name="front_specular-coefficient" value="1.0" />
+ <parameter name="back_specular-coefficient" value="1.0" />
+ <parameter name="specular-color" value="#555585" />
</section>
<section name="Plaster" >
- <parameter name="shininess" value="0.0078125" />
- <parameter name="ambient-coefficient" value="0.26" />
- <parameter name="ambient-color" value="#313131" />
- <parameter name="diffuse-coefficient" value="0.23" />
- <parameter name="diffuse-color" value="#818181" />
- <parameter name="specular-coefficient" value="0.06" />
- <parameter name="specular-color" value="#828282" />
+ <parameter name="front_shininess" value="0.0078125" />
+ <parameter name="back_shininess" value="0.0078125" />
+ <parameter name="front_ambient-coefficient" value="0.26" />
+ <parameter name="back_ambient-coefficient" value="0.18" />
+ <parameter name="ambient-color" value="#313131" />
+ <parameter name="front_diffuse-coefficient" value="0.23" />
+ <parameter name="back_diffuse-coefficient" value="0.18" />
+ <parameter name="diffuse-color" value="#818181" />
+ <parameter name="front_specular-coefficient" value="0.06" />
+ <parameter name="back_specular-coefficient" value="0.06" />
+ <parameter name="specular-color" value="#828282" />
</section>
<section name="Silver" >
- <parameter name="physical" value="true" />
- <parameter name="shininess" value="0.2" />
- <parameter name="ambient-coefficient" value="1.0" />
- <parameter name="ambient-color" value="#313131" />
- <parameter name="diffuse-coefficient" value="1.0" />
- <parameter name="diffuse-color" value="#818181" />
- <parameter name="specular-coefficient" value="1.0" />
- <parameter name="specular-color" value="#828282" />
+ <parameter name="physical" value="true" />
+ <parameter name="front_shininess" value="0.2" />
+ <parameter name="back_shininess" value="0.2" />
+ <parameter name="front_ambient-coefficient" value="1.0" />
+ <parameter name="back_ambient-coefficient" value="0.6" />
+ <parameter name="ambient-color" value="#313131" />
+ <parameter name="front_diffuse-coefficient" value="1.0" />
+ <parameter name="back_diffuse-coefficient" value="0.95" />
+ <parameter name="diffuse-color" value="#818181" />
+ <parameter name="front_specular-coefficient" value="1.0" />
+ <parameter name="back_specular-coefficient" value="1.0" />
+ <parameter name="specular-color" value="#828282" />
</section>
<section name="Steel" >
- <parameter name="physical" value="true" />
- <parameter name="shininess" value="0.06" />
- <parameter name="ambient-coefficient" value="0.01" />
- <parameter name="diffuse-coefficient" value="0.03" />
- <parameter name="specular-coefficient" value="0.98" />
- <parameter name="specular-color" value="#ffffff" />
+ <parameter name="physical" value="true" />
+ <parameter name="front_shininess" value="0.06" />
+ <parameter name="back_shininess" value="0.06" />
+ <parameter name="front_ambient-coefficient" value="0.01" />
+ <parameter name="back_ambient-coefficient" value="0.01" />
+ <parameter name="front_diffuse-coefficient" value="0.03" />
+ <parameter name="back_diffuse-coefficient" value="0.01" />
+ <parameter name="front_specular-coefficient" value="0.98" />
+ <parameter name="back_specular-coefficient" value="0.63" />
+ <parameter name="specular-color" value="#ffffff" />
</section>
<section name="Stone" >
- <parameter name="physical" value="true" />
- <parameter name="shininess" value="0.17" />
- <parameter name="ambient-coefficient" value="0.19" />
- <parameter name="ambient-color" value="#ffcc9e" />
- <parameter name="diffuse-coefficient" value="0.75" />
- <parameter name="diffuse-color" value="#ffcc9e" />
- <parameter name="specular-coefficient" value="0.08" />
- <parameter name="specular-color" value="#faff99" />
+ <parameter name="physical" value="true" />
+ <parameter name="front_shininess" value="0.17" />
+ <parameter name="back_shininess" value="0.17" />
+ <parameter name="front_ambient-coefficient" value="0.19" />
+ <parameter name="back_ambient-coefficient" value="0.19" />
+ <parameter name="ambient-color" value="#ffcc9e" />
+ <parameter name="front_diffuse-coefficient" value="0.75" />
+ <parameter name="back_diffuse-coefficient" value="0.5" />
+ <parameter name="diffuse-color" value="#ffcc9e" />
+ <parameter name="front_specular-coefficient" value="0.08" />
+ <parameter name="back_specular-coefficient" value="0.08" />
+ <parameter name="specular-color" value="#faff99" />
</section>
<section name="Chrome" >
- <parameter name="physical" value="true" />
- <parameter name="shininess" value="0.1" />
- <parameter name="ambient-coefficient" value="1.0" />
- <parameter name="ambient-color" value="#595959" />
- <parameter name="diffuse-coefficient" value="1.0" />
- <parameter name="diffuse-color" value="#666666" />
- <parameter name="specular-coefficient" value="1.0" />
- <parameter name="specular-color" value="#f9f9f9" />
+ <parameter name="physical" value="true" />
+ <parameter name="front_shininess" value="0.1" />
+ <parameter name="back_shininess" value="0.1" />
+ <parameter name="front_ambient-coefficient" value="1.0" />
+ <parameter name="back_ambient-coefficient" value="0.6" />
+ <parameter name="ambient-color" value="#595959" />
+ <parameter name="front_diffuse-coefficient" value="1.0" />
+ <parameter name="back_diffuse-coefficient" value="0.95" />
+ <parameter name="diffuse-color" value="#666666" />
+ <parameter name="front_specular-coefficient" value="1.0" />
+ <parameter name="back_specular-coefficient" value="1.0" />
+ <parameter name="specular-color" value="#f9f9f9" />
</section>
<section name="Neon (physical)" >
- <parameter name="physical" value="true" />
- <parameter name="shininess" value="0.05" />
- <parameter name="ambient" value="false" />
- <parameter name="ambient-coefficient" value="1.0" />
- <parameter name="ambient-color" value="#ffffff" />
- <parameter name="diffuse" value="false" />
- <parameter name="diffuse-coefficient" value="1.0" />
- <parameter name="diffuse-color" value="#ffffff" />
- <parameter name="specular-coefficient" value="0.62" />
- <parameter name="specular-color" value="#ffffff" />
- <parameter name="emissive" value="true" />
- <parameter name="emissive-coefficient" value="0.9" />
- <parameter name="emissive-color" value="#00ff75" />
+ <parameter name="physical" value="true" />
+ <parameter name="front_shininess" value="0.05" />
+ <parameter name="back_shininess" value="0.05" />
+ <parameter name="ambient" value="false" />
+ <parameter name="front_ambient-coefficient" value="1.0" />
+ <parameter name="back_ambient-coefficient" value="1.0" />
+ <parameter name="ambient-color" value="#ffffff" />
+ <parameter name="diffuse" value="false" />
+ <parameter name="front_diffuse-coefficient" value="1.0" />
+ <parameter name="back_diffuse-coefficient" value="1.0" />
+ <parameter name="diffuse-color" value="#ffffff" />
+ <parameter name="front_specular-coefficient" value="0.62" />
+ <parameter name="back_specular-coefficient" value="0.62" />
+ <parameter name="specular-color" value="#ffffff" />
+ <parameter name="emissive" value="true" />
+ <parameter name="front_emissive-coefficient" value="0.9" />
+ <parameter name="back_emissive-coefficient" value="0.72" />
+ <parameter name="emissive-color" value="#00ff75" />
</section>
<section name="Aluminium" >
- <parameter name="physical" value="true" />
- <parameter name="shininess" value="0.09" />
- <parameter name="ambient-coefficient" value="1.0" />
- <parameter name="ambient-color" value="#4c4c4c" />
- <parameter name="diffuse-coefficient" value="1.0" />
- <parameter name="diffuse-color" value="#4c4c4c" />
- <parameter name="specular-coefficient" value="1.0" />
- <parameter name="specular-color" value="#b3b3cc" />
+ <parameter name="physical" value="true" />
+ <parameter name="front_shininess" value="0.09" />
+ <parameter name="back_shininess" value="0.09" />
+ <parameter name="front_ambient-coefficient" value="1.0" />
+ <parameter name="back_ambient-coefficient" value="0.6" />
+ <parameter name="ambient-color" value="#4c4c4c" />
+ <parameter name="front_diffuse-coefficient" value="1.0" />
+ <parameter name="back_diffuse-coefficient" value="1.0" />
+ <parameter name="diffuse-color" value="#4c4c4c" />
+ <parameter name="front_specular-coefficient" value="1.0" />
+ <parameter name="back_specular-coefficient" value="1.0" />
+ <parameter name="specular-color" value="#b3b3cc" />
</section>
<section name="Obsidian" >
- <parameter name="physical" value="true" />
- <parameter name="shininess" value="0.3" />
- <parameter name="ambient-coefficient" value="1.0" />
- <parameter name="ambient-color" value="#0d0c10" />
- <parameter name="diffuse-coefficient" value="1.0" />
- <parameter name="diffuse-color" value="#2e2b39" />
- <parameter name="specular-coefficient" value="1.0" />
- <parameter name="specular-color" value="#555458" />
+ <parameter name="physical" value="true" />
+ <parameter name="front_shininess" value="0.3" />
+ <parameter name="back_shininess" value="0.3" />
+ <parameter name="front_ambient-coefficient" value="1.0" />
+ <parameter name="back_ambient-coefficient" value="1.0" />
+ <parameter name="ambient-color" value="#0d0c10" />
+ <parameter name="front_diffuse-coefficient" value="1.0" />
+ <parameter name="back_diffuse-coefficient" value="0.7" />
+ <parameter name="diffuse-color" value="#2e2b39" />
+ <parameter name="front_specular-coefficient" value="1.0" />
+ <parameter name="back_specular-coefficient" value="0.9" />
+ <parameter name="specular-color" value="#555458" />
</section>
<section name="Jade" >
- <parameter name="physical" value="true" />
- <parameter name="shininess" value="0.1" />
- <parameter name="ambient-coefficient" value="1.0" />
- <parameter name="ambient-color" value="#223828" />
- <parameter name="diffuse-coefficient" value="1.0" />
- <parameter name="diffuse-color" value="#8ae3a1" />
- <parameter name="specular-coefficient" value="1.0" />
- <parameter name="specular-color" value="#505050" />
+ <parameter name="physical" value="true" />
+ <parameter name="front_shininess" value="0.1" />
+ <parameter name="back_shininess" value="0.1" />
+ <parameter name="front_ambient-coefficient" value="1.0" />
+ <parameter name="back_ambient-coefficient" value="0.6" />
+ <parameter name="ambient-color" value="#223828" />
+ <parameter name="front_diffuse-coefficient" value="1.0" />
+ <parameter name="back_diffuse-coefficient" value="0.85" />
+ <parameter name="diffuse-color" value="#8ae3a1" />
+ <parameter name="front_specular-coefficient" value="1.0" />
+ <parameter name="back_specular-coefficient" value="1.0" />
+ <parameter name="specular-color" value="#505050" />
</section>
</document>
myDrawer->ShadingAspect()->Aspect()->SetFrontMaterial(aMatAspect);
myDrawer->ShadingAspect()->Aspect()->SetBackMaterial(aMatAspect);
}
- myCurrentMaterial = myDrawer->ShadingAspect()->Aspect()->FrontMaterial();
+ myCurrentFrontMaterial = myDrawer->ShadingAspect()->Aspect()->FrontMaterial();
+ myCurrentBackMaterial = myDrawer->ShadingAspect()->Aspect()->BackMaterial();
}
void GEOM_AISShape::setIO(const Handle(SALOME_InteractiveObject)& io){
}
Graphic3d_MaterialAspect FMat = myDrawer->ShadingAspect()->Aspect()->FrontMaterial();
+ Graphic3d_MaterialAspect BMat = myDrawer->ShadingAspect()->Aspect()->BackMaterial();
FMat.SetTransparency(aValue);
myDrawer->ShadingAspect()->Aspect()->SetFrontMaterial(FMat);
- myDrawer->ShadingAspect()->Aspect()->SetBackMaterial(FMat);
- myCurrentMaterial = FMat;
+ myDrawer->ShadingAspect()->Aspect()->SetBackMaterial(BMat);
+ myCurrentFrontMaterial = FMat;
+ myCurrentBackMaterial = BMat;
myTransparency = aValue;
}
Graphic3d_MaterialAspect aMatAspect(Graphic3d_NOM_PLASTIC);
aMatAspect.SetTransparency(myTransparency);
- myCurrentMaterial = myDrawer->ShadingAspect()->Aspect()->FrontMaterial();
- myDrawer->ShadingAspect()->Aspect()->SetFrontMaterial( isTopLevel() ? aMatAspect : myCurrentMaterial );
- myDrawer->ShadingAspect()->Aspect()->SetBackMaterial( isTopLevel() ? aMatAspect : myCurrentMaterial );
+ myCurrentFrontMaterial = myDrawer->ShadingAspect()->Aspect()->FrontMaterial();
+ myCurrentBackMaterial = myDrawer->ShadingAspect()->Aspect()->BackMaterial();
+ myDrawer->ShadingAspect()->Aspect()->SetFrontMaterial( isTopLevel() ? aMatAspect : myCurrentFrontMaterial );
+ myDrawer->ShadingAspect()->Aspect()->SetBackMaterial( isTopLevel() ? aMatAspect : myCurrentBackMaterial );
//Handle(Graphic3d_AspectFillArea3d) a4bis = myDrawer->ShadingAspect()->Aspect();
// P->SetPrimitivesAspect(a4bis);
TCollection_AsciiString myName;
bool myDisplayVectors;
Standard_Boolean myTopLevel;
- Graphic3d_MaterialAspect myCurrentMaterial;
+ Graphic3d_MaterialAspect myCurrentFrontMaterial;
+ Graphic3d_MaterialAspect myCurrentBackMaterial;
Standard_Integer myPrevDisplayMode;
static TopLevelDispMode myTopLevelDm;
myHighlightProp(vtkProperty::New()),
myPreHighlightProp(vtkProperty::New()),
- myShadingFaceProp(vtkProperty::New())
+ myShadingFaceProp(vtkProperty::New()),
+ myShadingBackFaceProp(vtkProperty::New())
{
#ifdef MYDEBUG
MESSAGE (this<< " GEOM_Actor::GEOM_Actor");
myHighlightProp->Delete();
myPreHighlightProp->Delete();
myShadingFaceProp->Delete();
+ myShadingBackFaceProp->Delete();
}
GEOM_Actor*
myPreHighlightProp->SetRepresentationToSurface();
myHighlightProp->SetRepresentationToSurface();
myShadingFaceProp->SetRepresentationToSurface();
+ myShadingBackFaceProp->SetRepresentationToSurface();
break;
}
if(myIsPreselected){
this->myHighlightActor->SetProperty(myPreHighlightProp.GetPointer());
myShadingFaceActor->SetProperty(myPreHighlightProp.GetPointer());
+ myShadingFaceActor->SetBackfaceProperty(myPreHighlightProp.GetPointer());
} else {
this->myHighlightActor->SetProperty(myShadingFaceProp.GetPointer());
myShadingFaceActor->SetProperty(myShadingFaceProp.GetPointer());
+ myShadingFaceActor->SetBackfaceProperty(myShadingBackFaceProp.GetPointer());
}
}
else{
this->myHighlightActor->SetProperty(myHighlightProp.GetPointer());
myShadingFaceActor->SetProperty(myHighlightProp.GetPointer());
+ myShadingFaceActor->SetBackfaceProperty(myHighlightProp.GetPointer());
}
this->Property->Render(this, ren);
{
// enk:tested OK
myShadingFaceProp->SetOpacity(opa);
+ myShadingBackFaceProp->SetOpacity(opa);
myHighlightProp->SetOpacity(opa);
myPreHighlightProp->SetOpacity(opa);
myVertexActor->GetProperty()->SetOpacity(opa);
{
// enk:tested OK
myShadingFaceProp->SetColor(r,g,b); // shading color (Shading)
+ myShadingBackFaceProp->SetColor(r,g,b); // back face shading color (Shading)
myVertexActor->GetProperty()->SetColor(r,g,b); // vertex actor (Shading/Wireframe)
if ( myDisplayMode != (int)eShadingWithEdges ) {
myIsolatedEdgeActor->GetProperty()->SetColor(r,g,b); // standalone edge color (Wireframe)
void GEOM_Actor::SetMaterial(std::vector<vtkProperty*> theProps)
{
// we set material properties as back and front material
+ int aSize = theProps.size();
+
+ if ( aSize < 1 || aSize > 2)
+ return;
+
+ // theProps[0] -- front material properties
+ // theProps[1] -- back material properties (if exist)
+
double aCoefnt;
// Set reflection coefficients
aCoefnt = theProps[0]->GetAmbient();
myShadingFaceProp->SetAmbient(aCoefnt);
myVertexActor->GetProperty()->SetAmbient(aCoefnt);
+ if ( aSize == 2 )
+ aCoefnt = theProps[1]->GetAmbient();
+ myShadingBackFaceProp->SetAmbient(aCoefnt);
// Set diffuse coefficients
aCoefnt = theProps[0]->GetDiffuse();
myShadingFaceProp->SetDiffuse(aCoefnt);
myVertexActor->GetProperty()->SetDiffuse(aCoefnt);
+ if ( aSize == 2 )
+ aCoefnt = theProps[1]->GetDiffuse();
+ myShadingBackFaceProp->SetDiffuse(aCoefnt);
// Set specular coefficients
aCoefnt = theProps[0]->GetSpecular();
myShadingFaceProp->SetSpecular(aCoefnt);
myVertexActor->GetProperty()->SetSpecular(aCoefnt);
+ if ( aSize == 2 )
+ aCoefnt = theProps[1]->GetSpecular();
+ myShadingBackFaceProp->SetSpecular(aCoefnt);
+
double* aColor;
aColor = theProps[0]->GetAmbientColor();
myShadingFaceProp->SetAmbientColor(aColor[0], aColor[1], aColor[2]);
myVertexActor->GetProperty()->SetAmbientColor(aColor[0], aColor[1], aColor[2]);
+ if ( aSize == 2 )
+ aColor = theProps[1]->GetAmbientColor();
+ myShadingBackFaceProp->SetAmbientColor(aColor[0], aColor[1], aColor[2]);
// Set diffuse colors
aColor = theProps[0]->GetDiffuseColor();
myShadingFaceProp->SetDiffuseColor(aColor[0], aColor[1], aColor[2]);
myVertexActor->GetProperty()->SetDiffuseColor(aColor[0], aColor[1], aColor[2]);
+ if ( aSize == 2 )
+ aColor = theProps[1]->GetDiffuseColor();
+ myShadingBackFaceProp->SetDiffuseColor(aColor[0], aColor[1], aColor[2]);
// Set specular colors
aColor = theProps[0]->GetSpecularColor();
myShadingFaceProp->SetSpecularColor(aColor[0], aColor[1], aColor[2]);
myVertexActor->GetProperty()->SetSpecularColor(aColor[0], aColor[1], aColor[2]);
+ if ( aSize == 2 )
+ aColor = theProps[1]->GetSpecularColor();
+ myShadingBackFaceProp->SetSpecularColor(aColor[0], aColor[1], aColor[2]);
// Set shininess
aCoefnt = theProps[0]->GetSpecularPower();
myShadingFaceProp->SetSpecularPower(aCoefnt);
myVertexActor->GetProperty()->SetSpecularPower(aCoefnt);
+ if ( aSize == 2 )
+ aCoefnt = theProps[1]->GetSpecularPower();
+ myShadingBackFaceProp->SetSpecularPower(aCoefnt);
+
+ // Set back face material property
+ myShadingFaceActor->SetBackfaceProperty(myShadingBackFaceProp.GetPointer());
}
-vtkProperty* GEOM_Actor::GetMaterial()
+vtkProperty* GEOM_Actor::GetFrontMaterial()
{
return myShadingFaceProp;
}
+vtkProperty* GEOM_Actor::GetBackMaterial()
+{
+ return myShadingBackFaceProp;
+}
+
bool GEOM_Actor::IsInfinitive()
{
return ((bool)myShape.Infinite() || isOnlyVertex);
// Material
void SetMaterial(std::vector<vtkProperty*> theProps);
- vtkProperty* GetMaterial();
-
+ vtkProperty* GetFrontMaterial();
+ vtkProperty* GetBackMaterial();
virtual bool IsInfinitive();
// overloaded functions
vtkSmartPointer<vtkProperty> myHighlightProp;
vtkSmartPointer<vtkProperty> myPreHighlightProp;
vtkSmartPointer<vtkProperty> myShadingFaceProp;
+ vtkSmartPointer<vtkProperty> myShadingBackFaceProp;
PAppendFilter myAppendFilter;
PPolyGeomPainterDataMapper myPolyDataMapper;
return myActor->GetProperty();
}
+void \r
+GEOM_DeviceActor:: \r
+SetBackfaceProperty(vtkProperty* theProperty)\r
+{\r
+ myActor->SetBackfaceProperty(theProperty);\r
+}\r
+ \r
+vtkProperty* \r
+GEOM_DeviceActor:: \r
+GetBackfaceProperty()\r
+{\r
+ return myActor->GetBackfaceProperty();\r
+}\r
+
void
GEOM_DeviceActor::
SetVisibility(int theVisibility)
void SetProperty(vtkProperty* theProperty);
vtkProperty* GetProperty();
-
+ \r
+ void SetBackfaceProperty(vtkProperty* theProperty);\r
+ vtkProperty* GetBackfaceProperty();
+
void SetVisibility(int theVisibility);
int GetVisibility();