Salome HOME
Fix previous wrong-tag commit
[modules/geom.git] / src / GEOMGUI / GEOM_Displayer.cxx
index ad8b77511713e5588828ee1dc4dda2a39c50abb6..ea0fbcade5092797f0a7eee8352b3e447d006986 100644 (file)
@@ -313,7 +313,11 @@ GEOM_Displayer::GEOM_Displayer( SalomeApp_Study* st )
   myShadingColor = SalomeApp_Tools::color( col );
 
   myDisplayMode = resMgr->integerValue("Geometry", "display_mode", 0);
+
   int aType = resMgr->integerValue("Geometry", "type_of_marker", (int)Aspect_TOM_PLUS);
+  myWidth = resMgr->integerValue("Geometry", "edge_width", -1);
+  myIsosWidth = resMgr->integerValue("Geometry", "isolines_width", -1);
+
   myTypeOfMarker = (Aspect_TypeOfMarker)(std::min((int)Aspect_TOM_RING3, std::max((int)Aspect_TOM_POINT, aType)));
   myScaleOfMarker = (resMgr->integerValue("Geometry", "marker_scale", 1)-(int)GEOM::MS_10)*0.5 + 1.0;
   myScaleOfMarker = std::min(7.0, std::max(1., myScaleOfMarker));
@@ -662,15 +666,18 @@ void GEOM_Displayer::Update( SALOME_OCCPrs* prs )
           AISShape->SetDisplayMode( aPropMap.value(DISPLAY_MODE_PROP).toInt() );
           AISShape->SetDisplayVectors(aPropMap.value(VECTOR_MODE_PROP).toInt());
 
-          //Color property
-          if(aPropMap.contains(COLOR_PROP)) {
+         if(aPropMap.contains(TOP_LEVEL_PROP)) {
+           AISShape->setTopLevel( aPropMap.value(TOP_LEVEL_PROP).value<Standard_Boolean>() );
+         } 
+         
+         if(aPropMap.contains(COLOR_PROP)) {
             Quantity_Color  quant_col = SalomeApp_Tools::color( aPropMap.value(COLOR_PROP).value<QColor>());
             AISShape->SetShadingColor( quant_col );
           } else
             useObjColor = true;
         }else {
           MESSAGE("myDisplayMode = "<< myDisplayMode)
-          AISShape->SetDisplayMode( myDisplayMode );
+           AISShape->SetDisplayMode( myDisplayMode );
           AISShape->SetShadingColor( myShadingColor );
         }
 
@@ -696,10 +703,15 @@ void GEOM_Displayer::Update( SALOME_OCCPrs* prs )
         Handle(Prs3d_IsoAspect) anAspect = AISShape->Attributes()->UIsoAspect();
         anAspect->SetNumber( anUIsoNumber );
         anAspect->SetColor( aColor );
+       if(HasIsosWidth())
+         anAspect->SetWidth( GetIsosWidth() );
         AISShape->Attributes()->SetUIsoAspect( anAspect );
 
+
         anAspect = AISShape->Attributes()->VIsoAspect();
         anAspect->SetNumber( aVIsoNumber );
+       if(HasIsosWidth())
+         anAspect->SetWidth( GetIsosWidth() );
         anAspect->SetColor( aColor );
         AISShape->Attributes()->SetVIsoAspect( anAspect );
 
@@ -797,6 +809,7 @@ void GEOM_Displayer::Update( SALOME_OCCPrs* prs )
             anAspect = AISShape->Attributes()->UnFreeBoundaryAspect();
             anAspect->SetColor( aColor );
             AISShape->Attributes()->SetUnFreeBoundaryAspect( anAspect );
+           AISShape->storeBoundaryColors();
 
             // Set free boundaries aspect
             col = aResMgr->colorValue( "Geometry", "free_bound_color", QColor( 0, 255, 0 ) );
@@ -827,6 +840,8 @@ void GEOM_Displayer::Update( SALOME_OCCPrs* prs )
             double aDC = 0;
             if(useStudy) {
               aDC = aPropMap.value(DEFLECTION_COEFF_PROP).toDouble();
+             SetWidth(aPropMap.value(EDGE_WIDTH_PROP).toInt());
+             SetIsosWidth(aPropMap.value(ISOS_WIDTH_PROP).toInt());
             }
             else {
               aDC = aResMgr->doubleValue("Geometry", "deflection_coeff", 0.001);
@@ -836,7 +851,7 @@ void GEOM_Displayer::Update( SALOME_OCCPrs* prs )
             AISShape->SetOwnDeviationCoefficient(aDC);
           }
         }
-
+               
         if ( HasTexture() )
         {
           AISShape->SetTextureFileName(TCollection_AsciiString(myTexture.c_str()));
@@ -844,7 +859,7 @@ void GEOM_Displayer::Update( SALOME_OCCPrs* prs )
           AISShape->DisableTextureModulate();
           AISShape->SetDisplayMode(3);
         }
-        
+         
         if ( HasWidth() )
           AISShape->SetWidth( GetWidth() );
 
@@ -887,7 +902,7 @@ void GEOM_Displayer::Update( SALOME_OCCPrs* prs )
                   anAspect->SetTypeOfMarker( myTypeOfMarker );
                   AISShape->Attributes()->SetPointAspect( anAspect );
                 }
