Salome HOME
0021514: EDF GEOM: Partition failure. A fix by PKV.
[modules/geom.git] / src / GEOMToolsGUI / GEOMToolsGUI_1.cxx
index 8f434de962ab40c58fdf272d2d96c48847e4f2ec..9057a8988dfbfa5214478890d01fc7716bfe01f0 100644 (file)
@@ -1,29 +1,28 @@
-//  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
+// 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
+// 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 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.
+// 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
+// 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
 
 //  GEOM GEOMGUI : GUI for Geometry component
 //  File   : GEOMToolsGUI_1.cxx
 //  Author : Sergey ANIKIN, Open CASCADE S.A.S. (sergey.anikin@opencascade.com)
-//
+
 #include <PyConsole_Console.h>
 
 #include "GEOMToolsGUI.h"
 #include "GEOMToolsGUI_DeflectionDlg.h"
 #include "GEOMToolsGUI_MarkerDlg.h"
 #include "GEOMToolsGUI_PublishDlg.h"
+#include "GEOMToolsGUI_MaterialPropertiesDlg.h"
+#include "GEOMToolsGUI_LineWidthDlg.h"
 
 #include <GeometryGUI.h>
+#include <GeometryGUI_Operations.h>
+#include <GEOM_Constants.h>
 #include <GEOM_Displayer.h>
 
 #include <GEOMBase.h>
 #include <GEOM_Actor.h>
 
+#include <Basics_OCCTVersion.hxx>
+
 #include <SALOME_ListIO.hxx>
 #include <SALOME_ListIteratorOfListIO.hxx>
 
 #include <Prs3d_IsoAspect.hxx>
 #include <Prs3d_PointAspect.hxx>
 #include <Graphic3d_AspectMarker3d.hxx>
+#include <Graphic3d_AspectLine3d.hxx>
+#include <AIS_ListIteratorOfListOfInteractive.hxx>
+#include <AIS_ListOfInteractive.hxx>
+
+
+#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
+#include <TColStd_HArray1OfByte.hxx>
+#else
 #include <Graphic3d_HArray1OfBytes.hxx>
+#endif
 
 // QT Includes
+#include <QAction>
 #include <QColorDialog>
 #include <QInputDialog>
+#include <QFileDialog>
 #include <QList>
 
 #include <QGridLayout>
 // VTK includes
 #include <vtkRenderer.h>
 
