]> SALOME platform Git repositories - modules/geom.git/blobdiff - src/GEOMGUI/GEOM_Displayer.cxx
Salome HOME
Implementation of the "21046: EDF 1610 GUI: To be able to change the width of the...
[modules/geom.git] / src / GEOMGUI / GEOM_Displayer.cxx
index 40b98f034dc680768ed0602a3ae57b57f7d28596..8d7bb760361c25c80ab02f5b41a011dcb7b61cab 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));
@@ -696,10 +700,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 +806,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 +837,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);
@@ -942,68 +954,74 @@ 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;
+          // 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 );   
-        }
+          } else {
+            // Get front material property from study and construct front material model
+            aModelF = new Material_Model();
+            aModelF->fromResources( aResMgr, "Geometry", true );
 
-       // Set front material property
-       QString aMaterialPropF = aModelF->getMaterialProperty();
-       aStudy->setObjectProperty( aMgrId, anIO->getEntry(), FRONT_MATERIAL_PROP, aMaterialPropF );
+            // Get back material property from study and construct back material model
+            aModelB = new Material_Model();
+            aModelB->fromResources( aResMgr, "Geometry", false );         
+          }
 
-       // Set back material property
-       QString aMaterialPropB = aModelB->getMaterialProperty();
-       aStudy->setObjectProperty( aMgrId, anIO->getEntry(), BACK_MATERIAL_PROP, aMaterialPropB );
+          // Set front material property
+          QString aMaterialPropF = aModelF->getMaterialProperty();
+          aStudy->setObjectProperty( aMgrId, anIO->getEntry(), FRONT_MATERIAL_PROP, aMaterialPropF );
 
-       // Get front material properties from the model
-        Graphic3d_MaterialAspect aMatF = aModelF->getMaterialOCCAspect();
+          // Set back material property
+          QString aMaterialPropB = aModelB->getMaterialProperty();
+          aStudy->setObjectProperty( aMgrId, anIO->getEntry(), BACK_MATERIAL_PROP, aMaterialPropB );
 
-       // Get back material properties from the model
-        Graphic3d_MaterialAspect aMatB = aModelB->getMaterialOCCAspect();
+          // Get front material properties from the model
+          Graphic3d_MaterialAspect aMatF = aModelF->getMaterialOCCAspect();
 
-       printf(">> GEOM_Displayer::Update() : SetMaterial\n");
-       // Set front material for the selected shape
-       AISShape->SetCurrentFacingModel(Aspect_TOFM_FRONT_SIDE);
-       AISShape->SetMaterial(aMatF);   
+          // Get back material properties from the model
+          Graphic3d_MaterialAspect aMatB = aModelB->getMaterialOCCAspect();
 
-       // Set back material for the selected shape
-       AISShape->SetCurrentFacingModel(Aspect_TOFM_BACK_SIDE);
-       AISShape->SetMaterial(aMatB);
+          // Set front material for the selected shape
+          AISShape->SetCurrentFacingModel(Aspect_TOFM_FRONT_SIDE);
+          AISShape->SetMaterial(aMatF); 
 
-       // Return to the default facing mode
-       AISShape->SetCurrentFacingModel(Aspect_TOFM_BOTH_SIDE);
+          // Set back material for the selected shape
+          AISShape->SetCurrentFacingModel(Aspect_TOFM_BACK_SIDE);
+          AISShape->SetMaterial(aMatB);
 
-       // Release memory
-       if ( aModelF )
-         delete aModelF;
-       if ( aModelB )
-         delete aModelB;
+          // Return to the default facing mode
+          AISShape->SetCurrentFacingModel(Aspect_TOFM_BOTH_SIDE);
+
+          // Release memory
+          if ( aModelF )
+            delete aModelF;
+          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 ???
         occPrs->AddObject( AISShape );
@@ -1133,11 +1151,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 );
@@ -1172,6 +1185,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,
@@ -1217,6 +1232,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
@@ -1292,6 +1314,17 @@ void GEOM_Displayer::Update( SALOME_VTKPrs* prs )
        }
       }
 
+    if ( HasWidth() )
+      {
+       aGeomGActor->SetWidth( GetWidth() );
+      }
+    
+    
+    if ( HasIsosWidth() )
+      {
+       aGeomGActor->SetIsosWidth( GetIsosWidth() );
+      }
+    
     if ( myToActivate )
       GActor->PickableOn();
     else
@@ -1760,6 +1793,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
@@ -1962,12 +2012,20 @@ 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));
+
+
   return aDefaultMap;
 }
 
@@ -2005,6 +2063,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);
 }