]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
Fix for PAL21179:
authormkr <mkr@opencascade.com>
Thu, 12 Jan 2012 16:36:50 +0000 (16:36 +0000)
committermkr <mkr@opencascade.com>
Thu, 12 Jan 2012 16:36:50 +0000 (16:36 +0000)
1) draw outlines (borders) of the shapes,
2) material properties.

45 files changed:
configure.ac
doc/salome/gui/GEOM/images/material_OCC.png [new file with mode: 0644]
doc/salome/gui/GEOM/images/material_VTK.png [new file with mode: 0644]
doc/salome/gui/GEOM/images/material_back.png [new file with mode: 0644]
doc/salome/gui/GEOM/images/material_front.png [new file with mode: 0644]
doc/salome/gui/GEOM/input/material.doc [new file with mode: 0644]
doc/salome/gui/GEOM/input/viewing_geom_obj.doc
resources/SalomeApp.xml.in
src/DisplayGUI/DisplayGUI.cxx
src/GEOMGUI/GEOMGUI_Selection.cxx
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/GEOMGUI/Makefile.am
src/GEOMToolsGUI/GEOMToolsGUI.cxx
src/GEOMToolsGUI/GEOMToolsGUI.h
src/GEOMToolsGUI/GEOMToolsGUI_1.cxx
src/GEOMToolsGUI/GEOMToolsGUI_DeflectionDlg.cxx
src/GEOMToolsGUI/GEOMToolsGUI_MarkerDlg.cxx
src/GEOMToolsGUI/GEOMToolsGUI_MaterialPropertiesDlg.cxx [new file with mode: 0644]
src/GEOMToolsGUI/GEOMToolsGUI_MaterialPropertiesDlg.h [new file with mode: 0644]
src/GEOMToolsGUI/GEOMToolsGUI_TransparencyDlg.cxx
src/GEOMToolsGUI/Makefile.am
src/Makefile.am
src/Material/Makefile.am [new file with mode: 0644]
src/Material/Material.h [new file with mode: 0644]
src/Material/Material_Model.cxx [new file with mode: 0644]
src/Material/Material_Model.h [new file with mode: 0644]
src/Material/Material_ResourceMgr.cxx [new file with mode: 0644]
src/Material/Material_ResourceMgr.h [new file with mode: 0644]
src/Material/resources/SalomeMaterial.xml [new file with mode: 0644]
src/OBJECT/GEOM_AISShape.cxx
src/OBJECT/GEOM_AISShape.hxx
src/OBJECT/GEOM_Actor.cxx
src/OBJECT/GEOM_Actor.h
src/OBJECT/GEOM_Constants.h [new file with mode: 0644]
src/OBJECT/GEOM_DeviceActor.cxx
src/OBJECT/GEOM_DeviceActor.h
src/OBJECT/GEOM_PainterPolyDataMapper.cxx [new file with mode: 0644]
src/OBJECT/GEOM_PainterPolyDataMapper.h [new file with mode: 0644]
src/OBJECT/GEOM_SmartPtr.h
src/OBJECT/Makefile.am

index 729d02fa134d2925a595f2c0270b1f95c211c6dc..8e0abd9f0d60551498e44efa1496749d4607a514 100644 (file)
@@ -448,6 +448,7 @@ AC_OUTPUT([ \
   src/GEOMBase/Makefile \
   src/GEOMClient/Makefile \
   src/GEOMFiltersSelection/Makefile \
+  src/Material/Makefile \
   src/GEOMGUI/Makefile \
   src/GEOMImpl/Makefile \
   src/GEOMToolsGUI/Makefile \
diff --git a/doc/salome/gui/GEOM/images/material_OCC.png b/doc/salome/gui/GEOM/images/material_OCC.png
new file mode 100644 (file)
index 0000000..6f23268
Binary files /dev/null and b/doc/salome/gui/GEOM/images/material_OCC.png differ
diff --git a/doc/salome/gui/GEOM/images/material_VTK.png b/doc/salome/gui/GEOM/images/material_VTK.png
new file mode 100644 (file)
index 0000000..b409c73
Binary files /dev/null and b/doc/salome/gui/GEOM/images/material_VTK.png differ
diff --git a/doc/salome/gui/GEOM/images/material_back.png b/doc/salome/gui/GEOM/images/material_back.png
new file mode 100644 (file)
index 0000000..713e89b
Binary files /dev/null and b/doc/salome/gui/GEOM/images/material_back.png differ
diff --git a/doc/salome/gui/GEOM/images/material_front.png b/doc/salome/gui/GEOM/images/material_front.png
new file mode 100644 (file)
index 0000000..2b426de
Binary files /dev/null and b/doc/salome/gui/GEOM/images/material_front.png differ
diff --git a/doc/salome/gui/GEOM/input/material.doc b/doc/salome/gui/GEOM/input/material.doc
new file mode 100644 (file)
index 0000000..fb89d01
--- /dev/null
@@ -0,0 +1,56 @@
+/*!
+
+\page material_page Material
+
+\n You can change the material properties of the selected shape(s) by
+- choosing one of predefined global materials,
+- choosing one of predefined user materials,
+- creating a new user material and applying it to the selected shape(s)
+
+in the following dialog box.
+
+\image html material_front.png
+<center><em><b>Set Material Properties</b> dialog: <b>Front material</b> tab</em></center>
+
+\image html material_back.png
+<center><em><b>Set Material Properties</b> dialog: <b>Back material</b> tab</em></center>
+
+This functionality is available in both OCC and VTK viewers.
+
+User can changed the following material properties
+
+- ambient color and coefficient
+- diffuse color and coefficient
+- specular color and coefficient
+- emission color and coefficient (available only in OCC viewer)
+- shininess
+
+With help of <b>Front material</b> and <b>Back material</b> tabs of
+<b>Set Material Properties</b> dialog it is possible to set front and
+back materials of the selected shape(s). To make <b>Back material</b>
+tab visible it is needed to check <b>Enable back material</b> check
+box. If back material is not defined, front material specified for the
+selected shape(s) is used as both front and back materials.
+
+All currently available materials are shown in the left-side list box
+of the <b>Set Material Properties</b> dialog.
+
+- <b>[Current]</b> item in the list corresponds to
+  the front/back (depending on what tab is currently active) material
+  currently used for the selected shape(s)
+- <b>[Default]</b> item in the list corresponds to the front/back material
+  specified in Geometry module preferences
+- <b>Global</b> materials are shown in blue color in the list
+- <b>User</b> materials are shown in black color in the list 
+
+
+<b>Examples:</b>
+
+\image html material_OCC.png
+<center><em>Different materials in OCC viewer</em></center>
+
+\image html material_VTK.png
+<center><em>Different materials in VTK viewer</em></center>
+
+*/
+
index 4a43a25dfc5795282958b034c984d3be4dbf4515..9ff6812596be19d1370706298300e1eef2f7a77f 100644 (file)
@@ -29,6 +29,8 @@ transparency of geometrical objects.</li>
 isolines displayed within a shape.</li>
 <li>\subpage deflection_page "Deflection" - allows to change the
 deflection coefficient of a shape.</li>
+<li>\subpage material_page "Material" - allows to change the
+material properties of a shape.</li>
 <li>\subpage point_marker_page "Point Marker" - allows to change the
 representation of geometrical vertices.</li>
 <li><b>Auto color</b> / <b>Disable auto color</b> - activates the auto color
index dc59f51f562857e3e9e864f08008ad579c3a3722..8ea7476e7c306d8510de4434e5b894856a696711 100644 (file)
@@ -43,6 +43,7 @@
     <parameter name="SettingsGeomStep"    value="10" />
     <parameter name="display_mode"        value="0"  />
     <parameter name="shading_color"       value="255, 255, 0" />
+    <parameter name="edges_in_shading_color" value="255, 255, 255" />
     <parameter name="wireframe_color"     value="255, 255, 0" />
     <parameter name="free_bound_color"    value="0, 255, 0" />
     <parameter name="line_color"          value="255, 0, 0" />
@@ -54,6 +55,8 @@
     <parameter name="base_vectors_length" value="1"  />
     <parameter name="marker_scale"        value="1"  />
     <parameter name="geom_preview"        value="false"  />
+    <parameter name="front_material"      value="Gold" />
+    <parameter name="back_material"       value="Gold" />
     <!-- Input field precisions -->
     <parameter name="def_precision"       value="3"  />
     <parameter name="length_precision"    value="6"  />
index a0d6812cec3deb7bc9e9a8687401a73e398e5e88..c7f5df89c5cafbb03f8e179a89bc97a913b66960 100644 (file)
@@ -27,6 +27,7 @@
 #include "DisplayGUI.h"
 #include <GeometryGUI.h>
 #include "GeometryGUI_Operations.h"
+#include <GEOM_Constants.h>
 #include <GEOM_Displayer.h>
 #include <GEOM_AISShape.hxx>
 #include <GEOM_Actor.h>
@@ -91,11 +92,28 @@ bool DisplayGUI::OnGUIEvent(int theCommandID, SUIT_Desktop* parent)
   SALOME_ListIO selected;
   Sel->selectedObjects( selected );
 
+  QString aDispModeName;
+  int aDispMode;
+  if ( theCommandID == GEOMOp::OpDisplayMode )
+    aDispMode = GetDisplayMode();
+
   switch ( theCommandID ) {
-  case GEOMOp::OpDisplayMode:    // MENU VIEW - DISPLAY MODE - WIREFRAME/SHADING
-    InvertDisplayMode();
-    getGeometryGUI()->action( GEOMOp::OpDisplayMode )->setText
-      ( GetDisplayMode() == 1 ? tr( "GEOM_MEN_WIREFRAME" ) : tr("GEOM_MEN_SHADING") );
+  case GEOMOp::OpDisplayMode:    // MENU VIEW - DISPLAY MODE - WIREFRAME/SHADING/SHADING WITH EDGES
+    //InvertDisplayMode();
+    switch ( aDispMode) {
+    case 0:
+      aDispModeName = tr( "GEOM_MEN_WIREFRAME" );
+      break;
+    case 1:
+      aDispModeName = tr("GEOM_MEN_SHADING");
+      break;
+    case 2:
+      aDispModeName = tr("GEOM_MEN_SHADING_WITH_EDGES");
+      break;
+    default:
+      break;
+    }
+    getGeometryGUI()->action( GEOMOp::OpDisplayMode )->setText( aDispModeName );
     getGeometryGUI()->menuMgr()->update();
     break;
   case GEOMOp::OpShowAll:        // MENU VIEW - SHOW ALL
@@ -128,11 +146,14 @@ bool DisplayGUI::OnGUIEvent(int theCommandID, SUIT_Desktop* parent)
   case GEOMOp::OpShading:        // POPUP MENU - DISPLAY MODE - SHADING
     ChangeDisplayMode( 1 );
     break;
+  case GEOMOp::OpShadingWithEdges: // POPUP MENU - DISPLAY MODE - SHADING WITH EDGES
+    ChangeDisplayMode( 2 );
+    break;
   case GEOMOp::OpTexture:        // POPUP MENU - DISPLAY MODE - TEXTURE
     ChangeDisplayMode( 3 );
     break;
-  case GEOMOp::OpVectors:        // POPUP MENU - DISPLAY MODE - SHOW EDGE DIRECTION
-    ChangeDisplayMode( 2 );
+    case GEOMOp::OpVectors:        // POPUP MENU - DISPLAY MODE - SHOW EDGE DIRECTION
+    ChangeDisplayMode( 4 );
     break;
   default:
     app->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID));
@@ -350,23 +371,42 @@ void DisplayGUI::SetDisplayMode( const int mode, SUIT_ViewWindow* viewWindow )
   else if ( viewWindow->getViewManager()->getType() == OCCViewer_Viewer::Type() ) {
     OCCViewer_Viewer* v3d = ((OCCViewer_ViewManager*)(viewWindow->getViewManager()))->getOCCViewer();
     Handle(AIS_InteractiveContext) ic = v3d->getAISContext();
-    AIS_DisplayMode newmode = (mode == 1 ? AIS_Shaded : AIS_WireFrame);
+
+    AIS_DisplayMode newmode;
+    switch (mode) {
+    case 0:
+      newmode = AIS_WireFrame;
+      break;
+    case 1:
+      newmode = AIS_Shaded;
+      break;
+    case 2:
+      newmode = AIS_DisplayMode( GEOM_AISShape::ShadingWithEdges );
+      break;
+    case 3:
+      newmode = AIS_DisplayMode( GEOM_AISShape::TexturedShape );
+      break;
+    default:
+      break;
+    }
+
     AIS_ListOfInteractive List;
     ic->DisplayedObjects( List );
     AIS_ListOfInteractive List1;
     ic->ObjectsInCollector( List1 );
     List.Append( List1 );
-
+    
     AIS_ListIteratorOfListOfInteractive ite( List );
     while( ite.More() ) {
       if( ite.Value()->IsInstance( STANDARD_TYPE(GEOM_AISShape) ) ) {
-        Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast( ite.Value() );
-        ic->SetDisplayMode( aSh, Standard_Integer( newmode ),true );
+       Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast( ite.Value() );
+       ic->SetDisplayMode( aSh, Standard_Integer( newmode ),true );
       }
       ite.Next();
     }
-
+      
     ic->SetDisplayMode( newmode, Standard_False );
+
     GeometryGUI::Modified();
   }
 }
@@ -386,9 +426,8 @@ int DisplayGUI::GetDisplayMode( SUIT_ViewWindow* viewWindow )
   } 
   else if ( viewWindow->getViewManager()->getType() == OCCViewer_Viewer::Type() ) {
     OCCViewer_Viewer* v3d = ((OCCViewer_ViewManager*)(viewWindow->getViewManager()))->getOCCViewer();
-    Handle(AIS_InteractiveContext) ic = v3d->getAISContext();
-    AIS_DisplayMode mode = (AIS_DisplayMode)ic->DisplayMode();
-    dispMode = (mode == AIS_WireFrame ? 0 : 1 );
+    Handle(AIS_InteractiveContext) ic = v3d->getAISContext();    
+    dispMode = ic->DisplayMode();
   }
   return dispMode;
 }
@@ -456,7 +495,7 @@ int DisplayGUI::GetVectorMode( SUIT_ViewWindow* viewWindow )
 
 //=====================================================================================
 // function : DisplayGUI::InvertDisplayMode()
-// purpose  : Invert display mode ( shadin <-> wireframe ) for the viewer 
+// purpose  : Invert display mode ( shading <-> wireframe ) for the viewer 
 //            (current viewer if <viewWindow> = 0 )
 //=====================================================================================
 void DisplayGUI::InvertDisplayMode( SUIT_ViewWindow* viewWindow )
@@ -503,11 +542,13 @@ void DisplayGUI::ChangeDisplayMode( const int mode, SUIT_ViewWindow* viewWindow
       SVTK_Prs* vtkPrs =
         stvkViewer ? dynamic_cast<SVTK_Prs*>( stvkViewer->CreatePrs( It.Value()->getEntry() ) ) : 0;
       if ( vtkPrs && !vtkPrs->IsNull() ) {
-        if ( mode == 0 )
+       if (mode == 0 )
           aView->ChangeRepresentationToWireframe( vtkPrs->GetObjects() );
-        else if ( mode == 1 )
+       else if ( mode == 1 )
           aView->ChangeRepresentationToSurface( vtkPrs->GetObjects() );
-        else if ( mode == 2 ) {
+       else if ( mode == 2 )
+         aView->ChangeRepresentationToSurfaceWithEdges( vtkPrs->GetObjects() );
+       else if ( mode == 4 ) {
           vtkActorCollection* anActors = vtkPrs->GetObjects();
           anActors->InitTraversal();
           while (vtkActor* anAct = anActors->GetNextActor()) {
@@ -516,12 +557,12 @@ void DisplayGUI::ChangeDisplayMode( const int mode, SUIT_ViewWindow* viewWindow
             aGeomActor->SetVectorMode(vectorMode);
           }
         }
-        if(mode == 0 || mode == 1) {
-          aStudy->setObjectProperty(mgrId,It.Value()->getEntry(),DISPLAY_MODE_PROP, mode);
-        } 
-        else if (mode == 3) {
-          aStudy->setObjectProperty(mgrId, It.Value()->getEntry(),VECTOR_MODE_PROP , vectorMode);
-        }
+       if(mode == 0 || mode == 1 || mode == 2) {
+         aStudy->setObjectProperty(mgrId,It.Value()->getEntry(),DISPLAY_MODE_PROP, mode);
+       }
+       else if (mode == 4) {
+         aStudy->setObjectProperty(mgrId, It.Value()->getEntry(),VECTOR_MODE_PROP, vectorMode);        
+       }
       }
     }
     aView->Repaint();
@@ -543,14 +584,16 @@ void DisplayGUI::ChangeDisplayMode( const int mode, SUIT_ViewWindow* viewWindow
         AIS_ListOfInteractive shapes; occPrs->GetObjects( shapes );
         AIS_ListIteratorOfListOfInteractive interIter( shapes );
         for ( ; interIter.More(); interIter.Next() ) {
-          if ( mode == 0 )
+         if ( mode == 0 )
             ic->SetDisplayMode( interIter.Value(), AIS_WireFrame, false );
-          else if ( mode == 1 )
+         else if ( mode == 1 )
             ic->SetDisplayMode( interIter.Value(), AIS_Shaded, false );
-          else if ( mode == 3 )
+         else if ( mode == 2 )
+           ic->SetDisplayMode( interIter.Value(), GEOM_AISShape::ShadingWithEdges, false );
+         else if ( mode == 3 )
             ic->SetDisplayMode( interIter.Value(), AIS_ExactHLR, false );
-          else if (mode == 2 ) {
-            Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast( interIter.Value() );
+         else if (mode == 4 ) {
+           Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast( interIter.Value() );
             if ( !aSh.IsNull() ) {
               vectorMode = !aSh->isShowVectors();      
               aSh->SetDisplayVectors(vectorMode);
@@ -558,11 +601,12 @@ void DisplayGUI::ChangeDisplayMode( const int mode, SUIT_ViewWindow* viewWindow
             }
           }
         }
-        if(mode == 0 || mode == 1) {
-          aStudy->setObjectProperty(mgrId, It.Value()->getEntry(),DISPLAY_MODE_PROP, mode);
-        } else if (mode == 2) {
-          aStudy->setObjectProperty(mgrId, It.Value()->getEntry(),VECTOR_MODE_PROP, vectorMode);
-        }
+       if(mode == 0 || mode == 1 || mode == 2 || mode == 3) {
+         aStudy->setObjectProperty(mgrId, It.Value()->getEntry(),DISPLAY_MODE_PROP, mode);
+       }
+       else if (mode == 4) {
+         aStudy->setObjectProperty(mgrId, It.Value()->getEntry(),VECTOR_MODE_PROP, vectorMode);
+       }
       }
     }
     ic->UpdateCurrentViewer();
index ef94bfc52d8b05e3507535105c18e7156e756971..ca089eb234200b03ee4dc9069f68e09ab8c2b0c5 100644 (file)
@@ -28,6 +28,8 @@
 #include "GeometryGUI.h"
 #include "GEOM_Displayer.h"
 
+#include <GEOM_Constants.h>
+
 #include <SalomeApp_Application.h>
 #include <SalomeApp_Study.h>
 
       str = QString( "Wireframe" ); \
     else if ( dm == AIS_Shaded )    \
       str = QString( "Shading" ); \
+    else if ( dm == GEOM_AISShape::ShadingWithEdges )    \
+      str = QString( "ShadingWithEdges" ); \
+    else if ( dm == GEOM_AISShape::TexturedShape )    \
+      str = QString( "Texture" ); \
     else \
       str = QString(); }
 
@@ -74,6 +80,8 @@
       str = QString( "Wireframe" ); \
     else if ( dm == 1 )    \
       str = QString( "Shading" ); \
+    else if ( dm == 3 )    \
+      str = QString( "ShadingWithEdges" ); \
     else \
       str = QString(); }
 
index ca2b6c92fd692ee49c4110058d09be298d2be490..40b98f034dc680768ed0602a3ae57b57f7d28596 100644 (file)
@@ -27,6 +27,7 @@
 
 #include "GeometryGUI.h"
 
+#include <GEOM_Constants.h>
 #include <GEOM_TypeFilter.h>
 #include <GEOM_EdgeFilter.h>
 #include <GEOM_FaceFilter.h>
@@ -41,6 +42,8 @@
 #include <GEOM_AISTrihedron.hxx>
 #include <GEOM_VTKTrihedron.hxx>
 
+#include <Material_Model.h>
+
 #include <SUIT_Desktop.h>
 #include <SUIT_ViewWindow.h>
 #include <SUIT_Session.h>
@@ -78,6 +81,7 @@
 #include <BRep_Tool.hxx>
 #include <Geom_Plane.hxx>
 #include <Geom_Axis2Placement.hxx>
+#include <Graphic3d_AspectFillArea3d.hxx>
 #include <gp_Pln.hxx>
 #include <TColStd_MapOfInteger.hxx>
 #include <TColStd_MapIteratorOfMapOfInteger.hxx>
@@ -810,6 +814,11 @@ void GEOM_Displayer::Update( SALOME_OCCPrs* prs )
             anAspect->SetColor( aColor );
             AISShape->Attributes()->SetWireAspect( anAspect );
 
+           // Set color for edges in shading
+           col = aResMgr->colorValue( "Geometry", "edges_in_shading_color", QColor( 255, 255, 0 ) );
+           aColor = SalomeApp_Tools::color( col );
+           AISShape->SetEdgesInShadingColor( aColor );
+           
             // bug [SALOME platform 0019868]
             // Set deviation angle. Default one is 12 degrees (Prs3d_Drawer.cxx:18)
             //AISShape->SetOwnDeviationAngle( 10*PI/180 );
@@ -934,6 +943,68 @@ void GEOM_Displayer::Update( SALOME_OCCPrs* prs )
             }
           }
         }
+
+       // get material properties, set material
+       Material_Model* aModelF = 0;
+       Material_Model* aModelB = 0;
+        if ( useStudy ) {
+         // Get front material property from study and construct front material model
+          QString aMaterialF = aPropMap.value(FRONT_MATERIAL_PROP).toString();
+          QStringList aProps =  aMaterialF.split(DIGIT_SEPARATOR);
+         aModelF = Material_Model::getMaterialModel( aProps );
+
+         // Get back material property from study and construct back material model
+          QString aMaterialB = aPropMap.value(BACK_MATERIAL_PROP).toString();
+         if ( !aMaterialB.isEmpty() ) {
+           QStringList aPropsB =  aMaterialB.split(DIGIT_SEPARATOR);
+           aModelB = Material_Model::getMaterialModel( aPropsB );
+         }
+         else
+           aModelB = aModelF;
+
+       } else {
+         // Get front material property from study and construct front material model
+         aModelF = new Material_Model();
+         aModelF->fromResources( aResMgr, "Geometry", true );
+         
+         // Get back material property from study and construct back material model
+         aModelB = new Material_Model();
+         aModelB->fromResources( aResMgr, "Geometry", false );   
+        }
+
+       // Set front material property
+       QString aMaterialPropF = aModelF->getMaterialProperty();
+       aStudy->setObjectProperty( aMgrId, anIO->getEntry(), FRONT_MATERIAL_PROP, aMaterialPropF );
+
+       // Set back material property
+       QString aMaterialPropB = aModelB->getMaterialProperty();
+       aStudy->setObjectProperty( aMgrId, anIO->getEntry(), BACK_MATERIAL_PROP, aMaterialPropB );
+
+       // Get front material properties from the model
+        Graphic3d_MaterialAspect aMatF = aModelF->getMaterialOCCAspect();
+
+       // Get back material properties from the model
+        Graphic3d_MaterialAspect aMatB = aModelB->getMaterialOCCAspect();
+
+       printf(">> GEOM_Displayer::Update() : SetMaterial\n");
+       // Set front material for the selected shape
+       AISShape->SetCurrentFacingModel(Aspect_TOFM_FRONT_SIDE);
+       AISShape->SetMaterial(aMatF);   
+
+       // Set back material for the selected shape
+       AISShape->SetCurrentFacingModel(Aspect_TOFM_BACK_SIDE);
+       AISShape->SetMaterial(aMatB);
+
+       // Return to the default facing mode
+       AISShape->SetCurrentFacingModel(Aspect_TOFM_BOTH_SIDE);
+
+       // Release memory
+       if ( aModelF )
+         delete aModelF;
+       if ( aModelB )
+         delete aModelB;
+
+
         // AISShape->SetName(???); ??? necessary to set name ???
         occPrs->AddObject( AISShape );
 
@@ -993,6 +1064,11 @@ void GEOM_Displayer::Update( SALOME_VTKPrs* prs )
 
   vtkActorCollection* theActors = 0;
 
+  QString anEntry;
+  if(!myIO.IsNull()) {
+    anEntry = myIO->getEntry();
+  }
+
   if ( myType == GEOM_MARKER && myShape.ShapeType() == TopAbs_FACE ) {
     //myToActivate = false; // ouv: commented to make the trihedron pickable (see IPAL18657)
     GEOM_VTKTrihedron* aTrh = GEOM_VTKTrihedron::New();
@@ -1021,10 +1097,8 @@ void GEOM_Displayer::Update( SALOME_VTKPrs* prs )
   else {
     PropMap aDefPropMap = getDefaultPropertyMap(SVTK_Viewer::Type());
 
-    QString anEntry;
     if(!myIO.IsNull()) {
       aMgrId = getViewManagerId(myViewFrame);
-      anEntry = myIO->getEntry();
     }
     useStudy = !anEntry.isEmpty() && aMgrId != -1;
 
@@ -1083,6 +1157,14 @@ void GEOM_Displayer::Update( SALOME_VTKPrs* prs )
           aGeomGActor->SetShadingProperty( aProp );
           aGeomGActor->SetWireframeProperty( aProp );
         }
+
+       // Set color for edges in shading
+       SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
+       if(aResMgr) {
+         QColor c = aResMgr->colorValue( "Geometry", "edges_in_shading_color", QColor( 255, 255, 0 ) );
+         aGeomGActor->SetEdgesInShadingColor( c.red()/255., c.green()/255., c.blue()/255. );
+       }
+
         int aIsos[2]= { 1, 1 };
         if(useStudy) {
           QString anIsos = aPropMap.value(ISOS_PROP).toString();
@@ -1091,9 +1173,61 @@ void GEOM_Displayer::Update( SALOME_VTKPrs* prs )
           aGeomGActor->SetNbIsos(aIsos);
           aGeomGActor->SetOpacity(1.0 - aPropMap.value(TRANSPARENCY_PROP).toDouble());
           aGeomGActor->SetVectorMode(aPropMap.value(VECTOR_MODE_PROP).toInt());
-          aGeomGActor->setDisplayMode(aPropMap.value(DISPLAY_MODE_PROP).toInt());
+         int aDispModeId = aPropMap.value(DISPLAY_MODE_PROP).toInt();
+         // Specially processing of 'Shading with edges' mode from preferences,
+         // because there is the following enum in VTK viewer:
+         // Points - 0, Wireframe - 1, Surface - 2, Insideframe - 3, SurfaceWithEdges - 4
+         // (see VTKViewer::Representation enum) and the following enum in GEOM_Actor:
+         // eWireframe - 0, eShading - 1, eShadingWithEdges - 3
+         if ( aDispModeId == 2 )
+           // this is 'Shading with edges' mode => do the correct mapping to EDisplayMode
+           // enum in GEOM_Actor (and further to VTKViewer::Representation enum)
+           aDispModeId++;
+          aGeomGActor->setDisplayMode(aDispModeId);
           aGeomGActor->SetDeflection(aPropMap.value(DEFLECTION_COEFF_PROP).toDouble());
 
+         // Get front material property of the object stored in the study
+         QString aMaterialF = aPropMap.value(FRONT_MATERIAL_PROP).toString();
+         QStringList aPropsF =  aMaterialF.split(DIGIT_SEPARATOR);
+         // Create front material model
+         Material_Model* aModelF = Material_Model::getMaterialModel( aPropsF );          
+         // Set front material properties for the object
+         QString aMaterialPropF = aModelF->getMaterialProperty();
+         aStudy->setObjectProperty( aMgrId, anEntry, FRONT_MATERIAL_PROP, aMaterialPropF );      
+         // Get material properties from the front model
+         vtkProperty* aMatPropF = aModelF->getMaterialVTKProperty();
+         
+         // Get back material property of the object stored in the study
+         QString aMaterialB = aPropMap.value(BACK_MATERIAL_PROP).toString();
+         if ( !aMaterialB.isEmpty() ) {
+           QStringList aPropsB =  aMaterialB.split(DIGIT_SEPARATOR);       
+           // Create back material model
+           Material_Model* aModelB = Material_Model::getMaterialModel( aPropsB );
+           // Set back material properties for the object
+           QString aMaterialPropB = aModelB->getMaterialProperty();
+           aStudy->setObjectProperty( aMgrId, anEntry, BACK_MATERIAL_PROP, aMaterialPropB );
+           // Get material properties from the back model
+           vtkProperty* aMatPropB = aModelB->getMaterialVTKProperty();
+
+           // Set front and back materials for the selected shape
+           std::vector<vtkProperty*> aProps;
+           aProps.push_back(aMatPropF);
+           aProps.push_back(aMatPropB);
+           aGeomGActor->SetMaterial(aProps);
+
+           // Release memory
+           delete aModelB;
+         }
+         else {
+           // Set the same front and back materials for the selected shape
+           std::vector<vtkProperty*> aProps;
+           aProps.push_back(aMatPropF);
+           aGeomGActor->SetMaterial(aProps);
+         }
+
+         // Release memory
+         delete aModelF;
+
           vtkFloatingPointType aColor[3] = {1.,0.,0.};
           if(aPropMap.contains(COLOR_PROP)) {
             QColor c = aPropMap.value(COLOR_PROP).value<QColor>();
@@ -1126,6 +1260,36 @@ void GEOM_Displayer::Update( SALOME_VTKPrs* prs )
           }
           aGeomGActor->SetColor(aColor[0],aColor[1],aColor[2]);
         }
+       else {
+         SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
+         if ( aResMgr ) {
+           // Create front material model
+           Material_Model aModelF;
+           // Get front material name from resources
+           aModelF.fromResources( aResMgr, "Geometry", true );
+           // Set front material properties for the object
+           QString aMaterialPropF = aModelF.getMaterialProperty();
+           aStudy->setObjectProperty( aMgrId, anEntry, FRONT_MATERIAL_PROP, aMaterialPropF );      
+           // Get material properties from the front model
+           vtkProperty* aMatPropF = aModelF.getMaterialVTKProperty();
+
+           // Create back material model
+           Material_Model aModelB;
+           // Get back material name from resources
+           aModelB.fromResources( aResMgr, "Geometry", false );
+           // Set back material properties for the object
+           QString aMaterialPropB = aModelB.getMaterialProperty();
+           aStudy->setObjectProperty( aMgrId, anEntry, BACK_MATERIAL_PROP, aMaterialPropB );
+           // Get material properties from the back model
+           vtkProperty* aMatPropB = aModelB.getMaterialVTKProperty();
+
+           // Set material for the selected shape
+           std::vector<vtkProperty*> aProps;
+           aProps.push_back(aMatPropF);
+           aProps.push_back(aMatPropB);
+           aGeomGActor->SetMaterial(aProps);
+         }
+       }
       }
 
     if ( myToActivate )
@@ -1791,6 +1955,19 @@ PropMap GEOM_Displayer::getDefaultPropertyMap(const QString& viewer_type) {
 
   aDefaultMap.insert( DEFLECTION_COEFF_PROP , aDC);
 
+  //8. Material
+  //   Front material
+  Material_Model aModelF;
+  aModelF.fromResources( aResMgr, "Geometry", true );
+  QString aMaterialF = aModelF.getMaterialProperty();
+  aDefaultMap.insert( FRONT_MATERIAL_PROP , aMaterialF );  
+
+  //  Back material
+  Material_Model aModelB;
+  aModelB.fromResources( aResMgr, "Geometry", false );
+  QString aMaterialB = aModelB.getMaterialProperty();
+  aDefaultMap.insert( BACK_MATERIAL_PROP , aMaterialB );
+
   return aDefaultMap;
 }
 
@@ -1820,6 +1997,14 @@ bool GEOM_Displayer::MergePropertyMaps(PropMap& theOrigin, PropMap& theDefault)
     theOrigin.insert(DEFLECTION_COEFF_PROP, theDefault.value(DEFLECTION_COEFF_PROP));
     nbInserted++;
   }
+  if(!theOrigin.contains(FRONT_MATERIAL_PROP)) {
+    theOrigin.insert(FRONT_MATERIAL_PROP, theDefault.value(FRONT_MATERIAL_PROP));
+    nbInserted++;
+  }
+  if(!theOrigin.contains(BACK_MATERIAL_PROP)) {
+    theOrigin.insert(BACK_MATERIAL_PROP, theDefault.value(BACK_MATERIAL_PROP));
+    nbInserted++;
+  }
   return (nbInserted > 0);
 }
 
index 09fa417d3a0f30c65a9f5b0a83e989e384168191..da7b2e0f8ac06d30bb7da91620b2fdae1b35083e 100644 (file)
@@ -945,6 +945,10 @@ Please, select face, shell or solid and try again</translation>
         <source>GEOM_MEN_SHADING</source>
         <translation>Shading</translation>
     </message>