-void GEOMToolsGUI::OnRename()
-{
-  SALOME_ListIO selected;
-  SalomeApp_Application* app =
-    dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
-  if ( app ) {
-    LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
-    SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
-    if ( aSelMgr && appStudy ) {
-      aSelMgr->selectedObjects( selected );
-      if ( !selected.IsEmpty() ) {
-        _PTR(Study) aStudy = appStudy->studyDS();
-
-        bool aLocked = (_PTR(AttributeStudyProperties)(aStudy->GetProperties()))->IsLocked();
-        if ( aLocked ) {
-          SUIT_MessageBox::warning ( app->desktop(),
-                                     QObject::tr("WRN_WARNING"),
-                                     QObject::tr("WRN_STUDY_LOCKED") );
-          return;
-        }
-
-        bool isAny = false; // is there any appropriate object selected
-        for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
-          Handle(SALOME_InteractiveObject) IObject = It.Value();
-
-          _PTR(SObject) obj ( aStudy->FindObjectID(IObject->getEntry()) );
-          _PTR(GenericAttribute) anAttr;
-          if ( obj ) {
-            if ( obj->FindAttribute(anAttr, "AttributeName") ) {
-              _PTR(AttributeName) aName (anAttr);
-
-              GEOM::GEOM_Object_var anObj =
-                GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(obj));
-              if (!CORBA::is_nil(anObj)) {
-                isAny = true;
-                QString newName = LightApp_NameDlg::getName( app->desktop(), aName->Value().c_str() );
-                if (!newName.isEmpty()) {
-                  aName->SetValue( newName.toLatin1().data() ); // rename the SObject
-                  IObject->setName( newName.toLatin1().data() );// rename the InteractiveObject
-                  anObj->SetName( newName.toLatin1().data() );  // Rename the corresponding GEOM_Object
-                  (dynamic_cast<SalomeApp_Module*>(app->activeModule()))->updateObjBrowser( false );
-                }
-              } // if ( anObj )
-            } // if ( name attribute )
-          } // if ( obj )
-        } // iterator
-
-        if (!isAny) {
-          SUIT_MessageBox::warning( app->desktop(),
-                                    QObject::tr("WRN_WARNING"),
-                                    QObject::tr("GEOM_WRN_NO_APPROPRIATE_SELECTION") );
-          return;
-        }
-      }
-    }
-  }
-
-  app->updateActions(); //SRN: To update a Save button in the toolbar
-}
-
 void GEOMToolsGUI::OnCheckGeometry()
 {
-  SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
+  SalomeApp_Application* app =
+    dynamic_cast< SalomeApp_Application* >(SUIT_Session::session()->activeApplication());
   PyConsole_Console* pyConsole = app->pythonConsole();
 
-  if(pyConsole)
+  if (pyConsole)
     pyConsole->exec("from GEOM_usinggeom import *");
 }
 
 void GEOMToolsGUI::OnAutoColor()
 {
   SALOME_ListIO selected;
-  SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
-  if( !app )
+  SalomeApp_Application* app =
+    dynamic_cast< SalomeApp_Application* >(SUIT_Session::session()->activeApplication());
+  if (!app)
     return;
 
   LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
-  SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
-  if( !aSelMgr || !appStudy )
+  SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(app->activeStudy());
+  if (!aSelMgr || !appStudy)
     return;
 
-  aSelMgr->selectedObjects( selected );
-  if( selected.IsEmpty() )
+  aSelMgr->selectedObjects(selected);
+  if (selected.IsEmpty())
     return;
 
   Handle(SALOME_InteractiveObject) anIObject = selected.First();
 
   _PTR(Study) aStudy = appStudy->studyDS();
-  _PTR(SObject) aMainSObject( aStudy->FindObjectID( anIObject->getEntry() ) );
+  _PTR(SObject) aMainSObject(aStudy->FindObjectID(anIObject->getEntry()));
   GEOM::GEOM_Object_var aMainObject = GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aMainSObject));
-  if( CORBA::is_nil( aMainObject ) )
+  if (CORBA::is_nil(aMainObject))
     return;
 
   aMainObject->SetAutoColor( true );
@@ -257,14 +215,23 @@ void GEOMToolsGUI::OnAutoColor()
       else {
         Standard_Integer aWidth, aHeight;
         aCurPointAspect->GetTextureSize( aWidth, aHeight );
+
+#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
+        Handle(TColStd_HArray1OfByte) aTexture = aCurPointAspect->GetTexture();
+#else
         Handle(Graphic3d_HArray1OfBytes) aTexture = aCurPointAspect->GetTexture();
+#endif
+
         aCurDrawer->SetPointAspect( new Prs3d_PointAspect( aQuanColor, 1, aWidth, aHeight, aTexture ) );
       }
       ic->SetLocalAttributes( io, aCurDrawer );
 
       io->SetColor( aQuanColor );
-      if ( io->IsKind( STANDARD_TYPE(GEOM_AISShape) ) )
-        Handle(GEOM_AISShape)::DownCast( io )->SetShadingColor( aQuanColor );
+      if ( io->IsKind( STANDARD_TYPE(GEOM_AISShape) ) ) {
+       Handle(GEOM_AISShape) aGAISShape = Handle(GEOM_AISShape)::DownCast( io );
+        aGAISShape->SetShadingColor( aQuanColor );
+       aGAISShape->storeBoundaryColors();
+      }
 
       io->Redisplay( Standard_True );
     }
@@ -314,7 +281,7 @@ void GEOMToolsGUI::OnColor()
         SUIT_ViewWindow* window = app->desktop()->activeWindow();
         bool isOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
         bool isVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
