]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
0021719: EDF 1654 : Materials
authorana <ana@opencascade.com>
Fri, 28 Dec 2012 15:55:12 +0000 (15:55 +0000)
committerana <ana@opencascade.com>
Fri, 28 Dec 2012 15:55:12 +0000 (15:55 +0000)
23 files changed:
resources/SalomeApp.xml.in
src/GEOMGUI/GEOMGUI.cxx
src/GEOMGUI/GEOMGUI.h
src/GEOMGUI/GEOM_Displayer.cxx
src/GEOMGUI/GEOM_msg_en.ts
src/GEOMGUI/GEOM_msg_fr.ts
src/GEOMGUI/GeometryGUI.cxx
src/GEOMGUI/GeometryGUI.h
src/GEOMGUI/GeometryGUI_Operations.h
src/GEOMToolsGUI/GEOMToolsGUI.cxx
src/GEOMToolsGUI/GEOMToolsGUI.h
src/GEOMToolsGUI/GEOMToolsGUI_1.cxx
src/GEOMToolsGUI/GEOMToolsGUI_MaterialPropertiesDlg.cxx
src/GEOMToolsGUI/GEOMToolsGUI_MaterialPropertiesDlg.h
src/Material/Material_Model.cxx
src/Material/Material_Model.h
src/Material/resources/SalomeMaterial.xml
src/OBJECT/GEOM_AISShape.cxx
src/OBJECT/GEOM_AISShape.hxx
src/OBJECT/GEOM_Actor.cxx
src/OBJECT/GEOM_Actor.h
src/OBJECT/GEOM_DeviceActor.cxx
src/OBJECT/GEOM_DeviceActor.h

index 83ef31de5ec1d2ea9e1126a0bfb3a1ee275a0cae..2d32d28fe2bfab923e7c55090cbdcd23b8051b70 100644 (file)
@@ -58,6 +58,7 @@
     <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" />
index b87f89833a6a9a41a4b1d0f9ea78112e0de498ba..2e1021de3931bdfe76ae7b961a0f19276733bde3 100644 (file)
@@ -48,6 +48,15 @@ GEOMGUI::~GEOMGUI()
 {
 }
 
+//=================================================================================
+// 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
index 87b76ed243cb020945d8d16be782c92ef05b1e23..eac15283a6899e7c7a3b3434fa0a1ae5ded870b5 100644 (file)
@@ -51,6 +51,7 @@ public :
 
   // 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* );
index 50dac6d681d79e645ee232c895197f622ec649f5..133ec0932750cc0f166a880619818f5a5f7723fe 100644 (file)
@@ -984,7 +984,15 @@ void GEOM_Displayer::Update( SALOME_OCCPrs* prs )
           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())
@@ -1191,7 +1199,8 @@ void GEOM_Displayer::Update( SALOME_VTKPrs* prs )
         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.};
@@ -1240,7 +1249,8 @@ void GEOM_Displayer::Update( SALOME_VTKPrs* prs )
                 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);
         }
       }
index 064abaa7f965ef03476a9d2dea0297f702321fff..1eeee7c4861cece75ad53c1f0d1e57d81e22eb51 100644 (file)
@@ -2966,6 +2966,10 @@ Please, select face, shell or solid and try again</translation>
         <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>
@@ -3026,6 +3030,10 @@ Please, select face, shell or solid and try again</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>
@@ -3170,6 +3178,10 @@ Please, select face, shell or solid and try again</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>
@@ -3202,6 +3214,10 @@ Please, select face, shell or solid and try again</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>
@@ -3614,6 +3630,14 @@ Please, select face, shell or solid and try again</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>
@@ -5566,6 +5590,14 @@ Would you like to continue?</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>
@@ -5582,10 +5614,6 @@ Would you like to continue?</translation>
         <source>REFLECTION_3</source>
         <translation>Emissive</translation>
     </message>
-    <message>
-        <source>ENABLED</source>
-        <translation>Enabled</translation>
-    </message>
     <message>
         <source>SHININESS</source>
         <translation>Shininess:</translation>
index b423af0621421e3500d667c4ca954ffd285c7742..adab9838d3fddb5817a4057bfa232f9d6bbb4d53 100644 (file)
@@ -5557,10 +5557,6 @@ Voulez-vous continuer?</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>
index 262efef7f6d855a78a7c6b85f25c989ca4ff0921..6fa068346e46dbcc03010136b190605bd60878bc 100644 (file)
@@ -38,6 +38,7 @@
 #include "GEOM_Actor.h"
 
 #include <Material_ResourceMgr.h>