+    <message>
+        <source>GEOM_MEN_SHADING_WITH_EDGES</source>
+        <translation>Shading With Edges</translation>
+    </message>
     <message>
         <source>GEOM_MEN_SKETCHER_X</source>
         <translation>Enter a Length to Set X</translation>
@@ -2561,6 +2565,10 @@ Please, select face, shell or solid and try again</translation>
         <source>MEN_POP_SHADING</source>
         <translation>Shading</translation>
     </message>
+    <message>
+        <source>MEN_POP_SHADING_WITH_EDGES</source>
+        <translation>Shading With Edges</translation>
+    </message>
     <message>
         <source>MEN_POP_TEXTURE</source>
         <translation>Texture</translation>
@@ -2637,6 +2645,10 @@ Please, select face, shell or solid and try again</translation>
         <source>MEN_SHADING</source>
         <translation>Shading</translation>
     </message>
+    <message>
+        <source>MEN_SHADING_WITH_EDGES</source>
+        <translation>Shading With Edges</translation>
+    </message>
     <message>
         <source>MEN_SHADING_COLOR</source>
         <translation>Shading Color</translation>
@@ -2753,6 +2765,10 @@ Please, select face, shell or solid and try again</translation>
         <source>MEN_POP_POINT_MARKER</source>
         <translation>Point Marker</translation>
     </message>
+    <message>
+        <source>MEN_POP_MATERIAL_PROPERTIES</source>
+        <translation>Material Properties</translation>
+    </message>
     <message>
         <source>NAME_LBL</source>
         <translation>Name: </translation>
@@ -2857,6 +2873,10 @@ Please, select face, shell or solid and try again</translation>
         <source>PREF_SHADING_COLOR</source>
         <translation>Default shading color</translation>
     </message>
+    <message>
+        <source>PREF_EDGES_IN_SHADING</source>
+        <translation>Edges in shading</translation>
+    </message>
     <message>
         <source>PREF_STEP_VALUE</source>
         <translation>Step value for spin boxes</translation>
@@ -2877,6 +2897,14 @@ Please, select face, shell or solid and try again</translation>
         <source>PREF_WIREFRAME_COLOR</source>
         <translation>Default wireframe color</translation>
     </message>
+    <message>
+        <source>PREF_FRONT_MATERIAL</source>
+        <translation>Default front material</translation>
+    </message>
+    <message>
+        <source>PREF_BACK_MATERIAL</source>
+        <translation>Default back material</translation>
+    </message>
     <message>
         <source>PROCESS_SHAPE_NEW_OBJ_NAME</source>
         <translation>ProcessShape</translation>
@@ -3229,6 +3257,10 @@ Please, select face, shell or solid and try again</translation>
         <source>STB_POP_SHADING</source>
         <translation>Shading</translation>
     </message>
+    <message>
+        <source>STB_POP_SHADING_WITH_EDGES</source>
+        <translation>Shading With Edges</translation>
+    </message>
     <message>
         <source>STB_POP_SETTEXTURE</source>
         <translation>Add a texture</translation>
@@ -3369,6 +3401,10 @@ Please, select face, shell or solid and try again</translation>
         <source>STB_POP_POINT_MARKER</source>
         <translation>Set Point Marker</translation>
     </message>
+    <message>
+        <source>STB_POP_MATERIAL_PROPERTIES</source>
+        <translation>Set Material Properties</translation>
+    </message>
     <message>
         <source>SUPPRESS_RESULT</source>
         <translation>Suppress Result</translation>
@@ -3781,6 +3817,10 @@ Please, select face, shell or solid and try again</translation>
         <source>TOP_POP_SHADING</source>
         <translation>Shading</translation>
     </message>
+    <message>
+        <source>TOP_POP_SHADING_WITH_EDGES</source>
+        <translation>Shading With Edges</translation>
+    </message>
     <message>
         <source>TOP_POP_SETTEXTURE</source>
         <translation>Texture</translation>
@@ -3901,6 +3941,10 @@ Please, select face, shell or solid and try again</translation>
         <source>TOP_POP_POINT_MARKER</source>
         <translation>Point Marker</translation>
     </message>
+    <message>
+        <source>TOP_POP_MATERIAL_PROPERTIES</source>
+        <translation>Material Properties</translation>
+    </message>
     <message>
         <source>WRN_NOT_IMPLEMENTED</source>
         <translation>Sorry, this functionality is not yet implemented</translation>
@@ -5005,6 +5049,61 @@ Would you like to continue?</translation>
         <translation>Load Texture</translation>
     </message>
 </context>
+<context>
+    <name>GEOMToolsGUI_MaterialPropertiesDlg</name>
+    <message>
+        <source>MATERIAL_PROPERTIES_TLT</source>
+        <translation>Set Material Properties</translation>
+    </message>
+    <message>
+        <source>MATERIAL_BACK_CHK</source>
+        <translation>Enable back material</translation>
+    </message>
+    <message>
+        <source>AMBIENT_GRP</source>
+        <translation>Ambient</translation>
+    </message>
+    <message>
+        <source>DIFFUSE_GRP</source>
+        <translation>Diffuse</translation>
+    </message>
+    <message>
+        <source>SPECULAR_GRP</source>
+        <translation>Specular</translation>
+    </message>
+    <message>
+        <source>EMISSION_GRP</source>
+        <translation>Emission</translation>
+    </message>
+    <message>
+        <source>COLOR</source>
+        <translation>Color:</translation>
+    </message>
+    <message>
+        <source>COEFFICIENT</source>
+        <translation>Coefficient:</translation>
+    </message>
+    <message>
+        <source>SHININESS</source>
+        <translation>Shininess:</translation>
+    </message>
+    <message>
+        <source>CUSTOM_MATERIAL</source>
+        <translation>Custom material</translation>
+    </message>
+    <message>
+        <source>OK_BTN</source>
+        <translation>&amp;OK</translation>
+    </message>
+    <message>
+        <source>CANCEL_BTN</source>
+        <translation>&amp;Cancel</translation>
+    </message>
+    <message>
+        <source>HELP_BTN</source>
+        <translation>&amp;Help</translation>
+    </message>
+</context>
 <context>
     <name>OperationGUI_GetSharedShapesDlg</name>
     <message>
index b5ee36ed4d35ec1f333a6bc7c79a6e1dd7347347..e037eb54ec1d35a359e947784afd4d2ec44b52f9 100644 (file)
@@ -945,6 +945,10 @@ Choisissez une face, une coque ou un solide et essayez de nouveau</translation>
         <source>GEOM_MEN_SHADING</source>
         <translation>Ombrage</translation>
     </message>
+    <message>
+        <source>GEOM_MEN_SHADING_WITH_EDGES</source>
+        <translation>Ombrage Avec Arêtes</translation>
+    </message>
     <message>
         <source>GEOM_MEN_SKETCHER_X</source>
         <translation>Indiquez la distance selon l&apos;axe X</translation>
@@ -2561,6 +2565,10 @@ Choisissez une face, une coque ou un solide et essayez de nouveau</translation>
         <source>MEN_POP_SHADING</source>
         <translation>Ombrage</translation>
     </message>
+    <message>
+        <source>MEN_POP_SHADING_WITH_EDGES</source>
+        <translation>Ombrage Avec Arêtes</translation>
+    </message>
     <message>
         <source>MEN_POP_TEXTURE</source>
         <translation>Texture</translation>
@@ -2637,6 +2645,10 @@ Choisissez une face, une coque ou un solide et essayez de nouveau</translation>
         <source>MEN_SHADING</source>
         <translation>Ombrage</translation>
     </message>
+    <message>
+        <source>MEN_SHADING_WITH_EDGES</source>
+        <translation>Ombrage Avec Arêtes</translation>
+    </message>
     <message>
         <source>MEN_SHADING_COLOR</source>
         <translation>Couleur d&apos;ombrage</translation>
@@ -2753,6 +2765,10 @@ Choisissez une face, une coque ou un solide et essayez de nouveau</translation>
         <source>MEN_POP_POINT_MARKER</source>
         <translation>Marqueur de point</translation>
     </message>
+    <message>
+        <source>MEN_POP_MATERIAL_PROPERTIES</source>
+        <translation>Propriétés des matériaux</translation>
+    </message>
     <message>
         <source>NAME_LBL</source>
         <translation>Nom : </translation>
@@ -2857,6 +2873,10 @@ Choisissez une face, une coque ou un solide et essayez de nouveau</translation>
         <source>PREF_SHADING_COLOR</source>
         <translation>Couleur d&apos;ombrage par défaut</translation>
     </message>
+    <message>
+        <source>PREF_EDGES_IN_SHADING</source>
+        <translation>Bords de l&apos;ombrage</translation>
+    </message>
     <message>
         <source>PREF_STEP_VALUE</source>
         <translation>Valeur du pas pour les boîtes d&apos;incrément</translation>
@@ -2877,6 +2897,14 @@ Choisissez une face, une coque ou un solide et essayez de nouveau</translation>
         <source>PREF_WIREFRAME_COLOR</source>
         <translation>Couleur des contours par défaut</translation>
     </message>
+    <message>
+        <source>PREF_FRONT_MATERIAL</source>
+        <translation>Devant du matériel par défaut</translation>
+    </message>
+    <message>
+        <source>PREF_BACK_MATERIAL</source>
+        <translation>Retour du matériel par défaut</translation>
+    </message>
     <message>
         <source>PROCESS_SHAPE_NEW_OBJ_NAME</source>
         <translation>FormeRetraitée</translation>
@@ -3229,6 +3257,10 @@ Choisissez une face, une coque ou un solide et essayez de nouveau</translation>
         <source>STB_POP_SHADING</source>
         <translation>Ombrage</translation>
     </message>
+    <message>
+        <source>STB_POP_SHADING_WITH_EDGES</source>
+        <translation>Ombrage Avec Arêtes</translation>
+    </message>
     <message>
         <source>STB_POP_SETTEXTURE</source>
         <translation>Ajoute une texture</translation>
@@ -3369,6 +3401,10 @@ Choisissez une face, une coque ou un solide et essayez de nouveau</translation>
         <source>STB_POP_POINT_MARKER</source>
         <translation>Définir un marqueur de point</translation>
     </message>
+    <message>
+        <source>STB_POP_MATERIAL_PROPERTIES</source>
+        <translation>Définir un propriétés des matériaux</translation>
+    </message>
     <message>
         <source>SUPPRESS_RESULT</source>
         <translation>Supprimer le résultat</translation>
@@ -3781,6 +3817,10 @@ Choisissez une face, une coque ou un solide et essayez de nouveau</translation>
         <source>TOP_POP_SHADING</source>
         <translation>Ombrage</translation>
     </message>
+    <message>
+        <source>TOP_POP_SHADING_WITH_EDGES</source>
+        <translation>Ombrage Avec Arêtes</translation>
+    </message>
     <message>
         <source>TOP_POP_SETTEXTURE</source>
         <translation>Texture</translation>
@@ -3901,6 +3941,10 @@ Choisissez une face, une coque ou un solide et essayez de nouveau</translation>
         <source>TOP_POP_POINT_MARKER</source>
         <translation>Marqueur de point</translation>
     </message>
+    <message>
+        <source>TOP_POP_MATERIAL_PROPERTIES</source>
+        <translation>Propriétés des matériaux</translation>
+    </message>
     <message>
         <source>WRN_NOT_IMPLEMENTED</source>
         <translation>Désolé, cette fonctionnalité n&apos;est pas encore implémentée</translation>
@@ -5005,6 +5049,61 @@ Voulez-vous continuer?</translation>
         <translation>Ouvrir une Texture</translation>
     </message>
 </context>
+<context>
+    <name>GEOMToolsGUI_MaterialPropertiesDlg</name>
+    <message>
+        <source>MATERIAL_PROPERTIES_TLT</source>
+        <translation>Définir un Propriétés des Matériaux</translation>
+    </message>
+    <message>
+        <source>MATERIAL_BACK_CHK</source>
+        <translation>Activer retour du matériel</translation>
+    </message>
+    <message>
+        <source>AMBIENT_GRP</source>
+        <translation>Ambiante</translation>
+    </message>
+    <message>
+        <source>DIFFUSE_GRP</source>
+        <translation>Diffuse</translation>
+    </message>
+    <message>
+        <source>SPECULAR_GRP</source>
+        <translation>Spéculaire</translation>
+    </message>
+    <message>
+        <source>EMISSION_GRP</source>
+        <translation>Démission</translation>
+    </message>
+    <message>
+        <source>COLOR</source>
+        <translation>Couleurs:</translation>
+    </message>
+    <message>
+        <source>COEFFICIENT</source>
+        <translation>Coefficient:</translation>
+    </message>
+    <message>
+        <source>SHININESS</source>
+        <translation>Shininess:</translation>
+    </message>
+    <message>
+        <source>CUSTOM_MATERIAL</source>
+        <translation>Matériau personnalisé</translation>
+    </message>
+    <message>
+        <source>OK_BTN</source>
+        <translation>&amp;OK</translation>
+    </message>
+    <message>
+        <source>CANCEL_BTN</source>
+        <translation>A&amp;nnuler</translation>
+    </message>
+    <message>
+        <source>HELP_BTN</source>
+        <translation>&amp;Aide</translation>
+    </message>
+</context>
 <context>
     <name>OperationGUI_GetSharedShapesDlg</name>
     <message>
index 60d7734729112d6dfefa044eb743b3bad648350b..cfa64c465b159ca7c398e3d49ce740cbf07a393d 100644 (file)
 #include "GeometryGUI_Operations.h"
 #include "GEOMGUI_OCCSelector.h"
 #include "GEOMGUI_Selection.h"
+#include "GEOM_Constants.h"
 #include "GEOM_Displayer.h"
 #include "GEOM_AISShape.hxx"
 
 #include "GEOM_Actor.h"
 
+#include <Material_ResourceMgr.h>
+
 #include <SUIT_Desktop.h>
 #include <SUIT_MessageBox.h>
 #include <SUIT_ResourceMgr.h>
@@ -389,169 +392,171 @@ void GeometryGUI::OnGUIEvent( int id )
   QString libName;
   // find corresponding GUI library
   switch ( id ) {
-  case GEOMOp::OpOriginAndVectors: // MENU BASIC - ORIGIN AND BASE VECTORS
+  case GEOMOp::OpOriginAndVectors:   // MENU BASIC - ORIGIN AND BASE VECTORS
     createOriginAndBaseVectors(); // internal operation
     return;
-  case GEOMOp::OpImport:           // MENU FILE - IMPORT
-  case GEOMOp::OpExport:           // MENU FILE - EXPORT
-  case GEOMOp::OpSelectVertex:     // POPUP MENU - SELECT ONLY - VERTEX
-  case GEOMOp::OpSelectEdge:       // POPUP MENU - SELECT ONLY - EDGE
-  case GEOMOp::OpSelectWire:       // POPUP MENU - SELECT ONLY - WIRE
-  case GEOMOp::OpSelectFace:       // POPUP MENU - SELECT ONLY - FACE
-  case GEOMOp::OpSelectShell:      // POPUP MENU - SELECT ONLY - SHELL
-  case GEOMOp::OpSelectSolid:      // POPUP MENU - SELECT ONLY - SOLID
-  case GEOMOp::OpSelectCompound:   // POPUP MENU - SELECT ONLY - COMPOUND
-  case GEOMOp::OpSelectAll:        // POPUP MENU - SELECT ONLY - SELECT ALL
-  case GEOMOp::OpDelete:           // MENU EDIT - DELETE
-  case GEOMOp::OpCheckGeom:        // MENU TOOLS - CHECK GEOMETRY
-  case GEOMOp::OpDeflection:       // POPUP MENU - DEFLECTION COEFFICIENT
-  case GEOMOp::OpColor:            // POPUP MENU - COLOR
-  case GEOMOp::OpSetTexture:       // POPUP MENU - SETTEXTURE
-  case GEOMOp::OpTransparency:     // POPUP MENU - TRANSPARENCY
-  case GEOMOp::OpIncrTransparency: // SHORTCUT   - INCREASE TRANSPARENCY
-  case GEOMOp::OpDecrTransparency: // SHORTCUT   - DECREASE TRANSPARENCY
-  case GEOMOp::OpIsos:             // POPUP MENU - ISOS
-  case GEOMOp::OpIncrNbIsos:       // SHORTCUT   - INCREASE NB ISOS
-  case GEOMOp::OpDecrNbIsos:       // SHORTCUT   - DECREASE NB ISOS
-  case GEOMOp::OpAutoColor:        // POPUP MENU - AUTO COLOR
-  case GEOMOp::OpNoAutoColor:      // POPUP MENU - DISABLE AUTO COLOR
-  case GEOMOp::OpShowChildren:     // POPUP MENU - SHOW CHILDREN
-  case GEOMOp::OpHideChildren:     // POPUP MENU - HIDE CHILDREN
-  case GEOMOp::OpUnpublishObject:  // POPUP MENU - UNPUBLISH
-  case GEOMOp::OpPublishObject:    // ROOT GEOM OBJECT - POPUP MENU - PUBLISH
-  case GEOMOp::OpPointMarker:      // POPUP MENU - POINT MARKER
+  case GEOMOp::OpImport:             // MENU FILE - IMPORT
+  case GEOMOp::OpExport:             // MENU FILE - EXPORT
+  case GEOMOp::OpSelectVertex:       // POPUP MENU - SELECT ONLY - VERTEX
+  case GEOMOp::OpSelectEdge:         // POPUP MENU - SELECT ONLY - EDGE
+  case GEOMOp::OpSelectWire:         // POPUP MENU - SELECT ONLY - WIRE
+  case GEOMOp::OpSelectFace:         // POPUP MENU - SELECT ONLY - FACE
+  case GEOMOp::OpSelectShell:        // POPUP MENU - SELECT ONLY - SHELL
+  case GEOMOp::OpSelectSolid:        // POPUP MENU - SELECT ONLY - SOLID
+  case GEOMOp::OpSelectCompound:     // POPUP MENU - SELECT ONLY - COMPOUND
+  case GEOMOp::OpSelectAll:          // POPUP MENU - SELECT ONLY - SELECT ALL
+  case GEOMOp::OpDelete:             // MENU EDIT - DELETE
+  case GEOMOp::OpCheckGeom:          // MENU TOOLS - CHECK GEOMETRY
+  case GEOMOp::OpDeflection:         // POPUP MENU - DEFLECTION COEFFICIENT
+  case GEOMOp::OpColor:              // POPUP MENU - COLOR
+  case GEOMOp::OpSetTexture:         // POPUP MENU - SETTEXTURE
+  case GEOMOp::OpTransparency:       // POPUP MENU - TRANSPARENCY
+  case GEOMOp::OpIncrTransparency:   // SHORTCUT   - INCREASE TRANSPARENCY
+  case GEOMOp::OpDecrTransparency:   // SHORTCUT   - DECREASE TRANSPARENCY
+  case GEOMOp::OpIsos:               // POPUP MENU - ISOS
+  case GEOMOp::OpIncrNbIsos:         // SHORTCUT   - INCREASE NB ISOS
+  case GEOMOp::OpDecrNbIsos:         // SHORTCUT   - DECREASE NB ISOS
+  case GEOMOp::OpAutoColor:          // POPUP MENU - AUTO COLOR
+  case GEOMOp::OpNoAutoColor:        // POPUP MENU - DISABLE AUTO COLOR
+  case GEOMOp::OpShowChildren:       // POPUP MENU - SHOW CHILDREN
+  case GEOMOp::OpHideChildren:       // POPUP MENU - HIDE CHILDREN
+  case GEOMOp::OpUnpublishObject:    // POPUP MENU - UNPUBLISH
+  case GEOMOp::OpPublishObject:      // ROOT GEOM OBJECT - POPUP MENU - PUBLISH
+  case GEOMOp::OpPointMarker:        // POPUP MENU - POINT MARKER
+  case GEOMOp::OpMaterialProperties: // POPUP MENU - MATERIAL PROPERTIES
     libName = "GEOMToolsGUI";
     break;
-  case GEOMOp::OpDisplayMode:      // MENU VIEW - WIREFRAME/SHADING
-  case GEOMOp::OpShowAll:          // MENU VIEW - SHOW ALL
-  case GEOMOp::OpShowOnly:         // MENU VIEW - DISPLAY ONLY
-  case GEOMOp::OpHideAll:          // MENU VIEW - ERASE ALL
-  case GEOMOp::OpHide:             // MENU VIEW - ERASE
-  case GEOMOp::OpShow:             // MENU VIEW - DISPLAY
-  case GEOMOp::OpSwitchVectors:    // MENU VIEW - VECTOR MODE
-  case GEOMOp::OpWireframe:        // POPUP MENU - WIREFRAME
-  case GEOMOp::OpShading:          // POPUP MENU - SHADING
-  case GEOMOp::OpTexture:          // POPUP MENU - TEXTURE
-  case GEOMOp::OpVectors:          // POPUP MENU - VECTORS
+  case GEOMOp::OpDisplayMode:        // MENU VIEW - WIREFRAME/SHADING
+  case GEOMOp::OpShowAll:            // MENU VIEW - SHOW ALL
+  case GEOMOp::OpShowOnly:           // MENU VIEW - DISPLAY ONLY
+  case GEOMOp::OpHideAll:            // MENU VIEW - ERASE ALL
+  case GEOMOp::OpHide:               // MENU VIEW - ERASE
+  case GEOMOp::OpShow:               // MENU VIEW - DISPLAY
+  case GEOMOp::OpSwitchVectors:      // MENU VIEW - VECTOR MODE
+  case GEOMOp::OpWireframe:          // POPUP MENU - WIREFRAME
+  case GEOMOp::OpShading:            // POPUP MENU - SHADING
+  case GEOMOp::OpShadingWithEdges:   // POPUP MENU - SHADING WITH EDGES
+  case GEOMOp::OpTexture:            // POPUP MENU - TEXTURE
+  case GEOMOp::OpVectors:            // POPUP MENU - VECTORS
     libName = "DisplayGUI";
     break;
-  case GEOMOp::OpPoint:            // MENU BASIC - POINT
-  case GEOMOp::OpLine:             // MENU BASIC - LINE
-  case GEOMOp::OpCircle:           // MENU BASIC - CIRCLE
-  case GEOMOp::OpEllipse:          // MENU BASIC - ELLIPSE
-  case GEOMOp::OpArc:              // MENU BASIC - ARC
-  case GEOMOp::OpVector:           // MENU BASIC - VECTOR
-  case GEOMOp::OpPlane:            // MENU BASIC - PLANE
-  case GEOMOp::OpCurve:            // MENU BASIC - CURVE
-  case GEOMOp::OpLCS:              // MENU BASIC - LOCAL COORDINATE SYSTEM
+  case GEOMOp::OpPoint:              // MENU BASIC - POINT
+  case GEOMOp::OpLine:               // MENU BASIC - LINE
+  case GEOMOp::OpCircle:             // MENU BASIC - CIRCLE
+  case GEOMOp::OpEllipse:            // MENU BASIC - ELLIPSE
+  case GEOMOp::OpArc:                // MENU BASIC - ARC
+  case GEOMOp::OpVector:             // MENU BASIC - VECTOR
+  case GEOMOp::OpPlane:              // MENU BASIC - PLANE
+  case GEOMOp::OpCurve:              // MENU BASIC - CURVE
+  case GEOMOp::OpLCS:                // MENU BASIC - LOCAL COORDINATE SYSTEM
     libName = "BasicGUI";
     break;
-  case GEOMOp::OpBox:              // MENU PRIMITIVE - BOX
-  case GEOMOp::OpCylinder:         // MENU PRIMITIVE - CYLINDER
-  case GEOMOp::OpSphere:           // MENU PRIMITIVE - SPHERE
-  case GEOMOp::OpTorus:            // MENU PRIMITIVE - TORUS
-  case GEOMOp::OpCone:             // MENU PRIMITIVE - CONE
-  case GEOMOp::OpRectangle:        // MENU PRIMITIVE - FACE
-  case GEOMOp::OpDisk:             // MENU PRIMITIVE - DISK
+  case GEOMOp::OpBox:                // MENU PRIMITIVE - BOX
+  case GEOMOp::OpCylinder:           // MENU PRIMITIVE - CYLINDER
+  case GEOMOp::OpSphere:             // MENU PRIMITIVE - SPHERE
+  case GEOMOp::OpTorus:              // MENU PRIMITIVE - TORUS
+  case GEOMOp::OpCone:               // MENU PRIMITIVE - CONE
+  case GEOMOp::OpRectangle:          // MENU PRIMITIVE - FACE
+  case GEOMOp::OpDisk:               // MENU PRIMITIVE - DISK
     libName = "PrimitiveGUI";
     break;
-  case GEOMOp::OpPrism:            // MENU GENERATION - PRISM
-  case GEOMOp::OpRevolution:       // MENU GENERATION - REVOLUTION
-  case GEOMOp::OpFilling:          // MENU GENERATION - FILLING
-  case GEOMOp::OpPipe:             // MENU GENERATION - PIPE
+  case GEOMOp::OpPrism:              // MENU GENERATION - PRISM
+  case GEOMOp::OpRevolution:         // MENU GENERATION - REVOLUTION
+  case GEOMOp::OpFilling:            // MENU GENERATION - FILLING
+  case GEOMOp::OpPipe:               // MENU GENERATION - PIPE
     libName = "GenerationGUI";
     break;
-  case GEOMOp::Op2dSketcher:       // MENU ENTITY - SKETCHER
-  case GEOMOp::Op3dSketcher:       // MENU ENTITY - 3D SKETCHER
-  case GEOMOp::OpExplode:          // MENU ENTITY - EXPLODE
+  case GEOMOp::Op2dSketcher:         // MENU ENTITY - SKETCHER
+  case GEOMOp::Op3dSketcher:         // MENU ENTITY - 3D SKETCHER
+  case GEOMOp::OpExplode:            // MENU ENTITY - EXPLODE
 #ifdef WITH_OPENCV
-  case GEOMOp::OpFeatureDetect:    // MENU ENTITY - FEATURE DETECTION
+  case GEOMOp::OpFeatureDetect:      // MENU ENTITY - FEATURE DETECTION
 #endif
-  case GEOMOp::OpPictureImport:    // MENU ENTITY - IMPORT PICTURE IN VIEWER
+  case GEOMOp::OpPictureImport:      // MENU ENTITY - IMPORT PICTURE IN VIEWER
     libName = "EntityGUI";
     break;
-  case GEOMOp::OpEdge:             // MENU BUILD - EDGE
-  case GEOMOp::OpWire:             // MENU BUILD - WIRE
-  case GEOMOp::OpFace:             // MENU BUILD - FACE
-  case GEOMOp::OpShell:            // MENU BUILD - SHELL
-  case GEOMOp::OpSolid:            // MENU BUILD - SOLID
-  case GEOMOp::OpCompound:         // MENU BUILD - COMPUND
+  case GEOMOp::OpEdge:               // MENU BUILD - EDGE
+  case GEOMOp::OpWire:               // MENU BUILD - WIRE
+  case GEOMOp::OpFace:               // MENU BUILD - FACE
+  case GEOMOp::OpShell:              // MENU BUILD - SHELL
+  case GEOMOp::OpSolid:              // MENU BUILD - SOLID
+  case GEOMOp::OpCompound:           // MENU BUILD - COMPUND
     libName = "BuildGUI";
     break;
-  case GEOMOp::OpFuse:             // MENU BOOLEAN - FUSE
-  case GEOMOp::OpCommon:           // MENU BOOLEAN - COMMON
-  case GEOMOp::OpCut:              // MENU BOOLEAN - CUT
-  case GEOMOp::OpSection:          // MENU BOOLEAN - SECTION
+  case GEOMOp::OpFuse:               // MENU BOOLEAN - FUSE
+  case GEOMOp::OpCommon:             // MENU BOOLEAN - COMMON
+  case GEOMOp::OpCut:                // MENU BOOLEAN - CUT
+  case GEOMOp::OpSection:            // MENU BOOLEAN - SECTION
     libName = "BooleanGUI";
     break;
-  case GEOMOp::OpTranslate:        // MENU TRANSFORMATION - TRANSLATION
-  case GEOMOp::OpRotate:           // MENU TRANSFORMATION - ROTATION
-  case GEOMOp::OpChangeLoc:        // MENU TRANSFORMATION - LOCATION
-  case GEOMOp::OpMirror:           // MENU TRANSFORMATION - MIRROR
-  case GEOMOp::OpScale:            // MENU TRANSFORMATION - SCALE
-  case GEOMOp::OpOffset:           // MENU TRANSFORMATION - OFFSET
-  case GEOMOp::OpProjection:       // MENU TRANSFORMATION - PROJECTION
-  case GEOMOp::OpMultiTranslate:   // MENU TRANSFORMATION - MULTI-TRANSLATION
-  case GEOMOp::OpMultiRotate:      // MENU TRANSFORMATION - MULTI-ROTATION
-  case GEOMOp::OpReimport:         // CONTEXT(POPUP) MENU - RELOAD_IMPORTED
+  case GEOMOp::OpTranslate:          // MENU TRANSFORMATION - TRANSLATION
+  case GEOMOp::OpRotate:             // MENU TRANSFORMATION - ROTATION
+  case GEOMOp::OpChangeLoc:          // MENU TRANSFORMATION - LOCATION
+  case GEOMOp::OpMirror:             // MENU TRANSFORMATION - MIRROR
+  case GEOMOp::OpScale:              // MENU TRANSFORMATION - SCALE
+  case GEOMOp::OpOffset:             // MENU TRANSFORMATION - OFFSET
+  case GEOMOp::OpProjection:         // MENU TRANSFORMATION - PROJECTION
+  case GEOMOp::OpMultiTranslate:     // MENU TRANSFORMATION - MULTI-TRANSLATION
+  case GEOMOp::OpMultiRotate:        // MENU TRANSFORMATION - MULTI-ROTATION
+  case GEOMOp::OpReimport:           // CONTEXT(POPUP) MENU - RELOAD_IMPORTED
     libName = "TransformationGUI";
     break;
-  case GEOMOp::OpPartition:        // MENU OPERATION - PARTITION
-  case GEOMOp::OpArchimede:        // MENU OPERATION - ARCHIMEDE
-  case GEOMOp::OpFillet3d:         // MENU OPERATION - FILLET
-  case GEOMOp::OpChamfer:          // MENU OPERATION - CHAMFER
-  case GEOMOp::OpClipping:         // MENU OPERATION - CLIPPING RANGE
-  case GEOMOp::OpShapesOnShape:    // MENU OPERATION - GET SHAPES ON SHAPE
-  case GEOMOp::OpFillet2d:         // MENU OPERATION - FILLET 2D
-  case GEOMOp::OpFillet1d:         // MENU OPERATION - FILLET 1D
-  case GEOMOp::OpSharedShapes:     // MENU OPERATION - GET SHARED SHAPES
+  case GEOMOp::OpPartition:          // MENU OPERATION - PARTITION
+  case GEOMOp::OpArchimede:          // MENU OPERATION - ARCHIMEDE
+  case GEOMOp::OpFillet3d:           // MENU OPERATION - FILLET
+  case GEOMOp::OpChamfer:            // MENU OPERATION - CHAMFER
+  case GEOMOp::OpClipping:           // MENU OPERATION - CLIPPING RANGE
+  case GEOMOp::OpShapesOnShape:      // MENU OPERATION - GET SHAPES ON SHAPE
+  case GEOMOp::OpFillet2d:           // MENU OPERATION - FILLET 2D
+  case GEOMOp::OpFillet1d:           // MENU OPERATION - FILLET 1D
+  case GEOMOp::OpSharedShapes:       // MENU OPERATION - GET SHARED SHAPES
     libName = "OperationGUI";
     break;
-  case GEOMOp::OpSewing:           // MENU REPAIR - SEWING
-  case GEOMOp::OpSuppressFaces:    // MENU REPAIR - SUPPRESS FACES
-  case GEOMOp::OpSuppressHoles:    // MENU REPAIR - SUPPRESS HOLE
-  case GEOMOp::OpShapeProcess:     // MENU REPAIR - SHAPE PROCESSING
-  case GEOMOp::OpCloseContour:     // MENU REPAIR - CLOSE CONTOUR
-  case GEOMOp::OpRemoveIntWires:   // MENU REPAIR - REMOVE INTERNAL WIRES
-  case GEOMOp::OpAddPointOnEdge:   // MENU REPAIR - ADD POINT ON EDGE
-  case GEOMOp::OpFreeBoundaries:   // MENU MEASURE - FREE BOUNDARIES
-  case GEOMOp::OpFreeFaces:        // MENU MEASURE - FREE FACES
-  case GEOMOp::OpOrientation:      // MENU REPAIR - CHANGE ORIENTATION
-  case GEOMOp::OpGlueFaces:        // MENU REPAIR - GLUE FACES
-  case GEOMOp::OpGlueEdges:        // MENU REPAIR - GLUE EDGES
-  case GEOMOp::OpLimitTolerance:   // MENU REPAIR - LIMIT TOLERANCE
-  case GEOMOp::OpRemoveExtraEdges: // MENU REPAIR - REMOVE EXTRA EDGES
+  case GEOMOp::OpSewing:             // MENU REPAIR - SEWING
+  case GEOMOp::OpSuppressFaces:      // MENU REPAIR - SUPPRESS FACES
+  case GEOMOp::OpSuppressHoles:      // MENU REPAIR - SUPPRESS HOLE
+  case GEOMOp::OpShapeProcess:       // MENU REPAIR - SHAPE PROCESSING
+  case GEOMOp::OpCloseContour:       // MENU REPAIR - CLOSE CONTOUR
+  case GEOMOp::OpRemoveIntWires:     // MENU REPAIR - REMOVE INTERNAL WIRES
+  case GEOMOp::OpAddPointOnEdge:     // MENU REPAIR - ADD POINT ON EDGE
+  case GEOMOp::OpFreeBoundaries:     // MENU MEASURE - FREE BOUNDARIES
+  case GEOMOp::OpFreeFaces:          // MENU MEASURE - FREE FACES
+  case GEOMOp::OpOrientation:        // MENU REPAIR - CHANGE ORIENTATION
+  case GEOMOp::OpGlueFaces:          // MENU REPAIR - GLUE FACES
+  case GEOMOp::OpGlueEdges:          // MENU REPAIR - GLUE EDGES
+  case GEOMOp::OpLimitTolerance:     // MENU REPAIR - LIMIT TOLERANCE
+  case GEOMOp::OpRemoveExtraEdges:   // MENU REPAIR - REMOVE EXTRA EDGES
     libName = "RepairGUI";
     break;
-  case GEOMOp::OpProperties:       // MENU MEASURE - PROPERTIES
-  case GEOMOp::OpCenterMass:       // MENU MEASURE - CDG
-  case GEOMOp::OpInertia:          // MENU MEASURE - INERTIA
-  case GEOMOp::OpNormale:          // MENU MEASURE - NORMALE
-  case GEOMOp::OpBoundingBox:      // MENU MEASURE - BOUNDING BOX
-  case GEOMOp::OpMinDistance:      // MENU MEASURE - MIN DISTANCE
-  case GEOMOp::OpAngle:            // MENU MEASURE - ANGLE
-  case GEOMOp::OpTolerance:        // MENU MEASURE - TOLERANCE
-  case GEOMOp::OpWhatIs:           // MENU MEASURE - WHATIS
-  case GEOMOp::OpCheckShape:       // MENU MEASURE - CHECK
-  case GEOMOp::OpCheckCompound:    // MENU MEASURE - CHECK COMPOUND OF BLOCKS
-  case GEOMOp::OpPointCoordinates: // MENU MEASURE - POINT COORDINATES
-  case GEOMOp::OpCheckSelfInters:  // MENU MEASURE - CHECK SELF INTERSECTIONS
+  case GEOMOp::OpProperties:         // MENU MEASURE - PROPERTIES
+  case GEOMOp::OpCenterMass:         // MENU MEASURE - CDG
+  case GEOMOp::OpInertia:            // MENU MEASURE - INERTIA
+  case GEOMOp::OpNormale:            // MENU MEASURE - NORMALE
+  case GEOMOp::OpBoundingBox:        // MENU MEASURE - BOUNDING BOX
+  case GEOMOp::OpMinDistance:        // MENU MEASURE - MIN DISTANCE
+  case GEOMOp::OpAngle:              // MENU MEASURE - ANGLE
+  case GEOMOp::OpTolerance:          // MENU MEASURE - TOLERANCE
+  case GEOMOp::OpWhatIs:             // MENU MEASURE - WHATIS
+  case GEOMOp::OpCheckShape:         // MENU MEASURE - CHECK
+  case GEOMOp::OpCheckCompound:      // MENU MEASURE - CHECK COMPOUND OF BLOCKS
+  case GEOMOp::OpPointCoordinates:   // MENU MEASURE - POINT COORDINATES
+  case GEOMOp::OpCheckSelfInters:    // MENU MEASURE - CHECK SELF INTERSECTIONS
     libName = "MeasureGUI";
     break;
-  case GEOMOp::OpGroupCreate:      // MENU GROUP - CREATE
-  case GEOMOp::OpGroupCreatePopup: // POPUP MENU - CREATE GROUP
-  case GEOMOp::OpGroupEdit:        // MENU GROUP - EDIT
+  case GEOMOp::OpGroupCreate:        // MENU GROUP - CREATE
+  case GEOMOp::OpGroupCreatePopup:   // POPUP MENU - CREATE GROUP
+  case GEOMOp::OpGroupEdit:          // MENU GROUP - EDIT
     libName = "GroupGUI";
     break;
-  case GEOMOp::OpHexaSolid:        // MENU BLOCKS - HEXAHEDRAL SOLID
-  case GEOMOp::OpMultiTransform:   // MENU BLOCKS - MULTI-TRANSFORMATION
-  case GEOMOp::OpQuadFace:         // MENU BLOCKS - QUADRANGLE FACE
-  case GEOMOp::OpPropagate:        // MENU BLOCKS - PROPAGATE
-  case GEOMOp::OpExplodeBlock:     // MENU BLOCKS - EXPLODE ON BLOCKS
+  case GEOMOp::OpHexaSolid:          // MENU BLOCKS - HEXAHEDRAL SOLID
+  case GEOMOp::OpMultiTransform:     // MENU BLOCKS - MULTI-TRANSFORMATION
+  case GEOMOp::OpQuadFace:           // MENU BLOCKS - QUADRANGLE FACE
+  case GEOMOp::OpPropagate:          // MENU BLOCKS - PROPAGATE
+  case GEOMOp::OpExplodeBlock:       // MENU BLOCKS - EXPLODE ON BLOCKS
     libName = "BlocksGUI";
     break;
-  case GEOMOp::OpAdvancedNoOp:     // NO OPERATION (advanced operations base)
-  case GEOMOp::OpPipeTShape:       // MENU NEW ENTITY - ADVANCED - PIPE TSHAPE
+  case GEOMOp::OpAdvancedNoOp:       // NO OPERATION (advanced operations base)
+  case GEOMOp::OpPipeTShape:         // MENU NEW ENTITY - ADVANCED - PIPE TSHAPE
 //   case GEOMOp::OpPipeTShapeGroups:     // MENU NEW ENTITY - ADVANCED - PIPE TSHAPE GROUPS
     //@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@ do not remove this line @@ do not remove this line @@//
     libName = "AdvancedGUI";
@@ -571,8 +576,24 @@ void GeometryGUI::OnGUIEvent( int id )
   }
 
   // call method of corresponding GUI library