-       int mgrId = window->getViewManager()->getGlobalId();
+        int mgrId = window->getViewManager()->getGlobalId();
         if ( isVTK ) {
           SVTK_ViewWindow* vtkVW = dynamic_cast<SVTK_ViewWindow*>( window );
           if ( !vtkVW )
@@ -326,19 +293,23 @@ void GEOMToolsGUI::OnColor()
             SUIT_OverrideCursor();
             for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
               aView->SetColor( It.Value(), c );
-             appStudy->setObjectProperty(mgrId,It.Value()->getEntry(),COLOR_PROP, c);
-           }
+              appStudy->setObjectProperty(mgrId,It.Value()->getEntry(),COLOR_PROP, c);
+            }
             GeometryGUI::Modified();
           }
         } // if ( isVTK )
         else if ( isOCC ) {
-          Handle(AIS_InteractiveObject) io = GEOMBase::GetAIS( selected.First() );
+         Handle(AIS_InteractiveObject) io = GEOMBase::GetAIS( selected.First() );
           if ( !io.IsNull() ) {
             Quantity_Color aColor;
-            io->Color( aColor );
-            QColor initcolor ((int)( aColor.Red() * 255.0 ),
-                              (int)( aColor.Green() * 255.0 ),
-                              (int)( aColor.Blue() * 255.0 ));
+            io->Color( aColor ); 
+           QColor ic = QColor((int )( aColor.Red() * 255.0 ),
+                             (int)( aColor.Green() * 255.0 ),
+                             (int)( aColor.Blue() * 255.0 ));      
+
+           QVariant v = appStudy->getObjectProperty(mgrId,selected.First()->getEntry(), COLOR_PROP, ic);
+
+            QColor initcolor = v.value<QColor>();
             QColor c =  QColorDialog::getColor( initcolor, app->desktop() );
             if ( c.isValid() ) {
               SUIT_OverrideCursor();
@@ -351,7 +322,8 @@ void GEOMToolsGUI::OnColor()
                   
                   if ( io->IsKind( STANDARD_TYPE(AIS_Shape) ) ) {
                     TopoDS_Shape theShape = Handle(AIS_Shape)::DownCast( io )->Shape();
-                    if (theShape.ShapeType() == TopAbs_VERTEX) {
+                    bool onlyVertex = (theShape.ShapeType() == TopAbs_VERTEX || GEOM_Displayer::isCompoundOfVertices( theShape ));
+                    if (onlyVertex) {
                       // Set color for a point
 
                       Handle(AIS_Drawer) aCurDrawer = io->Attributes();
@@ -366,19 +338,28 @@ void GEOMToolsGUI::OnColor()
                       else {
                         Standard_Integer aWidth, aHeight;
                         aCurPointAspect->GetTextureSize( aWidth, aHeight );
+
+#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
+                        Handle(TColStd_HArray1OfByte) aTexture = aCurPointAspect->GetTexture();
+#else
                         Handle(Graphic3d_HArray1OfBytes) aTexture = aCurPointAspect->GetTexture();
+#endif
+
                         aCurDrawer->SetPointAspect(new Prs3d_PointAspect(aColor, 1, aWidth, aHeight, aTexture));
                       }
                       ic->SetLocalAttributes(io, aCurDrawer, Standard_False);
                     }
                   }
-
+                 
                   io->SetColor( aColor );
-                  if ( io->IsKind( STANDARD_TYPE(GEOM_AISShape) ) )
-                    Handle(GEOM_AISShape)::DownCast( io )->SetShadingColor( aColor );
-
-                 appStudy->setObjectProperty(mgrId,It.Value()->getEntry(), COLOR_PROP, c);
-
+                  if ( io->IsKind( STANDARD_TYPE(GEOM_AISShape) ) ) {
+                    Handle(GEOM_AISShape) aGAISShape = Handle(GEOM_AISShape)::DownCast( io );
+                   aGAISShape->SetShadingColor( aColor );
+                   aGAISShape->storeBoundaryColors();
+                 }
+                 
+                  appStudy->setObjectProperty(mgrId,It.Value()->getEntry(), COLOR_PROP, c);
+                 
                   io->Redisplay( Standard_True );
 
                   // store color to GEOM_Object
@@ -393,7 +374,7 @@ void GEOMToolsGUI::OnColor()
                   aSColor.G = (double)c.green() / 255.0;
                   aSColor.B = (double)c.blue() / 255.0;
                   anObject->SetColor( aSColor );
-                  anObject->SetAutoColor( false );
+                  anObject->SetAutoColor( false );               
                 }
               } // for
               ic->UpdateCurrentViewer();
@@ -408,6 +389,47 @@ void GEOMToolsGUI::OnColor()
   app->updateActions(); //SRN: To update a Save button in the toolbar
 }
 
+void GEOMToolsGUI::OnTexture()
+{
+  SALOME_ListIO selected;
+  SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
+  SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
+  if ( app && appStudy ) {
+    LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
+    if ( aSelMgr ) {
+      aSelMgr->selectedObjects( selected );
+      if ( !selected.IsEmpty() ) {
+        SUIT_ViewWindow* window = app->desktop()->activeWindow();
+        bool isOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
+        if ( isOCC ) {
+          QString aTexture = QFileDialog::getOpenFileName(window,tr( "GEOM_SELECT_IMAGE"),QString(), tr("OCC_IMAGE_FILES"));
+          if( !aTexture.isEmpty() )
+          {
+            SUIT_OverrideCursor();
+            OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*> ( window->getViewManager()->getViewModel() );
+            Handle (AIS_InteractiveContext) ic = vm->getAISContext();
+            Handle(AIS_InteractiveObject) io ;
+            for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
+              io = GEOMBase::GetAIS( It.Value(), true );
+              if ( !io.IsNull() ) {
+                if ( io->IsKind( STANDARD_TYPE(GEOM_AISShape) ) )
+                 Handle(GEOM_AISShape)::DownCast( io )->SetTextureFileName(TCollection_AsciiString(aTexture.toStdString().c_str()));
+               io->Redisplay( Standard_True );
+              } // if ( !io.IsNull() )
+            } // for
+            ic->UpdateCurrentViewer();
+            GeometryGUI::Modified();
+            GeometryGUI* myGeomGUI = getGeometryGUI();
+            myGeomGUI->OnGUIEvent(GEOMOp::OpTexture);
+          } // if ( !selFile.isEmpty() )
+        } // if ( isOCC )
+      } // if ( selection not empty )
+    }
+  }
+
+  app->updateActions(); //SRN: To update a Save button in the toolbar
+}
+
 void GEOMToolsGUI::OnTransparency()
 {
   GEOMToolsGUI_TransparencyDlg dlg( SUIT_Session::session()->activeApplication()->desktop() );
@@ -512,6 +534,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();
@@ -533,7 +556,7 @@ void GEOMToolsGUI::OnNbIsos( ActionType actionType )
           newNbUIso = NbIsosDlg->getU();
           newNbVIso = NbIsosDlg->getV();
         } else //Cancel case