+#include <Material_Model.h>
 
 #include <SUIT_Desktop.h>
 #include <SUIT_MessageBox.h>
@@ -84,6 +85,7 @@
 #include <QFileInfo>
 #include <QString>
 #include <QPainter>
+#include <QSignalMapper>
 
 #include <AIS_Drawer.hxx>
 #include <AIS_ListOfInteractive.hxx>
@@ -358,7 +360,7 @@ void GeometryGUI::OnGUIEvent()
 // 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;
@@ -407,6 +409,7 @@ void GeometryGUI::OnGUIEvent( int id )
   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
@@ -424,6 +427,8 @@ void GeometryGUI::OnGUIEvent( int id )
   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
@@ -594,8 +599,10 @@ void GeometryGUI::OnGUIEvent( int id )
 
   // 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();
@@ -845,6 +852,7 @@ void GeometryGUI::initialize( CAM_Application* app )
   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" );
@@ -886,7 +894,8 @@ void GeometryGUI::initialize( CAM_Application* app )
   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" );
 
@@ -1084,6 +1093,11 @@ void GeometryGUI::initialize( CAM_Application* app )
   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 );
@@ -1288,6 +1302,7 @@ void GeometryGUI::initialize( CAM_Application* app )
   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
@@ -1299,9 +1314,13 @@ void GeometryGUI::initialize( CAM_Application* app )
   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
@@ -1688,6 +1707,55 @@ void GeometryGUI::contextMenuPopup( const QString& client, QMenu* menu, QString&
   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() );
@@ -1701,6 +1769,12 @@ void GeometryGUI::contextMenuPopup( const QString& client, QMenu* menu, QString&
   }
 }
 
+void GeometryGUI::OnSetMaterial(const QString& theName)
+{
+  OnGUIEvent( GEOMOp::OpPredefMaterial, QVariant( theName ) );
+}
+
+
 void GeometryGUI::createPreferences()
 {
   int tabId = addPreference( tr( "PREF_TAB_SETTINGS" ) );
@@ -1745,6 +1819,9 @@ void GeometryGUI::createPreferences()
   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" );
@@ -1863,6 +1940,8 @@ void GeometryGUI::createPreferences()
   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() );
index bde9446a7e13828f91237dc7399aa1f2d331346d..b9553c157daf53911677a9d3177e1ca616a00c64 100644 (file)
@@ -111,7 +111,7 @@ public:
   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;   }
@@ -151,6 +151,7 @@ private slots:
   void                        OnGUIEvent();
   void                        onWindowActivated( SUIT_ViewWindow* );
   void                        onViewAboutToShow();
+  void                        OnSetMaterial( const QString& );
 
 signals :
   void                        SignalDeactivateActiveDialog();
index e17172e490f00ba6660175118f1dda070d238d08..cea4c90485edec2bae75b78708f0bcdef092f873 100644 (file)
@@ -29,6 +29,7 @@ namespace GEOMOp {
     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
@@ -50,6 +51,8 @@ namespace GEOMOp {
     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
index 01f2c182f63289704f0f28c68f863313d689af99..95b4507e85f386c97388fd38b1058d62c2db2591 100644 (file)
@@ -325,7 +325,7 @@ bool GEOMToolsGUI::OnGUIEvent(int theCommandID, SUIT_Desktop* parent)
   case GEOMOp::OpColor:          // POPUP - COLOR
     OnColor();
     break;
-  case GEOMOp::OpSetTexture:        // POPUP - TEXTURE
+  case GEOMOp::OpSetTexture:     // POPUP - TEXTURE
     OnTexture();
     break;
   case GEOMOp::OpTransparency:   // POPUP - TRANSPARENCY
@@ -349,6 +349,12 @@ bool GEOMToolsGUI::OnGUIEvent(int theCommandID, SUIT_Desktop* parent)
   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;
@@ -387,6 +393,25 @@ bool GEOMToolsGUI::OnGUIEvent(int theCommandID, SUIT_Desktop* parent)
   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  :
index 8b6c32c78f1f8f3aa9e2270bf2675c1f3f6d4b89..6c04a9be5ffe36f4508925c5ca993517b48c1aef 100644 (file)
@@ -54,6 +54,8 @@ public:
   ~GEOMToolsGUI();
 
   bool         OnGUIEvent( int, SUIT_Desktop* );
+  bool         OnGUIEvent( int theCommandID, SUIT_Desktop*, const QVariant& );
+
   virtual void deactivate();
 
   enum ActionType { SHOWDLG, INCR, DECR };
@@ -82,6 +84,8 @@ private:
   void         OnPublishObject() ;
   void         OnPointMarker();
   void         OnMaterialProperties();
+  void         OnMaterialsLibrary();
+  void         OnSetMaterial(const QVariant& );
   void         OnEdgeWidth();
   void         OnIsosWidth();
   void         OnBringToFront();
index 526a9b1e4e5e09c2bc6e379583db94a94fd9f4b7..ac3e8f5b4172db297173d2b53e47d90aa92e6806 100644 (file)
@@ -34,7 +34,9 @@
 #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
@@ -1006,7 +1009,14 @@ void GEOMToolsGUI::OnPointMarker()
 
 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();
 }
 
@@ -1444,3 +1454,90 @@ void GEOMToolsGUI::OnClsBringToFront() {
   }
 }
   