-  if ( library )
+  if ( library ) {
     library->OnGUIEvent( id, desk );
+    
+    // Update a list of materials for "Preferences" dialog
+    if ( id == GEOMOp::OpMaterialProperties ) {
+      LightApp_Preferences* pref = preferences();
+      if ( pref ) {
+       Material_ResourceMgr aMatResMgr;
+       QStringList aPerfMatNames = aMatResMgr.getPreferenceMaterialsNames();
+       setPreferenceProperty( pref->rootItem()->findItem( tr( "PREF_FRONT_MATERIAL" ), true )->id(),
+                              "strings",
+                              aPerfMatNames );
+       setPreferenceProperty( pref->rootItem()->findItem( tr( "PREF_BACK_MATERIAL" ), true )->id(),
+                              "strings",
+                              aPerfMatNames );
+      }
+    }
+  }
   else
     SUIT_MessageBox::critical( desk, tr( "GEOM_ERROR" ), tr( "GEOM_ERR_LIB_NOT_FOUND" ), tr( "GEOM_BUT_OK" ) );
 }
@@ -821,6 +842,7 @@ void GeometryGUI::initialize( CAM_Application* app )
 
   createGeomAction( GEOMOp::OpWireframe,        "POP_WIREFRAME", "", 0, true );
   createGeomAction( GEOMOp::OpShading,          "POP_SHADING", "", 0, true );
+  createGeomAction( GEOMOp::OpShadingWithEdges, "POP_SHADING_WITH_EDGES", "", 0, true );
   createGeomAction( GEOMOp::OpTexture,          "POP_TEXTURE", "", 0, true );
   createGeomAction( GEOMOp::OpVectors,          "POP_VECTORS", "", 0, true );
   createGeomAction( GEOMOp::OpDeflection,       "POP_DEFLECTION" );
@@ -836,6 +858,7 @@ 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::OpPipeTShape, "PIPETSHAPE" );
 
@@ -1185,6 +1208,9 @@ void GeometryGUI::initialize( CAM_Application* app )
   mgr->insert( action(  GEOMOp::OpShading ), dispmodeId, -1 ); // shading
   mgr->setRule( action( GEOMOp::OpShading ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule );
   mgr->setRule( action( GEOMOp::OpShading ), clientOCCorVTK + " and displaymode='Shading'", QtxPopupMgr::ToggleRule );
+  mgr->insert( action(  GEOMOp::OpShadingWithEdges ), dispmodeId, -1 ); // shading with edges
+  mgr->setRule( action( GEOMOp::OpShadingWithEdges ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule );
+  mgr->setRule( action( GEOMOp::OpShadingWithEdges ), clientOCCorVTK + " and displaymode='ShadingWithEdges'", QtxPopupMgr::ToggleRule );
   mgr->insert( action(  GEOMOp::OpTexture ), dispmodeId, -1 ); // wireframe
   mgr->setRule( action( GEOMOp::OpTexture ), clientOCC_AndSomeVisible, QtxPopupMgr::VisibleRule );
   mgr->setRule( action( GEOMOp::OpTexture), clientOCC + " and displaymode='Texture'", QtxPopupMgr::ToggleRule );
@@ -1204,6 +1230,8 @@ 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
   mgr->setRule( action( GEOMOp::OpSetTexture ), clientOCCorOB_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
   mgr->insert( separator(), -1, -1 );     // -----------
@@ -1624,6 +1652,9 @@ void GeometryGUI::createPreferences()
   addPreference( tr( "PREF_SHADING_COLOR" ), genGroup,
                  LightApp_Preferences::Color, "Geometry", "shading_color" );
 
+  addPreference( tr( "PREF_EDGES_IN_SHADING" ), genGroup,
+                 LightApp_Preferences::Color, "Geometry", "edges_in_shading_color" );
+
   addPreference( tr( "PREF_WIREFRAME_COLOR" ), genGroup,
                  LightApp_Preferences::Color, "Geometry", "wireframe_color" );
 
@@ -1645,6 +1676,14 @@ void GeometryGUI::createPreferences()
   int defl = addPreference( tr( "PREF_DEFLECTION" ), genGroup,
                             LightApp_Preferences::DblSpin, "Geometry", "deflection_coeff" );
 
+  int front_material = addPreference( tr( "PREF_FRONT_MATERIAL" ), genGroup,
+                                     LightApp_Preferences::Selector,
+                                     "Geometry", "front_material" );
+
+  int back_material = addPreference( tr( "PREF_BACK_MATERIAL" ), genGroup,
+                                    LightApp_Preferences::Selector,
+                                    "Geometry", "back_material" );
+
   // Quantities with individual precision settings
   int precGroup = addPreference( tr( "GEOM_PREF_GROUP_PRECISION" ), tabId );
   setPreferenceProperty( precGroup, "columns", 2 );
@@ -1688,10 +1727,12 @@ void GeometryGUI::createPreferences()
   QStringList aModesList;
   aModesList.append( tr("MEN_WIREFRAME") );
   aModesList.append( tr("MEN_SHADING") );
+  aModesList.append( tr("MEN_SHADING_WITH_EDGES") );
 
   QList<QVariant> anIndexesList;
   anIndexesList.append(0);
   anIndexesList.append(1);
+  anIndexesList.append(2);
 
   setPreferenceProperty( dispmode, "strings", aModesList );
   setPreferenceProperty( dispmode, "indexes", anIndexesList );
@@ -1707,6 +1748,12 @@ void GeometryGUI::createPreferences()
   setPreferenceProperty( defl, "step", 1.0e-04 );
   setPreferenceProperty( defl, "precision", 6 );
 
+  // Set property for default material
+  Material_ResourceMgr aMatResMgr;
+  QStringList aPrefMatNames = aMatResMgr.getPreferenceMaterialsNames();
+  setPreferenceProperty( front_material, "strings", aPrefMatNames );
+  setPreferenceProperty( back_material, "strings", aPrefMatNames );
+
   // Set property vertex marker type
   QList<QVariant> aMarkerTypeIndicesList;
   QList<QVariant> aMarkerTypeIconsList;
@@ -1787,7 +1834,7 @@ const char gDigitsSep = ':'; // character used to separate numeric parameter val
  * \brief Store visual parameters
  *
  * This method is called just before the study document is saved.
- * Store visual parameters in AttributeParameter attribue(s)
+ * Store visual parameters in AttributeParameter attribute(s)
  */
 void GeometryGUI::storeVisualParameters (int savePoint)
 {
@@ -1894,6 +1941,16 @@ void GeometryGUI::storeVisualParameters (int savePoint)
           param = occParam + MARKER_TYPE_PROP;
           ip->setParameter(entry, param, aProps.value(MARKER_TYPE_PROP).toString().toLatin1().data());
         }
+
+       if(aProps.contains(FRONT_MATERIAL_PROP)) {
+          param = occParam + FRONT_MATERIAL_PROP;
+          ip->setParameter(entry, param, aProps.value(FRONT_MATERIAL_PROP).toString().toLatin1().data());
+        }
+
+       if(aProps.contains(BACK_MATERIAL_PROP)) {
+          param = occParam + BACK_MATERIAL_PROP;
+          ip->setParameter(entry, param, aProps.value(BACK_MATERIAL_PROP).toString().toLatin1().data());
+        }
       } // object iterator
     } // for (views)
   } // for (viewManagers)
@@ -1903,7 +1960,7 @@ void GeometryGUI::storeVisualParameters (int savePoint)
  * \brief Restore visual parameters
  *
  * This method is called after the study document is opened.
- * Restore visual parameters from AttributeParameter attribue(s)
+ * Restore visual parameters from AttributeParameter attribute(s)
  */
 void GeometryGUI::restoreVisualParameters (int savePoint)
 {
@@ -2001,6 +2058,10 @@ void GeometryGUI::restoreVisualParameters (int savePoint)
         aListOfMap[viewIndex].insert( DEFLECTION_COEFF_PROP, val.toDouble());
       }  else if(paramNameStr == MARKER_TYPE_PROP) {
         aListOfMap[viewIndex].insert( MARKER_TYPE_PROP, val);
+      } else if(paramNameStr == FRONT_MATERIAL_PROP) {
+        aListOfMap[viewIndex].insert( FRONT_MATERIAL_PROP, val);
+      } else if(paramNameStr == BACK_MATERIAL_PROP) {
+        aListOfMap[viewIndex].insert( BACK_MATERIAL_PROP, val);
       }
 
     } // for names/parameters iterator
index e523da284fee525e3fe7b9b8625a63b5cdfbb4ec..406120e937773f2a8b4ea30a0336910798e954e6 100644 (file)
 #include "SALOMEconfig.h"
 #include CORBA_CLIENT_HEADER(SALOMEDS)
 
-// minimum allowed value for deflection coefficient
-#define DEFLECTION_MIN 1e-06
-
-//Define separators
-#define NAME_SEPARATOR  '_' // character used to separate parameter names
-#define DIGIT_SEPARATOR ':' // character used to separate numeric parameter values (color = r:g:b)
-
-#define VISIBILITY_PROP       "Visibility"      //Object visibility property
-#define OPACITY_PROP          "Opacity"         //Object opacity property
-#define TRANSPARENCY_PROP     "Transparency"    //Object transparency property
-#define DISPLAY_MODE_PROP     "DisplayMode"     //Object display mode property
-#define ISOS_PROP             "Isos"            //Number of the Isos property of the object
-#define COLOR_PROP            "Color"           //Color of the object 
-#define VECTOR_MODE_PROP      "VectorMode"      //Vector mode property
-#define DEFLECTION_COEFF_PROP "DeflectionCoeff" //Deflection coeff property
-#define MARKER_TYPE_PROP      "MarkerType"      // Marker type property
-
-
 class QDialog;
 class QMenu;
 class GEOMGUI_OCCSelector;
index 1731c17720aa3d3c918720827c68b5fc2a394e6b..5ff8d5921547cf7f6f80bd5ee72e57c65fed0f41 100644 (file)
 namespace GEOMOp {
   enum {
     // ToolsGUI ------------------//--------------------------------
-    OpImport            = 1000,   // MENU FILE  - IMPORT
-    OpExport            = 1001,   // MENU FILE  - EXPORT
-    OpDelete            = 1020,   // MENU EDIT  - DELETE
-    OpCheckGeom         = 1030,   // MENU TOOLS - CHECK GEOMETRY
-    OpSelectVertex      = 1100,   // POPUP MENU - SELECT ONLY - VERTEX
-    OpSelectEdge        = 1101,   // POPUP MENU - SELECT ONLY - EDGE
-    OpSelectWire        = 1102,   // POPUP MENU - SELECT ONLY - WIRE
-    OpSelectFace        = 1103,   // POPUP MENU - SELECT ONLY - FACE
-    OpSelectShell       = 1104,   // POPUP MENU - SELECT ONLY - SHELL
-    OpSelectSolid       = 1105,   // POPUP MENU - SELECT ONLY - SOLID
-    OpSelectCompound    = 1106,   // POPUP MENU - SELECT ONLY - COMPOUND
-    OpSelectAll         = 1107,   // POPUP MENU - SELECT ONLY - SELECT ALL
-    OpDeflection        = 1200,   // POPUP MENU - DEFLECTION COEFFICIENT
-    OpColor             = 1201,   // POPUP MENU - COLOR
-    OpTransparency      = 1202,   // POPUP MENU - TRANSPARENCY
-    OpIncrTransparency  = 1203,   // SHORTCUT   - INCREASE TRANSPARENCY
-    OpDecrTransparency  = 1204,   // SHORTCUT   - DECREASE TRANSPARENCY
-    OpIsos              = 1205,   // POPUP MENU - ISOS
-    OpIncrNbIsos        = 1206,   // SHORTCUT   - INCREASE NB ISOS
-    OpDecrNbIsos        = 1207,   // SHORTCUT   - DECREASE NB ISOS
-    OpAutoColor         = 1208,   // POPUP MENU - AUTO COLOR
-    OpNoAutoColor       = 1209,   // POPUP MENU - DISABLE AUTO COLOR
-    OpPointMarker       = 1210,   // POPUP MENU - POINT MARKER
-    OpSetTexture        = 1211,   // POPUP MENU - SETTEXTURE
-    OpShowChildren      = 1250,   // POPUP MENU - SHOW CHILDREN
-    OpHideChildren      = 1251,   // POPUP MENU - HIDE CHILDREN
-    OpUnpublishObject   = 1253,   // POPUP MENU - UNPUBLISH
-    OpPublishObject     = 1254,   // GEOM ROOT OBJECT - POPUP MENU - PUBLISH
+    OpImport              = 1000,   // MENU FILE  - IMPORT
+    OpExport              = 1001,   // MENU FILE  - EXPORT
+    OpDelete              = 1020,   // MENU EDIT  - DELETE
+    OpCheckGeom           = 1030,   // MENU TOOLS - CHECK GEOMETRY
+    OpSelectVertex        = 1100,   // POPUP MENU - SELECT ONLY - VERTEX
+    OpSelectEdge          = 1101,   // POPUP MENU - SELECT ONLY - EDGE
+    OpSelectWire          = 1102,   // POPUP MENU - SELECT ONLY - WIRE
+    OpSelectFace          = 1103,   // POPUP MENU - SELECT ONLY - FACE
+    OpSelectShell         = 1104,   // POPUP MENU - SELECT ONLY - SHELL
+    OpSelectSolid         = 1105,   // POPUP MENU - SELECT ONLY - SOLID
+    OpSelectCompound      = 1106,   // POPUP MENU - SELECT ONLY - COMPOUND
+    OpSelectAll           = 1107,   // POPUP MENU - SELECT ONLY - SELECT ALL
+    OpDeflection          = 1200,   // POPUP MENU - DEFLECTION COEFFICIENT
+    OpColor               = 1201,   // POPUP MENU - COLOR
+    OpTransparency        = 1202,   // POPUP MENU - TRANSPARENCY
+    OpIncrTransparency    = 1203,   // SHORTCUT   - INCREASE TRANSPARENCY
+    OpDecrTransparency    = 1204,   // SHORTCUT   - DECREASE TRANSPARENCY
+    OpIsos                = 1205,   // POPUP MENU - ISOS
+    OpIncrNbIsos          = 1206,   // SHORTCUT   - INCREASE NB ISOS
+    OpDecrNbIsos          = 1207,   // SHORTCUT   - DECREASE NB ISOS
+    OpAutoColor           = 1208,   // POPUP MENU - AUTO COLOR
+    OpNoAutoColor         = 1209,   // POPUP MENU - DISABLE AUTO COLOR
+    OpPointMarker         = 1210,   // POPUP MENU - POINT MARKER
+    OpSetTexture          = 1211,   // POPUP MENU - SETTEXTURE
+    OpMaterialProperties  = 1212,   // POPUP MENU - MATERIAL PROPERTIES
+    OpShowChildren        = 1250,   // POPUP MENU - SHOW CHILDREN
+    OpHideChildren        = 1251,   // POPUP MENU - HIDE CHILDREN
+    OpUnpublishObject     = 1253,   // POPUP MENU - UNPUBLISH
+    OpPublishObject       = 1254,   // GEOM ROOT OBJECT - POPUP MENU - PUBLISH
 
     // DisplayGUI ----------------//--------------------------------
-    OpDisplayMode       = 2000,   // MENU VIEW  - DISPLAY MODE - WIREFRAME/SHADING
-    OpSwitchVectors     = 2001,   // MENU VIEW  - DISPLAY MODE - SHOW/HIDE EDGE DIRECTION
-    OpShowAll           = 2002,   // MENU VIEW  - SHOW ALL
-    OpHideAll           = 2003,   // MENU VIEW  - HIDE ALL
-    OpShow              = 2100,   // POPUP MENU - SHOW
-    OpShowOnly          = 2101,   // POPUP MENU - SHOW ONLY
-    OpHide              = 2102,   // POPUP MENU - HIDE
-    OpWireframe         = 2200,   // POPUP MENU - DISPLAY MODE - WIREFRAME
-    OpShading           = 2201,   // POPUP MENU - DISPLAY MODE - SHADING
-    OpVectors           = 2202,   // POPUP MENU - DISPLAY MODE - SHOW EDGE DIRECTION
-    OpTexture           = 2203,   // POPUP MENU - DISPLAY MODE - TEXTURE
+    OpDisplayMode         = 2000,   // MENU VIEW  - DISPLAY MODE - WIREFRAME/SHADING/SHADING WITH EDGES
+    OpSwitchVectors       = 2001,   // MENU VIEW  - DISPLAY MODE - SHOW/HIDE EDGE DIRECTION
+    OpShowAll             = 2002,   // MENU VIEW  - SHOW ALL
+    OpHideAll             = 2003,   // MENU VIEW  - HIDE ALL
+    OpShow                = 2100,   // POPUP MENU - SHOW
+    OpShowOnly            = 2101,   // POPUP MENU - SHOW ONLY
+    OpHide                = 2102,   // POPUP MENU - HIDE
+    OpWireframe           = 2200,   // POPUP MENU - DISPLAY MODE - WIREFRAME
+    OpShading             = 2201,   // POPUP MENU - DISPLAY MODE - SHADING
+    OpShadingWithEdges    = 2202,   // POPUP MENU - DISPLAY MODE - SHADING WITH EDGES
+    OpVectors             = 2203,   // POPUP MENU - DISPLAY MODE - SHOW EDGE DIRECTION
+    OpTexture             = 2204,   // POPUP MENU - DISPLAY MODE - TEXTURE
     // BasicGUI ------------------//--------------------------------
-    OpPoint             = 3000,   // MENU NEW ENTITY - BASIC - POINT
-    OpLine              = 3001,   // MENU NEW ENTITY - BASIC - LINE
-    OpCircle            = 3002,   // MENU NEW ENTITY - BASIC - CIRCLE
-    OpEllipse           = 3003,   // MENU NEW ENTITY - BASIC - ELLIPSE
-    OpArc               = 3004,   // MENU NEW ENTITY - BASIC - ARC
-    OpVector            = 3005,   // MENU NEW ENTITY - BASIC - VECTOR
-    OpPlane             = 3006,   // MENU NEW ENTITY - BASIC - PLANE
-    OpCurve             = 3007,   // MENU NEW ENTITY - BASIC - CURVE
-    OpLCS               = 3008,   // MENU NEW ENTITY - BASIC - LOCAL COORDINATE SYSTEM
-    OpOriginAndVectors  = 3009,   // MENU NEW ENTITY - BASIC - ORIGIN AND BASE VECTORS
+    OpPoint               = 3000,   // MENU NEW ENTITY - BASIC - POINT
+    OpLine                = 3001,   // MENU NEW ENTITY - BASIC - LINE
+    OpCircle              = 3002,   // MENU NEW ENTITY - BASIC - CIRCLE
+    OpEllipse             = 3003,   // MENU NEW ENTITY - BASIC - ELLIPSE
+    OpArc                 = 3004,   // MENU NEW ENTITY - BASIC - ARC
+    OpVector              = 3005,   // MENU NEW ENTITY - BASIC - VECTOR
+    OpPlane               = 3006,   // MENU NEW ENTITY - BASIC - PLANE
+    OpCurve               = 3007,   // MENU NEW ENTITY - BASIC - CURVE
+    OpLCS                 = 3008,   // MENU NEW ENTITY - BASIC - LOCAL COORDINATE SYSTEM
+    OpOriginAndVectors    = 3009,   // MENU NEW ENTITY - BASIC - ORIGIN AND BASE VECTORS
     // PrimitiveGUI --------------//--------------------------------
-    OpBox               = 3100,   // MENU NEW ENTITY - PRIMITIVES - BOX
-    OpCylinder          = 3101,   // MENU NEW ENTITY - PRIMITIVES - CYLINDER
-    OpSphere            = 3102,   // MENU NEW ENTITY - PRIMITIVES - SPHERE
-    OpTorus             = 3103,   // MENU NEW ENTITY - PRIMITIVES - TORUS
-    OpCone              = 3104,   // MENU NEW ENTITY - PRIMITIVES - CONE
-    OpRectangle         = 3105,   // MENU NEW ENTITY - PRIMITIVES - FACE
-    OpDisk              = 3106,   // MENU NEW ENTITY - PRIMITIVES - DISK
+    OpBox                 = 3100,   // MENU NEW ENTITY - PRIMITIVES - BOX
+    OpCylinder            = 3101,   // MENU NEW ENTITY - PRIMITIVES - CYLINDER
+    OpSphere              = 3102,   // MENU NEW ENTITY - PRIMITIVES - SPHERE
+    OpTorus               = 3103,   // MENU NEW ENTITY - PRIMITIVES - TORUS
+    OpCone                = 3104,   // MENU NEW ENTITY - PRIMITIVES - CONE
+    OpRectangle           = 3105,   // MENU NEW ENTITY - PRIMITIVES - FACE
+    OpDisk                = 3106,   // MENU NEW ENTITY - PRIMITIVES - DISK
     // GenerationGUI -------------//--------------------------------
-    OpPrism             = 3200,   // MENU NEW ENTITY - GENERATION - EXTRUSION
-    OpRevolution        = 3201,   // MENU NEW ENTITY - GENERATION - REVOLUTION
-    OpFilling           = 3202,   // MENU NEW ENTITY - GENERATION - FILLING
-    OpPipe              = 3203,   // MENU NEW ENTITY - GENERATION - EXTRUSION ALONG PATH
+    OpPrism               = 3200,   // MENU NEW ENTITY - GENERATION - EXTRUSION
+    OpRevolution          = 3201,   // MENU NEW ENTITY - GENERATION - REVOLUTION
+    OpFilling             = 3202,   // MENU NEW ENTITY - GENERATION - FILLING
+    OpPipe                = 3203,   // MENU NEW ENTITY - GENERATION - EXTRUSION ALONG PATH
     // EntityGUI -----------------//--------------------------------
-    Op2dSketcher        = 3300,   // MENU NEW ENTITY - SKETCHER
-    Op3dSketcher        = 3301,   // MENU NEW ENTITY - 3D SKETCHER
-    OpExplode           = 3302,   // MENU NEW ENTITY - EXPLODE
+    Op2dSketcher          = 3300,   // MENU NEW ENTITY - SKETCHER
+    Op3dSketcher          = 3301,   // MENU NEW ENTITY - 3D SKETCHER
+    OpExplode             = 3302,   // MENU NEW ENTITY - EXPLODE
 #ifdef WITH_OPENCV
-    OpFeatureDetect     = 3303,   // MENU NEW ENTITY - FEATURE DETECTION
+    OpFeatureDetect       = 3303,   // MENU NEW ENTITY - FEATURE DETECTION
 #endif
-    OpPictureImport     = 3304,   // MENU NEW ENTITY - IMPORT PICTURE IN VIEWER
+    OpPictureImport       = 3304,   // MENU NEW ENTITY - IMPORT PICTURE IN VIEWER
 
     // BuildGUI ------------------//--------------------------------
-    OpEdge              = 3400,   // MENU NEW ENTITY - BUILD - EDGE
-    OpWire              = 3401,   // MENU NEW ENTITY - BUILD - WIRE
-    OpFace              = 3402,   // MENU NEW ENTITY - BUILD - FACE
-    OpShell             = 3403,   // MENU NEW ENTITY - BUILD - SHELL
-    OpSolid             = 3404,   // MENU NEW ENTITY - BUILD - SOLID
-    OpCompound          = 3405,   // MENU NEW ENTITY - BUILD - COMPOUND
+    OpEdge                = 3400,   // MENU NEW ENTITY - BUILD - EDGE
+    OpWire                = 3401,   // MENU NEW ENTITY - BUILD - WIRE
+    OpFace                = 3402,   // MENU NEW ENTITY - BUILD - FACE
+    OpShell               = 3403,   // MENU NEW ENTITY - BUILD - SHELL
+    OpSolid               = 3404,   // MENU NEW ENTITY - BUILD - SOLID
+    OpCompound            = 3405,   // MENU NEW ENTITY - BUILD - COMPOUND
     // BooleanGUI ----------------//--------------------------------
-    OpFuse              = 3500,   // MENU OPERATIONS - BOOLEAN - FUSE
-    OpCommon            = 3501,   // MENU OPERATIONS - BOOLEAN - COMMON
-    OpCut               = 3502,   // MENU OPERATIONS - BOOLEAN - CUT
-    OpSection           = 3503,   // MENU OPERATIONS - BOOLEAN - SECTION
+    OpFuse                = 3500,   // MENU OPERATIONS - BOOLEAN - FUSE
+    OpCommon              = 3501,   // MENU OPERATIONS - BOOLEAN - COMMON
+    OpCut                 = 3502,   // MENU OPERATIONS - BOOLEAN - CUT
+    OpSection             = 3503,   // MENU OPERATIONS - BOOLEAN - SECTION
     // TransformationGUI ---------//--------------------------------
-    OpTranslate         = 3600,   // MENU OPERATIONS - TRANSFORMATION - TRANSLATION
-    OpRotate            = 3601,   // MENU OPERATIONS - TRANSFORMATION - ROTATION
-    OpChangeLoc         = 3602,   // MENU OPERATIONS - TRANSFORMATION - LOCATION
-    OpMirror            = 3603,   // MENU OPERATIONS - TRANSFORMATION - MIRROR
-    OpScale             = 3604,   // MENU OPERATIONS - TRANSFORMATION - SCALE
-    OpOffset            = 3605,   // MENU OPERATIONS - TRANSFORMATION - OFFSET
-    OpMultiTranslate    = 3606,   // MENU OPERATIONS - TRANSFORMATION - MULTI-TRANSLATION
-    OpMultiRotate       = 3607,   // MENU OPERATIONS - TRANSFORMATION - MULTI-ROTATION
-    OpReimport          = 3608,   // POPUP MENU - RELOAD IMPORTED
-    OpProjection        = 3609,   // MENU OPERATIONS - TRANSFORMATION - PROJECTION
+    OpTranslate           = 3600,   // MENU OPERATIONS - TRANSFORMATION - TRANSLATION
+    OpRotate              = 3601,   // MENU OPERATIONS - TRANSFORMATION - ROTATION
+    OpChangeLoc           = 3602,   // MENU OPERATIONS - TRANSFORMATION - LOCATION
+    OpMirror              = 3603,   // MENU OPERATIONS - TRANSFORMATION - MIRROR
+    OpScale               = 3604,   // MENU OPERATIONS - TRANSFORMATION - SCALE
+    OpOffset              = 3605,   // MENU OPERATIONS - TRANSFORMATION - OFFSET
+    OpMultiTranslate      = 3606,   // MENU OPERATIONS - TRANSFORMATION - MULTI-TRANSLATION
+    OpMultiRotate         = 3607,   // MENU OPERATIONS - TRANSFORMATION - MULTI-ROTATION
+    OpReimport            = 3608,   // POPUP MENU - RELOAD IMPORTED
+    OpProjection          = 3609,   // MENU OPERATIONS - TRANSFORMATION - PROJECTION
     // OperationGUI
-    OpPartition         = 3700,   // MENU OPERATION - PARTITION
-    OpArchimede         = 3701,   // MENU OPERATION - ARCHIMEDE
-    OpFillet3d          = 3702,   // MENU OPERATION - FILLET
-    OpChamfer           = 3703,   // MENU OPERATION - CHAMFER
-    OpShapesOnShape     = 3704,   // MENU OPERATION - GET SHAPES ON SHAPE
-    OpFillet2d          = 3705,   // MENU OPERATION - FILLET 2D
-    OpFillet1d          = 3706,   // MENU OPERATION - FILLET 1D
-    OpClipping          = 3707,   // MENU OPERATION - CLIPPING RANGE
-    OpSharedShapes      = 3708,   // MENU OPERATION - GET SHARED SHAPES
+    OpPartition           = 3700,   // MENU OPERATION - PARTITION
+    OpArchimede           = 3701,   // MENU OPERATION - ARCHIMEDE
+    OpFillet3d            = 3702,   // MENU OPERATION - FILLET
+    OpChamfer             = 3703,   // MENU OPERATION - CHAMFER
+    OpShapesOnShape       = 3704,   // MENU OPERATION - GET SHAPES ON SHAPE
+    OpFillet2d            = 3705,   // MENU OPERATION - FILLET 2D
+    OpFillet1d            = 3706,   // MENU OPERATION - FILLET 1D
+    OpClipping            = 3707,   // MENU OPERATION - CLIPPING RANGE
+    OpSharedShapes        = 3708,   // MENU OPERATION - GET SHARED SHAPES
     // RepairGUI -----------------//--------------------------------
-    OpSewing            = 4000,   // MENU REPAIR - SEWING
-    OpSuppressFaces     = 4001,   // MENU REPAIR - SUPPRESS FACES
-    OpSuppressHoles     = 4002,   // MENU REPAIR - SUPPRESS HOLES
-    OpShapeProcess      = 4003,   // MENU REPAIR - SHAPE PROCESSING
-    OpCloseContour      = 4004,   // MENU REPAIR - CLOSE CONTOUR
-    OpRemoveIntWires    = 4005,   // MENU REPAIR - REMOVE INTERNAL WIRES
-    OpAddPointOnEdge    = 4006,   // MENU REPAIR - ADD POINT ON EDGE
-    OpFreeBoundaries    = 4007,   // MENU MEASURES - FREE BOUNDARIES
-    OpFreeFaces         = 4008,   // MENU MEASURES - FREE FACES
-    OpOrientation       = 4009,   // MENU REPAIR - CHANGE ORIENTATION
-    OpGlueFaces         = 4010,   // MENU REPAIR - GLUE FACES
-    OpRemoveExtraEdges  = 4011,   // MENU REPAIR - REMOVE EXTRA EDGES
-    OpLimitTolerance    = 4012,   // MENU REPAIR - LIMIT TOLERANCE
-    OpGlueEdges         = 4013,   // MENU REPAIR - GLUE EDGES
+    OpSewing              = 4000,   // MENU REPAIR - SEWING
+    OpSuppressFaces       = 4001,   // MENU REPAIR - SUPPRESS FACES
+    OpSuppressHoles       = 4002,   // MENU REPAIR - SUPPRESS HOLES
+    OpShapeProcess        = 4003,   // MENU REPAIR - SHAPE PROCESSING
+    OpCloseContour        = 4004,   // MENU REPAIR - CLOSE CONTOUR
+    OpRemoveIntWires      = 4005,   // MENU REPAIR - REMOVE INTERNAL WIRES
+    OpAddPointOnEdge      = 4006,   // MENU REPAIR - ADD POINT ON EDGE
+    OpFreeBoundaries      = 4007,   // MENU MEASURES - FREE BOUNDARIES
+    OpFreeFaces           = 4008,   // MENU MEASURES - FREE FACES
+    OpOrientation         = 4009,   // MENU REPAIR - CHANGE ORIENTATION
+    OpGlueFaces           = 4010,   // MENU REPAIR - GLUE FACES
+    OpRemoveExtraEdges    = 4011,   // MENU REPAIR - REMOVE EXTRA EDGES
+    OpLimitTolerance      = 4012,   // MENU REPAIR - LIMIT TOLERANCE
+    OpGlueEdges           = 4013,   // MENU REPAIR - GLUE EDGES
     // MeasureGUI ----------------//--------------------------------
-    OpProperties        = 5000,   // MENU MEASURES - PROPERTIES
-    OpCenterMass        = 5001,   // MENU MEASURES - CENTRE OF MASS
-    OpInertia           = 5002,   // MENU MEASURES - INERTIA
-    OpNormale           = 5003,   // MENU MEASURES - NORMALE
-    OpBoundingBox       = 5004,   // MENU MEASURES - BOUNDING BOX
-    OpMinDistance       = 5005,   // MENU MEASURES - MIN DISTANCE
-    OpAngle             = 5006,   // MENU MEASURES - ANGLE
-    OpTolerance         = 5007,   // MENU MEASURES - TOLERANCE
-    OpWhatIs            = 5008,   // MENU MEASURES - WHAT IS
-    OpCheckShape        = 5009,   // MENU MEASURES - CHECK
-    OpCheckCompound     = 5010,   // MENU MEASURES - CHECK COMPOUND OF BLOCKS
-    OpPointCoordinates  = 5011,   // MENU MEASURES - POINT COORDINATES
-    OpCheckSelfInters   = 5012,   // MENU MEASURES - CHECK SELF INTERSECTIONS
+    OpProperties          = 5000,   // MENU MEASURES - PROPERTIES
+    OpCenterMass          = 5001,   // MENU MEASURES - CENTRE OF MASS
+    OpInertia             = 5002,   // MENU MEASURES - INERTIA
+    OpNormale             = 5003,   // MENU MEASURES - NORMALE
+    OpBoundingBox         = 5004,   // MENU MEASURES - BOUNDING BOX
+    OpMinDistance         = 5005,   // MENU MEASURES - MIN DISTANCE
+    OpAngle               = 5006,   // MENU MEASURES - ANGLE
+    OpTolerance           = 5007,   // MENU MEASURES - TOLERANCE
+    OpWhatIs              = 5008,   // MENU MEASURES - WHAT IS
+    OpCheckShape          = 5009,   // MENU MEASURES - CHECK
+    OpCheckCompound       = 5010,   // MENU MEASURES - CHECK COMPOUND OF BLOCKS
+    OpPointCoordinates    = 5011,   // MENU MEASURES - POINT COORDINATES
+    OpCheckSelfInters     = 5012,   // MENU MEASURES - CHECK SELF INTERSECTIONS
     // GroupGUI ------------------//--------------------------------
-    OpGroupCreate       = 6000,   // MENU GROUP - CREATE
-    OpGroupEdit         = 6001,   // MENU GROUP - EDIT
-    OpGroupCreatePopup  = 6002,   // POPUP MENU - CREATE GROUP
+    OpGroupCreate         = 6000,   // MENU GROUP - CREATE
+    OpGroupEdit           = 6001,   // MENU GROUP - EDIT
+    OpGroupCreatePopup    = 6002,   // POPUP MENU - CREATE GROUP
     // BlocksGUI -----------------//--------------------------------
-    OpHexaSolid         = 6100,   // MENU BLOCKS - HEXAHEDRAL SOLID
-    OpMultiTransform    = 6101,   // MENU BLOCKS - MULTI-TRANSFORMATION
-    OpQuadFace          = 6102,   // MENU BLOCKS - QUADRANGLE FACE
-    OpPropagate         = 6103,   // MENU BLOCKS - PROPAGATE
-    OpExplodeBlock      = 6104,   // MENU BLOCKS - EXPLODE ON BLOCKS
+    OpHexaSolid           = 6100,   // MENU BLOCKS - HEXAHEDRAL SOLID
+    OpMultiTransform      = 6101,   // MENU BLOCKS - MULTI-TRANSFORMATION
+    OpQuadFace            = 6102,   // MENU BLOCKS - QUADRANGLE FACE
+    OpPropagate           = 6103,   // MENU BLOCKS - PROPAGATE
+    OpExplodeBlock        = 6104,   // MENU BLOCKS - EXPLODE ON BLOCKS
     // AdvancedGUI ---------------//--------------------------------
-    OpAdvancedNoOp      = 10000,  // NO OPERATION (advanced operations base)
-    OpPipeTShape        = 10001,  // MENU NEW ENTITY - ADVANCED - PIPE TSHAPE
+    OpAdvancedNoOp        = 10000,  // NO OPERATION (advanced operations base)
+    OpPipeTShape          = 10001,  // MENU NEW ENTITY - ADVANCED - PIPE TSHAPE
 //     OpPipeTShapeGroups  = 10002,  // MENU NEW ENTITY - ADVANCED - PIPE TSHAPE GROUPS
     //@@ insert new functions before this line @@ do not remove this line @@//
   };
index bfd12147f143d3a463a75165023f784c8aab8d38..056df6e059afbce82ee6fd3f27302b8f3b9e97ac 100644 (file)
@@ -74,6 +74,7 @@ libGEOM_la_CPPFLAGS =                         \
        $(OPENCV_INCLUDES)                      \
        -I$(srcdir)/../OBJECT                   \
        -I$(srcdir)/../GEOMFiltersSelection     \
+       -I$(srcdir)/../Material                 \
        -I$(srcdir)/../GEOMClient               \
        -I$(srcdir)/../GEOMImpl                 \
        -I$(top_builddir)/idl                   \
@@ -82,6 +83,7 @@ libGEOM_la_CPPFLAGS =                         \
 libGEOM_la_LDFLAGS =                                           \
        $(PYTHON_LIBS)                                          \
        ../GEOMFiltersSelection/libGEOMFiltersSelection.la      \
+       ../Material/libMaterial.la                              \
        ../GEOMClient/libGEOMClient.la                          \
        ../OBJECT/libGEOMObject.la                              \
        $(KERNEL_LDFLAGS) -lSalomeLifeCycleCORBA -lSalomeNS -lSalomeDSClient            \
index cc95e6831cb7f9a2411e2993da468138be3fc490..f1abd61d09d33cc6fa8c1b82747a07e4fa23b9ff 100644 (file)
@@ -349,6 +349,9 @@ bool GEOMToolsGUI::OnGUIEvent(int theCommandID, SUIT_Desktop* parent)
   case GEOMOp::OpDecrNbIsos:     // SHORTCUT   - DECREASE NB ISOLINES
     OnNbIsos( DECR );
     break;
+  case GEOMOp::OpMaterialProperties: // POPUP - MATERIAL PROPERTIES
+    OnMaterialProperties();
+    break;
   case GEOMOp::OpAutoColor:      // POPUP - AUTO COLOR
     OnAutoColor();
     break;
index 12cead468218d1bcb3afef44e75f8ca93b7368a7..5706765f0d2b878d69b31c75f0b2a6fa6b7adb91 100644 (file)
@@ -75,6 +75,7 @@ private:
   void         OnUnpublishObject();
   void         OnPublishObject() ;
   void         OnPointMarker();
+  void         OnMaterialProperties();
 
   // Shortcut commands
   void         OnChangeTransparency( bool );
index 103a4bcfa07bbb41d8bedc9618efc5ee2103d258..5d2005cc0a11fd536d70317c1f9e3113d409d1b4 100644 (file)
 #include "GEOMToolsGUI_DeflectionDlg.h"
 #include "GEOMToolsGUI_MarkerDlg.h"
 #include "GEOMToolsGUI_PublishDlg.h"
+#include "GEOMToolsGUI_MaterialPropertiesDlg.h"
 
 #include <GeometryGUI.h>
 #include <GeometryGUI_Operations.h>
+#include <GEOM_Constants.h>
 #include <GEOM_Displayer.h>
 
 #include <GEOMBase.h>
@@ -518,6 +520,7 @@ void GEOMToolsGUI::OnNbIsos( ActionType actionType )
     ic->InitCurrent();
     if ( ic->MoreCurrent() ) {
       Handle(GEOM_AISShape) CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current());
+      CurObject->restoreIsoNumbers();
       Handle(AIS_Drawer)    CurDrawer = CurObject->Attributes();
 
       int UIso = CurDrawer->UIsoAspect()->Number();
@@ -557,16 +560,18 @@ void GEOMToolsGUI::OnNbIsos( ActionType actionType )
         CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current());
 
         Handle(AIS_Drawer) CurDrawer = CurObject->Attributes();