-         return;
+          return;
       }
       else if ( actionType == INCR || actionType == DECR ) {
         int delta = 1;
@@ -548,21 +571,25 @@ void GEOMToolsGUI::OnNbIsos( ActionType actionType )
       }
 
       for(; ic->MoreCurrent(); ic->NextCurrent()) {
+        int aMgrId = window->getViewManager()->getGlobalId();
         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) );
+
+       QVariant v = aStudy->getObjectProperty( aMgrId, CurObject->getIO()->getEntry(), EDGE_WIDTH_PROP , QVariant() );
+
+       int width = v.isValid() ? v.toInt() : 1;
+
+        CurDrawer->SetUIsoAspect( new Prs3d_IsoAspect(Quantity_NOC_GRAY75, Aspect_TOL_SOLID, width , newNbUIso) );
+        CurDrawer->SetVIsoAspect( new Prs3d_IsoAspect(Quantity_NOC_GRAY75, Aspect_TOL_SOLID, width , 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);
+        QString anIsos("%1%2%3");anIsos = anIsos.arg(newNbUIso);anIsos = anIsos.arg(DIGIT_SEPARATOR);anIsos = anIsos.arg(newNbVIso);
+        aStudy->setObjectProperty(aMgrId ,CurObject->getIO()->getEntry(), ISOS_WIDTH_PROP, anIsos);
       }
     }
     GeometryGUI::Modified();
@@ -612,8 +639,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;
     
@@ -633,7 +662,7 @@ void GEOMToolsGUI::OnNbIsos( ActionType actionType )
         newNbUIso = NbIsosDlg->getU();
         newNbVIso = NbIsosDlg->getV();
       } else 