+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();
+  }
+}
index ca92d6f087db1e48a83b2f0dcdfe1be79451cf4c..dc00889c895262262d372e5b3f606d213e9f074e 100644 (file)
@@ -26,6 +26,7 @@
 #include "GEOM_Constants.h"
 #include "GEOM_VTKPropertyMaterial.hxx"
 #include "GEOMBase.h"
+#include "GEOM_Displayer.h"
 
 #include <QtxColorButton.h>
 #include <QtxDoubleSpinBox.h>
@@ -50,6 +51,7 @@
 #include <QHBoxLayout>
 #include <QKeyEvent>
 #include <QLabel>
+#include <QLineEdit>
 #include <QMap>
 #include <QMenu>
 #include <QPushButton>
@@ -89,13 +91,17 @@ void GEOMToolsGUI_MaterialList::contextMenuEvent( QContextMenuEvent* e )
 /*!
   \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 );
@@ -105,6 +111,11 @@ GEOMToolsGUI_MaterialPropertiesDlg::GEOMToolsGUI_MaterialPropertiesDlg( QWidget*
   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 );
@@ -130,41 +141,64 @@ GEOMToolsGUI_MaterialPropertiesDlg::GEOMToolsGUI_MaterialPropertiesDlg( QWidget*
   // "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 );
@@ -178,21 +212,42 @@ GEOMToolsGUI_MaterialPropertiesDlg::GEOMToolsGUI_MaterialPropertiesDlg( QWidget*
   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 );
@@ -227,6 +282,9 @@ GEOMToolsGUI_MaterialPropertiesDlg::GEOMToolsGUI_MaterialPropertiesDlg( QWidget*
   // 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 
@@ -234,10 +292,12 @@ GEOMToolsGUI_MaterialPropertiesDlg::GEOMToolsGUI_MaterialPropertiesDlg( QWidget*
   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* ) ),
@@ -249,6 +309,9 @@ GEOMToolsGUI_MaterialPropertiesDlg::GEOMToolsGUI_MaterialPropertiesDlg( QWidget*
   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 ) ) );
@@ -276,7 +339,10 @@ GEOMToolsGUI_MaterialPropertiesDlg::GEOMToolsGUI_MaterialPropertiesDlg( QWidget*
       }
     }
   }
-  
+  myLineEditCurArg->setText(""); 
+  myPushBtn->click();
+  SelectionIntoArgument();
+
   // finally activate current material properties
   myMaterials->setCurrentRow( 0 );
 }
@@ -324,12 +390,14 @@ void GEOMToolsGUI_MaterialPropertiesDlg::fromModel( const Material_Model& model
   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() );
@@ -345,13 +413,15 @@ void GEOMToolsGUI_MaterialPropertiesDlg::toModel( Material_Model& model ) const
   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() );
   }
 }
@@ -391,7 +461,7 @@ void GEOMToolsGUI_MaterialPropertiesDlg::onApply()
 {  
   // save user materials
   myResourceMgr.save();
-
+  if( !myShowSelWidget ) return;
   // store selected material properties in the current model
   toModel( myCurrentModel );
 
@@ -421,19 +491,20 @@ void GEOMToolsGUI_MaterialPropertiesDlg::onApply()
     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();
@@ -448,25 +519,32 @@ void GEOMToolsGUI_MaterialPropertiesDlg::onApply()
     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();
@@ -670,3 +748,37 @@ void GEOMToolsGUI_MaterialPropertiesDlg::updateState()
   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 );
+}
index 1e2a7c6f77bcbb6269e1785070f4da65170e6e3a..c9f20598e53ed061dd9ca2aad02cd34d41bfcbd3 100644 (file)
@@ -45,7 +45,7 @@ class GEOMTOOLSGUI_EXPORT GEOMToolsGUI_MaterialPropertiesDlg : public QtxDialog
   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();
@@ -72,26 +72,33 @@ private slots:
   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
index 9744571c5e395b63572288d004b20d4ff3d0c532..f90d849bb8fb1e65d10a0ec579cf50fd00163449 100644 (file)
@@ -78,21 +78,36 @@ void Material_Model::fromProperties( const QString& props )
     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 );
     }
@@ -128,7 +143,7 @@ QString Material_Model::toProperties()
   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() );
@@ -137,25 +152,25 @@ QString Material_Model::toProperties()
   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( ":" );
 }
@@ -194,8 +209,11 @@ void Material_Model::fromResources( const QString& material, QtxResourceMgr* res
   }
 
   // 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
@@ -207,8 +225,11 @@ void Material_Model::fromResources( const QString& material, QtxResourceMgr* res
   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" ) );
@@ -218,8 +239,11 @@ void Material_Model::fromResources( const QString& material, QtxResourceMgr* res
   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" ) );
@@ -229,8 +253,11 @@ void Material_Model::fromResources( const QString& material, QtxResourceMgr* res
   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" ) );
@@ -240,8 +267,11 @@ void Material_Model::fromResources( const QString& material, QtxResourceMgr* res
   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" ) );
@@ -267,7 +297,8 @@ void Material_Model::toResources( const QString& material, QtxResourceMgr* resMg
     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() );
@@ -275,46 +306,33 @@ void Material_Model::toResources( const QString& material, QtxResourceMgr* resMg
     // 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
@@ -390,14 +408,18 @@ void Material_Model::setColor( ReflectionType type, const QColor& value )
 /*!
   \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;
 }
 
@@ -405,32 +427,44 @@ double Material_Model::reflection( ReflectionType type ) const
   \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;
 }
 
 /*!
@@ -464,39 +498,45 @@ void Material_Model::init()
   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;
@@ -508,7 +548,7 @@ Graphic3d_MaterialAspect Material_Model::getMaterialOCCAspect()
     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
@@ -519,7 +559,7 @@ Graphic3d_MaterialAspect Material_Model::getMaterialOCCAspect()
     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
@@ -530,7 +570,7 @@ Graphic3d_MaterialAspect Material_Model::getMaterialOCCAspect()
     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
@@ -541,14 +581,14 @@ Graphic3d_MaterialAspect Material_Model::getMaterialOCCAspect()
     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() );
@@ -561,9 +601,10 @@ Graphic3d_MaterialAspect Material_Model::getMaterialOCCAspect()
 
 /*!
   \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
@@ -579,25 +620,25 @@ GEOM_VTKPropertyMaterial* Material_Model::getMaterialVTKProperty()
   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() );
index 3f3c8ff24695231fed5077aed4e5c3a1d8ba734a..96ef16fae362b05765203b311eed93ad22e142b0 100644 (file)
@@ -63,17 +63,17 @@ public:
   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();
@@ -81,14 +81,16 @@ private:
 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;
 };
index d1e26882c08ab3191beccf38b174a89e203b84a4..8c9349db209421914f29fe4bd32183894a6116cc 100644 (file)
 -->
 <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>
index 4b5b686e43cb72288548af952fee46fc4d8b55aa..6e731d256efb948a901561bd29a95cecf1c1030f 100644 (file)
@@ -166,7 +166,8 @@ GEOM_AISShape::GEOM_AISShape(const TopoDS_Shape& shape,
        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){
@@ -327,10 +328,12 @@ void GEOM_AISShape::SetTransparency(const Standard_Real aValue)
     }
 
   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;
 }
 
@@ -388,9 +391,10 @@ void GEOM_AISShape::shadingMode(const Handle(PrsMgr_PresentationManager3d)& aPre
 
   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);
index eec1ef7bfd39b587ce27add31848b422e3fb01aa..437193822cd5b102b839a941e7d680ec166fc2f4 100644 (file)
@@ -172,7 +172,8 @@ private:
   TCollection_AsciiString  myName;
   bool                     myDisplayVectors;
   Standard_Boolean         myTopLevel;
-  Graphic3d_MaterialAspect myCurrentMaterial;
+  Graphic3d_MaterialAspect myCurrentFrontMaterial;
+  Graphic3d_MaterialAspect myCurrentBackMaterial;
   Standard_Integer         myPrevDisplayMode;
 
   static TopLevelDispMode myTopLevelDm;
index 353992d56f76c1f869b1bae9b912f5c981dad096..5865ba5d28ccc5759e5858a7ddac1c1a58f14aa4 100644 (file)
@@ -112,7 +112,8 @@ GEOM_Actor::GEOM_Actor():
 
   myHighlightProp(vtkProperty::New()),
   myPreHighlightProp(vtkProperty::New()),
-  myShadingFaceProp(vtkProperty::New())
+  myShadingFaceProp(vtkProperty::New()),
+  myShadingBackFaceProp(vtkProperty::New())
 { 
 #ifdef MYDEBUG
   MESSAGE (this<< " GEOM_Actor::GEOM_Actor");
@@ -201,6 +202,7 @@ GEOM_Actor::~GEOM_Actor()
   myHighlightProp->Delete();
   myPreHighlightProp->Delete();
   myShadingFaceProp->Delete();
+  myShadingBackFaceProp->Delete();
 } 
  
 GEOM_Actor*  
@@ -546,6 +548,7 @@ void GEOM_Actor::Render(vtkRenderer *ren, vtkMapper *theMapper)
     myPreHighlightProp->SetRepresentationToSurface();
     myHighlightProp->SetRepresentationToSurface();
     myShadingFaceProp->SetRepresentationToSurface();
+    myShadingBackFaceProp->SetRepresentationToSurface();
     break;
   }
 
@@ -553,14 +556,17 @@ void GEOM_Actor::Render(vtkRenderer *ren, vtkMapper *theMapper)
     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);
@@ -671,6 +677,7 @@ void GEOM_Actor::SetOpacity(vtkFloatingPointType opa)
 {
   // enk:tested OK
   myShadingFaceProp->SetOpacity(opa);
+  myShadingBackFaceProp->SetOpacity(opa);
   myHighlightProp->SetOpacity(opa);
   myPreHighlightProp->SetOpacity(opa);
   myVertexActor->GetProperty()->SetOpacity(opa);
@@ -686,6 +693,7 @@ void GEOM_Actor::SetColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloat
 {
   // 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)
@@ -709,22 +717,40 @@ void GEOM_Actor::GetColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFlo
 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;
 
@@ -732,28 +758,48 @@ void GEOM_Actor::SetMaterial(std::vector<vtkProperty*> theProps)
   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);
index 99bc8efb5b093fbfea8642eda9d7d6eab64e9201..f3acde3030d583da1316d6bb81c4238f8a2cbd63 100644 (file)
@@ -126,8 +126,8 @@ public:
 
   // Material
   void SetMaterial(std::vector<vtkProperty*> theProps);
-  vtkProperty* GetMaterial();
-
+  vtkProperty* GetFrontMaterial();
+  vtkProperty* GetBackMaterial();
   virtual bool IsInfinitive();
 
   // overloaded functions
@@ -242,6 +242,7 @@ private:
   vtkSmartPointer<vtkProperty>  myHighlightProp;
   vtkSmartPointer<vtkProperty>  myPreHighlightProp;
   vtkSmartPointer<vtkProperty>  myShadingFaceProp;
+  vtkSmartPointer<vtkProperty>  myShadingBackFaceProp;
 
   PAppendFilter myAppendFilter;
   PPolyGeomPainterDataMapper myPolyDataMapper;
index 266814569d523efd6066d03b4a504f2ae753dee9..9a25e86e57f99c5e30f6c34d733eebdd19eb0015 100755 (executable)
@@ -73,6 +73,20 @@ GetProperty()
   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)
index 8b36ab7ae3813c4bb34ccaa90d41e778feebf09b..67edada940fa30d9b8d691fc6e4c635ee3a392d9 100755 (executable)
@@ -52,7 +52,10 @@ public:
 
   void SetProperty(vtkProperty* theProperty);
   vtkProperty* GetProperty();
\r
+  void SetBackfaceProperty(vtkProperty* theProperty);\r
+  vtkProperty* GetBackfaceProperty();
+
   void SetVisibility(int theVisibility); 
   int GetVisibility();