-        
+
         CurDrawer->SetUIsoAspect( new Prs3d_IsoAspect(Quantity_NOC_GRAY75, Aspect_TOL_SOLID, 0.5 , newNbUIso) );
         CurDrawer->SetVIsoAspect( new Prs3d_IsoAspect(Quantity_NOC_GRAY75, Aspect_TOL_SOLID, 0.5 , newNbVIso) );
+
+       CurObject->storeIsoNumbers();
         
         ic->SetLocalAttributes(CurObject, CurDrawer);
         ic->Redisplay(CurObject);
 
         QString anIsos("%1%2%3");anIsos = anIsos.arg(newNbUIso);anIsos = anIsos.arg(DIGIT_SEPARATOR);anIsos = anIsos.arg(newNbVIso);
         int aMgrId = window->getViewManager()->getGlobalId();
-        aStudy->setObjectProperty(aMgrId ,CurObject->getIO()->getEntry(), "Isos", anIsos);
+        aStudy->setObjectProperty(aMgrId ,CurObject->getIO()->getEntry(), ISOS_PROP, anIsos);
       }
     }
     GeometryGUI::Modified();
@@ -616,8 +621,10 @@ void GEOMToolsGUI::OnNbIsos( ActionType actionType )
     int VIso = 0;
 
     vtkActor* anAct = aCollection->GetNextActor();
-    if (GEOM_Actor* anActor = GEOM_Actor::SafeDownCast(anAct))
+    if (GEOM_Actor* anActor = GEOM_Actor::SafeDownCast(anAct)) {
+      anActor->RestoreIsoNumbers();
       anActor->GetNbIsos(UIso,VIso);
+    }
     else
       return;
     
@@ -656,6 +663,7 @@ void GEOMToolsGUI::OnNbIsos( ActionType actionType )
         // There are no casting to needed actor.
         int aIsos[2]={newNbUIso,newNbVIso};
         anActor->SetNbIsos(aIsos);
+       anActor->StoreIsoNumbers();
 
         QString anIsos("%1%2%3");anIsos = anIsos.arg(newNbUIso);anIsos = anIsos.arg(DIGIT_SEPARATOR);anIsos = anIsos.arg(newNbVIso);
         int aMgrId = window->getViewManager()->getGlobalId();
@@ -847,6 +855,11 @@ void GEOMToolsGUI::OnPointMarker()
   dlg.exec();
 }
 