-              } else if(!hasColor) {
+              } else if( !hasColor ) {
                 //In case if color wasn't defined in the property map of the object
                 //and GEOM_Object color also wasn't defined get default color from Resource Mgr.
                 QColor col = aResMgr->colorValue( "Geometry", "shading_color", QColor( 255, 0, 0 ) );
@@ -1002,6 +1017,13 @@ void GEOM_Displayer::Update( SALOME_OCCPrs* prs )
           if ( aModelB )
             delete aModelB;
 
+         if(HasWidth())
+           aStudy->setObjectProperty( aMgrId, anIO->getEntry(), EDGE_WIDTH_PROP, GetWidth() );
+
+         if(HasIsosWidth())
+           aStudy->setObjectProperty( aMgrId, anIO->getEntry(), ISOS_WIDTH_PROP, GetIsosWidth() );
+
+
         }
 
         // AISShape->SetName(???); ??? necessary to set name ???
@@ -1132,11 +1154,6 @@ void GEOM_Displayer::Update( SALOME_VTKPrs* prs )
     aProp->SetColor( aColor.Red(), aColor.Green(), aColor.Blue() );
   }
 
-  if ( HasWidth() )
-  {
-    aProp->SetLineWidth( GetWidth() );
-  }
-
   while ( anActor != NULL )
   {
     SALOME_Actor* GActor = SALOME_Actor::SafeDownCast( anActor );
@@ -1171,6 +1188,8 @@ void GEOM_Displayer::Update( SALOME_VTKPrs* prs )
           aIsos[0] = uv[0].toInt(); aIsos[1] = uv[1].toInt();
           aGeomGActor->SetNbIsos(aIsos);
           aGeomGActor->SetOpacity(1.0 - aPropMap.value(TRANSPARENCY_PROP).toDouble());
+         SetWidth(aPropMap.value(EDGE_WIDTH_PROP).toInt());
+         SetIsosWidth(aPropMap.value(ISOS_WIDTH_PROP).toInt());
           aGeomGActor->SetVectorMode(aPropMap.value(VECTOR_MODE_PROP).toInt());
          int aDispModeId = aPropMap.value(DISPLAY_MODE_PROP).toInt();
          // Specially processing of 'Shading with edges' mode from preferences,
@@ -1216,6 +1235,13 @@ void GEOM_Displayer::Update( SALOME_VTKPrs* prs )
 
            // Release memory
            delete aModelB;
+
+           if(HasWidth())
+             aStudy->setObjectProperty( aMgrId, anEntry, EDGE_WIDTH_PROP, GetWidth() );
+
+           if(HasIsosWidth())
+             aStudy->setObjectProperty( aMgrId, anEntry, ISOS_WIDTH_PROP, GetIsosWidth() );
+         
          }
          else {
            // Set the same front and back materials for the selected shape
@@ -1291,6 +1317,17 @@ void GEOM_Displayer::Update( SALOME_VTKPrs* prs )
        }
       }
 
+    if ( HasWidth() )
+      {
+       aGeomGActor->SetWidth( GetWidth() );
+      }
+    
+    
+    if ( HasIsosWidth() )
+      {
+       aGeomGActor->SetIsosWidth( GetIsosWidth() );
+      }
+    
     if ( myToActivate )
       GActor->PickableOn();
     else
@@ -1759,6 +1796,23 @@ void GEOM_Displayer::UnsetWidth()
   myWidth = -1;
 }
 
+
+int GEOM_Displayer::GetIsosWidth() const
+{
+  return myIsosWidth;
+}
+
+void GEOM_Displayer::SetIsosWidth(const int width) 
+{
+  myIsosWidth = width;
+}
+
+bool GEOM_Displayer::HasIsosWidth() const
+{
+  return myIsosWidth != -1;
+}
+
+
 //=================================================================
 /*!
  *  GEOM_Displayer::SetToActivate
@@ -1961,12 +2015,24 @@ PropMap GEOM_Displayer::getDefaultPropertyMap(const QString& viewer_type) {
   QString aMaterialF = aModelF.getMaterialProperty();
   aDefaultMap.insert( FRONT_MATERIAL_PROP , aMaterialF );  
 
-  //  Back material
+  //9.  Back material
   Material_Model aModelB;
   aModelB.fromResources( aResMgr, "Geometry", false );
   QString aMaterialB = aModelB.getMaterialProperty();
   aDefaultMap.insert( BACK_MATERIAL_PROP , aMaterialB );
 
+  //10. Width of the edges
+  aDefaultMap.insert( EDGE_WIDTH_PROP , aResMgr->integerValue("Geometry", "edge_width", 1));
+
+
+  //11. Width of iso-lines
+  aDefaultMap.insert( ISOS_WIDTH_PROP , aResMgr->integerValue("Geometry", "isolines_width", 1));
+
+  if(viewer_type == SOCC_Viewer::Type()) {
+
+    aDefaultMap.insert(TOP_LEVEL_PROP, Standard_False);
+  }
+
   return aDefaultMap;
 }
 
@@ -2004,6 +2070,17 @@ bool GEOM_Displayer::MergePropertyMaps(PropMap& theOrigin, PropMap& theDefault)
     theOrigin.insert(BACK_MATERIAL_PROP, theDefault.value(BACK_MATERIAL_PROP));
     nbInserted++;
   }
+
+  if(!theOrigin.contains(EDGE_WIDTH_PROP)) {
+    theOrigin.insert(EDGE_WIDTH_PROP, theDefault.value(EDGE_WIDTH_PROP));
+    nbInserted++;
+  }
+
+  if(!theOrigin.contains(ISOS_WIDTH_PROP)) {
+    theOrigin.insert(ISOS_WIDTH_PROP, theDefault.value(ISOS_WIDTH_PROP));
+    nbInserted++;
+  }
+
   return (nbInserted > 0);
 }