-       return; //Cancel case 
+        return; //Cancel case 
     }
     else if ( actionType == INCR || actionType == DECR ) {
       int delta = 1;
@@ -652,10 +681,11 @@ 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();
-       aStudy->setObjectProperty(aMgrId ,anActor->getIO()->getEntry(), ISOS_PROP, anIsos);
+        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 ,anActor->getIO()->getEntry(), ISOS_PROP, anIsos);
       }
       anAct = aCollection->GetNextActor();
     }
@@ -702,7 +732,7 @@ void GEOMToolsGUI::OnDeflection()
               CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current());
               ic->SetDeviationCoefficient(CurObject, aNewDC, Standard_True);
               ic->Redisplay(CurObject);
-             appStudy->setObjectProperty(mgrId,CurObject->getIO()->getEntry(), DEFLECTION_COEFF_PROP, aNewDC);
+              appStudy->setObjectProperty(mgrId,CurObject->getIO()->getEntry(), DEFLECTION_COEFF_PROP, aNewDC);
             }
           }
         }
@@ -771,7 +801,7 @@ void GEOMToolsGUI::OnDeflection()
         if (GEOM_Actor* anActor = GEOM_Actor::SafeDownCast(anAct)) {
           // There are no casting to needed actor.
           anActor->SetDeflection(aDC);
-         appStudy->setObjectProperty(mgrId, anActor->getIO()->getEntry(), DEFLECTION_COEFF_PROP, aDC);
+          appStudy->setObjectProperty(mgrId, anActor->getIO()->getEntry(), DEFLECTION_COEFF_PROP, aDC);
         }
         anAct = aCollection->GetNextActor();
       }
@@ -826,8 +856,8 @@ void GEOMToolsGUI::OnShowHideChildren( bool show )
           if ( obj ) {
             _PTR(AttributeExpandable) aExp = B->FindOrCreateAttribute( obj, "AttributeExpandable" );
             aExp->SetExpandable( show );
-           if(!show)
-             disp->EraseWithChildren(IObject,true);
+            if(!show)
+              disp->EraseWithChildren(IObject,true);
           } // if ( obj )
         } // iterator
       }
@@ -843,6 +873,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;
@@ -878,7 +913,7 @@ void GEOMToolsGUI::OnUnpublishObject() {
           if ( obj ) {
             _PTR(AttributeDrawable) aDrw = B->FindOrCreateAttribute( obj, "AttributeDrawable" );
             aDrw->SetDrawable( false );
-           disp->EraseWithChildren(IObject);
+            disp->EraseWithChildren(IObject);
           } // if ( obj )
         } // iterator
         aSelMgr->clearSelected();
@@ -908,8 +943,8 @@ void GEOMToolsGUI::OnPublishObject() {
   bool aLocked = ( _PTR(AttributeStudyProperties)( aStudy->GetProperties() ) )->IsLocked();
   if ( aLocked ) {
     SUIT_MessageBox::warning( app->desktop(),
-                             QObject::tr( "WRN_WARNING" ),
-                             QObject::tr( "WRN_STUDY_LOCKED" ) );
+                              QObject::tr( "WRN_WARNING" ),
+                              QObject::tr( "WRN_STUDY_LOCKED" ) );
     return;
   } 
   
@@ -917,3 +952,354 @@ void GEOMToolsGUI::OnPublishObject() {
     new GEOMToolsGUI_PublishDlg( SUIT_Session::session()->activeApplication()->desktop() );
   publishDlg->exec();
 }