+void GEOMToolsGUI::OnMaterialProperties()
+{
+  GEOMToolsGUI_MaterialPropertiesDlg dlg( SUIT_Session::session()->activeApplication()->desktop() );
+  dlg.exec();
+}
 
 void GEOMToolsGUI::OnUnpublishObject() {
   SALOME_ListIO selected;
index 1e4240103fd43863c487258971fbb095e9f3b213..bc9e9ea6329446958692ce19a2928f215a33adef 100644 (file)
@@ -23,6 +23,7 @@
 //
 #include "GEOMToolsGUI_DeflectionDlg.h"
 #include <GeometryGUI.h>
+#include <GEOM_Constants.h>
 #include <LightApp_Application.h>
 #include <SalomeApp_DoubleSpinBox.h>
 
index bf70a697f3156da53065a1bb5207544f1e748dda..54131a27ff296d0063a59106922adf9b450e77fb 100644 (file)
@@ -22,6 +22,7 @@
 #include "GEOMToolsGUI_MarkerDlg.h"
 
 #include <GeometryGUI.h>
+#include <GEOM_Constants.h>
 #include <GEOM_Displayer.h>
 
 #include <Basics_OCCTVersion.hxx>
diff --git a/src/GEOMToolsGUI/GEOMToolsGUI_MaterialPropertiesDlg.cxx b/src/GEOMToolsGUI/GEOMToolsGUI_MaterialPropertiesDlg.cxx
new file mode 100644 (file)
index 0000000..9a826cc
--- /dev/null
@@ -0,0 +1,1254 @@
+// Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+
+// File   : GEOMToolsGUI_MaterialPropertiesDlg.cxx
+// Author : Margarita KARPUNINA, Open CASCADE S.A.S. (margarita.karpunina@opencascade.com)
+
+#include "GEOMToolsGUI_MaterialPropertiesDlg.h"
+
+#include "Material_Model.h"
+#include "Material_ResourceMgr.h"
+
+#include <GeometryGUI.h>
+#include <GEOM_Constants.h>
+#include <GEOM_Displayer.h>
+#include <GEOM_Actor.h>
+
+#include <GEOMBase.h>
+
+#include <Basics_OCCTVersion.hxx>
+
+#include <SALOME_ListIO.hxx>
+#include <SALOME_ListIteratorOfListIO.hxx>
+
+#include <SVTK_Functor.h>
+#include <SVTK_Prs.h>
+#include <SVTK_ViewModel.h>
+#include <SVTK_ViewWindow.h>
+#include <SVTK_View.h>
+
+#include <VTKViewer_Algorithm.h>
+
+#include <OCCViewer_ViewModel.h>
+
+#include <SUIT_Desktop.h>
+#include <SUIT_MessageBox.h>
+#include <SUIT_OverrideCursor.h>
+#include <SUIT_ResourceMgr.h>
+#include <SUIT_Session.h>
+#include <SUIT_ViewManager.h>
+
+#include <SalomeApp_Application.h>
+#include <SalomeApp_Study.h>
+
+#include <LightApp_SelectionMgr.h>
+
+#include <QtxColorButton.h>
+#include <QtxDoubleSpinBox.h>
+
+// OCCT Includes
+#include <Graphic3d_AspectFillArea3d.hxx>
+
+// VTK includes
+#include <vtkRenderer.h>
+#include <vtkProperty.h>
+
+// QT Includes
+#include <QApplication>
+#include <QButtonGroup>
+#include <QCheckBox>
+#include <QGridLayout>
+#include <QGroupBox>
+#include <QHBoxLayout>
+#include <QKeyEvent>
+#include <QLabel>
+#include <QListWidget>
+#include <QMap>
+#include <QMessageBox>
+#include <QPushButton>
+#include <QSpinBox>
+#include <QTabWidget>
+#include <QVBoxLayout>
+
+#define MARGIN  9
+#define SPACING 6
+
+/*!
+  \class GEOMToolsGUI_MaterialPropertiesDlg
+  \brief GEOM material properties dialog box class.
+
+  The dialog box lists all GEOM materials available via the application and allows
+  user to create own materials.
+*/
+
+/*!
+  \brief Constructor
+  \param parent parent widget
+*/
+GEOMToolsGUI_MaterialPropertiesDlg::GEOMToolsGUI_MaterialPropertiesDlg( QWidget* parent )
+  : QtxDialog( parent, true, true, OK | Close | Apply | Help),
+    myResMgr( 0 )
+{
+  // Set title
+  setWindowTitle( tr( "MATERIAL_PROPERTIES_TLT" ) );
+
+  // Set viewer type
+  SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
+  if ( app ) {
+    SUIT_ViewWindow* window = app->desktop()->activeWindow();
+    if ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() )
+      myViewerType = OCC;
+    else if ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() )
+      myViewerType = VTK;
+  }
+
+  // Create main layout
+  QVBoxLayout* main = new QVBoxLayout( mainFrame() );
+  main->setMargin( 0 ); main->setSpacing( SPACING );
+
+  // Create main widgets
+  myBackMaterialCheck = new QCheckBox( tr( "MATERIAL_BACK_CHK" ), this );
+  QFrame* fr = new QFrame( this );
+  fr->setFrameStyle( QFrame::Box | QFrame::Sunken );
+
+  main->addWidget( myBackMaterialCheck );
+  main->addWidget( fr );
+
+  // Create editor widgets
+  myMaterialList = new QListWidget( fr );
+  myMaterialTab  = new QTabWidget( fr );
+
+  QHBoxLayout* frLayout = new QHBoxLayout( fr );
+  frLayout->setMargin( MARGIN ); frLayout->setSpacing( SPACING );
+  frLayout->addWidget( myMaterialList );
+  frLayout->addWidget( myMaterialTab );
+  frLayout->setStretchFactor( myMaterialList, 1 );
+  frLayout->setStretchFactor( myMaterialTab, 2 );
+
+  // ======================= Create a tab for front material ======================= 
+  QWidget* w1 = new QWidget( myMaterialTab );
+  QVBoxLayout* vLayout1 = new QVBoxLayout( w1 );
+
+  QGridLayout* gLayout1 = new QGridLayout( w1 );
+  gLayout1->setMargin( MARGIN ); gLayout1->setSpacing( SPACING );
+
+  // ----------------- "Ambient" reflection type group box -----------------
+  myAmbientGroupF = new QGroupBox( tr( "AMBIENT_GRP" ), w1 );
+  myAmbientGroupF->setCheckable(true);
+  connect( myAmbientGroupF, SIGNAL( toggled( bool ) ), this, SLOT( onReflectionTypeToggled( bool ) ) ); 
+
+  // Ambient color
+  QLabel* ambColorLab1 = new QLabel( tr( "COLOR" ), myAmbientGroupF );
+  myAmbientColorF = new QtxColorButton( myAmbientGroupF );
+  myAmbientColorF->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+  connect( myAmbientColorF, SIGNAL( changed( QColor ) ), this, SIGNAL( changed() ) ); 
+
+  // Ambient coefficient
+  QLabel* ambCoefficientLab1 = new QLabel( tr( "COEFFICIENT" ), myAmbientGroupF );
+  myAmbientCoefntF = new QtxDoubleSpinBox( myAmbientGroupF );
+  myAmbientCoefntF->setMaximum(1);
+  myAmbientCoefntF->setSingleStep(0.05);
+  connect( myAmbientCoefntF, SIGNAL( valueChanged( double ) ), this, SIGNAL( materialChanged() ) );
+
+  // Ambient group box layout
+  QGridLayout* ambientLayout1 = new QGridLayout( myAmbientGroupF );
+  ambientLayout1->setMargin( MARGIN ); ambientLayout1->setSpacing( SPACING );
+  ambientLayout1->addWidget( ambColorLab1,       0, 0 );
+  ambientLayout1->addWidget( myAmbientColorF,    0, 1 );
+  ambientLayout1->addWidget( ambCoefficientLab1, 1, 0 );
+  ambientLayout1->addWidget( myAmbientCoefntF,   1, 1 );
+
+  // ----------------- "Diffuse" reflection type group box -----------------
+  myDiffuseGroupF = new QGroupBox( tr( "DIFFUSE_GRP" ), w1 );
+  myDiffuseGroupF->setCheckable(true);
+  connect( myDiffuseGroupF, SIGNAL( toggled( bool ) ), this, SLOT( onReflectionTypeToggled( bool ) ) );
+
+  // Diffuse color
+  QLabel* difColorLab1 = new QLabel( tr( "COLOR" ), myDiffuseGroupF );
+  myDiffuseColorF = new QtxColorButton( myDiffuseGroupF );
+  myDiffuseColorF->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+  connect( myDiffuseColorF, SIGNAL( changed( QColor ) ), this, SIGNAL( changed() ) ); 
+
+  // Diffuse coefficient
+  QLabel* difCoefficientLab1 = new QLabel( tr( "COEFFICIENT" ), myDiffuseGroupF );
+  myDiffuseCoefntF = new QtxDoubleSpinBox( myDiffuseGroupF );
+  myDiffuseCoefntF->setMaximum(1);
+  myDiffuseCoefntF->setSingleStep(0.05);
+  connect( myDiffuseCoefntF, SIGNAL( valueChanged( double ) ), this, SIGNAL( materialChanged() ) );
+
+  // Diffuse group box layout
+  QGridLayout* diffuseLayout1 = new QGridLayout( myDiffuseGroupF );
+  diffuseLayout1->setMargin( MARGIN ); diffuseLayout1->setSpacing( SPACING );
+  diffuseLayout1->addWidget( difColorLab1,       0, 0 );
+  diffuseLayout1->addWidget( myDiffuseColorF,    0, 1 );
+  diffuseLayout1->addWidget( difCoefficientLab1, 1, 0 );
+  diffuseLayout1->addWidget( myDiffuseCoefntF,   1, 1 );
+
+  // ----------------- "Specular" reflection type group box -----------------
+  mySpecularGroupF = new QGroupBox( tr( "SPECULAR_GRP" ), w1 );
+  mySpecularGroupF->setCheckable(true);
+  connect( mySpecularGroupF, SIGNAL( toggled( bool ) ), this, SLOT( onReflectionTypeToggled( bool ) ) );
+
+  // Specular color
+  QLabel* specColorLab1 = new QLabel( tr( "COLOR" ), mySpecularGroupF );
+  mySpecularColorF = new QtxColorButton( mySpecularGroupF );
+  mySpecularColorF->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+  connect( mySpecularColorF, SIGNAL( changed( QColor ) ), this, SIGNAL( changed() ) ); 
+
+  // Specular coefficient
+  QLabel* specCoefficientLab1 = new QLabel( tr( "COEFFICIENT" ), mySpecularGroupF );
+  mySpecularCoefntF = new QtxDoubleSpinBox( mySpecularGroupF );
+  mySpecularCoefntF->setMaximum(1);
+  mySpecularCoefntF->setSingleStep(0.05);
+  connect( mySpecularCoefntF, SIGNAL( valueChanged( double ) ), this, SIGNAL( materialChanged() ) );
+
+  // Specular group box layout
+  QGridLayout* specularLayout1 = new QGridLayout( mySpecularGroupF );
+  specularLayout1->setMargin( MARGIN ); specularLayout1->setSpacing( SPACING );
+  specularLayout1->addWidget( specColorLab1,       0, 0 );
+  specularLayout1->addWidget( mySpecularColorF,    0, 1 );
+  specularLayout1->addWidget( specCoefficientLab1, 1, 0 );
+  specularLayout1->addWidget( mySpecularCoefntF,   1, 1 );
+
+  // ----------------- "Emission" reflection type group box -----------------
+  myEmissionGroupF = new QGroupBox( tr( "EMISSION_GRP" ), w1 );
+  myEmissionGroupF->setCheckable(true);
+  connect( myEmissionGroupF, SIGNAL( toggled( bool ) ), this, SLOT( onReflectionTypeToggled( bool ) ) );
+
+  // Emission color
+  QLabel* emisColorLab1 = new QLabel( tr( "COLOR" ), myEmissionGroupF );
+  myEmissionColorF = new QtxColorButton( myEmissionGroupF );
+  myEmissionColorF->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+  connect( myEmissionColorF, SIGNAL( changed( QColor ) ), this, SIGNAL( changed() ) ); 
+
+  // Emission coefficient
+  QLabel* emisCoefficientLab1 = new QLabel( tr( "COEFFICIENT" ), myEmissionGroupF );
+  myEmissionCoefntF = new QtxDoubleSpinBox( myEmissionGroupF );
+  myEmissionCoefntF->setMaximum(1);
+  myEmissionCoefntF->setSingleStep(0.05);
+  connect( myEmissionCoefntF, SIGNAL( valueChanged( double ) ), this, SIGNAL( materialChanged() ) );
+
+  // Emission group box layout
+  QGridLayout* emissionLayout1 = new QGridLayout( myEmissionGroupF );
+  emissionLayout1->setMargin( MARGIN ); emissionLayout1->setSpacing( SPACING );
+  emissionLayout1->addWidget( emisColorLab1,       0, 0 );
+  emissionLayout1->addWidget( myEmissionColorF,    0, 1 );
+  emissionLayout1->addWidget( emisCoefficientLab1, 1, 0 );
+  emissionLayout1->addWidget( myEmissionCoefntF,   1, 1 );
+
+  // Erase emission group in case of VTK viewer
+  if ( myViewerType == VTK )
+    myEmissionGroupF->hide();
+
+  // Add group boxes to the main grid layout of the frame with material properties
+  gLayout1->addWidget( myAmbientGroupF,  0, 0 );
+  gLayout1->addWidget( myDiffuseGroupF,  0, 1 );
+  gLayout1->addWidget( mySpecularGroupF, 1, 0 );
+  gLayout1->addWidget( myEmissionGroupF, 1, 1 );
+
+  // Shininess
+  QLabel* shininessLab1 = new QLabel( tr( "SHININESS" ), w1 );
+  myShininessF = new QtxDoubleSpinBox( w1 );
+  myShininessF->setMaximum(1);
+  myShininessF->setSingleStep(0.05);
+  connect( myShininessF, SIGNAL( valueChanged( double ) ), this, SIGNAL( materialChanged() ) );
+
+  // Shininess layout
+  QHBoxLayout* shLayout1 = new QHBoxLayout( w1 );
+  shLayout1->setMargin( MARGIN ); frLayout->setSpacing( SPACING );
+  shLayout1->addWidget( shininessLab1 );
+  shLayout1->addWidget( myShininessF );
+
+  // Fill initial vertical layout of the reflection type group box
+  vLayout1->addLayout( gLayout1 );
+  vLayout1->addLayout( shLayout1 );
+  vLayout1->addStretch();
+
+  // ======================= Create a tab for back material ======================= 
+  myMaterialBWidget = new QWidget( myMaterialTab );
+  QVBoxLayout* vLayout2 = new QVBoxLayout( myMaterialBWidget );
+
+  QGridLayout* gLayout2 = new QGridLayout( myMaterialBWidget );
+  gLayout2->setMargin( MARGIN ); gLayout2->setSpacing( SPACING );
+
+  // ----------------- "Ambient" reflection type group box -----------------
+  myAmbientGroupB = new QGroupBox( tr( "AMBIENT_GRP" ), myMaterialBWidget );
+  myAmbientGroupB->setCheckable(true);
+  connect( myAmbientGroupB, SIGNAL( toggled( bool ) ), this, SLOT( onReflectionTypeToggled( bool ) ) ); 
+
+  // Ambient color
+  QLabel* ambColorLab2 = new QLabel( tr( "COLOR" ), myAmbientGroupB );
+  myAmbientColorB = new QtxColorButton( myAmbientGroupB );
+  myAmbientColorB->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+  connect( myAmbientColorB, SIGNAL( changed( QColor ) ), this, SIGNAL( changed() ) ); 
+
+  // Ambient coefficient
+  QLabel* ambCoefficientLab2 = new QLabel( tr( "COEFFICIENT" ), myAmbientGroupB );
+  myAmbientCoefntB = new QtxDoubleSpinBox( myAmbientGroupB );
+  myAmbientCoefntB->setMaximum(1);
+  myAmbientCoefntB->setSingleStep(0.05);
+  connect( myAmbientCoefntB, SIGNAL( valueChanged( double ) ), this, SIGNAL( materialChanged() ) );
+
+  // Ambient group box layout
+  QGridLayout* ambientLayout2 = new QGridLayout( myAmbientGroupB );
+  ambientLayout2->setMargin( MARGIN ); ambientLayout2->setSpacing( SPACING );
+  ambientLayout2->addWidget( ambColorLab2,       0, 0 );
+  ambientLayout2->addWidget( myAmbientColorB,    0, 1 );
+  ambientLayout2->addWidget( ambCoefficientLab2, 1, 0 );
+  ambientLayout2->addWidget( myAmbientCoefntB,   1, 1 );
+
+  // ----------------- "Diffuse" reflection type group box -----------------
+  myDiffuseGroupB = new QGroupBox( tr( "DIFFUSE_GRP" ), myMaterialBWidget );
+  myDiffuseGroupB->setCheckable(true);
+  connect( myDiffuseGroupB, SIGNAL( toggled( bool ) ), this, SLOT( onReflectionTypeToggled( bool ) ) );
+
+  // Diffuse color
+  QLabel* difColorLab2 = new QLabel( tr( "COLOR" ), myDiffuseGroupB );
+  myDiffuseColorB = new QtxColorButton( myDiffuseGroupB );
+  myDiffuseColorB->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+  connect( myDiffuseColorB, SIGNAL( changed( QColor ) ), this, SIGNAL( changed() ) ); 
+
+  // Diffuse coefficient
+  QLabel* difCoefficientLab2 = new QLabel( tr( "COEFFICIENT" ), myDiffuseGroupB );
+  myDiffuseCoefntB = new QtxDoubleSpinBox( myDiffuseGroupB );
+  myDiffuseCoefntB->setMaximum(1);
+  myDiffuseCoefntB->setSingleStep(0.05);
+  connect( myDiffuseCoefntB, SIGNAL( valueChanged( double ) ), this, SIGNAL( materialChanged() ) );
+
+  // Diffuse group box layout
+  QGridLayout* diffuseLayout2 = new QGridLayout( myDiffuseGroupB );
+  diffuseLayout2->setMargin( MARGIN ); diffuseLayout2->setSpacing( SPACING );
+  diffuseLayout2->addWidget( difColorLab2,       0, 0 );
+  diffuseLayout2->addWidget( myDiffuseColorB,    0, 1 );
+  diffuseLayout2->addWidget( difCoefficientLab2, 1, 0 );
+  diffuseLayout2->addWidget( myDiffuseCoefntB,   1, 1 );
+
+  // ----------------- "Specular" reflection type group box -----------------
+  mySpecularGroupB = new QGroupBox( tr( "SPECULAR_GRP" ), myMaterialBWidget );
+  mySpecularGroupB->setCheckable(true);
+  connect( mySpecularGroupB, SIGNAL( toggled( bool ) ), this, SLOT( onReflectionTypeToggled( bool ) ) );
+
+  // Specular color
+  QLabel* specColorLab2 = new QLabel( tr( "COLOR" ), mySpecularGroupB );
+  mySpecularColorB = new QtxColorButton( mySpecularGroupB );
+  mySpecularColorB->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+  connect( mySpecularColorB, SIGNAL( changed( QColor ) ), this, SIGNAL( changed() ) ); 
+
+  // Specular coefficient
+  QLabel* specCoefficientLab2 = new QLabel( tr( "COEFFICIENT" ), mySpecularGroupB );
+  mySpecularCoefntB = new QtxDoubleSpinBox( mySpecularGroupB );
+  mySpecularCoefntB->setMaximum(1);
+  mySpecularCoefntB->setSingleStep(0.05);
+  connect( mySpecularCoefntB, SIGNAL( valueChanged( double ) ), this, SIGNAL( materialChanged() ) );
+
+  // Specular group box layout
+  QGridLayout* specularLayout2 = new QGridLayout( mySpecularGroupB );
+  specularLayout2->setMargin( MARGIN ); specularLayout2->setSpacing( SPACING );
+  specularLayout2->addWidget( specColorLab2,       0, 0 );
+  specularLayout2->addWidget( mySpecularColorB,    0, 1 );
+  specularLayout2->addWidget( specCoefficientLab2, 1, 0 );
+  specularLayout2->addWidget( mySpecularCoefntB,   1, 1 );
+
+  // ----------------- "Emission" reflection type group box -----------------
+  myEmissionGroupB = new QGroupBox( tr( "EMISSION_GRP" ), myMaterialBWidget );
+  myEmissionGroupB->setCheckable(true);
+  connect( myEmissionGroupB, SIGNAL( toggled( bool ) ), this, SLOT( onReflectionTypeToggled( bool ) ) );
+
+  // Emission color
+  QLabel* emisColorLab2 = new QLabel( tr( "COLOR" ), myEmissionGroupB );
+  myEmissionColorB = new QtxColorButton( myEmissionGroupB );
+  myEmissionColorB->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+  connect( myEmissionColorB, SIGNAL( changed( QColor ) ), this, SIGNAL( changed() ) ); 
+
+  // Emission coefficient
+  QLabel* emisCoefficientLab2 = new QLabel( tr( "COEFFICIENT" ), myEmissionGroupB );
+  myEmissionCoefntB = new QtxDoubleSpinBox( myEmissionGroupB );
+  myEmissionCoefntB->setMaximum(1);
+  myEmissionCoefntB->setSingleStep(0.05);
+  connect( myEmissionCoefntB, SIGNAL( valueChanged( double ) ), this, SIGNAL( materialChanged() ) );
+
+  // Emission group box layout
+  QGridLayout* emissionLayout2 = new QGridLayout( myEmissionGroupB );
+  emissionLayout2->setMargin( MARGIN ); emissionLayout2->setSpacing( SPACING );
+  emissionLayout2->addWidget( emisColorLab2,       0, 0 );
+  emissionLayout2->addWidget( myEmissionColorB,    0, 1 );
+  emissionLayout2->addWidget( emisCoefficientLab2, 1, 0 );
+  emissionLayout2->addWidget( myEmissionCoefntB,   1, 1 );
+
+  // Erase emission group in case of VTK viewer
+  if ( myViewerType == VTK )
+    myEmissionGroupB->hide();
+
+  // Add group boxes to the main grid layout of the frame with material properties
+  gLayout2->addWidget( myAmbientGroupB,  0, 0 );
+  gLayout2->addWidget( myDiffuseGroupB,  0, 1 );
+  gLayout2->addWidget( mySpecularGroupB, 1, 0 );
+  gLayout2->addWidget( myEmissionGroupB, 1, 1 );
+
+  // Shininess
+  QLabel* shininessLab2 = new QLabel( tr( "SHININESS" ), myMaterialBWidget );
+  myShininessB = new QtxDoubleSpinBox( myMaterialBWidget );
+  myShininessB->setMaximum(1);
+  myShininessB->setSingleStep(0.05);
+  connect( myShininessB, SIGNAL( valueChanged( double ) ), this, SIGNAL( materialChanged() ) );
+
+  // Shininess layout
+  QHBoxLayout* shLayout2 = new QHBoxLayout( myMaterialBWidget );
+  shLayout2->setMargin( MARGIN ); frLayout->setSpacing( SPACING );
+  shLayout2->addWidget( shininessLab2 );
+  shLayout2->addWidget( myShininessB );
+
+  // Fill initial vertical layout of the reflection type group box
+  vLayout2->addLayout( gLayout2 );
+  vLayout2->addLayout( shLayout2 );
+  vLayout2->addStretch();
+
+  // Add tabs to material tab widget
+  myMaterialTab->addTab( w1, tr( "Front material" ) );
+  myMaterialTab->addTab( myMaterialBWidget, tr( "Back material" ) );
+
+  // Initialize dialog box
+  setFocusProxy( fr );
+  setButtonPosition( Right, Close );
+  setDialogFlags( AlignOnce );
+  myMaterialList->setEditTriggers( QAbstractItemView::EditKeyPressed );
+
+  // ! RESOURCES
+  QStringList globalMaterials = resourceMgr()->materials( Material_ResourceMgr::Global );
+  QStringList userMaterials = resourceMgr()->materials( Material_ResourceMgr::User );
+
+  QListWidgetItem* item;
+
+  // Current material
+  item = new QListWidgetItem( tr( "[ Current ]" ) );
+  item->setForeground( QColor( Qt::red ) );
+  item->setData( TypeRole, QVariant( Current ) );
+  myMaterialList->addItem( item );
+  // Default material
+  item = new QListWidgetItem( tr( "[ Default ]" ) );
+  item->setForeground( QColor( Qt::green ) );
+  item->setData( TypeRole, QVariant( Default ) );
+  myMaterialList->addItem( item );  
+  // ! RESOURCES
+  // Global materials
+  foreach ( QString sname, globalMaterials ) {
+    item = new QListWidgetItem( sname );
+    item->setForeground( QColor( Qt::blue ) );
+    item->setData( TypeRole, QVariant( Global ) );
+    item->setData( NameRole, QVariant( sname ) );
+    myMaterialList->addItem( item );
+  }
+  // ! RESOURCES
+  // User materials
+  foreach ( QString sname, userMaterials ) {
+    item = new QListWidgetItem( sname );
+    item->setData( TypeRole, QVariant( User ) );
+    item->setData( NameRole, QVariant( sname ) );
+    item->setFlags( item->flags() | Qt::ItemIsEditable );
+    myMaterialList->addItem( item );
+  }
+  
+  // Connect signals
+  connect( myMaterialTab,       SIGNAL( currentChanged( int ) ),
+          this,                SLOT( onCurrentTabChanged( int ) ) );
+  connect( myBackMaterialCheck, SIGNAL( toggled( bool ) ),
+          this,                SLOT( onBackMaterialChecked( bool ) ) );
+
+  connect( myMaterialList,      SIGNAL( itemSelectionChanged() ),
+          this,                SLOT( onMaterialChanged() ) );
+  connect( myMaterialList,      SIGNAL( itemChanged( QListWidgetItem* ) ),       
+           this,                SLOT( onItemChanged( QListWidgetItem* ) ) );
+  connect( myMaterialList,      SIGNAL( itemDoubleClicked( QListWidgetItem* ) ), 
+           this,                SLOT( onApply() ) );
+
+  connect( this, SIGNAL( changed() ),      this, SIGNAL( materialChanged() ) );
+  connect( this, SIGNAL( materialChanged() ), this, SLOT( onChanged() ) );
+  
+  connect( this, SIGNAL( dlgApply() ), this, SLOT( onApply() ) );
+  connect( this, SIGNAL( dlgHelp() ),  this, SLOT( onHelp() ) );
+
+  // Initialize current fornt and back material models of the selected shape
+  if ( app ) {
+    LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
+    if ( aSelMgr ) {
+      SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(app->activeStudy());
+      if( aStudy ) {
+       SALOME_ListIO selected;
+       aSelMgr->selectedObjects( selected );
+
+       Handle(SALOME_InteractiveObject) FirstIOS =  selected.First();
+       if ( !FirstIOS.IsNull() ) {
+         SUIT_ViewWindow* window = app->desktop()->activeWindow();
+         int aMgrId = window->getViewManager()->getGlobalId();
+         
+         QString aMaterialF;
+         QString aMaterialB;
+
+         for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
+
+           PropMap aPropMap = aStudy->getObjectPropMap( aMgrId, It.Value()->getEntry() );
+           aMaterialF = aPropMap.value(FRONT_MATERIAL_PROP).toString();            
+           aMaterialB = aPropMap.value(BACK_MATERIAL_PROP).toString();
+             
+           if ( !aMaterialF.isEmpty() ) {
+             
+             QStringList aPropsF = aMaterialF.split(DIGIT_SEPARATOR);
+             
+             myCurrentModelF = Material_Model::getMaterialModel( aPropsF );            
+             
+             if ( !aMaterialB.isEmpty() ) {            
+               QStringList aPropsB = aMaterialB.split(DIGIT_SEPARATOR);                
+               myCurrentModelB = Material_Model::getMaterialModel( aPropsB );
+               
+               myBackMaterialCheck->setChecked( true );
+             }
+             else {
+               myCurrentModelB = Material_Model::getMaterialModel( aPropsF );
+               
+               myBackMaterialCheck->setChecked( false );
+               myMaterialTab->removeTab( 1 );
+             }
+             
+             break;
+           }
+         }
+           
+         if ( aMaterialF.isEmpty() ) {
+           myCurrentModelF = new Material_Model();
+           myCurrentModelF->fromResources( SUIT_Session::session()->resourceMgr(), "Geometry" );
+
+           myCurrentModelB = new Material_Model();
+           myCurrentModelB->fromResources( SUIT_Session::session()->resourceMgr(), "Geometry", false );
+         }
+       }
+      }
+    }
+  }
+
+  myMaterialList->setCurrentRow( 0 );
+  myMaterialListFId = 0;
+  myMaterialListBId = 0;
+
+  myIsBTabWasActivated = false;
+
+  myHelpFileName = "material_page.html";
+}
+
+/*!
+  \brief Destructor
+*/
+GEOMToolsGUI_MaterialPropertiesDlg::~GEOMToolsGUI_MaterialPropertiesDlg()
+{
+  if ( myCurrentModelF )
+    delete myCurrentModelF;
+
+  if ( myCurrentModelB )
+    delete myCurrentModelB;
+}
+
+/*!
+  \brief Called when "OK" button is clicked
+*/
+void GEOMToolsGUI_MaterialPropertiesDlg::accept()
+{
+  onApply();
+  QtxDialog::accept();
+}
+
+/*!
+  \brief Process key press event
+  \param e key event
+*/
+void GEOMToolsGUI_MaterialPropertiesDlg::keyPressEvent( QKeyEvent* e )
+{
+  if ( e->key() == Qt::Key_Delete ) {
+    QListWidgetItem* item = myMaterialList->currentItem();
+    if ( item && item->data( TypeRole ).toInt() == User ) {
+      if ( QMessageBox::question( this,
+                                  tr( "Delete user material" ),
+                                  tr( "Remove material %1?" ).arg( item->text() ),
+                                  QMessageBox::Yes | QMessageBox::No,
+                                  QMessageBox::Yes ) == QMessageBox::Yes ) {
+        resourceMgr()->remove( item->data( NameRole ).toString() );
+        resourceMgr()->save();
+        delete item;
+      }
+    }
+  }
+  QtxDialog::keyPressEvent( e );
+}
+
+/*!
+  \brief Get GEOM materials resource manager
+  \return materials resource manager
+*/
+Material_ResourceMgr* GEOMToolsGUI_MaterialPropertiesDlg::resourceMgr()
+{
+  if ( !myResMgr )
+    myResMgr = new Material_ResourceMgr();
+  return myResMgr;
+}
+
+/*!
+  \brief Initialize dialog box fields from material model
+  \param model material model
+*/
+void GEOMToolsGUI_MaterialPropertiesDlg::fromModel( Material_Model* model)
+{
+  if ( !model ) return;
+
+  bool isReflectionTypeActive;
+
+  if ( isFrontTabActive() ) { // Fill in front material tab
+    
+    // Ambient reflection type
+    isReflectionTypeActive = model->hasAmbientReflection();
+    myAmbientGroupF->setChecked( isReflectionTypeActive );
+    if ( isReflectionTypeActive ) {
+      // Load ambient color
+      myAmbientColorF->setColor( model->color(Material_Model::Ambient) );
+      // Load ambient coefficient
+      myAmbientCoefntF->setValue( model->coefficient(Material_Model::Ambient) );
+    }
+    
+    // Diffuse reflection type
+    isReflectionTypeActive = model->hasDiffuseReflection();
+    myDiffuseGroupF->setChecked( isReflectionTypeActive );
+    if ( isReflectionTypeActive ) {
+      // Load diffuse color
+      myDiffuseColorF->setColor( model->color(Material_Model::Diffuse) );
+      // Load diffuse coefficient
+      myDiffuseCoefntF->setValue( model->coefficient(Material_Model::Diffuse) );
+    }
+    
+    // Specular reflection type
+    isReflectionTypeActive = model->hasSpecularReflection();
+    mySpecularGroupF->setChecked( isReflectionTypeActive );
+    if ( isReflectionTypeActive ) {
+      // Load specular color
+      mySpecularColorF->setColor( model->color(Material_Model::Specular) );
+      // Load specular coefficient
+      mySpecularCoefntF->setValue( model->coefficient(Material_Model::Specular) );
+    }
+    
+    // Emission reflection type
+    isReflectionTypeActive = model->hasEmissionReflection();
+    myEmissionGroupF->setChecked( isReflectionTypeActive );
+    if ( isReflectionTypeActive ) {
+      // Load emission color
+      myEmissionColorF->setColor( model->color(Material_Model::Emission) );
+      // Load emission coefficient
+      myEmissionCoefntF->setValue( model->coefficient(Material_Model::Emission) );
+    }
+    
+    // Shininess
+    myShininessF->setValue( model->shininess() );
+    
+  }
+  else { // Fill in back material tab
+    
+    // Ambient reflection type
+    isReflectionTypeActive = model->hasAmbientReflection();
+    myAmbientGroupB->setChecked( isReflectionTypeActive );
+    if ( isReflectionTypeActive ) {
+      // Load ambient color
+      myAmbientColorB->setColor( model->color(Material_Model::Ambient) );
+      // Load ambient coefficient
+      myAmbientCoefntB->setValue( model->coefficient(Material_Model::Ambient) );
+    }
+    
+    // Diffuse reflection type
+    isReflectionTypeActive = model->hasDiffuseReflection();
+    myDiffuseGroupB->setChecked( isReflectionTypeActive );
+    if ( isReflectionTypeActive ) {
+      // Load diffuse color
+      myDiffuseColorB->setColor( model->color(Material_Model::Diffuse) );
+      // Load diffuse coefficient
+      myDiffuseCoefntB->setValue( model->coefficient(Material_Model::Diffuse) );
+    }
+    
+    // Specular reflection type
+    isReflectionTypeActive = model->hasSpecularReflection();
+    mySpecularGroupB->setChecked( isReflectionTypeActive );
+    if ( isReflectionTypeActive ) {
+      // Load specular color
+      mySpecularColorB->setColor( model->color(Material_Model::Specular) );
+      // Load specular coefficient
+      mySpecularCoefntB->setValue( model->coefficient(Material_Model::Specular) );
+    }
+    
+    // Emission reflection type
+    isReflectionTypeActive = model->hasEmissionReflection();
+    myEmissionGroupB->setChecked( isReflectionTypeActive );
+    if ( isReflectionTypeActive ) {
+      // Load emission color
+      myEmissionColorB->setColor( model->color(Material_Model::Emission) );
+      // Load emission coefficient
+      myEmissionCoefntB->setValue( model->coefficient(Material_Model::Emission) );
+    }
+    
+    // Shininess
+    myShininessB->setValue( model->shininess() );
+    
+  }
+}
+/*!
+  \brief Save values from dialog box fields to material model
+  \param model material model
+*/
+void GEOMToolsGUI_MaterialPropertiesDlg::toModel( Material_Model* model ) const
+{
+  if ( !model ) return;
+    
+  if ( isFrontTabActive() )
+    toFrontModel( model );
+  else
+    toBackModel( model );
+}
+
+/*!
+  \brief Save values from dialog box fields to front material model
+  \param model front material model to be filled
+*/
+void GEOMToolsGUI_MaterialPropertiesDlg::toFrontModel( Material_Model* model ) const
+{
+  if ( !model ) return;
+    
+  // "Ambient" reflection type
+  if ( myAmbientGroupF->isChecked() ) {
+    model->setColor( Material_Model::Ambient, myAmbientColorF->color() );
+    model->setCoefficient( Material_Model::Ambient, myAmbientCoefntF->value() );
+  }
+  else {
+    model->removeColor( Material_Model::Ambient );
+    model->removeCoefficient( Material_Model::Ambient );
+  }
+  
+  // "Diffuse" reflection type
+  if ( myDiffuseGroupF->isChecked() ) {
+    model->setColor( Material_Model::Diffuse, myDiffuseColorF->color() );
+    model->setCoefficient( Material_Model::Diffuse, myDiffuseCoefntF->value() );
+  }
+  else {
+    model->removeColor( Material_Model::Diffuse );
+    model->removeCoefficient( Material_Model::Diffuse );
+  }
+  
+  // "Specular" reflection type
+  if ( mySpecularGroupF->isChecked() ) {
+    model->setColor( Material_Model::Specular, mySpecularColorF->color() );
+    model->setCoefficient( Material_Model::Specular, mySpecularCoefntF->value() );
+  }
+  else {
+    model->removeColor( Material_Model::Specular );
+    model->removeCoefficient( Material_Model::Specular );
+  }
+  
+  // "Emission" reflection type
+  if ( myEmissionGroupF->isChecked() ) {
+    model->setColor( Material_Model::Emission, myEmissionColorF->color() );
+    model->setCoefficient( Material_Model::Emission, myEmissionCoefntF->value() );
+  }
+  else {
+    model->removeColor( Material_Model::Emission );
+    model->removeCoefficient( Material_Model::Emission );
+  }
+  
+  // Shininess
+  model->setShininess( myShininessF->value() );
+}
+
+/*!
+  \brief Save values from dialog box fields to back material model
+  \param model back material model to be filled
+*/
+void GEOMToolsGUI_MaterialPropertiesDlg::toBackModel( Material_Model* model ) const
+{
+  if ( !model )
+    return;
+
+  // "Ambient" reflection type
+  if ( myAmbientGroupB->isChecked() ) {
+    model->setColor( Material_Model::Ambient, myAmbientColorB->color() );
+    model->setCoefficient( Material_Model::Ambient, myAmbientCoefntB->value() );
+  }
+  else {
+    model->removeColor( Material_Model::Ambient );
+    model->removeCoefficient( Material_Model::Ambient );
+  }
+  
+  // "Diffuse" reflection type
+  if ( myDiffuseGroupB->isChecked() ) {
+    model->setColor( Material_Model::Diffuse, myDiffuseColorB->color() );
+    model->setCoefficient( Material_Model::Diffuse, myDiffuseCoefntB->value() );
+  }
+  else {
+    model->removeColor( Material_Model::Diffuse );
+    model->removeCoefficient( Material_Model::Diffuse );
+  }
+  
+  // "Specular" reflection type
+  if ( mySpecularGroupB->isChecked() ) {
+    model->setColor( Material_Model::Specular, mySpecularColorB->color() );
+    model->setCoefficient( Material_Model::Specular, mySpecularCoefntB->value() );
+  }
+  else {
+    model->removeColor( Material_Model::Specular );
+    model->removeCoefficient( Material_Model::Specular );
+  }
+  
+  // "Emission" reflection type
+  if ( myEmissionGroupB->isChecked() ) {
+    model->setColor( Material_Model::Emission, myEmissionColorB->color() );
+    model->setCoefficient( Material_Model::Emission, myEmissionCoefntB->value() );
+  }
+  else {
+    model->removeColor( Material_Model::Emission );
+    model->removeCoefficient( Material_Model::Emission );
+  }
+  
+  // Shininess
+  model->setShininess( myShininessB->value() );
+}
+
+/*!
+  \brief Find unique name for the material name
+  \param name material name template
+  \param item if not 0, used to be ignored when browsing through items list
+  \param addSuffix if \c true, the integrer suffix is always added to the material name (otherwise
+  suffix is added only if item name is not unique)
+  \return new unique material name
+*/
+QString GEOMToolsGUI_MaterialPropertiesDlg::findUniqueName( const QString& name, QListWidgetItem* item, bool addSuffix )
+{
+  bool found = false;
+  int idx = 0;
+  for( int i = 2; i < myMaterialList->count(); i++ ) {
+    if ( item == myMaterialList->item( i ) ) continue;
+    QString iname = myMaterialList->item( i )->text();
+    if ( iname == name ) {
+      found = true;
+    }
+    else {
+      iname = iname.mid( name.length() ).trimmed();
+      bool ok = false;
+      int nx = iname.toInt( &ok );
+      if ( ok ) idx = qMax( idx, nx );
+    }
+  }
+  return found || addSuffix ? QString( "%1 %2" ).arg( name ).arg( idx+1 ) : name;
+}
+
+/*!
+  \brief Check if tab with front material properties is currently active
+  \return true if front material tab is active
+*/
+bool GEOMToolsGUI_MaterialPropertiesDlg::isFrontTabActive() const
+{
+  return ( myMaterialTab->currentIndex() == 0 ? true : false );
+}
+
+/*!
+  \brief Called when "Apply" button is pressed
+*/
+void GEOMToolsGUI_MaterialPropertiesDlg::onApply()
+{  
+  // save user materials
+  resourceMgr()->save();
+
+  toFrontModel( myCurrentModelF );
+  if ( myBackMaterialCheck->isChecked() && myIsBTabWasActivated )
+    toBackModel( myCurrentModelB );
+
+  SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
+  if ( !app )
+    return;
+  LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
+  if ( !aSelMgr )
+    return;
+  
+  SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(app->activeStudy());
+  
+  if(!aStudy)
+    return;
+  
+  SALOME_ListIO selected;
+  aSelMgr->selectedObjects( selected );
+  if ( selected.IsEmpty() )
+    return;
+
+  Handle(SALOME_InteractiveObject) FirstIOS =  selected.First();
+  if ( FirstIOS.IsNull() )
+    return;
+        
+  SUIT_ViewWindow* window = app->desktop()->activeWindow();
+  int aMgrId = window->getViewManager()->getGlobalId();
+
+  // Parse material properties and form a string for persistent purpose
+  QString aMaterialF = myCurrentModelF->getMaterialProperty();
+  QString aMaterialB;
+  if ( myBackMaterialCheck->isChecked() )
+    aMaterialB = myCurrentModelB->getMaterialProperty();
+  
+  if ( myViewerType == VTK ) {    
+    // Get material properties from the current model
+    /*
+    vtkProperty* aPropertyF;
+    if ( !unsetMaterial )
+      aPropertyF = myCurrentModelF->getMaterialVTKProperty();
+    */
+    vtkProperty* aPropertyF = myCurrentModelF->getMaterialVTKProperty();
+    vtkProperty* aPropertyB = aPropertyF;
+    if ( myBackMaterialCheck->isChecked() )
+      aPropertyB = myCurrentModelB->getMaterialVTKProperty();
+
+    SVTK_ViewWindow* vtkVW = dynamic_cast<SVTK_ViewWindow*>( window );
+    if ( !vtkVW )
+      return;
+    SVTK_View* aView = vtkVW->getView();
+
+    SUIT_OverrideCursor();
+    for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
+
+      /*
+      if ( unsetMaterial || aMaterialF.isEmpty() )
+       // Unset material for the selected shape
+       aisShape->UnsetMaterial();
+      else
+       // Set material for the selected shape
+      */
+       aView->SetMaterial( It.Value(), aPropertyF, aPropertyB );
+
+      // Persistent
+      aStudy->setObjectProperty( aMgrId, It.Value()->getEntry(), FRONT_MATERIAL_PROP, aMaterialF );
+      aStudy->setObjectProperty( aMgrId, It.Value()->getEntry(), BACK_MATERIAL_PROP, aMaterialB );
+    } // for...
+    aView->Repaint();
+    GeometryGUI::Modified();
+  } // if ( VTK )
+        
+  else if ( myViewerType == OCC ) {
+    // Get material properties from the current model
+    /*
+    Graphic3d_MaterialAspect aMatF;
+    if ( !unsetMaterial )
+      aMatF = myCurrentModelF->getMaterialOCCAspect();
+    */
+    Graphic3d_MaterialAspect aMatF = myCurrentModelF->getMaterialOCCAspect();
+    Graphic3d_MaterialAspect aMatB = aMatF;
+    if ( myBackMaterialCheck->isChecked() )
+      aMatB = myCurrentModelB->getMaterialOCCAspect();
+
+    Handle(GEOM_AISShape) aisShape;
+    
+    SUIT_OverrideCursor();
+    OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*>( window->getViewManager()->getViewModel() );
+    if ( !vm )
+      return;
+
+    GEOMBase* gb = new GEOMBase();
+
+    Handle(AIS_InteractiveContext) ic = vm->getAISContext();
+    for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
+      aisShape = gb->ConvertIOinGEOMAISShape( It.Value(), true );
+      if ( !aisShape.IsNull() ) {
+
+       if(!aisShape->HasInteractiveContext())
+         aisShape->SetContext(ic);
+
+       /*
+       if ( unsetMaterial || aMaterialF.isEmpty() )
+         // Unset material for the selected shape
+         aisShape->UnsetMaterial();
+       else
+       */
+         if ( myBackMaterialCheck->isChecked() ) {
+           // Set front material for the selected shape
+           aisShape->SetCurrentFacingModel(Aspect_TOFM_FRONT_SIDE);
+           aisShape->SetMaterial(aMatF);
+           // Set back material for the selected shape
+           aisShape->SetCurrentFacingModel(Aspect_TOFM_BACK_SIDE);
+           aisShape->SetMaterial(aMatB);
+           // Return to the default facing mode
+           aisShape->SetCurrentFacingModel(Aspect_TOFM_BOTH_SIDE);
+         }
+         else {
+           // Set the same front and back (is equal to front) materials for the selected shape
+           aisShape->SetMaterial(aMatF);
+         }
+
+       if (aisShape->DisplayMode() != AIS_Shaded/*aisShape->DisplayMode() == GEOM_AISShape::ShadingWithEdges*/)
+         ic->RecomputePrsOnly( aisShape, Standard_False );
+
+       // Persistent   
+       aStudy->setObjectProperty( aMgrId, It.Value()->getEntry(), FRONT_MATERIAL_PROP, aMaterialF );
+       aStudy->setObjectProperty( aMgrId, It.Value()->getEntry(), BACK_MATERIAL_PROP, aMaterialB );
+      }
+    } // for...    
+    ic->UpdateCurrentViewer();
+    GeometryGUI::Modified();
+  } // if ( OCC )
+}
+
+/*!
+  \brief Called when "Help" button is pressed
+*/
+void GEOMToolsGUI_MaterialPropertiesDlg::onHelp()
+{
+  LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
+  if (app) {
+    GeometryGUI* aGeomGUI = dynamic_cast<GeometryGUI*>( app->module( "Geometry" ) );
+    app->onHelpContextModule(aGeomGUI ? app->moduleName(aGeomGUI->moduleName()) : QString(""), myHelpFileName);
+  }
+  else {
+                QString platform;
+#ifdef WIN32
+                platform = "winapplication";
+#else
+                platform = "application";
+#endif
+    SUIT_MessageBox::warning(0, QObject::tr("WRN_WARNING"),
+                             QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
+                             arg(app->resourceMgr()->stringValue("ExternalBrowser", platform)).arg(myHelpFileName),
+                             QObject::tr("BUT_OK"));
+  }  
+}
+
+/*!
+  \brief Called when user check/uncheck "Enable back material" check box
+  \param theIsChecked the check state of the check box
+*/
+void GEOMToolsGUI_MaterialPropertiesDlg::onBackMaterialChecked( bool theIsChecked )
+{
+  if ( theIsChecked ) {
+    // Tab with back material properties is displayed
+    myMaterialTab->addTab( myMaterialBWidget, tr( "Back material" ) );
+
+    // Create a current model of back material
+    if ( !myCurrentModelB ) {
+      myCurrentModelB = new Material_Model();
+      myCurrentModelB->fromResources( SUIT_Session::session()->resourceMgr(), "Geometry", false );
+    }
+    
+    myMaterialListBId = 0;
+  }
+  else {
+    // Tab with back material properties is hidden
+    myMaterialTab->removeTab( 1 );
+    
+    // Remove the current model for back material
+    if ( myCurrentModelB ) {
+      delete myCurrentModelB;
+      myCurrentModelB = 0;
+    }
+  }
+}
+
+/*!
+  \brief Called when user activates material tab
+  \param theIndex the index of the tab which was activated by the user
+*/
+void GEOMToolsGUI_MaterialPropertiesDlg::onCurrentTabChanged(int theIndex)
+{
+  blockSignals( true );
+
+  // Change selection in the list of materials
+  if ( isFrontTabActive() )
+    myMaterialList->setCurrentRow( myMaterialListFId );
+  else if ( myBackMaterialCheck->isChecked() )
+    myMaterialList->setCurrentRow( myMaterialListBId );    
+
+  if ( theIndex == 1 )
+    myIsBTabWasActivated = true;
+
+  blockSignals( false );
+
+  onMaterialChanged();
+}
+
+/*!
+  \brief Called when user selects any material item in the materials list
+*/
+void GEOMToolsGUI_MaterialPropertiesDlg::onMaterialChanged()
+{
+  blockSignals( true );
+
+  QListWidgetItem* item = myMaterialList->currentItem();
+  int type = item->data( TypeRole ).toInt();
+  
+  Material_Model* model = 0;
+
+  bool isFrontTab = isFrontTabActive();
+
+  if ( isFrontTab )
+    myMaterialListFId = myMaterialList->currentRow();
+  else
+    myMaterialListBId = myMaterialList->currentRow();
+
+  switch ( type ) {    
+  case Current:
+    // current material
+    model = ( isFrontTab ? myCurrentModelF : myCurrentModelB );
+    break;    
+  case Default:
+    // default material
+    model = new Material_Model();
+    model->fromResources( SUIT_Session::session()->resourceMgr(), "Geometry", ( isFrontTab ? true : false ) );
+    break;    
+  case Global:
+  case User:
+    // global material, user material
+    model = new Material_Model();
+    model->fromResources( resourceMgr(), item->data( NameRole ).toString() );
+    break;
+  default:
+    break;
+  }
+
+  fromModel( model );
+  if ( type != Current )
+    delete model;
+
+  blockSignals( false );
+}
+
+/*!
+  \brief Called when any material parameter is changed by the user
+*/
+void GEOMToolsGUI_MaterialPropertiesDlg::onChanged()
+{
+  QListWidgetItem* item = myMaterialList->currentItem();
+  int type = item->data( TypeRole ).toInt();
+
+  bool isFrontTab = isFrontTabActive();
+
+  // for the current and user schemas do not perform any actions
+  if ( type == Current ) {    
+    Material_Model model = ( isFrontTab ? *( myCurrentModelF ) : *( myCurrentModelB ) );
+    toModel( &model );
+    model.save( 0, QString(), isFrontTab );
+    blockSignals( true );
+    fromModel( &model );
+    blockSignals( false );    
+  }
+  else if ( type == User ) {    
+    Material_Model model;
+    toModel( &model );
+    QString oldName = item->data( NameRole ).toString(), newName = item->text();
+    if ( oldName == newName ) {
+      model.save( resourceMgr(), oldName, isFrontTab );
+    }
+    else {
+      resourceMgr()->remove( oldName );
+      model.save( resourceMgr(), newName, isFrontTab );
+      item->setData( NameRole, newName );
+    }
+    blockSignals( true );
+    fromModel( &model );
+    blockSignals( false );    
+  }
+  else {
+    // if user tries to change global (or default, or no material) material,
+    // we create a new user material basing on selected one
+    QString newName = findUniqueName( tr( "CUSTOM_MATERIAL" ), 0, true );
+    item = new QListWidgetItem( newName );
+    item->setData( TypeRole, QVariant( User ) );
+    item->setData( NameRole, QVariant( newName ) );
+    item->setFlags( item->flags() | Qt::ItemIsEditable );
+    myMaterialList->addItem( item );
+    
+    Material_Model model;
+    toModel( &model );
+    model.save( resourceMgr(), newName, isFrontTab );
+    
+    myMaterialList->setCurrentItem( item );
+
+    if ( isFrontTab )
+      myMaterialListFId = myMaterialList->currentRow();
+    else
+      myMaterialListBId = myMaterialList->currentRow();
+
+  }
+}
+
+/*!
+  \brief Called when user material is renamed by the user
+*/
+void GEOMToolsGUI_MaterialPropertiesDlg::onItemChanged( QListWidgetItem* item )
+{
+  QString newName = item->text();
+  QString uniqueName = findUniqueName( newName, item );
+  if ( uniqueName != newName ) {
+    myMaterialList->blockSignals( true );
+    item->setText( uniqueName );
+    myMaterialList->blockSignals( false );
+  }
+  onChanged();
+}                               
+
+/*!
+  \brief Called when widget effect is changed
+*/
+void GEOMToolsGUI_MaterialPropertiesDlg::onReflectionTypeToggled( bool theIsOn )
+{
+  QGroupBox* anObj = (QGroupBox*)sender();
+
+  // Set an empty values for color and coefficient
+  // of the checked/unchecked reflection type
+  QColor c;
+
+
+  // Make changes on front material tab
+  if ( anObj == myAmbientGroupF ) {    
+    myAmbientColorF->setColor( c );
+    myAmbientCoefntF->setValue( 0.0 );
+  }
+  else if ( anObj == myDiffuseGroupF ) {
+    myDiffuseColorF->setColor( c );
+    myDiffuseCoefntF->setValue( 0.0 );
+  }
+  else if ( anObj == mySpecularGroupF ) {
+    mySpecularColorF->setColor( c );
+    mySpecularCoefntF->setValue( 0.0 );
+  }
+  else if ( anObj == myEmissionGroupF ) {
+    myEmissionColorF->setColor( c );
+    myEmissionCoefntF->setValue( 0.0 );
+  }
+
+  // Make changes on back material tab    
+  if ( anObj == myAmbientGroupB ) {    
+    myAmbientColorB->setColor( c );
+    myAmbientCoefntB->setValue( 0.0 );
+  }
+  else if ( anObj == myDiffuseGroupB ) {
+    myDiffuseColorB->setColor( c );
+    myDiffuseCoefntB->setValue( 0.0 );
+  }
+  else if ( anObj == mySpecularGroupB ) {
+    mySpecularColorB->setColor( c );
+    mySpecularCoefntB->setValue( 0.0 );
+  }
+  else if ( anObj == myEmissionGroupB ) {
+    myEmissionColorB->setColor( c );
+    myEmissionCoefntB->setValue( 0.0 );
+  }
+  
+  emit( changed() );
+}
diff --git a/src/GEOMToolsGUI/GEOMToolsGUI_MaterialPropertiesDlg.h b/src/GEOMToolsGUI/GEOMToolsGUI_MaterialPropertiesDlg.h
new file mode 100644 (file)
index 0000000..77c4b26
--- /dev/null
@@ -0,0 +1,163 @@
+// Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+// File   : GEOMToolsGUI_MaterialPropertiesDlg.h
+// Author : Margarita KARPUNINA, Open CASCADE S.A.S. (margarita.karpunina@opencascade.com)
+//
+#ifndef GEOMTOOLSGUI_MATERIALPROPERTIESDLG_H
+#define GEOMTOOLSGUI_MATERIALPROPERTIESDLG_H
+
+#include "GEOM_ToolsGUI.hxx"
+
+#include <QtxDialog.h>
+#include <QFrame>
+#include <QMap>
+
+class QCheckBox;
+class QGroupBox;
+class QLabel;
+class QListWidget;
+class QListWidgetItem;
+class QPushButton;
+class QSpinBox;
+class QTabWidget;
+
+class QtxColorButton;
+class QtxDoubleSpinBox;
+
+class Material_Model;
+class Material_ResourceMgr;
+
+class GEOMTOOLSGUI_EXPORT GEOMToolsGUI_MaterialPropertiesDlg : public QtxDialog
+{
+  Q_OBJECT
+
+  enum { Current, Default, Global, User };
+  enum { TypeRole = Qt::UserRole + 123, NameRole  };
+
+  //! Enumeration of viewer types
+  typedef enum {
+    OCC,  //!< OCC viewer
+    VTK  //!< VTK viewer
+  } ViewerType;
+
+public:
+  GEOMToolsGUI_MaterialPropertiesDlg( QWidget* = 0 );
+  ~GEOMToolsGUI_MaterialPropertiesDlg();  
+
+  void                  accept();
+
+protected:
+  void                  keyPressEvent( QKeyEvent* );
+
+private:
+  Material_ResourceMgr* resourceMgr();
+
+  void                  fromModel( Material_Model* );
+  void                  toModel( Material_Model* ) const;
+  void                  toFrontModel( Material_Model* ) const;
+  void                  toBackModel( Material_Model* ) const;
+  
+  QString               findUniqueName( const QString&,
+                                       QListWidgetItem* = 0,
+                                       bool = false );
+
+  bool                  isFrontTabActive() const;
+
+signals:
+  void                  materialChanged();
+  void                  changed();
+
+private slots:
+
+  void                  onApply();
+  void                  onHelp();
+
+  void                  onBackMaterialChecked( bool );
+  void                  onCurrentTabChanged( int );
+  void                  onMaterialChanged();
+  void                  onChanged();
+  void                  onItemChanged( QListWidgetItem* );
+  void                  onReflectionTypeToggled( bool );
+
+private:
+  
+  Material_ResourceMgr* myResMgr;
+
+  QCheckBox*            myBackMaterialCheck;
+
+  //! Current material model for front material
+  Material_Model*       myCurrentModelF;
+
+  //! Current material model for back material
+  Material_Model*       myCurrentModelB;
+
+  QListWidget*          myMaterialList;
+  int                   myMaterialListFId;
+  int                   myMaterialListBId;
+
+  QTabWidget*           myMaterialTab;
+  QWidget*              myMaterialBWidget;
+  bool                  myIsBTabWasActivated;
+
+  //! Controls defining front material properties
+  QGroupBox*            myAmbientGroupF;
+  QtxColorButton*       myAmbientColorF;
+  QtxDoubleSpinBox*     myAmbientCoefntF;
+
+  QGroupBox*            myDiffuseGroupF;
+  QtxColorButton*       myDiffuseColorF;
+  QtxDoubleSpinBox*     myDiffuseCoefntF;
+
+  QGroupBox*            mySpecularGroupF;
+  QtxColorButton*       mySpecularColorF;
+  QtxDoubleSpinBox*     mySpecularCoefntF;
+
+  QGroupBox*            myEmissionGroupF;
+  QtxColorButton*       myEmissionColorF;
+  QtxDoubleSpinBox*     myEmissionCoefntF;
+
+  QtxDoubleSpinBox*     myShininessF;
+
+  //! Controls defining back material properties
+  QGroupBox*            myAmbientGroupB;
+  QtxColorButton*       myAmbientColorB;
+  QtxDoubleSpinBox*     myAmbientCoefntB;
+
+  QGroupBox*            myDiffuseGroupB;
+  QtxColorButton*       myDiffuseColorB;
+  QtxDoubleSpinBox*     myDiffuseCoefntB;
+
+  QGroupBox*            mySpecularGroupB;
+  QtxColorButton*       mySpecularColorB;
+  QtxDoubleSpinBox*     mySpecularCoefntB;
+
+  QGroupBox*            myEmissionGroupB;
+  QtxColorButton*       myEmissionColorB;
+  QtxDoubleSpinBox*     myEmissionCoefntB;
+
+  QtxDoubleSpinBox*     myShininessB;
+
+  QString               myHelpFileName;
+
+  ViewerType            myViewerType;
+  
+};
+
+#endif // GEOMTOOLSGUI_MATERIALPROPERTIESDLG_H
index 3447f1f975889231cbff805a8a4747b7163241e8..2de71038a5664439c55d384711ea28ee212658e1 100644 (file)
@@ -28,6 +28,7 @@
 #include <GEOMBase.h>
 #include <GEOM_AISShape.hxx>
 #include <GeometryGUI.h>
