]> SALOME platform Git repositories - modules/smesh.git/commitdiff
Salome HOME
Implementation of the "0022102: EDF 1496 SMESH : Displaying of discrete elements...
authorrnv <rnv@opencascade.com>
Fri, 13 Sep 2013 10:00:15 +0000 (10:00 +0000)
committerrnv <rnv@opencascade.com>
Fri, 13 Sep 2013 10:00:15 +0000 (10:00 +0000)
17 files changed:
doc/salome/gui/SMESH/images/pref22.png
doc/salome/gui/SMESH/input/mesh_preferences.doc
resources/SalomeApp.xml.in
src/OBJECT/SMESH_Actor.cxx
src/OBJECT/SMESH_ActorDef.h
src/OBJECT/SMESH_CellLabelActor.cxx
src/OBJECT/SMESH_DeviceActor.cxx
src/OBJECT/SMESH_DeviceActor.h
src/OBJECT/SMESH_Object.cxx
src/OBJECT/SMESH_SVTKActor.cxx
src/OBJECT/SMESH_SVTKActor.h
src/SMESHGUI/SMESHGUI.cxx
src/SMESHGUI/SMESHGUI_AddMeshElementDlg.cxx
src/SMESHGUI/SMESHGUI_AddMeshElementDlg.h
src/SMESHGUI/SMESHGUI_AddQuadraticElementDlg.cxx
src/SMESHGUI/SMESHGUI_ClippingDlg.cxx
src/SMESHGUI/SMESH_msg_en.ts

index ff13403fba5b5974eb858d0b81aa7a3db86183ef..f6a7b597853685476c7a4fbbd2394f69a0c9915d 100755 (executable)
Binary files a/doc/salome/gui/SMESH/images/pref22.png and b/doc/salome/gui/SMESH/images/pref22.png differ
index 80d751d6f057132817336fe10f77ce2592eb342d..b93723a3e46668c264aba94453068330432ec1d6 100644 (file)
@@ -156,6 +156,7 @@ later sessions with this module.
     borders.
   - <b>Wireframe color</b> - allows to select the color of borders of
     elements in the wireframe mode.
+  - <b>Preview color</b> - allows to select the preview color of the elements.
   - <b>Size of 0D elements</b> - specifies default size of 0D elements.
   - <b>Size of ball elements</b> - specifies default size of discrete
     elements (balls).
index 18ab16368bca111eddc10f873a29a9d1e8fa5f52..70bfd5226e39457ba33141a1bf5dd317ce4d550b 100644 (file)
@@ -34,6 +34,7 @@
     <parameter name="node_color"                   value="255, 0,   0"/>
     <parameter name="fill_color"                   value="#00aaff|100"/>
     <parameter name="volume_color"                 value="255, 0, 170|-100"/>
+    <parameter name="preview_color"                value="0, 255, 0|-100"/>
     <parameter name="wireframe_color"              value="0, 170, 255"/>
     <parameter name="outline_color"                value="#004600"/>
     <parameter name="elem0d_color"                 value="0, 255,   0"/>
index b2882117b8bd3e9ede4d9248d222c963447501c9..ec2a7c949bc29db214b71bccf95f0b10343af4d1 100644 (file)
@@ -375,7 +375,6 @@ SMESH_ActorDef::SMESH_ActorDef()
   my0DActor->SetProperty(my0DProp);
   my0DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
   aFilter = my0DActor->GetExtractUnstructuredGrid();
-  //aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
   aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
   aFilter->RegisterCellsWithType(VTK_VERTEX);
 
@@ -394,6 +393,7 @@ SMESH_ActorDef::SMESH_ActorDef()
   myBallActor->SetVisibility(false);
   myBallActor->SetProperty(myBallProp);
   myBallActor->SetRepresentation(SMESH_DeviceActor::eSurface);
+  myBallActor->SetBallEnabled(true);
   aFilter = myBallActor->GetExtractUnstructuredGrid();
   aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
   aFilter->RegisterCellsWithType(VTK_POLY_VERTEX);
@@ -474,11 +474,6 @@ SMESH_ActorDef::SMESH_ActorDef()
   myHighlightProp->SetLineWidth(aLineWidth);
   myHighlightProp->SetRepresentation(1);
 
-  myBallHighlightProp = vtkProperty::New();
-  myBallHighlightProp->DeepCopy(myHighlightProp);
-  myBallHighlightProp->SetPointSize(aBallElemSize);
-
-
   myOutLineProp = vtkProperty::New();
   myOutLineProp->SetAmbient(1.0);
   myOutLineProp->SetDiffuse(0.0);
@@ -498,10 +493,6 @@ SMESH_ActorDef::SMESH_ActorDef()
   myPreselectProp->SetLineWidth(aLineWidth);
   myPreselectProp->SetRepresentation(1);
 