+
+
+void GEOMToolsGUI::OnEdgeWidth()
+{
+  SUIT_ViewWindow* window = SUIT_Session::session()->activeApplication()->desktop()->activeWindow();
+  SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
+
+
+  bool isOCC = (window && window->getViewManager()->getType() == OCCViewer_Viewer::Type());
+  bool isVTK = (window && window->getViewManager()->getType() == SVTK_Viewer::Type());
+  int mgrId = window->getViewManager()->getGlobalId();
+
+  if (isOCC) { // if is OCCViewer
+    OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*>(window->getViewManager()->getViewModel());
+    Handle (AIS_InteractiveContext) ic = vm->getAISContext();
+    ic->InitCurrent();
+    if (ic->MoreCurrent()) {
+      Handle(GEOM_AISShape) CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current());
+
+      int aWidth = (int)CurObject->Width();
+
+      GEOMToolsGUI_LineWidthDlg * Dlg = new GEOMToolsGUI_LineWidthDlg
+        (SUIT_Session::session()->activeApplication()->desktop(),"EDGE_WIDTH_TLT");
+      Dlg->setTheLW(aWidth);
+      int aNewWidth = 0;
+      if (Dlg->exec()) {
+       aNewWidth = Dlg->getTheLW();
+       bool ok = (aNewWidth != aWidth && aNewWidth != 0 );
+       if (ok) {
+         for(; ic->MoreCurrent(); ic->NextCurrent()) {
+           CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current());
+           CurObject->SetWidth(aNewWidth);
+           ic->Redisplay(CurObject);
+           appStudy->setObjectProperty(mgrId,CurObject->getIO()->getEntry(), EDGE_WIDTH_PROP, aNewWidth);
+         }
+       }
+      }
+    }
+    else {
+      return;
+    }
+    GeometryGUI::Modified();
+  }
+  else if (isVTK) { // if is VTKViewer
+    SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>
+      (SUIT_Session::session()->activeApplication());
+    if (!app)
+      return;
+
+    LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
+    if (!aSelMgr)
+      return;
+
+    SALOME_ListIO selected;
+    aSelMgr->selectedObjects(selected);
+    if (selected.IsEmpty())
+      return;
+
+    SVTK_ViewWindow* vtkVW = dynamic_cast<SVTK_ViewWindow*>(window);
+    if (!vtkVW)
+      return;
+
+    SALOME_View* view = GEOM_Displayer::GetActiveView();
+
+    vtkActorCollection* aCollection = vtkActorCollection::New();
+
+    for (SALOME_ListIteratorOfListIO It (selected); It.More(); It.Next()) {
+      Handle(SALOME_InteractiveObject) anIObject = It.Value();
+      SALOME_Prs* aPrs = view->CreatePrs(anIObject->getEntry());
+      SVTK_Prs* vtkPrs = dynamic_cast<SVTK_Prs*>(aPrs);
+      if (vtkPrs) {
+        vtkActorCollection* anActors = vtkPrs->GetObjects();
+        anActors->InitTraversal();
+        vtkActor* anAct = anActors->GetNextActor();
+        aCollection->AddItem(anAct);
+      }
+    }
+
+    if (aCollection)
+      aCollection->InitTraversal();
+    else
+      return;
+
+    int aWidth = 1;
+
+    vtkActor* anAct = aCollection->GetNextActor();
+    if (GEOM_Actor* anActor = GEOM_Actor::SafeDownCast(anAct))
+      aWidth = anActor->GetWidth();
+    else
+      return;
+
+    GEOMToolsGUI_LineWidthDlg * Dlg = new GEOMToolsGUI_LineWidthDlg
+      (SUIT_Session::session()->activeApplication()->desktop(),"EDGE_WIDTH_TLT");
+    
+    Dlg->setTheLW(aWidth);
+    if (Dlg->exec()) {
+      SUIT_OverrideCursor();
+      aWidth = Dlg->getTheLW();
+      while (anAct != NULL) {
+        if (GEOM_Actor* anActor = GEOM_Actor::SafeDownCast(anAct)) {
+          // There are no casting to needed actor.
+          anActor->SetWidth(aWidth);
+          appStudy->setObjectProperty(mgrId, anActor->getIO()->getEntry(), EDGE_WIDTH_PROP, aWidth);
+        }
+        anAct = aCollection->GetNextActor();
+      }
+    }
+    GeometryGUI::Modified();
+  } // end vtkviewer
+}
+
+
+void GEOMToolsGUI::OnIsosWidth() {
+  SalomeApp_Application* app =
+    dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
+  SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
+  SUIT_ViewWindow* window = app->desktop()->activeWindow();
+
+  bool isOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
+  bool isVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
+
+  if(isOCC){ // if is OCCViewer
+
+    OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*>( window->getViewManager()->getViewModel() );
+    Handle (AIS_InteractiveContext) ic = vm->getAISContext();
+
+    ic->InitCurrent();
+    if ( ic->MoreCurrent() ) {
+      Handle(GEOM_AISShape) CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current());
+      CurObject->restoreIsoNumbers();
+      Handle(AIS_Drawer)    CurDrawer = CurObject->Attributes();
+
+      Handle(Graphic3d_AspectLine3d) asp = CurDrawer->UIsoAspect()->Aspect();
+      
+      Quantity_Color C;
+      Aspect_TypeOfLine T;
+      Standard_Real W;
+      asp->Values(C,T,W);
+
+      int aWidth = (int)W;
+
+      GEOMToolsGUI_LineWidthDlg * Dlg =
+       new GEOMToolsGUI_LineWidthDlg( SUIT_Session::session()->activeApplication()->desktop(),"ISOS_WIDTH_TLT" );
+
+      Dlg->setTheLW( aWidth );
+
+      if ( Dlg->exec() ) {
+       SUIT_OverrideCursor();          
+       aWidth = Dlg->getTheLW();
+      } else //Cancel case
+       return;
+      
+      for(; ic->MoreCurrent(); ic->NextCurrent()) {
+       int aMgrId = window->getViewManager()->getGlobalId();
+       CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current());
+       
+       Handle(AIS_Drawer) CurDrawer = CurObject->Attributes();
+       
+       CurObject->Attributes()->UIsoAspect()->SetWidth(aWidth);
+       CurObject->Attributes()->VIsoAspect()->SetWidth(aWidth);
+       
+       ic->Redisplay(CurObject);
+       
+       aStudy->setObjectProperty(aMgrId ,CurObject->getIO()->getEntry(), ISOS_WIDTH_PROP, aWidth);
+      }
+      GeometryGUI::Modified();
+    }
+  }
+  else if(isVTK){ // if is VTKViewer
+    //
+    // Warning. It's works incorrect. must be recheked.
+    //
+    SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >
+      ( SUIT_Session::session()->activeApplication() );
+    if ( !app )
+      return;
+    LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
+    if ( !aSelMgr )
+      return;
+    SALOME_ListIO selected;
+    aSelMgr->selectedObjects( selected );
+    if ( selected.IsEmpty() )
+      return;
+
+    SVTK_ViewWindow* vtkVW = dynamic_cast<SVTK_ViewWindow*>( window );
+    if ( !vtkVW )
+      return;
+
+    SALOME_View* view = GEOM_Displayer::GetActiveView();
+
+    vtkActorCollection* aCollection = vtkActorCollection::New();
+
+    for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
+      Handle(SALOME_InteractiveObject) anIObject = It.Value();
+      SALOME_Prs* aPrs = view->CreatePrs( anIObject->getEntry() );
+      SVTK_Prs* vtkPrs = dynamic_cast<SVTK_Prs*>( aPrs );
+      if ( vtkPrs ) {
+        vtkActorCollection* anActors = vtkPrs->GetObjects();
+        anActors->InitTraversal();
+        vtkActor* anAct = anActors->GetNextActor();
+        aCollection->AddItem(anAct);
+      }
+    }
+
+    if(aCollection)
+      aCollection->InitTraversal();
+    else
+      return;
+
+    int aWidth = 1;
+
+    vtkActor* anAct = aCollection->GetNextActor();
+    if (GEOM_Actor* anActor = GEOM_Actor::SafeDownCast(anAct)) {
+      aWidth = anActor->GetIsosWidth();
+    }
+    else
+      return;
+    
+    GEOMToolsGUI_LineWidthDlg* Dlg =
+      new GEOMToolsGUI_LineWidthDlg( SUIT_Session::session()->activeApplication()->desktop(), "ISOS_WIDTH_TLT" );
+    
+    Dlg->setTheLW( aWidth );
+    if (Dlg->exec() ) {
+      SUIT_OverrideCursor();
+      aWidth = Dlg->getTheLW();
+    } else 
+      return; //Cancel case 
+    
+    while( anAct!= NULL ) {
+      if(GEOM_Actor* anActor = GEOM_Actor::SafeDownCast(anAct)) {
+        // There are no casting to needed actor.
+       anActor->SetIsosWidth(aWidth);
+       int aMgrId = window->getViewManager()->getGlobalId();
+        aStudy->setObjectProperty(aMgrId ,anActor->getIO()->getEntry(), ISOS_WIDTH_PROP, aWidth);
+      }
+      anAct = aCollection->GetNextActor();
+    }
+    
+    view->Repaint();
+    GeometryGUI::Modified();
+  } // end vtkviewer  
+}
+
+void GEOMToolsGUI::OnBringToFront() {
+ SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
+  if ( !app )
+    return;
+
+  SalomeApp_Module* mod = dynamic_cast<SalomeApp_Module*>(app->activeModule());
+  if(!mod)
+    return;
+  
+  GEOM_Displayer* disp  = dynamic_cast<GEOM_Displayer*>(mod->displayer());
+  
+  if(!disp)
+    return;
+  
+  LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
+  if ( !aSelMgr )
+    return;
+
+  SALOME_ListIO selected;
+  aSelMgr->selectedObjects( selected );
+  if ( selected.IsEmpty() )
+    return;
+
+  SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(app->activeStudy());  
+  if(!appStudy)
+    return;
+
+  SUIT_ViewWindow* window = app->desktop()->activeWindow();
+
+  OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*>( window->getViewManager()->getViewModel() );
+  if ( !vm )
+    return;
+  
+  bool isOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
+
+  QAction* a = getGeometryGUI()->getAction( GEOMOp::OpBringToFront );
+  bool checked = a->isChecked();
+  
+  if ( isOCC ) {
+    GEOMBase* gb = new GEOMBase();
+    Handle(GEOM_AISShape) aisShape;
+   
+    Handle(AIS_InteractiveContext) ic = vm->getAISContext();
+    SALOME_ListIO anIOlst;
+    for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
+      aisShape = gb->ConvertIOinGEOMAISShape( It.Value(), true );
+      if ( !aisShape.IsNull() ) {
+       aisShape->setTopLevel(checked);
+       int aMgrId = window->getViewManager()->getGlobalId();
+       appStudy->setObjectProperty( aMgrId, aisShape->getIO()->getEntry(), TOP_LEVEL_PROP, checked );
+       anIOlst.Append(aisShape->getIO());
+      }
+    } // for...
+    disp->Redisplay(anIOlst);
+    GeometryGUI::Modified();
+  } // if ( isOCC )
+}
+
+void GEOMToolsGUI::OnClsBringToFront() {
+  SalomeApp_Application* app =
+    dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
+  if(!app)
+    return;
+
+  SalomeApp_Module* mod = dynamic_cast<SalomeApp_Module*>(app->activeModule());
+  if(!mod)
+    return;
+  
+  GEOM_Displayer* disp  = dynamic_cast<GEOM_Displayer*>(mod->displayer());
+  
+  if(!disp)
+    return;
+
+
+  SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(app->activeStudy());  
+  if(!appStudy)
+    return;
+  
+  SUIT_ViewWindow* window = app->desktop()->activeWindow();  
+  
+  bool isOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
+  
+  if(isOCC){ // if is OCCViewer
+    
+    OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*>( window->getViewManager()->getViewModel() );
+    Handle (AIS_InteractiveContext) ic = vm->getAISContext();
+    
+    SALOME_ListIO anIOlst;
+    AIS_ListOfInteractive aList;
+    ic->DisplayedObjects( aList );
+    for ( AIS_ListIteratorOfListOfInteractive it( aList ); it.More(); it.Next() ) {
+      
+      Handle(GEOM_AISShape) CurObject = Handle(GEOM_AISShape)::DownCast(it.Value());
+      
+      if(CurObject.IsNull())
+       continue;
+      
+      CurObject->setTopLevel(Standard_False);
+      
+      int aMgrId = window->getViewManager()->getGlobalId();
+      appStudy->setObjectProperty( aMgrId, QString(CurObject->getIO()->getEntry()), TOP_LEVEL_PROP, Standard_False );
+      anIOlst.Append(CurObject->getIO());
+    }
+    disp->Redisplay(anIOlst);
+    GeometryGUI::Modified();
+  }
+}
+