+#include <GEOM_Constants.h>
 
 #include <SALOME_ListIO.hxx>
 #include <SALOME_ListIteratorOfListIO.hxx>
index 0404e787c624bf67bf1fa3d41a6c082778b5301b..63afb84f2f687fc663ab9f81d6d8c9cb7641063b 100644 (file)
@@ -35,7 +35,8 @@ salomeinclude_HEADERS =                               \
        GEOMToolsGUI_TransparencyDlg.h          \
        GEOMToolsGUI_DeleteDlg.h                \
        GEOMToolsGUI_MarkerDlg.h                \
-       GEOMToolsGUI_PublishDlg.h
+       GEOMToolsGUI_PublishDlg.h               \
+       GEOMToolsGUI_MaterialPropertiesDlg.h
 
 dist_libGEOMToolsGUI_la_SOURCES =              \
        GEOMToolsGUI.cxx                        \
@@ -45,7 +46,8 @@ dist_libGEOMToolsGUI_la_SOURCES =             \
        GEOMToolsGUI_DeflectionDlg.cxx          \
        GEOMToolsGUI_DeleteDlg.cxx              \
        GEOMToolsGUI_MarkerDlg.cxx              \
-       GEOMToolsGUI_PublishDlg.cxx
+       GEOMToolsGUI_PublishDlg.cxx             \
+       GEOMToolsGUI_MaterialPropertiesDlg.cxx
 
 MOC_FILES =                                    \
        GEOMToolsGUI_TransparencyDlg_moc.cxx    \
@@ -53,7 +55,8 @@ MOC_FILES =                                   \
        GEOMToolsGUI_DeflectionDlg_moc.cxx      \
        GEOMToolsGUI_DeleteDlg_moc.cxx          \
        GEOMToolsGUI_MarkerDlg_moc.cxx          \
-       GEOMToolsGUI_PublishDlg_moc.cxx
+       GEOMToolsGUI_PublishDlg_moc.cxx         \
+       GEOMToolsGUI_MaterialPropertiesDlg_moc.cxx
 
 nodist_libGEOMToolsGUI_la_SOURCES =            \
        $(MOC_FILES)
@@ -72,6 +75,7 @@ libGEOMToolsGUI_la_CPPFLAGS =         \
        $(CORBA_INCLUDES)               \
        -I$(srcdir)/../OBJECT           \
        -I$(srcdir)/../GEOMBase         \
+       -I$(srcdir)/../Material         \
        -I$(srcdir)/../GEOMGUI          \
        -I$(srcdir)/../GEOMClient       \
        -I$(srcdir)/../GEOMImpl         \
@@ -79,5 +83,6 @@ libGEOMToolsGUI_la_CPPFLAGS =         \
 
 libGEOMToolsGUI_la_LDFLAGS  =          \
        ../GEOMBase/libGEOMBase.la      \
+       ../Material/libMaterial.la      \
        ../GEOMGUI/libGEOM.la           \
        $(GUI_LDFLAGS) -lVTKViewer -lOCCViewer -lsuit -lSalomeApp -lPyConsole
index 243974ffac4537a73777ba98588dc6713d278863..ad025e3ccefd021a4cc22f92c1da12683befcae8 100644 (file)
@@ -32,7 +32,7 @@ if WITH_OPENCV
 endif
 
 if GEOM_ENABLE_GUI
-  SUBDIRS += OBJECT DlgRef GEOMFiltersSelection GEOMGUI GEOMBase GEOMToolsGUI  \
+  SUBDIRS += OBJECT DlgRef GEOMFiltersSelection Material GEOMGUI GEOMBase GEOMToolsGUI \
              DisplayGUI BasicGUI PrimitiveGUI GenerationGUI EntityGUI BuildGUI \
              BooleanGUI TransformationGUI OperationGUI RepairGUI MeasureGUI    \
              GroupGUI BlocksGUI AdvancedGUI GEOM_SWIG_WITHIHM