-  myBallPreselectProp = vtkProperty::New();
-  myBallPreselectProp->DeepCopy(myPreselectProp);
-  myBallPreselectProp->SetPointSize(aBallElemSize);
-
   myHighlitableActor = SMESH_DeviceActor::New();
   myHighlitableActor->SetUserMatrix(aMatrix);
   myHighlitableActor->PickableOff();
@@ -602,9 +593,6 @@ SMESH_ActorDef::~SMESH_ActorDef()
   myOutLineProp->Delete();
   myPreselectProp->Delete();
 
-  myBallHighlightProp->Delete();
-  myBallPreselectProp->Delete();
-
   myHighlitableActor->Delete();
 
   my2DExtProp->Delete();
@@ -678,8 +666,6 @@ void SMESH_ActorDef::SetCellsFontProperties( SMESH::LabelFont theFamily, int the
 {    
   if(my3DActor) {
     my3DActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
-    SetRepresentation( GetRepresentation() );
-    myTimeStamp->Modified();
   }
   if(my2DActor) {
     my2DActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
@@ -1094,8 +1080,6 @@ SetControlMode(eControl theMode,
 
 void SMESH_ActorDef::AddToRender(vtkRenderer* theRenderer){
 
-  //myHighlightActor->AddToRender(theRenderer);
-
   theRenderer->AddActor(myBaseActor);
   theRenderer->AddActor(myNodeExtActor);
   theRenderer->AddActor(my1DExtActor);
@@ -1108,7 +1092,6 @@ void SMESH_ActorDef::AddToRender(vtkRenderer* theRenderer){
   my1DActor   ->AddToRender(theRenderer);
   my0DActor   ->AddToRender(theRenderer);
   myBallActor ->AddToRender(theRenderer);
-  //theRenderer->AddActor(my0DExtActor);
 
   theRenderer->AddActor(myHighlitableActor);
 
@@ -1157,6 +1140,9 @@ bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj,
   myVisualObj = theVisualObj;
   myVisualObj->Update(theIsClear);
 
+  SMESH_SVTKActor::SafeDownCast(myHighlightActor)->SetVisualObject(myVisualObj);
+  SMESH_SVTKActor::SafeDownCast(myPreHighlightActor)->SetVisualObject(myVisualObj);
+
   myNodeActor->Init(myVisualObj,myImplicitBoolean);
   myBaseActor->Init(myVisualObj,myImplicitBoolean);
 
@@ -1559,7 +1545,6 @@ void SMESH_ActorDef::SetEntityMode(unsigned int theMode)
 
   if (myEntityMode & eBallElem) {
     aFilter->RegisterCellsWithType(VTK_POLY_VERTEX);
-    aHightFilter->RegisterCellsWithType(VTK_POLY_VERTEX);
   }
 
   if (myEntityMode & eEdges) {
@@ -1638,9 +1623,9 @@ void SMESH_ActorDef::SetRepresentation (int theMode)
 
   if (theMode < 0) {
     myRepresentation = eSurface;
-    if (!aNbFaces && !aNbVolumes && aNbEdges) {
+    if (!aNbFaces && !aNbVolumes && !aNbBalls && aNbEdges) {
       myRepresentation = eEdge;
-    } else if (!aNbFaces && !aNbVolumes && !aNbEdges) {
+    } else if (!aNbFaces && !aNbVolumes && !aNbEdges && !aNbBalls) {
       myRepresentation = ePoint;
     }
   } else {
@@ -1710,17 +1695,13 @@ void SMESH_ActorDef::SetRepresentation (int theMode)
   my3DActor->SetBackfaceProperty(aPropVR);
   my3DActor->SetRepresentation(aReperesent);
 
-  //my0DExtActor->SetVisibility(false);
+
   my1DExtActor->SetVisibility(false);
   my2DExtActor->SetVisibility(false);
   my3DExtActor->SetVisibility(false);
 
-  // ???
-  //my0DActor->SetProperty(aProp);
-  //my0DActor->SetBackfaceProperty(aBackProp);
   my0DActor->SetRepresentation(aReperesent);
   myBallActor->SetRepresentation(aReperesent);
-  //my0DExtActor->SetRepresentation(aReperesent);
 
   switch(myControlMode){
   case eLength:
@@ -1770,7 +1751,6 @@ bool SMESH_ActorDef::GetPointRepresentation(){
 void SMESH_ActorDef::UpdateHighlight(){
   myHighlitableActor->SetHighlited(false);
   myHighlitableActor->SetVisibility(false);
-
   bool anIsVisible = GetVisibility();
 
   switch(myRepresentation){
@@ -1779,12 +1759,9 @@ void SMESH_ActorDef::UpdateHighlight(){
     {
       if(myIsHighlighted) {
         myHighlitableActor->SetProperty(myHighlightProp);
-        myBallActor->SetProperty(myBallHighlightProp);
       }else if(myIsPreselected){
         myHighlitableActor->SetProperty(myPreselectProp);
-        myBallActor->SetProperty(myBallPreselectProp);
       } else if(anIsVisible){
-        myBallActor->SetProperty(myBallProp);
         (myRepresentation == eSurface) ?
           myHighlitableActor->SetProperty(myOutLineProp) : myHighlitableActor->SetProperty(myEdgeProp);
       }
@@ -2042,7 +2019,6 @@ void SMESH_ActorDef::GetBallColor(double& r,double& g,double& b){
 
 void SMESH_ActorDef::SetHighlightColor(double r,double g,double b){ 
   myHighlightProp->SetColor(r,g,b);
-  myBallHighlightProp->SetColor(r,g,b);
   Modified();
 }
 
@@ -2052,7 +2028,6 @@ void SMESH_ActorDef::GetHighlightColor(double& r,double& g,double& b){
 
 void SMESH_ActorDef::SetPreHighlightColor(double r,double g,double b){ 
   myPreselectProp->SetColor(r,g,b);
-  myBallPreselectProp->SetColor(r,g,b);
   Modified();
 }
 
@@ -2111,8 +2086,7 @@ double SMESH_ActorDef::Get0DSize(){
 
 void SMESH_ActorDef::SetBallSize(double theVal){
   myBallProp->SetPointSize(theVal);
-  myBallHighlightProp->SetPointSize(theVal);
-  myBallPreselectProp->SetPointSize(theVal);
+
   if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myHighlightActor )) {
     aCustom->SetBallSize(theVal);
   }
index d412ac68a31016569f9777df65cd02b1330d3109..c891d3cc8765f08fecf2be7dde9dd1df84224e5c 100644 (file)
@@ -259,9 +259,6 @@ class SMESH_ActorDef : public SMESH_Actor
   vtkProperty* myOutLineProp;
   vtkProperty* myPreselectProp;
 
-  vtkProperty* myBallHighlightProp;
-  vtkProperty* myBallPreselectProp;
-          
   SMESH_DeviceActor* myHighlitableActor;
 
   eControl myControlMode;
index 90d28e162d73ebae310393adcd0c33b62b6539f0..71add3460aaa713dd2619b841c11dfc94eb5e2b9 100644 (file)
@@ -27,6 +27,7 @@
 
 #include <VTKViewer_TransformFilter.h>
 #include <VTKViewer_CellCenters.h>
+#include <VTKViewer_ExtractUnstructuredGrid.h>
 
 #include <vtkObjectFactory.h>
 #include <vtkCallbackCommand.h>
@@ -152,7 +153,9 @@ void SMESH_CellLabelActor::SetCellsLabeled(bool theIsCellsLabeled) {
     vtkIntArray *anArray = vtkIntArray::New();
     anArray->SetNumberOfValues(aNbElem);
     for(int anId = 0; anId < aNbElem; anId++){
-      int aSMDSId = myVisualObj->GetElemObjId(anId);
+      vtkIdType id = myExtractUnstructuredGrid->GetInputId(anId);
+      id = (id >=0) ? id : anId; 
+      int aSMDSId = myVisualObj->GetElemObjId(id);
       anArray->SetValue(anId,aSMDSId);
     }
     aDataSet->GetCellData()->SetScalars(anArray);
index 562eaed739f011ba16d605f1288819fb8f18352c..4a46932cc7f52eb89953f21da815187f584dc8b0 100644 (file)
@@ -228,6 +228,11 @@ SMESH_DeviceActor
     myExtractUnstructuredGrid->SetInputData(theGrid);
 
     myMergeFilter->SetGeometryConnection(myExtractUnstructuredGrid->GetOutputPort());
+    
+    //Pass diameters of the balls
+    if(myMapper->GetBallEnabled()) {
+      myMergeFilter->SetScalarsConnection(myExtractUnstructuredGrid->GetOutputPort());
+    }
 
     myExtractGeometry->SetInputConnection(myMergeFilter->GetOutputPort());
 
@@ -935,6 +940,14 @@ void SMESH_DeviceActor::SetMarkerEnabled( bool theMarkerEnabled )
   myMapper->SetMarkerEnabled( theMarkerEnabled );
 }
 
+/*!
+ * Set point marker enabled
+ * \param theBallEnabled flag to enable/disable ball drawing
+ */
+void SMESH_DeviceActor::SetBallEnabled( bool theBallEnabled ) {
+  myMapper->SetBallEnabled( theBallEnabled );
+}
+
 /*!
  * Set standard point marker
  * \param theMarkerType type of the marker
index bcce5c974b4396db53ae1f35fba40cdf80d6875a..e3c63a76125918e1c808c806181e3c03b469aa0b 100644 (file)
@@ -144,6 +144,7 @@ class SMESHOBJECT_EXPORT SMESH_DeviceActor: public vtkLODActor{
   bool IsImplicitFunctionUsed() const{ return myIsImplicitFunctionUsed;}
 
   void SetMarkerEnabled( bool );
+  void SetBallEnabled( bool );
   void SetMarkerStd( VTK::MarkerType, VTK::MarkerScale );
   void SetMarkerTexture( int, VTK::MarkerTexture );
   VTK::MarkerType GetMarkerType();
index b4fcbf6dbf6563622362420662bc3275ae7a4b34..466b9af6483a19faa7fa49f2664209759f5444b5 100644 (file)
@@ -30,6 +30,7 @@
 
 #include "SMDS_Mesh.hxx"
 #include "SMDS_PolyhedralVolumeOfNodes.hxx"
+#include "SMDS_BallElement.hxx"
 #include "SMESH_Actor.h"
 #include "SMESH_ControlsDef.hxx"
 #include "SalomeApp_Application.h"
@@ -43,7 +44,7 @@
 #include <vtkIdList.h>
 #include <vtkCellArray.h>
 #include <vtkUnsignedCharArray.h>
-
+#include <vtkCellData.h>
 #include <vtkUnstructuredGrid.h>
 
 #include <memory>
@@ -279,7 +280,9 @@ void SMESH_VisualObjDef::buildPrs(bool buildGrid)
         //MESSAGE(myGrid->GetReferenceCount());
         //MESSAGE( "Update - myGrid->GetNumberOfCells() = "<<myGrid->GetNumberOfCells() );
         //MESSAGE( "Update - myGrid->GetNumberOfPoints() = "<<myGrid->GetNumberOfPoints() );
-        if( MYDEBUGWITHFILES ) SMESH::WriteUnstructuredGrid( myGrid,"buildPrs.vtu" );
+        if( MYDEBUGWITHFILES ) {
+         SMESH::WriteUnstructuredGrid( myGrid,"myPrs.vtu" );
+       }
   }
 }
 
@@ -417,7 +420,13 @@ void SMESH_VisualObjDef::buildElemPrs()
   aConnect.reserve(VTK_CELL_SIZE);
 
   SMDS_Mesh::CheckMemory(); // PAL16631
-
+  bool hasBalls = nbEnts[ SMDSAbs_Ball ] > 0;
+  vtkDataArray* aScalars = 0;
+  if(hasBalls) {
+    aScalars = vtkDataArray::CreateDataArray(VTK_DOUBLE);
+    aScalars->SetNumberOfComponents(1);
+    aScalars->SetNumberOfTuples(aNbCells);
+  }
   for ( int i = 0; i < nbTypes; i++ ) // iterate through all types of elements
   {
     if ( nbEnts[ aTypes[ i ] ] > 0 ) {
@@ -475,8 +484,19 @@ void SMESH_VisualObjDef::buildElemPrs()
             }
           }
         }
-        aConnectivity->InsertNextCell( anIdList );
+        vtkIdType aCurId = aConnectivity->InsertNextCell( anIdList );
         aCellTypesArray->InsertNextValue( vtkElemType );
+       
+       //Store diameters of the balls
+       if(aScalars) {
+         double aDiam = 0;
+         if(aType == SMDSAbs_Ball) {
+           if (const SMDS_BallElement* ball = dynamic_cast<const SMDS_BallElement*>(anElem) ) {
+             aDiam = ball->GetDiameter();
+           }
+         }
+         aScalars->SetTuple(aCurId,&aDiam);
+       }
 
         iElem++;
       }
@@ -497,6 +517,7 @@ void SMESH_VisualObjDef::buildElemPrs()
     aCellLocationsArray->SetValue( idType, aConnectivity->GetTraversalLocation( npts ) );
 
   myGrid->SetCells( aCellTypesArray, aCellLocationsArray,aConnectivity );
+  myGrid->GetCellData()->SetScalars(aScalars);
 
   aCellLocationsArray->Delete();
   aCellTypesArray->Delete();
index de143a7901df15960ba33ab8bff1b8f6ae19f8da..8d8f5a51360cd02582bb653f432e6ac42fd3de93 100644 (file)
@@ -39,6 +39,7 @@
 #include <vtkCell.h>
 #include <vtkDataSetMapper.h>
 #include <vtkPolyhedron.h>
+#include <vtkCellData.h>
 
 #include <Utils_SALOME_Exception.hxx>
 
@@ -53,6 +54,7 @@ SMESH_SVTKActor::SMESH_SVTKActor():
 {
   my0DActor = SVTK_DeviceActor::New();
   myBallActor = SVTK_DeviceActor::New();
+  myBallActor->SetBallEnabled(true);
 
   myBallActor->SetResolveCoincidentTopology(false);
   myBallActor->SetCoincident3DAllowed(true);
@@ -121,8 +123,18 @@ SMESH_SVTKActor
   SVTK::CopyPoints( GetSource(), aSourceDataSet );
   SVTK::CopyPoints( myBallGrid, aSourceDataSet );
   SVTK::CopyPoints( my0DGrid,    aSourceDataSet );
+  
 
   int aNbOfParts = theMapIndex.Extent();
+
+  vtkCellData* cd = 0;
+  vtkCellData* outputCD = 0;
+  //Copy deamaters of the balls
+  if(myVisualObj) {
+    outputCD = myBallGrid->GetCellData();
+    cd = aSourceDataSet->GetCellData();
+  }
+  outputCD->CopyAllocate(cd,aNbOfParts,aNbOfParts/2);
   for(int ind = 1; ind <= aNbOfParts; ind++){
     int aPartId = theMapIndex( ind );
     if(vtkCell* aCell = theMapActor->GetElemCell(aPartId))
@@ -132,7 +144,10 @@ SMESH_SVTKActor
         if(aCell->GetCellType() == VTK_VERTEX ) {
           my0DGrid->InsertNextCell(aCell->GetCellType(),aCell->GetPointIds());
         } else if(aCell->GetCellType() == VTK_POLY_VERTEX ) {
-          myBallGrid->InsertNextCell(aCell->GetCellType(),aCell->GetPointIds());
+         vtkIdType newCellId = myBallGrid->InsertNextCell(aCell->GetCellType(),aCell->GetPointIds());
+         if(myVisualObj) {
+           outputCD->CopyData(cd, myVisualObj->GetElemVTKId(aPartId), newCellId);
+         }
         } else {
           myUnstructuredGrid->InsertNextCell(aCell->GetCellType(),aCell->GetPointIds());
         }
@@ -182,3 +197,7 @@ void SMESH_SVTKActor::SetBallSize(float theSize) {
   myBallActor->GetProperty()->SetPointSize(theSize);
 }
 
+void SMESH_SVTKActor::SetVisualObject(TVisualObjPtr theVisualObj) {
+  myVisualObj = theVisualObj;
+}
+
index 08c47d3f41e050f54e5986c3f9c6bb0189f85e54..e727181dbd4d905ec9e2c1c63ebde517c7d95dba 100644 (file)
@@ -68,12 +68,15 @@ public:
   void
   RemoveFromRender(vtkRenderer* theRendere);
 
+  void SetVisualObject(TVisualObjPtr theVisualObj);
+
  protected:
   SVTK_DeviceActor* my0DActor;
   SVTK_DeviceActor* myBallActor;
 
   vtkUnstructuredGrid* my0DGrid;
   vtkUnstructuredGrid* myBallGrid;
+  TVisualObjPtr myVisualObj;
   
   SMESH_SVTKActor();
   virtual ~SMESH_SVTKActor();
index e3fb6fcd1b82c5f44045f7584671e4fcc10e9e61..fe435204003ff2777ca92f2f1babea6ae71de86f 100644 (file)
@@ -4994,6 +4994,7 @@ void SMESHGUI::createPreferences()
   addPreference( tr( "PREF_BALL_COLOR" ), elemGroup, LightApp_Preferences::Color, "SMESH", "ball_elem_color" );
   addPreference( tr( "PREF_OUTLINE"  ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
   addPreference( tr( "PREF_WIREFRAME"  ), elemGroup, LightApp_Preferences::Color, "SMESH", "wireframe_color" );
+  addPreference( tr( "PREF_PREVIEW_COLOR"  ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "preview_color" );
 
 
   int grpGroup = addPreference( tr( "PREF_GROUP_GROUPS" ), meshTab );
index f198189ce2ef20d9b625ca9e6361e3435a1ea1c3..067f35b9bad716f8de6737f6e9de99818c2f1c37 100644 (file)
 #include <SalomeApp_Application.h>
 #include <SVTK_ViewModel.h>
 #include <SVTK_ViewWindow.h>
+#include <VTKViewer_PolyDataMapper.h>
+#include <SVTK_Renderer.h>
+#include <Qtx.h>
+
 
 // IDL incldues
 #include CORBA_SERVER_HEADER(SMESH_MeshEditor)
@@ -65,6 +69,7 @@
 #include <vtkDataSetMapper.h>
 #include <vtkPolyDataMapper.h>
 #include <vtkProperty.h>
+#include <vtkCellData.h>
 
 // Qt includes
 #include <QComboBox>
@@ -95,6 +100,10 @@ namespace SMESH
     SALOME_Actor* myPreviewActor;
     vtkDataSetMapper* myMapper;
     vtkUnstructuredGrid* myGrid;
+    
+    SALOME_Actor* myBallActor;
+    VTKViewer_PolyDataMapper* myBallMapper;
+    vtkPolyData* myBallPolyData; 
 
     SALOME_Actor* myFaceOrientation;
     vtkPolyDataMapper* myFaceOrientationDataMapper;
@@ -120,16 +129,18 @@ namespace SMESH
       myPreviewActor->VisibilityOff();
       myPreviewActor->SetMapper(myMapper);
 
-      double anRGB[3];
+      QColor ffc, bfc;
+      int delta;
+
       vtkProperty* aProp = vtkProperty::New();
-      GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
-      aProp->SetColor( anRGB[0], anRGB[1], anRGB[2] );
+      SMESH::GetColor( "SMESH", "preview_color", ffc, delta, "0, 255, 0|-100" ) ;
+      aProp->SetColor( ffc.red() / 255. , ffc.green() / 255. , ffc.blue() / 255. );
       myPreviewActor->SetProperty( aProp );
       aProp->Delete();
 
       vtkProperty* aBackProp = vtkProperty::New();
-      GetColor( "SMESH", "backface_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 0, 255 ) );
-      aBackProp->SetColor( anRGB[0], anRGB[1], anRGB[2] );
+      bfc = Qtx::mainColorToSecondary(ffc, delta);
+      aBackProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
       myPreviewActor->SetBackfaceProperty( aBackProp );
       aBackProp->Delete();
 
@@ -148,12 +159,34 @@ namespace SMESH
       myFaceOrientation->SetMapper(myFaceOrientationDataMapper);
 
       vtkProperty* anOrientationProp = vtkProperty::New();
+      double anRGB[3];
       GetColor( "SMESH", "orientation_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
       anOrientationProp->SetColor( anRGB[0], anRGB[1], anRGB[2] );
       myFaceOrientation->SetProperty( anOrientationProp );
       anOrientationProp->Delete();
-
       myVTKViewWindow->AddActor(myFaceOrientation);
+
+      // Preview for the balls
+      vtkProperty* aBallProp = vtkProperty::New();
+      aBallProp->SetColor(ffc.red() / 255. , ffc.green() / 255. , ffc.blue() / 255.);
+      double aBallElemSize = SMESH::GetFloat("SMESH:ball_elem_size",10);
+      aBallProp->SetPointSize(aBallElemSize);
+
+      myBallPolyData = vtkPolyData::New();
+      myBallPolyData->Allocate();
+
+      myBallMapper = VTKViewer_PolyDataMapper::New();
+      myBallMapper->SetInputData(myBallPolyData);
+      myBallMapper->SetBallEnabled(true);
+
+      myBallActor = SALOME_Actor::New();
+      myBallActor->PickableOff();
+      myBallActor->SetVisibility(false);
+      myBallActor->SetProperty(aBallProp);
+      myBallActor->SetMapper(myBallMapper);
+      aBallProp->Delete();
+      
+      myVTKViewWindow->AddActor(myBallActor);
     }
 
     typedef std::vector<vtkIdType> TVTKIds;
@@ -163,7 +196,7 @@ namespace SMESH
     {
       vtkUnstructuredGrid *aGrid = theActor->GetUnstructuredGrid();
       myGrid->SetPoints(aGrid->GetPoints());
-      myGrid->Reset();
+      myGrid->Reset();      
 
       const std::vector<int>& interlace = SMDS_MeshCell::toVtkOrder( VTKCellType( theType ));
       SMDS_MeshCell::applyInterlace( interlace, theIds );
@@ -177,36 +210,68 @@ namespace SMESH
 
       myGrid->Modified();
 
-      SetVisibility(true, theActor->GetFacesOriented());
+      SetVisibility(true, theActor->GetFacesOriented(), false);
     }
 
+    void SetBallPosition(SMESH_Actor* theActor,TVTKIds& theIds, double theDiameter) {
+      vtkUnstructuredGrid *aGrid = theActor->GetUnstructuredGrid();
+      myBallPolyData->Reset();
+      myBallPolyData->DeleteCells();
+      myBallPolyData->SetPoints(aGrid->GetPoints());
+      
+      vtkDataArray* aScalars = vtkDataArray::CreateDataArray(VTK_DOUBLE);
+      aScalars->SetNumberOfComponents(1);
+      aScalars->SetNumberOfTuples(theIds.size());
+      myBallPolyData->GetCellData()->SetScalars(aScalars);
+      aScalars->Delete();
+
+      vtkIdList *anIds = vtkIdList::New();
+      anIds->SetNumberOfIds(1);
+      for (int i = 0, iEnd = theIds.size(); i < iEnd; i++){
+        anIds->InsertId(0,theIds[i]);
+       vtkIdType anId = myBallPolyData->InsertNextCell(VTK_POLY_VERTEX,anIds);
+       double d = theDiameter;
+       aScalars->SetTuple(anId,&d);
+       anIds->Reset();
+      }
+      
+      anIds->Delete();
+      myBallPolyData->Modified();
+      SetVisibility (false, false, true);
+    }
 
-    void SetVisibility (bool theVisibility, bool theShowOrientation = false)
+    void SetVisibility (bool theVisibility, bool theShowOrientation = false, bool theShowBalls = false)
     {
       myPreviewActor->SetVisibility(theVisibility);
       myFaceOrientation->SetVisibility(theShowOrientation);
+      myBallActor->SetVisibility(theShowBalls);
       RepaintCurrentView();
     }
 
 
     ~TElementSimulation()
     {
+      myMapper->RemoveAllInputs();
+      myFaceOrientationDataMapper->RemoveAllInputs();
+      myBallMapper->RemoveAllInputs();
+
       if (FindVtkViewWindow(myApplication->activeViewManager(), myViewWindow)) {
-        myVTKViewWindow->RemoveActor(myPreviewActor);
-        myVTKViewWindow->RemoveActor(myFaceOrientation);
+        myVTKViewWindow->RemoveActor(myPreviewActor,false,false);
+        myVTKViewWindow->RemoveActor(myFaceOrientation,false,false);
+       myVTKViewWindow->RemoveActor(myBallActor,false,false);
       }
-      myPreviewActor->Delete();
-      myFaceOrientation->Delete();
 
-      myMapper->RemoveAllInputs();
       myMapper->Delete();
-
-      myFaceOrientationFilter->Delete();
-
-      myFaceOrientationDataMapper->RemoveAllInputs();
+      myGrid->Delete();
+      myPreviewActor->Delete();
+            
+      myFaceOrientationFilter->Delete();      
       myFaceOrientationDataMapper->Delete();
+      myFaceOrientation->Delete();
 
-      myGrid->Delete();
+      myBallMapper->Delete();
+      myBallPolyData->Delete();
+      myBallActor->Delete();
     }
   };
 }
@@ -363,6 +428,7 @@ SMESHGUI_AddMeshElementDlg::SMESHGUI_AddMeshElementDlg( SMESHGUI*          theMo
 
     DiameterSpinBox->RangeStepAndValidator( 1e-7, 1e+9, 0.1 );
     DiameterSpinBox->SetValue( 1. );
+    connect( DiameterSpinBox, SIGNAL( valueChanged ( double ) ), this, SLOT( onDiameterChanged( ) ) );
   }
   /* Add to group ************************************************/
   GroupGroups = new QGroupBox( tr( "SMESH_ADD_TO_GROUP" ), this );
@@ -578,9 +644,9 @@ void SMESHGUI_AddMeshElementDlg::ClickOnApply()
     mySelector->ClearIndex();
     mySelectionMgr->setSelectedObjects( aList, false );
 
-    SMESH::UpdateView();
     mySimulation->SetVisibility(false);
-
+    SMESH::UpdateView();
+    
     buttonOk->setEnabled(false);
     buttonApply->setEnabled(false);
 
@@ -608,7 +674,6 @@ void SMESHGUI_AddMeshElementDlg::ClickOnOk()
 //=================================================================================
 void SMESHGUI_AddMeshElementDlg::reject()
 {
-  //mySelectionMgr->clearSelected();
   mySimulation->SetVisibility(false);
   SMESH::SetPointRepresentation(false);
   if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
@@ -808,7 +873,11 @@ void SMESHGUI_AddMeshElementDlg::displaySimulation()
     }
 
     vtkIdType aType = SMDS_MeshCell::toVtkType( myGeomType );
-    mySimulation->SetPosition(myActor,aType,anIds);
+    if(aType == VTK_POLY_VERTEX) {
+      mySimulation->SetBallPosition(myActor,anIds,DiameterSpinBox->GetValue());
+    } else {
+      mySimulation->SetPosition(myActor,aType,anIds);
+    }
     SMESH::UpdateView();
   }
 }
@@ -905,6 +974,14 @@ void SMESHGUI_AddMeshElementDlg::keyPressEvent( QKeyEvent* e )
   }
 }
 
+//=================================================================================
+// function : isValid
+// purpose  :
+//=================================================================================
+void SMESHGUI_AddMeshElementDlg::onDiameterChanged(){
+  displaySimulation();
+}
+
 //=================================================================================
 // function : isValid
 // purpose  :
index 1bc25cdb5e234963bbb4cbf8411d77bf19bc91f1..aa4bd8e20cfedee0bbc758516da4e3af7c3bb078 100644 (file)
@@ -64,7 +64,6 @@ namespace SMESH
 class SMESHGUI_EXPORT SMESHGUI_AddMeshElementDlg : public QDialog
 { 
   Q_OBJECT
-
 public:
   SMESHGUI_AddMeshElementDlg( SMESHGUI*, SMDSAbs_EntityType = SMDSEntity_Edge );
   ~SMESHGUI_AddMeshElementDlg();
@@ -119,6 +118,7 @@ private:
   
 protected slots:
   virtual void                reject();
+          void                onDiameterChanged();
 
 private slots:
   void                        ClickOnOk();
index 652336eca4f03abd047ac0950fc3421e6b9557f6..ab2a0743f7f14da9ed3d8127768b55e679abf51f 100644 (file)
@@ -55,6 +55,8 @@
 
 #include <SalomeApp_Application.h>
 
+#include <Qtx.h>
+
 // IDL includes
 #include <SALOMEconfig.h>
 #include CORBA_SERVER_HEADER(SMESH_MeshEditor)
@@ -146,17 +148,19 @@ namespace SMESH
       myPreviewActor->PickableOff();
       myPreviewActor->VisibilityOff();
       myPreviewActor->SetMapper(myMapper);
-
+      
+      QColor ffc, bfc;
+      int delta;
       vtkProperty* myProp = vtkProperty::New();
-      double aRGB[3], aBackRGB[3];
-      GetColor( "SMESH", "fill_color", aRGB[0], aRGB[1], aRGB[2], QColor( 0, 170, 255 ) );
-      myProp->SetColor( aRGB[0], aRGB[1], aRGB[2] );
+      SMESH::GetColor( "SMESH", "preview_color", ffc, delta, "0, 255, 0|-100" ) ;
+   
+      myProp->SetColor( ffc.red() / 255. , ffc.green() / 255. , ffc.blue() / 255. );
       myPreviewActor->SetProperty( myProp );
       myProp->Delete();
 
       vtkProperty* myBackProp = vtkProperty::New();
-      GetColor( "SMESH", "backface_color", aBackRGB[0], aBackRGB[1], aBackRGB[2], QColor( 0, 0, 255 ) );
-      myBackProp->SetColor( aBackRGB[0], aBackRGB[1], aBackRGB[2] );
+      bfc = Qtx::mainColorToSecondary(ffc, delta);
+      myBackProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
       myPreviewActor->SetBackfaceProperty( myBackProp );
       myBackProp->Delete();
 
@@ -175,6 +179,7 @@ namespace SMESH
       myFaceOrientation->SetMapper(myFaceOrientationDataMapper);
 
       vtkProperty* anOrientationProp = vtkProperty::New();
+      double aRGB[3];
       GetColor( "SMESH", "orientation_color", aRGB[0], aRGB[1], aRGB[2], QColor( 255, 255, 255 ) );
       anOrientationProp->SetColor( aRGB[0], aRGB[1], aRGB[2] );
       myFaceOrientation->SetProperty( anOrientationProp );
index f426c5e1f72e16236cf615e4debcdcde49d83584..c1e63059dd6daa944d8d2d516269d4f29a658621 100644 (file)
@@ -141,17 +141,20 @@ void SMESH::OrientedPlane::Init()
   myActor->SetInfinitive(true);
   myActor->SetMapper(myMapper);
 
-  double anRGB[3];
+  QColor ffc, bfc;
+  int delta;
+  SMESH::GetColor( "SMESH", "fill_color", ffc, delta, "255, 170, 0|-100" ) ;
   vtkProperty* aProp = vtkProperty::New();
-  SMESH::GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
-  aProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
+  SMESH::GetColor( "SMESH", "fill_color", ffc, delta, "255, 170, 0|-100" ) ;
+  aProp->SetColor(ffc.red() / 255. , ffc.green() / 255. , ffc.blue() / 255.);
   aProp->SetOpacity(0.75);
   myActor->SetProperty(aProp);
   aProp->Delete();
 
   vtkProperty* aBackProp = vtkProperty::New();
-  SMESH::GetColor( "SMESH", "backface_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 0, 255 ) );
-  aBackProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
+  bfc = Qtx::mainColorToSecondary(ffc, delta);
+  aBackProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255.);
   aBackProp->SetOpacity(0.75);
   myActor->SetBackfaceProperty(aBackProp);
   aBackProp->Delete();
index e989562ed2709af2f56e4b19746b636d2a855ed6..3d5d748144aaaf00788d81a554bc32aac3c9f799 100644 (file)
@@ -4302,6 +4302,10 @@ Please, create VTK viewer and try again</translation>
         <source>PREF_FILL</source>
         <translation>Surface color</translation>
     </message>
+    <message>
+        <source>PREF_PREVIEW_COLOR</source>
+        <translation>Preview color</translation>
+    </message>
     <message>
         <source>PREF_NOTIFY_MODE</source>
         <translation>Show a computation result notification</translation>