diff --git a/src/Material/Makefile.am b/src/Material/Makefile.am
new file mode 100644 (file)
index 0000000..5c19313
--- /dev/null
@@ -0,0 +1,51 @@
+# Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+# File    : Makefile.am
+# Author  : Margarita KARPUNINA, Open CASCADE S.A.S. (margarita.karpunina@opencascade.com)
+# Package : Material
+#
+include $(top_srcdir)/adm_local/unix/make_common_starter.am
+
+# Libraries targets
+lib_LTLIBRARIES = libMaterial.la
+
+# header files 
+salomeinclude_HEADERS =                        \
+       Material.h                      \
+       Material_Model.h                \
+       Material_ResourceMgr.h
+
+dist_libMaterial_la_SOURCES =          \
+       Material_Model.cxx              \
+       Material_ResourceMgr.cxx
+
+# additional information to compile and link file
+libMaterial_la_CPPFLAGS =              \
+       $(QT_INCLUDES)                  \
+       $(VTK_INCLUDES)                 \
+       $(CAS_CPPFLAGS)                 \
+       $(KERNEL_CXXFLAGS)              \
+       $(GUI_CXXFLAGS)                 \
+       -I$(srcdir)/../OBJECT
+
+libMaterial_la_LDFLAGS  =              \
+       $(GUI_LDFLAGS) -lVTKViewer -lOCCViewer -lsuit -lSalomeApp
+
+dist_salomeres_DATA = resources/SalomeMaterial.xml
diff --git a/src/Material/Material.h b/src/Material/Material.h
new file mode 100644 (file)
index 0000000..3f7a39b
--- /dev/null
@@ -0,0 +1,36 @@
+// Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+// File   : Material.h
+// Author : Margarita KARPUNINA, Open CASCADE S.A.S.
+//
+#ifndef MATERIAL_H
+#define MATERIAL_H
+
+#if defined WIN32
+#  if defined MATERIAL_SALOME_EXPORTS || defined MATERIAL_EXPORTS || defined SalomeMaterial_EXPORTS
+#    define MATERIAL_SALOME_EXPORT _declspec( dllexport )
+#  else
+#    define MATERIAL_SALOME_EXPORT _declspec( dllimport )
+#  endif
+#else
+#  define MATERIAL_SALOME_EXPORT  
+#endif
+
+#endif // MATERIAL_H
diff --git a/src/Material/Material_Model.cxx b/src/Material/Material_Model.cxx
new file mode 100644 (file)
index 0000000..e41c1df
--- /dev/null
@@ -0,0 +1,682 @@
+// Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+// File   : Material_Model.cxx
+// Author : Margarita KARPUNINA, Open CASCADE S.A.S. (margarita.karpunina@opencascade.com)
+//
+
+#include "Material_Model.h"
+#include "Material_ResourceMgr.h"
+
+#include <GEOM_Constants.h>
+
+#include <QtxResourceMgr.h>
+#include <SUIT_ResourceMgr.h>
+#include <SUIT_Session.h>
+
+// OCCT Includes
+#include <Graphic3d_AspectFillArea3d.hxx>
+
+// VTK includes
+#include <vtkProperty.h> 
+
+/*!
+  \brief Constructor
+
+  Create new SALOME material model with default properties.
+*/
+Material_Model::Material_Model()
+  : myResourceMgr( 0 )
+{
+  myShininess = 0.0;
+}
+
+/*!
+  \brief Destructor
+*/
+Material_Model::~Material_Model()
+{
+}
+
+/*!
+  \brief Construct material model according to the given list of
+  material properties
+  
+  \param theProps the list of material properties
+  \return material model object with correspondent properties
+  \sa getMaterialProperty()
+*/
+Material_Model* Material_Model::getMaterialModel( QStringList theProps )
+{
+  Material_Model* aModel = new Material_Model();
+
+  foreach ( QString aProp, theProps ) {
+    if ( aProp.isNull() ) continue;
+    
+    // Set current ambient color
+    aModel->setColor( aProp, "AmbientColor=", Material_Model::Ambient );
+    // Set current ambient coefficient
+    aModel->setCoefficient( aProp, "AmbientCoefficient=", Material_Model::Ambient );
+    
+    // Set current diffuse color
+    aModel->setColor( aProp, "DiffuseColor=", Material_Model::Diffuse );
+    // Set current diffuse coefficient
+    aModel->setCoefficient( aProp, "DiffuseCoefficient=", Material_Model::Diffuse );
+    
+    // Set current specular color
+    aModel->setColor( aProp, "SpecularColor=", Material_Model::Specular );
+    // Set current specular coefficient
+    aModel->setCoefficient( aProp, "SpecularCoefficient=", Material_Model::Specular );
+    
+    // Set current emission color
+    aModel->setColor( aProp, "EmissionColor=", Material_Model::Emission );
+    // Set current emission coefficient
+    aModel->setCoefficient( aProp, "EmissionCoefficient=", Material_Model::Emission );
+    
+    // Set current shininess
+    QString aPropName = "Shininess=";
+    int anId = aProp.indexOf(aPropName);
+    if ( anId != -1 ) {
+      bool ok;
+      double aCoef = aProp.right( aProp.length() - (anId+aPropName.length()) ).toDouble(&ok);
+      if ( ok )
+       aModel->setShininess( aCoef );
+    }    
+  }
+
+  return aModel;
+}
+
+/*!
+  \brief Construct string of material properties for this model object
+  
+  \return a string representing a set of material properties
+  \sa getMaterialModel()
+*/
+QString Material_Model::getMaterialProperty()
+{
+  // Parse material properties of the current model and form a string for persistent purpose
+  QString aMaterial;
+
+  bool isReflectionTypeActive;  
+  QColor c;
+  double coef;
+
+  // Ambient reflection
+  isReflectionTypeActive = hasAmbientReflection();
+  if ( isReflectionTypeActive ) {
+    c = color( Material_Model::Ambient );
+    coef = coefficient(Material_Model::Ambient);
+    // Insert properties into persistent string
+    aMaterial = "AmbientColor=%1%2AmbientCoefficient=%3";
+    aMaterial = aMaterial.arg( Qtx::colorToString(c) );
+    aMaterial = aMaterial.arg( DIGIT_SEPARATOR );
+    aMaterial = aMaterial.arg( coef );
+  }
+  // Diffuse reflection
+  isReflectionTypeActive = hasDiffuseReflection();
+  if ( isReflectionTypeActive ) {
+    c = color( Material_Model::Diffuse );
+    coef = coefficient(Material_Model::Diffuse);
+    // Insert properties into persistent string
+    aMaterial += "%1DiffuseColor=%2%3DiffuseCoefficient=%4";
+    aMaterial = aMaterial.arg( DIGIT_SEPARATOR );
+    aMaterial = aMaterial.arg( Qtx::colorToString(c) );
+    aMaterial = aMaterial.arg( DIGIT_SEPARATOR );
+    aMaterial = aMaterial.arg( coef );
+  }
+  // Specular reflection
+  isReflectionTypeActive = hasSpecularReflection();
+  if ( isReflectionTypeActive ) {
+    c = color( Material_Model::Specular );
+    coef = coefficient(Material_Model::Specular);
+    // Insert properties into persistent string
+    aMaterial += "%1SpecularColor=%2%3SpecularCoefficient=%4";
+    aMaterial = aMaterial.arg( DIGIT_SEPARATOR );
+    aMaterial = aMaterial.arg( Qtx::colorToString(c) );
+    aMaterial = aMaterial.arg( DIGIT_SEPARATOR );
+    aMaterial = aMaterial.arg( coef );
+  }
+  // Emission reflection
+  isReflectionTypeActive = hasEmissionReflection();
+  if ( isReflectionTypeActive ) {
+    c = color( Material_Model::Emission );
+    coef = coefficient(Material_Model::Emission);
+    // Insert properties into persistent string
+    aMaterial += "%1EmissionColor=%2%3EmissionCoefficient=%4";
+    aMaterial = aMaterial.arg( DIGIT_SEPARATOR );
+    aMaterial = aMaterial.arg( Qtx::colorToString(c) );
+    aMaterial = aMaterial.arg( DIGIT_SEPARATOR );
+    aMaterial = aMaterial.arg( coef );
+  }
+  if ( !aMaterial.isEmpty() ) {
+    // Shininess
+    // Insert properties into persistent string
+    aMaterial += "%1Shininess=%2";
+    aMaterial = aMaterial.arg( DIGIT_SEPARATOR );
+    aMaterial = aMaterial.arg( shininess() );
+  }
+
+  return aMaterial;
+}
+
+/*!
+  \brief Construct OCCT material aspect object based on the current model
+  
+  \return material aspect object with correspondent properties
+*/
+Graphic3d_MaterialAspect Material_Model::getMaterialOCCAspect()
+{
+  // Get material aspect from the current model
+  Graphic3d_MaterialAspect aMat;
+
+  bool isReflectionTypeActive;
+  QColor c;
+  double coef;
+
+  // Ambient reflection
+  isReflectionTypeActive = hasAmbientReflection();
+  if ( isReflectionTypeActive ) {
+    aMat.SetReflectionModeOn( Graphic3d_TOR_AMBIENT );
+    c = color( Material_Model::Ambient );
+    aMat.SetAmbientColor( Quantity_Color( c.redF(), c.greenF(), c.blueF(), Quantity_TOC_RGB ) );
+    coef = coefficient( Material_Model::Ambient );
+    aMat.SetAmbient( coef );
+  }
+  // Diffuse reflection
+  isReflectionTypeActive = hasDiffuseReflection();
+  if ( isReflectionTypeActive ) {
+    aMat.SetReflectionModeOn( Graphic3d_TOR_DIFFUSE );
+    c = color( Material_Model::Diffuse );
+    aMat.SetDiffuseColor( Quantity_Color( c.redF(), c.greenF(), c.blueF(), Quantity_TOC_RGB ) );
+    coef = coefficient( Material_Model::Diffuse );
+    aMat.SetDiffuse( coef );     
+  }
+  // Specular reflection
+  isReflectionTypeActive = hasSpecularReflection();
+  if ( isReflectionTypeActive ) {
+    aMat.SetReflectionModeOn( Graphic3d_TOR_SPECULAR );
+    c = color( Material_Model::Specular );
+    aMat.SetSpecularColor( Quantity_Color( c.redF(), c.greenF(), c.blueF(), Quantity_TOC_RGB ) );
+    coef = coefficient( Material_Model::Specular );
+    aMat.SetSpecular( coef );
+  }
+  // Emission reflection
+  isReflectionTypeActive = hasEmissionReflection();
+  if ( isReflectionTypeActive ) {
+    aMat.SetReflectionModeOn( Graphic3d_TOR_EMISSION );
+    c = color( Material_Model::Emission );
+    aMat.SetEmissiveColor( Quantity_Color( c.redF(), c.greenF(), c.blueF(), Quantity_TOC_RGB ) );
+    coef = coefficient( Material_Model::Emission );
+    aMat.SetEmissive( coef );
+  }
+  // Shininess
+  aMat.SetShininess( shininess() );
+
+  return aMat;
+}
+
+/*!
+  \brief Construct VTK property with properties of material based on the current model
+  
+  \return VTK property with correspondent material properties
+*/
+vtkProperty* Material_Model::getMaterialVTKProperty()
+{
+  // Get material properties from the current model
+  vtkProperty* aProperty = vtkProperty::New();
+  
+  bool isReflectionTypeActive;
+  QColor c;
+  double coef;
+
+  // Ambient reflection
+  isReflectionTypeActive = hasAmbientReflection();
+  if ( isReflectionTypeActive ) {
+    c = color( Material_Model::Ambient );
+    aProperty->SetAmbientColor( c.redF(), c.greenF(), c.blueF() ); //SalomeApp_Tools::color( c )
+    coef = coefficient( Material_Model::Ambient );
+    aProperty->SetAmbient( coef );
+  }
+  // Diffuse reflection
+  isReflectionTypeActive = hasDiffuseReflection();
+  if ( isReflectionTypeActive ) {
+    c = color( Material_Model::Diffuse );
+    aProperty->SetDiffuseColor( c.redF(), c.greenF(), c.blueF() );
+    coef = coefficient( Material_Model::Diffuse );
+    aProperty->SetDiffuse( coef );      
+  }
+  // Specular reflection
+  isReflectionTypeActive = hasSpecularReflection();
+  if ( isReflectionTypeActive ) {
+    c = color( Material_Model::Specular );
+    aProperty->SetSpecularColor( c.redF(), c.greenF(), c.blueF() );
+    coef = coefficient( Material_Model::Specular );
+    aProperty->SetSpecular( coef );
+  }
+  // Shininess
+  aProperty->SetSpecularPower( shininess()*100.0 );
+
+  return aProperty;
+}
+
+/*!
+  \brief Initialize material model with default values
+*/
+void Material_Model::initDefaults()
+{  
+  // Set default ambient color
+  setColor( Ambient, "#333333" );
+  // Set default ambient coefficient
+  setCoefficient( Ambient, 0.3 );
+
+  // Set default diffuse color
+  setColor( Diffuse, "#000000" );
+  // Set default diffuse coefficient
+  setCoefficient( Diffuse, 0.65 );
+
+  // Set default specular color
+  setColor( Specular, "#ffffff" );
+  // Set default specular coefficient
+  setCoefficient( Specular, 0.0 );
+  
+  // Set default shininess
+  setShininess( 0.039 );
+}
+
+/*!
+  \brief Clear current content of this material model
+*/
+void Material_Model::clearModel()
+{
+  myColors.clear();
+  myCoefficients.clear();
+  myShininess = 0.0;
+}
+
+/*!
+  \brief Initialize material model from the resources
+
+  This function can be used to retrieve material properties from the resource file(s).
+  Note, that paremeters \a theResMgr and \a theResSection are stored by the model to be used
+  later with save() method.
+
+  \param theResMgr resources manager
+  \param theResSection resources section name
+  \sa save()
+*/
+void Material_Model::fromResources( QtxResourceMgr* theResMgr,
+                                   const QString& theResSection,
+                                   bool theIsFront )
+{
+  // Clear current content of the model
+  // before setting properties from resources
+  clearModel();
+
+  myResourceMgr     = theResMgr;
+  myResourceSection = theResSection;
+
+  // init from resource manager
+  if ( !resourceMgr() )
+    return;
+
+  if ( theResSection.compare( "Geometry" ) == 0 ) {
+    if ( theIsFront ) {
+      myResourceSection = theResMgr->stringValue("Geometry", "front_material", "Gold");
+    }
+    else {
+      myResourceSection = theResMgr->stringValue("Geometry", "back_material", "");
+      if ( myResourceSection.isEmpty() )
+       myResourceSection = theResMgr->stringValue("Geometry", "front_material", "Gold");
+    }
+      
+    myResourceMgr = new Material_ResourceMgr();
+  }
+  
+  QString section = resourceSection( theIsFront );
+
+  // If there is no material preference in XML files,
+  // use the default material hardcoded in material model
+  if ( section.isEmpty() ) {
+    initDefaults();
+    return;
+  }
+
+  // Set ambient color
+  if ( resourceMgr()->hasValue( section, "ambient-color" ) ) {
+    setColor( Ambient, resourceMgr()->colorValue( section, "ambient-color" ) );
+  }
+  // Set ambient coefficient
+  if ( resourceMgr()->hasValue( section, "ambient-coefficient" ) ) {
+    setCoefficient( Ambient, resourceMgr()->doubleValue( section, "ambient-coefficient" ) );
+  }
+
+  // Set diffuse color
+  if ( resourceMgr()->hasValue( section, "diffuse-color" ) ) {
+    setColor( Diffuse, resourceMgr()->colorValue( section, "diffuse-color" ) );
+  }
+  // Set diffuse coefficient
+  if ( resourceMgr()->hasValue( section, "diffuse-coefficient" ) ) {
+    setCoefficient( Diffuse, resourceMgr()->doubleValue( section, "diffuse-coefficient" ) );
+  }
+
+  // Set specular color
+  if ( resourceMgr()->hasValue( section, "specular-color" ) ) {
+    setColor( Specular, resourceMgr()->colorValue( section, "specular-color" ) );
+  }
+  // Set specular coefficient
+  if ( resourceMgr()->hasValue( section, "specular-coefficient" ) ) {
+    setCoefficient( Specular, resourceMgr()->doubleValue( section, "specular-coefficient" ) );
+  }
+
+  // Set emission color
+  if ( resourceMgr()->hasValue( section, "emission-color" ) ) {
+    setColor( Emission, resourceMgr()->colorValue( section, "emission-color" ) );
+  }
+  // Set emission coefficient
+  if ( resourceMgr()->hasValue( section, "emission-coefficient" ) ) {
+    setCoefficient( Emission, resourceMgr()->doubleValue( section, "emission-coefficient" ) );
+  }
+
+  // Set shininess
+  if ( resourceMgr()->hasValue( section, "shininess" ) ) {
+    setShininess( resourceMgr()->doubleValue( section, "shininess" ) );
+  }
+}
+
+/*!
+  \brief Save material properties to the resource file.
+  
+  If paremeters \a theResMgr and \a theResSection are not specified, default ones
+  (those passed to the fromResources() function) are used instead.
+
+  \param theResMgr resources manager
+  \param theResSection resources section name
+  \sa fromResources()
+*/
+void Material_Model::save( QtxResourceMgr* theResMgr,
+                          const QString& theResSection,
+                          bool theIsFront )
+{
+  if ( !theResMgr )
+    theResMgr = resourceMgr();
+  if ( !theResMgr )
+    return;
+
+  QString section = theResSection.isEmpty() ? resourceSection( theIsFront ) : theResSection;
+  myResourceSection = section;
+
+  if ( hasAmbientReflection() ) {
+    // Save ambient color
+    theResMgr->setValue( section, "ambient-color", color( Ambient ) );
+    // Save ambient coefficient
+    theResMgr->setValue( section, "ambient-coefficient", coefficient( Ambient ) );
+  }
+  else {
+    // Remove ambient color
+    theResMgr->remove( section, "ambient-color" );
+    // Remove ambient coefficient
+    theResMgr->remove( section, "ambient-coefficient" );
+  }
+
+  if ( hasDiffuseReflection() ) {
+    // Save diffuse color
+    theResMgr->setValue( section, "diffuse-color", color( Diffuse ) );
+    // Save diffuse coefficient
+    theResMgr->setValue( section, "diffuse-coefficient", coefficient( Diffuse ) );
+  }
+  else {
+    // Remove diffuse color
+    theResMgr->remove( section, "diffuse-color" );
+    // Remove diffuse coefficient
+    theResMgr->remove( section, "diffuse-coefficient" );
+  }
+
+  if ( hasSpecularReflection() ) {
+    // Save specular color
+    theResMgr->setValue( section, "specular-color", color( Specular ) );
+    // Save specular coefficient
+    theResMgr->setValue( section, "specular-coefficient", coefficient( Specular ) );
+  }
+  else {
+    // Remove specular color
+    theResMgr->remove( section, "specular-color" );
+    // Remove specular coefficient
+    theResMgr->remove( section, "specular-coefficient" );
+  }
+
+  if ( hasEmissionReflection() ) {
+    // Save emission color
+    theResMgr->setValue( section, "emission-color", color( Emission ) );
+    // Save emission coefficient
+    theResMgr->setValue( section, "emission-coefficient", coefficient( Emission ) );
+  }
+  else {
+    // Remove emission color
+    theResMgr->remove( section, "emission-color" );
+    // Remove emission coefficient
+    theResMgr->remove( section, "emission-coefficient" );
+  }
+
+  // Save shininess
+  theResMgr->setValue( section, "shininess", shininess() );
+}
+
+/*!
+  \brief Get resource manager used by this material model.
+
+  \return pointer to the resource manager passed previously to the fromResources() method
+  \sa fromResources(), resourceSection()
+*/
+QtxResourceMgr* Material_Model::resourceMgr() const
+{
+  return myResourceMgr;
+}
+
+/*!
+  \brief Get resources section name
+
+  If section name is empty, default material name from "Geometry" section
+  is returned ("front_material" or "back_material" is used depending on
+  the parameter value)
+
+  \param theIsFront the flag indicating that section of front or back material
+  is required
+  \return resource section name passed previously to the fromResources() method
+  \sa fromResources(), resourceMgr()
+*/
+QString Material_Model::resourceSection( bool theIsFront ) const
+{
+  return !myResourceSection.isEmpty() ? myResourceSection : 
+    SUIT_Session::session()->resourceMgr()->stringValue("Geometry", 
+                                                       ( theIsFront ? "front_material" : "back_material" ),
+                                                       "Gold");
+}
+
+/*!
+  \brief Check if ambient reflection type is defined for this material
+
+  \return true if ambient reflection type is defined for this material,
+  false - otherwise
+*/
+bool Material_Model::hasAmbientReflection()
+{
+  return ( !myColors.isEmpty() && myColors.contains(Ambient) || !myCoefficients.isEmpty() && myCoefficients.contains(Ambient) );
+}
+
+/*!
+  \brief Check if diffuse reflection type is defined for this material
+
+  \return true if diffuse reflection type is defined for this material,
+  false - otherwise
+*/
+bool Material_Model::hasDiffuseReflection()
+{
+  return ( !myColors.isEmpty() && myColors.contains(Diffuse) || !myCoefficients.isEmpty() && myCoefficients.contains(Diffuse) );
+}
+
+/*!
+  \brief Check if specular reflection type is defined for this material
+
+  \return true if specular reflection type is defined for this material,
+  false - otherwise
+*/
+bool Material_Model::hasSpecularReflection()
+{
+  return ( !myColors.isEmpty() && myColors.contains(Specular) || !myCoefficients.isEmpty() && myCoefficients.contains(Specular) );
+}
+
+/*!
+  \brief Check if emission reflection type is defined for this material
+
+  \return true if emission reflection type is defined for this material,
+  false - otherwise
+*/
+bool Material_Model::hasEmissionReflection()
+{
+  return ( !myColors.isEmpty() && myColors.contains(Emission) || !myCoefficients.isEmpty() && myCoefficients.contains(Emission) );
+}
+
+/*!
+  \brief Get color value for the given reflection type
+  \param theReflectionType reflection type
+  \return a color which should be used by the given reflection type
+  \sa setColor()
+*/
+QColor Material_Model::color( ReflectionType theReflectionType ) const
+{
+  return myColors[ theReflectionType ];
+}
+
+/*!
+  \brief Set color value for the given reflection type
+
+  \param theReflectionType reflection type
+  \param theColor a color to be used by the given reflection type
+  \sa color()
+*/
+void Material_Model::setColor( ReflectionType theReflectionType,
+                              const QColor& theColor )
+{
+  myColors[ theReflectionType ] = theColor;
+}
+
+/*!
+  \brief Set color of the current material from the given string
+  \param theProp the considered property
+  \param theColorName the name of the color property
+  \param theReflectionType the type of reflection
+*/
+void Material_Model::setColor( QString theProp,
+                              QString theColorName,
+                              ReflectionType theReflectionType )
+{
+  int anId = theProp.indexOf( theColorName );
+  if ( anId != -1 ) {
+    QColor c;
+    if ( Qtx::stringToColor( theProp.right( theProp.length() - ( anId + theColorName.length() ) ), c ) )
+      setColor( theReflectionType, c );
+  }
+}
+
+/*!
+  \brief Remove color value for the given reflection type
+
+  \param theReflectionType reflection type
+  \sa color(), setColor()
+*/
+void Material_Model::removeColor( ReflectionType theReflectionType )
+{
+  myColors.remove( theReflectionType );
+}
+
+/*!
+  \brief Get coefficient value for the given reflection type
+  \param theReflectionType reflection type
+  \return a coefficient which should be used by the given reflection type
+  \sa setCoefficient()
+*/
+double Material_Model::coefficient( ReflectionType theReflectionType ) const
+{
+  return myCoefficients[ theReflectionType ];
+}
+
+/*!
+  \brief Set coefficient value for the given reflection type
+
+  \param theReflectionType reflection type
+  \param theCoefficient a coefficient to be used by the given reflection type
+  \sa coefficient()
+*/
+void Material_Model::setCoefficient( ReflectionType theReflectionType,
+                                    double theCoefficient )
+{
+  myCoefficients[ theReflectionType ] = theCoefficient;
+}
+
+/*!
+  \brief Set coefficient of the current material from the given string
+  \param theProp the considered property
+  \param theCoefName the name of the color property
+  \param theReflectionType the type of reflection
+*/
+void Material_Model::setCoefficient( QString theProp,
+                                    QString theCoefName,
+                                    ReflectionType theReflectionType )
+{
+  int anId = theProp.indexOf( theCoefName );
+  if ( anId != -1 ) {
+    bool ok;
+    double aCoef = theProp.right( theProp.length() - ( anId + theCoefName.length() ) ).toDouble( &ok );
+    if ( ok )
+      setCoefficient( theReflectionType, aCoef );
+  }
+}
+
+/*!
+  \brief Remove coefficient value for the given reflection type
+
+  \param theReflectionType reflection type
+  \sa coefficient(), setCoefficient()
+*/
+void Material_Model::removeCoefficient( ReflectionType theReflectionType )
+{
+  myCoefficients.remove( theReflectionType );
+}
+
+/*!
+  \brief Get shininess value
+  \return a shininess value of this material
+  \sa setShininess()
+*/
+double Material_Model::shininess() const
+{
+  return myShininess;
+}
+
+/*!
+  \brief Set shininess value
+
+  \param theShininess a shininess value of this material
+  \sa shininess()
+*/
+void Material_Model::setShininess( double theShininess)
+{
+  myShininess = theShininess;
+}
diff --git a/src/Material/Material_Model.h b/src/Material/Material_Model.h
new file mode 100644 (file)
index 0000000..8543e7a
--- /dev/null
@@ -0,0 +1,108 @@
+// Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+// File   : Material_Model.h
+// Author : Margarita KARPUNINA, Open CASCADE S.A.S. (margarita.karpunina@opencascade.com)
+//
+#ifndef MATERIAL_MODEL_H
+#define MATERIAL_MODEL_H
+
+#include "Material.h"
+
+#include <QColor>
+#include <QMap>
+#include <QString>
+
+class Graphic3d_MaterialAspect;
+
+class vtkProperty;
+
+class QtxResourceMgr;
+
+class MATERIAL_SALOME_EXPORT Material_Model
+{
+
+public:
+
+  //! Enumeration of reflection types of material
+  typedef enum {
+    Ambient,  //!< Ambient 
+    Diffuse,  //!< Diffuse
+    Specular, //!< Specular
+    Emission  //!< Emission
+  } ReflectionType;
+
+
+  Material_Model();
+  virtual ~Material_Model();
+
+  static Material_Model* getMaterialModel( QStringList );
+
+  QString                getMaterialProperty();
+
+  Graphic3d_MaterialAspect getMaterialOCCAspect();
+  vtkProperty*             getMaterialVTKProperty();
+
+  void                initDefaults();
+  void                fromResources( QtxResourceMgr*, const QString& = QString(), bool theIsFront = true );
+  void                save( QtxResourceMgr* = 0, const QString& = QString(), bool theIsFront = true );
+
+  QtxResourceMgr*     resourceMgr() const;
+  QString             resourceSection( bool theIsFront ) const;
+
+  bool                hasAmbientReflection();
+  bool                hasDiffuseReflection();
+  bool                hasSpecularReflection();
+  bool                hasEmissionReflection();
+
+  QColor              color( ReflectionType ) const;
+  void                setColor( ReflectionType, const QColor& );
+  void                setColor( QString,
+                               QString,
+                               ReflectionType );
+  void                removeColor( ReflectionType );
+
+  double              coefficient( ReflectionType ) const;
+  void                setCoefficient( ReflectionType, double );  
+  void                setCoefficient( QString,
+                                     QString,
+                                     ReflectionType );
+  void                removeCoefficient( ReflectionType );
+
+  double              shininess() const;
+  void                setShininess( double );  
+
+private:
+  void                clearModel();
+
+private:
+  typedef QMap<ReflectionType, QColor> ColorMap;
+  typedef QMap<ReflectionType, double> CoefficientMap;
+
+  QtxResourceMgr*     myResourceMgr;
+  QString             myResourceSection;
+
+  ColorMap            myColors;
+  CoefficientMap      myCoefficients;
+
+  double              myShininess;
+
+};
+
+#endif // MATERIAL_MODEL_H
diff --git a/src/Material/Material_ResourceMgr.cxx b/src/Material/Material_ResourceMgr.cxx
new file mode 100644 (file)
index 0000000..ccb2cd4
--- /dev/null
@@ -0,0 +1,407 @@
+// Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+// File   : Material_ResourceMgr.cxx
+// Author : Margarita KARPUNINA, Open CASCADE S.A.S. (margarita.karpunina@opencascade.com)
+//
+#include "Material_ResourceMgr.h"
+
+//#include "Qtx.h"    // used to print colors of global materials
+//#include <iostream> // used to print colors of global materials
+
+/*!
+  \class Material_ResourceMgr
+  \brief Material properties resources manager.
+
+  This class is used to manage the material properties throughout the application
+  in the similar way as QtxResourceMgr does it with application preferences.
+
+  Standard material types are stored in the global application settings files
+  (named as SalomeMaterial.xml). User-defined materials are stored in user's home
+  directory - in the file .SalomeMaterialrc.
+
+  The Material_ResourceMgr class is used by material properties dialog box
+  (GEOMToolsGUI_MaterialPropertiesDlg class).
+*/
+
+/*!
+  \brief Constructor
+*/
+Material_ResourceMgr::Material_ResourceMgr()
+  : QtxResourceMgr( "SalomeMaterial", "%1Config" )
+{
+  if ( dirList().isEmpty() && ::getenv( "GEOM_ROOT_DIR" ) )
+    setDirList( QStringList() << Qtx::addSlash( ::getenv( "GEOM_ROOT_DIR" ) ) + "share/salome/resources/geom" );
+  setCurrentFormat( "xml" );
+
+  /*
+  // Get string equivalent for colors of global materials ---->
+  QColor c;
+  QString s;
+
+  // 1. ============= Plastic
+  std::cout << "---- Plastic:" << std::endl;
+  // ambient
+  c.setRgbF(0.2, 0.2, 0.2);
+  s = Qtx::colorToString( c );
+  std::cout << "        ambient color: " << s.toStdString().c_str() << std::endl;  
+  // diffuse
+  c.setRgbF(0.0, 0.0, 0.0);
+  s = Qtx::colorToString( c );
+  std::cout << "        diffuse color: " << s.toStdString().c_str() << std::endl;  
+  // specular
+  c.setRgbF(1.0, 1.0, 1.0);
+  s = Qtx::colorToString( c );
+  std::cout << "        specular color: " << s.toStdString().c_str() << std::endl;
+
+  // 2. ============= Shiny plastic
+  std::cout << "---- Shiny plastic:" << std::endl;
+  // ambient
+  c.setRgbF(0.2, 0.2, 0.2);
+  s = Qtx::colorToString( c );
+  std::cout << "        ambient color: " << s.toStdString().c_str() << std::endl;  
+  // diffuse
+  c.setRgbF(0.0, 0.0, 0.0);
+  s = Qtx::colorToString( c );
+  std::cout << "        diffuse color: " << s.toStdString().c_str() << std::endl;  
+  // specular
+  c.setRgbF(1.0, 1.0, 1.0);
+  s = Qtx::colorToString( c );
+  std::cout << "        specular color: " << s.toStdString().c_str() << std::endl;
+
+  // 3. ============= Satin
+  std::cout << "---- Satin:" << std::endl;
+  // ambient
+  c.setRgbF(0.2, 0.2, 0.2);
+  s = Qtx::colorToString( c );
+  std::cout << "        ambient color: " << s.toStdString().c_str() << std::endl;  
+  // diffuse
+  c.setRgbF(0.0, 0.0, 0.0);
+  s = Qtx::colorToString( c );
+  std::cout << "        diffuse color: " << s.toStdString().c_str() << std::endl;  
+  // specular
+  c.setRgbF(1.0, 1.0, 1.0);
+  s = Qtx::colorToString( c );
+  std::cout << "        specular color: " << s.toStdString().c_str() << std::endl;
+
+  // 4. ============= Metal
+  std::cout << "---- Metal:" << std::endl;
+  // diffuse
+  c.setRgbF(0.0, 0.0, 0.0);
+  s = Qtx::colorToString( c );
+  std::cout << "        diffuse color: " << s.toStdString().c_str() << std::endl;  
+  // specular
+  c.setRgbF(1.0, 1.0, 1.0);
+  s = Qtx::colorToString( c );
+  std::cout << "        specular color: " << s.toStdString().c_str() << std::endl;
+
+  // 5. ============= Brass
+  std::cout << "---- Brass:" << std::endl;
+  // ambient
+  c.setRgbF(0.329412, 0.223529, 0.027451);
+  s = Qtx::colorToString( c );
+  std::cout << "        ambient color: " << s.toStdString().c_str() << std::endl;  
+  // diffuse
+  c.setRgbF(0.780392, 0.568627, 0.113725);
+  s = Qtx::colorToString( c );
+  std::cout << "        diffuse color: " << s.toStdString().c_str() << std::endl;  
+  // specular
+  c.setRgbF(0.992157, 0.941176, 0.807843);
+  s = Qtx::colorToString( c );
+  std::cout << "        specular color: " << s.toStdString().c_str() << std::endl;  
+
+  // 6. ============= Bronze
+  std::cout << "---- Bronze:" << std::endl;
+  // ambient
+  c.setRgbF(0.2125, 0.1275, 0.054);
+  s = Qtx::colorToString( c );
+  std::cout << "        ambient color: " << s.toStdString().c_str() << std::endl;  
+  // diffuse
+  c.setRgbF(0.714, 0.4284, 0.18144);
+  s = Qtx::colorToString( c );
+  std::cout << "        diffuse color: " << s.toStdString().c_str() << std::endl;  
+  // specular
+  c.setRgbF(0.393548, 0.271906, 0.166721);
+  s = Qtx::colorToString( c );
+  std::cout << "        specular color: " << s.toStdString().c_str() << std::endl;
+
+  // 7. ============= Copper
+  std::cout << "---- Copper:" << std::endl;
+  // ambient
+  c.setRgbF(0.33, 0.26, 0.23);
+  s = Qtx::colorToString( c );
+  std::cout << "        ambient color: " << s.toStdString().c_str() << std::endl;  
+  // diffuse
+  c.setRgbF(0.50, 0.11, 0.0);
+  s = Qtx::colorToString( c );
+  std::cout << "        diffuse color: " << s.toStdString().c_str() << std::endl;  
+  // specular
+  c.setRgbF(0.95, 0.73, 0.0);
+  s = Qtx::colorToString( c );
+  std::cout << "        specular color: " << s.toStdString().c_str() << std::endl;
+
+  // 8. ============= Gold
+  std::cout << "---- Gold:" << std::endl;
+  // ambient
+  c.setRgbF(1.0, 0.76862745, 0.31764706);
+  s = Qtx::colorToString( c );
+  std::cout << "        ambient color: " << s.toStdString().c_str() << std::endl;  
+  // diffuse
+  c.setRgbF(1.0, 0.69, 0.0);
+  s = Qtx::colorToString( c );
+  std::cout << "        diffuse color: " << s.toStdString().c_str() << std::endl;  
+  // specular
+  c.setRgbF(1.0, 0.98, 0.78);
+  s = Qtx::colorToString( c );
+  std::cout << "        specular color: " << s.toStdString().c_str() << std::endl;
+
+  // 9. ============= Pewter
+  std::cout << "---- Pewter:" << std::endl;
+  // ambient
+  c.setRgbF(0.105882, 0.058824, 0.113725);
+  s = Qtx::colorToString( c );
+  std::cout << "        ambient color: " << s.toStdString().c_str() << std::endl;  
+  // diffuse
+  c.setRgbF(0.427451, 0.470588, 0.541176);
+  s = Qtx::colorToString( c );
+  std::cout << "        diffuse color: " << s.toStdString().c_str() << std::endl;  
+  // specular
+  c.setRgbF(0.333333, 0.333333, 0.521569);
+  s = Qtx::colorToString( c );
+  std::cout << "        specular color: " << s.toStdString().c_str() << std::endl;
+
+  // 10. ============= Plaster
+  std::cout << "---- Plaster:" << std::endl;
+  // ambient
+  c.setRgbF(0.19225, 0.19225, 0.19225);
+  s = Qtx::colorToString( c );
+  std::cout << "        ambient color: " << s.toStdString().c_str() << std::endl;  
+  // diffuse
+  c.setRgbF(0.50754, 0.50754, 0.50754);
+  s = Qtx::colorToString( c );
+  std::cout << "        diffuse color: " << s.toStdString().c_str() << std::endl;  
+  // specular
+  c.setRgbF(0.508273, 0.508273, 0.508273);
+  s = Qtx::colorToString( c );
+  std::cout << "        specular color: " << s.toStdString().c_str() << std::endl;
+
+  // 11. ============= Silver
+  std::cout << "---- Silver:" << std::endl;
+  // ambient
+  c.setRgbF(0.19225, 0.19225, 0.19225);
+  s = Qtx::colorToString( c );
+  std::cout << "        ambient color: " << s.toStdString().c_str() << std::endl;  
+  // diffuse
+  c.setRgbF(0.50754, 0.50754, 0.50754);
+  s = Qtx::colorToString( c );
+  std::cout << "        diffuse color: " << s.toStdString().c_str() << std::endl;  
+  // specular
+  c.setRgbF(0.508273, 0.508273, 0.508273);
+  s = Qtx::colorToString( c );
+  std::cout << "        specular color: " << s.toStdString().c_str() << std::endl;
+
+  // 12. ============= Steel
+  std::cout << "---- Steel:" << std::endl;
+  // ambient
+  c.setRgbF(0.2, 0.2, 0.2);
+  s = Qtx::colorToString( c );
+  std::cout << "        ambient color: " << s.toStdString().c_str() << std::endl;  
+  // diffuse
+  c.setRgbF(0.0, 0.0, 0.0);
+  s = Qtx::colorToString( c );
+  std::cout << "        diffuse color: " << s.toStdString().c_str() << std::endl;  
+  // specular
+  c.setRgbF(1.0, 1.0, 1.0);
+  s = Qtx::colorToString( c );
+  std::cout << "        specular color: " << s.toStdString().c_str() << std::endl;
+
+  // 13. ============= Stone
+  std::cout << "---- Stone:" << std::endl;
+  // ambient
+  c.setRgbF(1.0, 0.8, 0.62);
+  s = Qtx::colorToString( c );
+  std::cout << "        ambient color: " << s.toStdString().c_str() << std::endl;  
+  // diffuse
+  c.setRgbF(1.0, 0.8, 0.62);
+  s = Qtx::colorToString( c );
+  std::cout << "        diffuse color: " << s.toStdString().c_str() << std::endl;  
+  // specular
+  c.setRgbF(0.98, 1.0, 0.60);
+  s = Qtx::colorToString( c );
+  std::cout << "        specular color: " << s.toStdString().c_str() << std::endl;
+
+  // 14. ============= Chrome
+  std::cout << "---- Chrome:" << std::endl;
+  // ambient
+  c.setRgbF(0.35, 0.35, 0.35);
+  s = Qtx::colorToString( c );
+  std::cout << "        ambient color: " << s.toStdString().c_str() << std::endl;  
+  // diffuse
+  c.setRgbF(0.4, 0.4, 0.4);
+  s = Qtx::colorToString( c );
+  std::cout << "        diffuse color: " << s.toStdString().c_str() << std::endl;  
+  // specular
+  c.setRgbF(0.974597, 0.974597, 0.974597);
+  s = Qtx::colorToString( c );
+  std::cout << "        specular color: " << s.toStdString().c_str() << std::endl;
+
+  // 15. ============= Neon
+  std::cout << "---- Neon:" << std::endl;
+  // ambient
+  c.setRgbF(1.0, 1.0, 1.0);
+  s = Qtx::colorToString( c );
+  std::cout << "        ambient color: " << s.toStdString().c_str() << std::endl;  
+  // diffuse
+  c.setRgbF(1.0, 1.0, 1.0);
+  s = Qtx::colorToString( c );
+  std::cout << "        diffuse color: " << s.toStdString().c_str() << std::endl;  
+  // specular
+  c.setRgbF(1.0, 1.0, 1.0);
+  s = Qtx::colorToString( c );
+  std::cout << "        specular color: " << s.toStdString().c_str() << std::endl;
+  // emissive
+  c.setRgbF(0.0, 1.0, 0.46);
+  s = Qtx::colorToString( c );
+  std::cout << "        emissive color: " << s.toStdString().c_str() << std::endl;  
+
+  // 16. ============= Aluminium
+  std::cout << "---- Aluminium:" << std::endl;
+  // ambient
+  c.setRgbF(0.30, 0.30, 0.30);
+  s = Qtx::colorToString( c );
+  std::cout << "        ambient color: " << s.toStdString().c_str() << std::endl;  
+  // diffuse
+  c.setRgbF(0.30, 0.30, 0.30);
+  s = Qtx::colorToString( c );
+  std::cout << "        diffuse color: " << s.toStdString().c_str() << std::endl;  
+  // specular
+  c.setRgbF(0.70, 0.70, 0.80);
+  s = Qtx::colorToString( c );
+  std::cout << "        specular color: " << s.toStdString().c_str() << std::endl;
+
+  // 17. ============= Obsidian
+  std::cout << "---- Obsidian:" << std::endl;
+  // ambient
+  c.setRgbF(0.05375, 0.05, 0.06625);
+  s = Qtx::colorToString( c );
+  std::cout << "        ambient color: " << s.toStdString().c_str() << std::endl;  
+  // diffuse
+  c.setRgbF(0.18275, 0.17, 0.22525);
+  s = Qtx::colorToString( c );
+  std::cout << "        diffuse color: " << s.toStdString().c_str() << std::endl;  
+  // specular
+  c.setRgbF(0.332741, 0.328634, 0.346435);
+  s = Qtx::colorToString( c );
+  std::cout << "        specular color: " << s.toStdString().c_str() << std::endl;
+
+  // 18. ============= Jade
+  std::cout << "---- Jade:" << std::endl;
+  // ambient
+  c.setRgbF(0.135, 0.2225, 0.1575);
+  s = Qtx::colorToString( c );
+  std::cout << "        ambient color: " << s.toStdString().c_str() << std::endl;  
+  // diffuse
+  c.setRgbF(0.54, 0.89, 0.63);
+  s = Qtx::colorToString( c );
+  std::cout << "        diffuse color: " << s.toStdString().c_str() << std::endl;  
+  // specular
+  c.setRgbF(0.316228, 0.316228, 0.316228);
+  s = Qtx::colorToString( c );
+  std::cout << "        specular color: " << s.toStdString().c_str() << std::endl;
+
+  // 19. ============= Default material
+  std::cout << "---- Default material:" << std::endl;
+  // ambient
+  c.setRgbF(0.2, 0.2, 0.2);
+  s = Qtx::colorToString( c );
+  std::cout << "        ambient color: " << s.toStdString().c_str() << std::endl;  
+  // diffuse
+  c.setRgbF(0.0, 0.0, 0.0);
+  s = Qtx::colorToString( c );
+  std::cout << "        diffuse color: " << s.toStdString().c_str() << std::endl;  
+  // specular
+  c.setRgbF(1.0, 1.0, 1.0);
+  s = Qtx::colorToString( c );
+  std::cout << "        specular color: " << s.toStdString().c_str() << std::endl;
+
+  // Get string equivalent for colors of global materials <----
+  */
+}
+
+/*!
+  \brief Destructor
+*/
+Material_ResourceMgr::~Material_ResourceMgr()
+{
+}
+
+/*!
+  \brief Get list of avaiable materials
+  \param theType material type
+  \param theSort if \c true (default), returns a list of materials sorted by name
+  \return list of avaiable materials names
+*/
+QStringList Material_ResourceMgr::materials( MaterialType theType, bool theSort )
+{
+  QStringList sl;
+  
+  WorkingMode m = workingMode();
+
+  switch ( theType ) {
+  case Global:
+    setWorkingMode( IgnoreUserValues );
+    sl = sections();
+    break;
+  case User:
+    {
+      setWorkingMode( AllowUserValues );
+      sl = sections();
+      setWorkingMode( IgnoreUserValues );
+      QMutableListIterator<QString> it( sl );
+      while ( it.hasNext() ) {
+        QString s = it.next();
+        if ( hasSection( s ) ) it.remove();
+      }
+    }
+    break;
+  case All:
+    setWorkingMode( AllowUserValues );
+    sl = sections();
+    break;
+  default:
+    break;
+  }
+
+  setWorkingMode( m );
+
+  if ( theSort )
+    qSort( sl );
+
+  return sl;
+}
+
+/*!
+  \brief Get list of materials names for preferences dialog
+  \return list of materials names
+*/
+QStringList Material_ResourceMgr::getPreferenceMaterialsNames()
+{
+  QStringList aMaterialsList = materials( Material_ResourceMgr::All );
+  return aMaterialsList;
+}
diff --git a/src/Material/Material_ResourceMgr.h b/src/Material/Material_ResourceMgr.h
new file mode 100644 (file)
index 0000000..a782033
--- /dev/null
@@ -0,0 +1,49 @@
+// Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+// File   : Material_ResourceMgr.h
+// Author : Margarita KARPUNINA, Open CASCADE S.A.S. (margarita.karpunina@opencascade.com)
+//
+#ifndef MATERIAL_RESOURCEMGR_H
+#define MATERIAL_RESOURCEMGR_H
+
+#include "Material.h"
+
+#include <QtxResourceMgr.h>
+
+class MATERIAL_SALOME_EXPORT Material_ResourceMgr : public QtxResourceMgr
+{
+public:
+  //! Material type
+  typedef enum {
+    Global,            //!< Global materials
+    User,              //!< User materials
+    All                //!< All materials
+  } MaterialType;
+
+  Material_ResourceMgr();
+  ~Material_ResourceMgr();
+
+  QStringList materials( MaterialType = All, bool = true );
+
+  QStringList getPreferenceMaterialsNames();
+  
+};
+
+#endif // MATERIAL_RESOURCEMGR_H
diff --git a/src/Material/resources/SalomeMaterial.xml b/src/Material/resources/SalomeMaterial.xml
new file mode 100644 (file)
index 0000000..9741ce6
--- /dev/null
@@ -0,0 +1,187 @@
+<!--
+  Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
+
+  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+
+  This library is free software; you can redistribute it and/or
+  modify it under the terms of the GNU Lesser General Public
+  License as published by the Free Software Foundation; either
+  version 2.1 of the License.
+
+  This library is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  Lesser General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public
+  License along with this library; if not, write to the Free Software
+  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+
+  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+
+-->
+<document>
+  <section name="Plastic" >
+    <parameter name="ambient-color"           value="#333333" />
+    <parameter name="ambient-coefficient"     value="0.5" />
+    <parameter name="diffuse-color"           value="#000000" />
+    <parameter name="diffuse-coefficient"     value="0.24" />
+    <parameter name="specular-color"          value="#ffffff" />
+    <parameter name="specular-coefficient"    value="0.06" />
+    <parameter name="shininess"               value="0.0078125" />
+  </section>
+  <section name="Shiny plastic" >
+    <parameter name="ambient-color"           value="#333333" />
+    <parameter name="ambient-coefficient"     value="0.44" />
+    <parameter name="diffuse-color"           value="#000000" />
+    <parameter name="diffuse-coefficient"     value="0.5" />
+    <parameter name="specular-color"          value="#ffffff" />
+    <parameter name="specular-coefficient"    value="1.0" />
+    <parameter name="shininess"               value="1.0" />
+  </section>
+  <section name="Satin" >
+    <parameter name="ambient-color"           value="#333333" />
+    <parameter name="ambient-coefficient"     value="0.33" />
+    <parameter name="diffuse-color"           value="#000000" />
+    <parameter name="diffuse-coefficient"     value="0.4" />
+    <parameter name="specular-color"          value="#ffffff" />
+    <parameter name="specular-coefficient"    value="0.44" />
+    <parameter name="shininess"               value="0.09375" />
+  </section>
+  <section name="Metal" >
+    <parameter name="diffuse-color"           value="#000000" />
+    <parameter name="diffuse-coefficient"     value="0.47" />
+    <parameter name="specular-color"          value="#ffffff" />
+    <parameter name="specular-coefficient"    value="0.45" />
+    <parameter name="shininess"               value="0.13" />
+  </section>
+  <section name="Brass">
+    <parameter name="ambient-color"           value="#543907" />
+    <parameter name="ambient-coefficient"     value="1.0" />
+    <parameter name="diffuse-color"           value="#c7911d" />
+    <parameter name="diffuse-coefficient"     value="1.0" />
+    <parameter name="specular-color"          value="#fdf0ce" />
+    <parameter name="specular-coefficient"    value="1.0" />
+    <parameter name="shininess"               value="0.21794844" />
+  </section>
+  <section name="Bronze">
+    <parameter name="ambient-color"           value="#36200d" />
+    <parameter name="ambient-coefficient"     value="1.0" />
+    <parameter name="diffuse-color"           value="#b66d2e" />
+    <parameter name="diffuse-coefficient"     value="1.0" />
+    <parameter name="specular-color"          value="#64452a" />
+    <parameter name="specular-coefficient"    value="1.0" />
+    <parameter name="shininess"               value="0.2" />
+  </section>
+  <section name="Copper" >
+    <parameter name="ambient-color"           value="#54423a" />
+    <parameter name="ambient-coefficient"     value="1.0" />
+    <parameter name="diffuse-color"           value="#801c00" />
+    <parameter name="diffuse-coefficient"     value="1.0" />
+    <parameter name="specular-color"          value="#f3ba00" />
+    <parameter name="specular-coefficient"    value="1.0" />
+    <parameter name="shininess"               value="0.93" />
+  </section>
+  <section name="Gold" >
+    <parameter name="ambient-color"           value="#ffc451" />
+    <parameter name="ambient-coefficient"     value="0.3" />
+    <parameter name="diffuse-color"           value="#ffb000" />
+    <parameter name="diffuse-coefficient"     value="0.4" />
+    <parameter name="specular-color"          value="#fffac7" />
+    <parameter name="specular-coefficient"    value="0.9" />
+    <parameter name="shininess"               value="0.0625" />
+  </section>
+  <section name="Pewter" >
+    <parameter name="ambient-color"           value="#1b0f1d" />
+    <parameter name="ambient-coefficient"     value="1.0" />
+    <parameter name="diffuse-color"           value="#6d788a" />
+    <parameter name="diffuse-coefficient"     value="1.0" />
+    <parameter name="specular-color"          value="#555585" />
+    <parameter name="specular-coefficient"    value="1.0" />
+    <parameter name="shininess"               value="0.076923047" />
+  </section>
+  <section name="Plaster" >
+    <parameter name="ambient-color"           value="#313131" />
+    <parameter name="ambient-coefficient"     value="0.26" />
+    <parameter name="diffuse-color"           value="#818181" />
+    <parameter name="diffuse-coefficient"     value="0.23" />
+    <parameter name="specular-color"          value="#828282" />
+    <parameter name="specular-coefficient"    value="0.06" />
+    <parameter name="shininess"               value="0.0078125" />
+  </section>
+  <section name="Silver" >
+    <parameter name="ambient-color"           value="#313131" />
+    <parameter name="ambient-coefficient"     value="1.0" />
+    <parameter name="diffuse-color"           value="#818181" />
+    <parameter name="diffuse-coefficient"     value="1.0" />
+    <parameter name="specular-color"          value="#828282" />
+    <parameter name="specular-coefficient"    value="1.0" />
+    <parameter name="shininess"               value="0.2" />
+  </section>
+  <section name="Steel" >
+    <parameter name="ambient-color"           value="#333333" />
+    <parameter name="ambient-coefficient"     value="0.01" />
+    <parameter name="diffuse-color"           value="#000000" />
+    <parameter name="diffuse-coefficient"     value="0.03" />
+    <parameter name="specular-color"          value="#ffffff" />
+    <parameter name="specular-coefficient"    value="0.98" />
+    <parameter name="shininess"               value="0.06" />
+  </section>
+  <section name="Stone" >
+    <parameter name="ambient-color"           value="#ffcc9e" />
+    <parameter name="ambient-coefficient"     value="0.19" />
+    <parameter name="diffuse-color"           value="#ffcc9e" />
+    <parameter name="diffuse-coefficient"     value="0.75" />
+    <parameter name="specular-color"          value="#faff99" />
+    <parameter name="specular-coefficient"    value="0.08" />
+    <parameter name="shininess"               value="0.17" />
+  </section>
+  <section name="Chrome" >
+    <parameter name="ambient-color"           value="#595959" />
+    <parameter name="ambient-coefficient"     value="1.0" />
+    <parameter name="diffuse-color"           value="#666666" />
+    <parameter name="diffuse-coefficient"     value="1.0" />
+    <parameter name="specular-color"          value="#f9f9f9" />
+    <parameter name="specular-coefficient"    value="1.0" />
+    <parameter name="shininess"               value="0.1" />
+  </section>
+  <section name="Neon" >
+    <parameter name="ambient-color"           value="#ffffff" />
+    <parameter name="ambient-coefficient"     value="1.0" />
+    <parameter name="diffuse-color"           value="#ffffff" />
+    <parameter name="diffuse-coefficient"     value="1.0" />
+    <parameter name="specular-color"          value="#ffffff" />
+    <parameter name="specular-coefficient"    value="0.62" />
+    <parameter name="emission-color"          value="#00ff75" />
+    <parameter name="emission-coefficient"    value="0.9" />
+    <parameter name="shininess"               value="0.05" />
+  </section>
+  <section name="Aluminium" >
+    <parameter name="ambient-color"           value="#4c4c4c" />
+    <parameter name="ambient-coefficient"     value="1.0" />
+    <parameter name="diffuse-color"           value="#4c4c4c" />
+    <parameter name="diffuse-coefficient"     value="1.0" />
+    <parameter name="specular-color"          value="#b3b3cc" />
+    <parameter name="specular-coefficient"    value="1.0" />
+    <parameter name="shininess"               value="0.09" />
+  </section>
+  <section name="Obsidian" >
+    <parameter name="ambient-color"           value="#0d0c10" />
+    <parameter name="ambient-coefficient"     value="1.0" />
+    <parameter name="diffuse-color"           value="#2e2b39" />
+    <parameter name="diffuse-coefficient"     value="1.0" />
+    <parameter name="specular-color"          value="#555458" />
+    <parameter name="specular-coefficient"    value="1.0" />
+    <parameter name="shininess"               value="0.3" />
+  </section>
+  <section name="Jade" >
+    <parameter name="ambient-color"           value="#223828" />
+    <parameter name="ambient-coefficient"     value="1.0" />
+    <parameter name="diffuse-color"           value="#8ae3a1" />
+    <parameter name="diffuse-coefficient"     value="1.0" />
+    <parameter name="specular-color"          value="#505050" />
+    <parameter name="specular-coefficient"    value="1.0" />
+    <parameter name="shininess"               value="0.1" />
+  </section>  
+</document>
index 7a945dc232a5b126c5e7c68f688fcfd027c20627..dfd5bdb24b990e635c99aa3fdef1090f81aece4c 100644 (file)
 #include <gp_Dir.hxx>
 #include <gp_Vec.hxx>
 #include <Graphic3d_AspectFillArea3d.hxx>
+#include <Graphic3d_AspectLine3d.hxx>
 
 #include <Prs3d_ShadingAspect.hxx>
 #include <Prs3d_Arrow.hxx>
+#include <Prs3d_IsoAspect.hxx>
 
 #include <SelectBasics_SensitiveEntity.hxx>
 #include <SelectMgr_EntityOwner.hxx>
@@ -130,6 +132,13 @@ GEOM_AISShape::GEOM_AISShape(const TopoDS_Shape& shape,
   : SALOME_AISShape(shape), myName(aName), myDisplayVectors(false)
 {
   myShadingColor = Quantity_Color( Quantity_NOC_GOLDENROD );
+
+  storeBoundaryColors();
+
+  myEdgesInShadingColor = Quantity_Color( Quantity_NOC_GOLDENROD );
+
+  myUIsoNumber = -1;
+  myVIsoNumber = -1;
 }
 
 void GEOM_AISShape::setIO(const Handle(SALOME_InteractiveObject)& io){
@@ -170,38 +179,19 @@ void GEOM_AISShape::Compute(const Handle(PrsMgr_PresentationManager3d)& aPresent
   switch (aMode) {
     case 0://StdSelect_DM_Wireframe: 
     {
+      restoreIsoNumbers();
+
+      // Restore wireframe edges colors
+      restoreBoundaryColors();
+
       StdPrs_WFDeflectionShape::Add(aPrs,myshape,myDrawer);
       break;
     }
     case 1://StdSelect_DM_Shading:
     {
-      myDrawer->ShadingAspect()->Aspect()->SetDistinguishOn();
-      
-      Graphic3d_MaterialAspect aMatAspect;
-      aMatAspect.SetAmbient( 0.5 );
-      aMatAspect.SetDiffuse( 0.5 );
-      aMatAspect.SetEmissive( 0.5 );
-      aMatAspect.SetShininess(0.5 );
-      aMatAspect.SetSpecular( 0.5 );
-      
-      myDrawer->ShadingAspect()->Aspect()->SetFrontMaterial(aMatAspect);
-      myDrawer->ShadingAspect()->Aspect()->SetBackMaterial(Graphic3d_NOM_JADE);
-      
-      Graphic3d_MaterialAspect FMat = myDrawer->ShadingAspect()->Aspect()->FrontMaterial();
-      Graphic3d_MaterialAspect BMat = myDrawer->ShadingAspect()->Aspect()->BackMaterial();
-      FMat.SetTransparency(myTransparency); BMat.SetTransparency(myTransparency);
-      myDrawer->ShadingAspect()->Aspect()->SetFrontMaterial(FMat);
-      myDrawer->ShadingAspect()->Aspect()->SetBackMaterial(BMat);
-
-      //Handle(Graphic3d_AspectFillArea3d) a4bis = myDrawer->ShadingAspect()->Aspect();
-      //       P->SetPrimitivesAspect(a4bis);
-      //        G->SetGroupPrimitivesAspect(a4bis);
-      //a4bis->SetInteriorColor(myShadingColor);
-      myDrawer->ShadingAspect()->SetColor(myShadingColor);
+      restoreIsoNumbers();
 
-      // PAL12113: AIS_Shape::Compute() works correctly with shapes containing no faces
-      //StdPrs_ShadedShape::Add(aPrs,myshape,myDrawer);
-      AIS_Shape::Compute(aPresentationManager, aPrs, aMode);
+      shadingMode(aPresentationManager, aPrs, aMode);
       break;
     }
     case 3: //StdSelect_DM_HLR:
@@ -211,6 +201,34 @@ void GEOM_AISShape::Compute(const Handle(PrsMgr_PresentationManager3d)& aPresent
     }
   }
 
+  if ( aMode == ShadingWithEdges ) {
+    // Temporary store number of iso lines in order to recover its later 
+    // when display mode is achnged to 'Wirefame' or 'Shading'.
+    // Iso lines are not displayed in 'Shading with edges' mode.
+    storeIsoNumbers();
+
+    // Reset number of iso lines to 0
+    resetIsoNumbers();
+
+    //Shaded faces
+    shadingMode(aPresentationManager, aPrs, AIS_Shaded);
+
+    // Store wireframe edges colors
+    storeBoundaryColors();
+
+    // Coloring edges
+    Handle(Prs3d_LineAspect) anAspect = myDrawer->UnFreeBoundaryAspect();
+    anAspect->SetColor( myEdgesInShadingColor );
+    myDrawer->SetUnFreeBoundaryAspect( anAspect );
+    
+    anAspect = myDrawer->FreeBoundaryAspect();
+    anAspect->SetColor( myEdgesInShadingColor );
+    myDrawer->SetFreeBoundaryAspect( anAspect );
+
+    // Add edges to presentation
+    StdPrs_WFDeflectionShape::Add(aPrs,myshape,myDrawer);
+  }
+
   if (isShowVectors())
   {
     const bool isVector = IsKind(STANDARD_TYPE(GEOM_AISVector));
@@ -282,6 +300,11 @@ void GEOM_AISShape::SetShadingColor(const Quantity_Color &aCol)
   myShadingColor = aCol;
 }
 
+void GEOM_AISShape::SetEdgesInShadingColor(const Quantity_Color &aCol)
+{
+  myEdgesInShadingColor = aCol;
+}
+
 void GEOM_AISShape::highlightSubShapes(const TColStd_IndexedMapOfInteger& aIndexMap, 
                                        const Standard_Boolean aHighlight )
 {
@@ -317,3 +340,92 @@ void GEOM_AISShape::SetDisplayVectors(bool isDisplayed)
 {
   myDisplayVectors = isDisplayed;
 }
+
+void GEOM_AISShape::shadingMode(const Handle(PrsMgr_PresentationManager3d)& aPresentationManager,
+                               const Handle(Prs3d_Presentation)& aPrs,
+                               const Standard_Integer aMode)
+{
+  myDrawer->ShadingAspect()->Aspect()->SetDistinguishOn();
+
+      Graphic3d_MaterialAspect aMatAspect;
+      if ( !HasMaterial() ) {
+       aMatAspect.SetAmbient( 0.5 );
+       aMatAspect.SetDiffuse( 0.5 );
+       aMatAspect.SetEmissive( 0.5 );
+       aMatAspect.SetShininess(0.5 );
+       aMatAspect.SetSpecular( 0.5 );
+       
+       myDrawer->ShadingAspect()->Aspect()->SetFrontMaterial(aMatAspect);
+       myDrawer->ShadingAspect()->Aspect()->SetBackMaterial(Graphic3d_NOM_JADE);
+      }
+      
+      Graphic3d_MaterialAspect FMat = myDrawer->ShadingAspect()->Aspect()->FrontMaterial();
+      Graphic3d_MaterialAspect BMat = myDrawer->ShadingAspect()->Aspect()->BackMaterial();
+      FMat.SetTransparency(myTransparency); BMat.SetTransparency(myTransparency);
+      myDrawer->ShadingAspect()->Aspect()->SetFrontMaterial(FMat);
+      myDrawer->ShadingAspect()->Aspect()->SetBackMaterial(BMat);
+
+      //Handle(Graphic3d_AspectFillArea3d) a4bis = myDrawer->ShadingAspect()->Aspect();
+      //       P->SetPrimitivesAspect(a4bis);
+      //        G->SetGroupPrimitivesAspect(a4bis);
+      //a4bis->SetInteriorColor(myShadingColor);
+      myDrawer->ShadingAspect()->SetColor(myShadingColor);
+
+      // PAL12113: AIS_Shape::Compute() works correctly with shapes containing no faces
+      //StdPrs_ShadedShape::Add(aPrs,myshape,myDrawer);
+      AIS_Shape::Compute(aPresentationManager, aPrs, aMode);
+}
+
+void GEOM_AISShape::storeIsoNumbers()
+{
+  myUIsoNumber = myDrawer->UIsoAspect()->Number();
+  myVIsoNumber = myDrawer->VIsoAspect()->Number();
+}
+
+void GEOM_AISShape::restoreIsoNumbers()
+{
+  if ( myUIsoNumber > 0 ) {
+    // Restore number of U iso lines
+    Handle(Prs3d_IsoAspect) anAspect = myDrawer->UIsoAspect();
+    anAspect->SetNumber( myUIsoNumber );
+    myDrawer->SetUIsoAspect( anAspect );
+  }
+  
+  if ( myVIsoNumber > 0 ) {
+    // Restore number of V iso lines
+    Handle(Prs3d_IsoAspect) anAspect = myDrawer->VIsoAspect();
+    anAspect->SetNumber( myVIsoNumber );
+    myDrawer->SetVIsoAspect( anAspect );
+  }
+}
+
+void GEOM_AISShape::resetIsoNumbers()
+{
+  Handle(Prs3d_IsoAspect) anAspect = myDrawer->UIsoAspect();
+  anAspect->SetNumber( 0 );
+  myDrawer->SetUIsoAspect( anAspect );
+  
+  anAspect = myDrawer->VIsoAspect();
+  anAspect->SetNumber( 0 );
+  myDrawer->SetVIsoAspect( anAspect );
+}
+
+void GEOM_AISShape::storeBoundaryColors()
+{
+  Aspect_TypeOfLine aLT;
+  Standard_Real aW;
+
+  myDrawer->FreeBoundaryAspect()->Aspect()->Values( myFreeBoundaryColor, aLT, aW);
+  myDrawer->UnFreeBoundaryAspect()->Aspect()->Values( myUnFreeBoundaryColor, aLT, aW);
+}
+void GEOM_AISShape::restoreBoundaryColors()
+{
+  Handle(Prs3d_LineAspect) anAspect = myDrawer->FreeBoundaryAspect();
+  anAspect->SetColor( myFreeBoundaryColor );
+  myDrawer->SetFreeBoundaryAspect( anAspect );
+
+  anAspect = myDrawer->UnFreeBoundaryAspect();
+  anAspect->SetColor( myUnFreeBoundaryColor );
+  myDrawer->SetUnFreeBoundaryAspect( anAspect );
+}
index fb8edfbfa14fb98d45d7bd1a566684a9b08e456b..1626936fb47a1817b781475993e9f13e46816bc9 100644 (file)
@@ -57,6 +57,8 @@
 
 #include <TCollection_AsciiString.hxx>
 
+#include <AIS_DisplayMode.hxx>
+
 class PrsMgr_PresentationManager3d;
 class Prs3d_Presentation;
 class SALOME_InteractiveObject;
@@ -66,6 +68,14 @@ class GEOM_OBJECT_EXPORT GEOM_AISShape : public SALOME_AISShape {
 
 public:
 
+    //! Enumeration of display modes
+    typedef enum {
+      //WireFrame,       //!< the same as AIS_WireFrame
+      //Shading,         //!< the same as AIS_Shaded
+      ShadingWithEdges = AIS_Shaded+1, //!< shading with edges
+      TexturedShape = ShadingWithEdges+1 //!< the same as AIS_ExactHLR
+    } DispMode;
+
     inline void* operator new(size_t,void* anAddress) 
       {
         return anAddress;
@@ -95,6 +105,7 @@ public:
 
         void SetTransparency(const Standard_Real aValue);
         void SetShadingColor(const Quantity_Color &aCol);
+        void SetEdgesInShadingColor(const Quantity_Color &aCol);
         void SetDisplayVectors(bool isShow);
 
         virtual  void Compute(const Handle(PrsMgr_PresentationManager3d)& aPresentationManager,
@@ -109,9 +120,28 @@ public:
         const Handle(Standard_Type)& DynamicType() const;
         Standard_Boolean             IsKind(const Handle(Standard_Type)&) const;
 
+        void storeIsoNumbers();
+        void restoreIsoNumbers();
+        void resetIsoNumbers();
+
 protected: 
+  void shadingMode(const Handle(PrsMgr_PresentationManager3d)& aPresentationManager,
+                  const Handle(Prs3d_Presentation)& aPrs,
+                  const Standard_Integer aMode);
+
+  void storeBoundaryColors();
+  void restoreBoundaryColors();
+
   Quantity_Color myShadingColor;
 
+  Quantity_Color myFreeBoundaryColor;
+  Quantity_Color myUnFreeBoundaryColor;
+
+  Quantity_Color myEdgesInShadingColor;
+
+  int            myUIsoNumber;
+  int            myVIsoNumber;
+
 private: 
   TCollection_AsciiString myName;
   bool                    myDisplayVectors;
index eeb5f0dc31be7ac75588590a8ff1723a6896e46e..3e2d7a1b1a4e7cf3c07015d25b992aaa6b78cc33 100644 (file)
@@ -37,6 +37,7 @@
 #include "GEOM_EdgeSource.h" 
 #include "GEOM_WireframeFace.h" 
 #include "GEOM_ShadingFace.h"
+#include "GEOM_PainterPolyDataMapper.h"
 #include "SVTK_Actor.h"
 
 #include <OCC2VTK_Tools.h>
@@ -103,11 +104,17 @@ GEOM_Actor::GEOM_Actor():
  
   myHighlightActor(GEOM_DeviceActor::New(),true), 
   myAppendFilter(vtkAppendPolyData::New(),true), 
-  myPolyDataMapper(vtkPolyDataMapper::New(),true),
+  // Use mapper as an instance of GEOM_PainterPolyDataMapper class
+  // to prevent drawing of mappers' content (due to an empty definition
+  // of GEOM_PainterPolyDataMapper::RenderPiece(...)).
+  // !!! Presentation of GEOM_Actor is drawing only with help of actors
+  // defined in this class !!!
+  myPolyDataMapper(GEOM_PainterPolyDataMapper::New(),true),
 
   myHighlightProp(vtkProperty::New()),
   myPreHighlightProp(vtkProperty::New()),
-  myShadingFaceProp(vtkProperty::New())
+  myShadingFaceProp(vtkProperty::New()),
+  myShadingBackFaceProp(vtkProperty::New())
 { 
 #ifdef MYDEBUG
   MESSAGE (this<< " GEOM_Actor::GEOM_Actor");
@@ -140,13 +147,13 @@ GEOM_Actor::GEOM_Actor():
   aProperty->SetPointSize(3); 
   aProperty->SetColor(1, 1, 0);
  
-  myAppendFilter->AddInput(myIsolatedEdgeSource->GetOutput()); 
+  myAppendFilter->AddInput(myIsolatedEdgeSource->GetOutput());
   myIsolatedEdgeActor->SetInput(myIsolatedEdgeSource->GetOutput(),false); 
   aProperty = myIsolatedEdgeActor->GetProperty(); 
   aProperty->SetRepresentation(VTK_WIREFRAME); 
   aProperty->SetColor(1, 0, 0);
  
-  myAppendFilter->AddInput(myOneFaceEdgeSource->GetOutput()); 
+  myAppendFilter->AddInput(myOneFaceEdgeSource->GetOutput());
   myOneFaceEdgeActor->SetInput(myOneFaceEdgeSource->GetOutput(),false); 
   aProperty = myOneFaceEdgeActor->GetProperty(); 
   aProperty->SetRepresentation(VTK_WIREFRAME); 
@@ -166,7 +173,7 @@ GEOM_Actor::GEOM_Actor():
 
   myShadingFaceActor->SetInput(myShadingFaceSource->GetOutput(),true); 
 
-  myShadingFaceProp->SetRepresentation(VTK_SURFACE); 
+  myShadingFaceProp->SetRepresentation(VTKViewer::Representation::Surface); 
   myShadingFaceProp->SetInterpolationToGouraud(); 
   myShadingFaceProp->SetAmbient(1.0);
   myShadingFaceProp->SetDiffuse(1.0);
@@ -177,10 +184,14 @@ GEOM_Actor::GEOM_Actor():
 
   myShadingFaceActor->SetProperty(myShadingFaceProp.GetPointer());
 
+  StoreBoundaryColors();
+
+  myNbIsos[0] = -1;
+  myNbIsos[1] = -1;
+
   // Toggle display mode 
   setDisplayMode(0); // WIRE FRAME
   SetVectorMode(0);  //
-
 } 
  
  
@@ -192,6 +203,7 @@ GEOM_Actor::~GEOM_Actor()
   myHighlightProp->Delete();
   myPreHighlightProp->Delete();
   myShadingFaceProp->Delete();
+  myShadingBackFaceProp->Delete();
 } 
  
 GEOM_Actor*  
@@ -282,8 +294,45 @@ GEOM_Actor::
 setDisplayMode(int theMode) 
 { 
 #ifdef MYDEBUG
-  MESSAGE ( "GEOM_Actor::SetDisplayMode = "<<theMode );
+  MESSAGE ( "GEOM_Actor::setDisplayMode = "<<theMode );
 #endif
+  
+  if ( theMode == (int)eWireframe ) {
+    RestoreIsoNumbers();
+    // Restore wireframe edges colors
+    RestoreBoundaryColors();
+  }
+  else if ( theMode == (int)eShading || theMode == (int)eShadingWithEdges ) {
+    // Temporary store number of iso lines in order to recover its later 
+    // when display mode is achnged to 'Wirefame' or 'Shading'.
+    // Iso lines are not displayed in 'Shading with edges' mode.
+    StoreIsoNumbers();
+
+    // Reset number of iso lines to 0
+    ResetIsoNumbers();
+
+    if ( theMode == (int)eShadingWithEdges ) {
+      // Store wireframe edges colors
+      StoreBoundaryColors();
+
+      // Coloring edges
+      myIsolatedEdgeActor->GetProperty()->SetColor(myEdgesInShadingColor[0],
+                                                  myEdgesInShadingColor[1],
+                                                  myEdgesInShadingColor[2]);
+      myOneFaceEdgeActor->GetProperty()->SetColor(myEdgesInShadingColor[0],
+                                                 myEdgesInShadingColor[1],
+                                                 myEdgesInShadingColor[2]);
+      mySharedEdgeActor->GetProperty()->SetColor(myEdgesInShadingColor[0],
+                                                myEdgesInShadingColor[1],
+                                                myEdgesInShadingColor[2]);
+      //SetModified();
+    } else {
+      myIsolatedEdgeActor->GetProperty()->SetColor(myEdgesInWireframeColor[0],
+                                                  myEdgesInWireframeColor[1],
+                                                  myEdgesInWireframeColor[2]);
+    }
+  }
+
   VTKViewer_Actor::setDisplayMode(theMode);
   SetVisibility(GetVisibility()); 
 } 
@@ -313,14 +362,14 @@ SetVisibility(int theVisibility)
 
   this->myHighlightActor->SetVisibility(theVisibility && (myIsSelected || myIsPreselected));
   
-  myShadingFaceActor->SetVisibility(theVisibility && (myDisplayMode == (int)eShading) && (!myIsSelected || !myIsPreselected)); 
-  myWireframeFaceActor->SetVisibility(theVisibility && (myDisplayMode ==(int)eWireframe) && !myIsSelected);
+  myShadingFaceActor->SetVisibility(theVisibility && (myDisplayMode == (int)eShading || myDisplayMode == (int)eShadingWithEdges) && (!myIsSelected || !myIsPreselected)); 
+  myWireframeFaceActor->SetVisibility(theVisibility && (myDisplayMode == (int)eWireframe) && !myIsSelected);
 
-  mySharedEdgeActor->SetVisibility(theVisibility && myDisplayMode == (int)eWireframe && !myIsSelected);
-  myOneFaceEdgeActor->SetVisibility(theVisibility && myDisplayMode == (int)eWireframe && !myIsSelected);
+  mySharedEdgeActor->SetVisibility(theVisibility && (myDisplayMode == (int)eWireframe || myDisplayMode == (int)eShadingWithEdges) && !myIsSelected);
+  myOneFaceEdgeActor->SetVisibility(theVisibility && (myDisplayMode == (int)eWireframe || myDisplayMode == (int)eShadingWithEdges) && !myIsSelected);
   myIsolatedEdgeActor->SetVisibility(theVisibility && !myIsSelected);
 
-  myVertexActor->SetVisibility(theVisibility && !myIsSelected);// must be added new mode points 
+  myVertexActor->SetVisibility(theVisibility && myDisplayMode == (int)eWireframe && !myIsSelected);// must be added new mode points
 }
  
 
@@ -479,11 +528,12 @@ void GEOM_Actor::Render(vtkRenderer *ren, vtkMapper *theMapper)
   }
 
   switch(myDisplayMode){
-  case 0://wireframe
+  case eWireframe://wireframe
     myPreHighlightProp->SetRepresentationToWireframe();
     myHighlightProp->SetRepresentationToWireframe();
     break;
-  case 1://shading
+  case eShading://shading
+  case eShadingWithEdges://shading with edges
     myPreHighlightProp->SetRepresentationToSurface();
     myHighlightProp->SetRepresentationToSurface();
     break;
@@ -493,14 +543,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);
@@ -604,13 +657,14 @@ void GEOM_Actor::highlight(bool highlight)
 #ifdef MYDEBUG
   MESSAGE ( this << " GEOM_Actor::highlight highlight="<<highlight );
 #endif
-  SALOME_Actor::highlight(highlight);
+  SALOME_Actor::highlight(highlight);  
 }
 
 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);
@@ -626,10 +680,13 @@ void GEOM_Actor::SetColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloat
 {
   // enk:tested OK
   myShadingFaceProp->SetColor(r,g,b);                          // shading color (Shading)
-  myIsolatedEdgeActor->GetProperty()->SetColor(r,g,b);         // standalone edge color (Wireframe)
+  myShadingBackFaceProp->SetColor(r,g,b);                      // back face shading color (Shading)
   myVertexActor->GetProperty()->SetColor(r,g,b);               // vertex actor (Shading/Wireframe)
-  myOneFaceEdgeActor->GetProperty()->SetColor(r,g,b);          // standalone face edge color (Wireframe)
-  mySharedEdgeActor->GetProperty()->SetColor(r,g,b);           // share edge color (Wireframe)
+  if ( myDisplayMode != (int)eShadingWithEdges ) {
+    myIsolatedEdgeActor->GetProperty()->SetColor(r,g,b);         // standalone edge color (Wireframe)
+    myOneFaceEdgeActor->GetProperty()->SetColor(r,g,b);          // standalone face edge color (Wireframe)
+    mySharedEdgeActor->GetProperty()->SetColor(r,g,b);           // share edge color (Wireframe)
+  }
 }
 
 void GEOM_Actor::GetColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b)
@@ -642,6 +699,93 @@ void GEOM_Actor::GetColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFlo
   b = aRGB[2];
 }
 
+void GEOM_Actor::SetMaterial(std::vector<vtkProperty*> theProps)
+{
+  int aSize = theProps.size();
+
+  if ( aSize < 1 || aSize > 2)
+    return;
+
+  // theProps[0] -- front material properties
+  // theProps[1] -- back material properties (if exist)
+  // If there are no back material properties,
+  // we get front material properties as back material
+
+  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;
+
+  // Set reflection colors
+  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::GetFrontMaterial()
+{
+  return myShadingFaceProp;
+}
+
+vtkProperty* GEOM_Actor::GetBackMaterial()
+{
+  return myShadingBackFaceProp;
+}
+
 bool GEOM_Actor::IsInfinitive()
 {
   return ((bool)myShape.Infinite() || isOnlyVertex);
@@ -658,7 +802,15 @@ GEOM_Actor
 #ifdef MYDEBUG
   MESSAGE ( this << " GEOM_Actor::Highlight myIsSelected="<<myIsSelected );
 #endif
-  
+
+  if ( myDisplayMode == (int)eShading || myDisplayMode == (int)eShadingWithEdges ) {
+    if ( theIsHighlight )
+      RestoreIsoNumbers();
+    else
+      // Reset number of iso lines to 0
+      ResetIsoNumbers();
+  }
+
   SALOME_Actor::Highlight(theIsHighlight); // this method call ::highlight(theIsHighlight) in the end
   SetVisibility(GetVisibility());
 }
@@ -679,6 +831,14 @@ GEOM_Actor
   if ( !GetPickable() )
     return false;  
 
+  if ( myDisplayMode == (int)eShading || myDisplayMode == (int)eShadingWithEdges ) {
+    if ( theIsHighlight )
+      RestoreIsoNumbers();
+    else
+      // Reset number of iso lines to 0
+      ResetIsoNumbers();
+  }
+
   myPreHighlightActor->SetVisibility( false );
   bool anIsPreselected = myIsPreselected;
   
@@ -821,4 +981,45 @@ void GEOM_Actor::GetMatrix(vtkCamera* theCam, vtkMatrix4x4 *result)
   this->Transform->Pop();  
 }  
 
+void GEOM_Actor::SetEdgesInShadingColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b)
+{
+  myEdgesInShadingColor[0] = r;
+  myEdgesInShadingColor[1] = g;
+  myEdgesInShadingColor[2] = b;
+}
+
+void GEOM_Actor::StoreIsoNumbers()
+{  
+  myWireframeFaceSource->GetNbIso(myNbIsos[0], myNbIsos[1]);
+}
 
+void GEOM_Actor::RestoreIsoNumbers()
+{
+  if ( myNbIsos[0] > 0 || myNbIsos[1] > 0 )
+    // Restore number of U and (or) V iso lines
+    myWireframeFaceSource->SetNbIso(myNbIsos);
+}
+  
+void GEOM_Actor::ResetIsoNumbers()
+{
+  int aNb[2] = {0, 0};
+  myWireframeFaceSource->SetNbIso(aNb);
+}
+
+void GEOM_Actor::StoreBoundaryColors()
+{
+  mySharedEdgeActor->GetProperty()->GetColor(myEdgesInWireframeColor);
+}
+void GEOM_Actor::RestoreBoundaryColors()
+{
+  myIsolatedEdgeActor->GetProperty()->SetColor(myEdgesInWireframeColor[0],
+                                              myEdgesInWireframeColor[1],
+                                              myEdgesInWireframeColor[2]);
+  myOneFaceEdgeActor->GetProperty()->SetColor(myEdgesInWireframeColor[0],
+                                             myEdgesInWireframeColor[1],
+                                             myEdgesInWireframeColor[2]);
+  mySharedEdgeActor->GetProperty()->SetColor(myEdgesInWireframeColor[0],
+                                            myEdgesInWireframeColor[1],
+                                            myEdgesInWireframeColor[2]);
+}
index 6a8bd9c0c5df67163c0821e238443e941d313f18..a6e890d65da11e4cc4040bc8f4d8e9f54fb1bcc9 100644 (file)
@@ -72,7 +72,7 @@ public:
   void AddToRender(vtkRenderer* theRenderer);
   void RemoveFromRender(vtkRenderer* theRenderer);
 
-  enum EDisplayMode{ eWireframe, eShading};
+  enum EDisplayMode{ eWireframe, eShading, eShadingWithEdges = eShading + 2 };
 
 /*   void SetDisplayMode(EDisplayMode theMode);  */
 /*   EDisplayMode GetDisplayMode() const { return myDisplayMode;}  */
@@ -122,6 +122,11 @@ public:
   void SetColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b);
   void GetColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b);
 
+  // Material
+  void SetMaterial(std::vector<vtkProperty*> theProps);
+  vtkProperty* GetFrontMaterial();
+  vtkProperty* GetBackMaterial();
+
   virtual bool IsInfinitive();
 
   // overloaded functions
@@ -169,12 +174,27 @@ public:
   virtual
   bool
   GetVectorMode();
+  
+  //! Edges in shading color management
+  void SetEdgesInShadingColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b);
+
+  void
+  StoreIsoNumbers();
+
+  void
+  RestoreIsoNumbers();
+  
+  void
+  ResetIsoNumbers();
 
 protected:
   void SetModified();
 
   void GetMatrix(vtkCamera* theCam, vtkMatrix4x4 *result);
 
+  void StoreBoundaryColors();
+  void RestoreBoundaryColors();
+
   GEOM_Actor();
   ~GEOM_Actor();
 
@@ -212,14 +232,18 @@ private:
   vtkSmartPointer<vtkProperty>  myHighlightProp;
   vtkSmartPointer<vtkProperty>  myPreHighlightProp;
   vtkSmartPointer<vtkProperty>  myShadingFaceProp;
+  vtkSmartPointer<vtkProperty>  myShadingBackFaceProp;
 
   PAppendFilter myAppendFilter;
-  PPolyDataMapper myPolyDataMapper;
+  PPolyGeomPainterDataMapper myPolyDataMapper;
 
   virtual void SetMapper(vtkMapper*);
 
   GEOM_Actor(const GEOM_Actor&);
   void operator=(const GEOM_Actor&);
+
+  vtkFloatingPointType myEdgesInWireframeColor[3];
+  vtkFloatingPointType myEdgesInShadingColor[3];
 };
 
 #endif //GEOM_ACTOR_H
diff --git a/src/OBJECT/GEOM_Constants.h b/src/OBJECT/GEOM_Constants.h
new file mode 100644 (file)
index 0000000..49bdabe
--- /dev/null
@@ -0,0 +1,49 @@
+// Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+//  File   : GEOM_Constants.h
+//  Author : Margarita KARPUNINA
+//  Module : GEOM
+//
+#ifndef GEOM_CONSTANTS_H
+#define GEOM_CONSTANTS_H
+
+// minimum allowed value for deflection coefficient
+#define DEFLECTION_MIN 1e-06
+
+//Define separators
+#define NAME_SEPARATOR  '_' // character used to separate parameter names
+#define DIGIT_SEPARATOR ':' // character used to separate numeric parameter values (color = r:g:b)
+
+#define VISIBILITY_PROP       "Visibility"      //Object visibility property
+#define OPACITY_PROP          "Opacity"         //Object opacity property
+#define TRANSPARENCY_PROP     "Transparency"    //Object transparency property
+#define DISPLAY_MODE_PROP     "DisplayMode"     //Object display mode property
+#define ISOS_PROP             "Isos"            //Number of the Isos property of the object
+#define COLOR_PROP            "Color"           //Color of the object 
+#define VECTOR_MODE_PROP      "VectorMode"      //Vector mode property
+#define DEFLECTION_COEFF_PROP "DeflectionCoeff" //Deflection coeff property
+#define MARKER_TYPE_PROP      "MarkerType"      //Marker type property
+#define FRONT_MATERIAL_PROP   "FrontMaterial"   //Object front material property
+#define BACK_MATERIAL_PROP    "BackMaterial"    //Object back material property
+
+#endif //GEOM_CONSTANTS_H
index b81406724a1dbd4b35b1190ea1a017edf42479df..8d2a5e911e85c0f9817272fd3bcb6b7a5cd9de36 100755 (executable)
@@ -72,6 +72,20 @@ GetProperty()
 {
   return myActor->GetProperty();
 }
+
+void 
+GEOM_DeviceActor:: 
+SetBackfaceProperty(vtkProperty* theProperty)
+{
+  myActor->SetBackfaceProperty(theProperty);
+}
+vtkProperty* 
+GEOM_DeviceActor:: 
+GetBackfaceProperty()
+{
+  return myActor->GetBackfaceProperty();
+}
  
 void 
 GEOM_DeviceActor:: 
index 7aad24d7ec5b28d0effda0061f81e20ba2e7ccc2..721ee1b6f6d90e8db81cfe9c066f7d0d7e89c5cd 100755 (executable)
@@ -52,6 +52,9 @@ public:
 
   void SetProperty(vtkProperty* theProperty);
   vtkProperty* GetProperty();
+
+  void SetBackfaceProperty(vtkProperty* theProperty);
+  vtkProperty* GetBackfaceProperty();
  
   void SetVisibility(int theVisibility); 
   int GetVisibility(); 
diff --git a/src/OBJECT/GEOM_PainterPolyDataMapper.cxx b/src/OBJECT/GEOM_PainterPolyDataMapper.cxx
new file mode 100644 (file)
index 0000000..c86d937
--- /dev/null
@@ -0,0 +1,24 @@
+// Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "GEOM_PainterPolyDataMapper.h"
+
+#include <vtkObjectFactory.h>
+
+vtkStandardNewMacro(GEOM_PainterPolyDataMapper);
diff --git a/src/OBJECT/GEOM_PainterPolyDataMapper.h b/src/OBJECT/GEOM_PainterPolyDataMapper.h
new file mode 100644 (file)
index 0000000..0c738f7
--- /dev/null
@@ -0,0 +1,44 @@
+// Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef GEOM_PAINTERPOLYDATAMAPPER_H 
+#define GEOM_PAINTERPOLYDATAMAPPER_H 
+
+#include <vtkPainterPolyDataMapper.h>
+
+/*
+ * This class can be used to prevent drawing of mappers' content (due to an
+ * empty definition of GEOM_PainterPolyDataMapper::RenderPiece(...) method).
+ * It is used as poly data mapper in GEOM_Actor class.
+ */
+class GEOM_PainterPolyDataMapper: public vtkPainterPolyDataMapper
+{
+ public:
+  vtkTypeMacro(GEOM_PainterPolyDataMapper,vtkPainterPolyDataMapper);
+  static GEOM_PainterPolyDataMapper* New();
+
+  virtual void RenderPiece(vtkRenderer *ren, vtkActor *act) {}
+
+ protected:
+  GEOM_PainterPolyDataMapper() {}
+  ~GEOM_PainterPolyDataMapper() {}
+
+};
+
+#endif //GEOM_PAINTERPOLYDATAMAPPER_H
index dae9f45e9c048973c497a6f8a9e449c8d6a2a055..12f981bc75a2846b98c83227e2c7daf31103a09e 100755 (executable)
@@ -41,12 +41,14 @@ public:
   T* Get() const { return this->GetPointer();} 
 }; 
  
 class GEOM_DeviceActor; 
 typedef GEOM_SmartPtr<GEOM_DeviceActor> PDeviceActor; 
  
 class vtkPolyDataMapper; 
-typedef GEOM_SmartPtr<vtkPolyDataMapper> PPolyDataMapper; 
+typedef GEOM_SmartPtr<vtkPolyDataMapper> PPolyDataMapper;
+
+class GEOM_PainterPolyDataMapper;
+typedef GEOM_SmartPtr<GEOM_PainterPolyDataMapper> PPolyGeomPainterDataMapper;
  
  
 #endif //GEOM_SMARTPTR_H 
index 52c23f398c050a7ab42aa9e033386ced76a6b6f9..c83d0ea40b3d44b792c75bec7b6a8bec7f9487f9 100644 (file)
@@ -42,6 +42,7 @@ salomeinclude_HEADERS =                               \
        GEOM_OBJECT_defs.hxx                    \
        GEOM_OCCReader.h                        \
        GEOM_SmartPtr.h                         \
+       GEOM_PainterPolyDataMapper.h            \
        GEOM_DeviceActor.h
 
 # Libraries targets
@@ -55,6 +56,7 @@ dist_libGEOMObject_la_SOURCES =               \
        GEOM_AISTrihedron.cxx           \
        GEOM_VTKTrihedron.cxx           \
        GEOM_AISVector.cxx              \
+       GEOM_PainterPolyDataMapper.cxx  \
        GEOM_DeviceActor.cxx