]> SALOME platform Git repositories - modules/smesh.git/commitdiff
Salome HOME
Bug PAL7334 DEVELOPMENT : Control Improvement
authorenk <enk@opencascade.com>
Mon, 27 Dec 2004 06:10:34 +0000 (06:10 +0000)
committerenk <enk@opencascade.com>
Mon, 27 Dec 2004 06:10:34 +0000 (06:10 +0000)
src/OBJECT/SMESH_Actor.cxx
src/OBJECT/SMESH_Actor.h
src/OBJECT/SMESH_DeviceActor.cxx
src/OBJECT/SMESH_DeviceActor.h
src/SMESHGUI/SMESHGUI.cxx

index 0c57a09da43f4fc503ac10e6bfa01bfb4a4d7824..bcd45fd945a7e169c61b3400ed282c22b109b6fb 100644 (file)
@@ -284,7 +284,7 @@ SMESH_Actor::SMESH_Actor(){
   myName = "";
   myIO = NULL;
 
-  myColorMode = eNone;
+  myControlMode = eNone;
   my1DColorMode = e1DNone;
   myControlActor = my2DActor;
 
@@ -438,7 +438,7 @@ SMESH_Actor::SMESH_Actor(){
   aPtsTextProp->SetShadow(0);
   myPtsLabeledDataMapper->SetLabelTextProperty(aPtsTextProp);
   aPtsTextProp->Delete();
-    
+  
   myEntityMode = eAllEntity;
 
   myIsPointsLabeled = false;
@@ -623,7 +623,7 @@ void SMESH_Actor::SetCellsLabeled(bool theIsCellsLabeled){
 
 
 void SMESH_Actor::SetControlMode(eControl theMode){
-  myColorMode = eNone;
+  myControlMode = eNone;
   my1DColorMode = e1DNone;
 
   my1DActor->GetMapper()->SetScalarVisibility(false);
@@ -644,6 +644,12 @@ void SMESH_Actor::SetControlMode(eControl theMode){
       myControlActor = my1DActor;
       break;
     }
+    case eLength:
+    {
+      aFunctor.reset(new SMESH::Controls::Length2D());
+      myControlActor = my2DActor;
+      break;
+    }
     case eFreeBorders:
       aFunctor.reset(new SMESH::Controls::FreeBorders());
       myControlActor = my1DActor;
@@ -719,11 +725,14 @@ void SMESH_Actor::SetControlMode(eControl theMode){
     vtkUnstructuredGrid* aGrid = myControlActor->GetUnstructuredGrid();
     vtkIdType aNbCells = aGrid->GetNumberOfCells();
     if(aNbCells){
-      myColorMode = theMode;
+      myControlMode = theMode;
       if(theMode == eFreeBorders || theMode == eFreeEdges){
        my1DColorMode = e1DHighlited;
        my1DExtActor->SetExtControlMode(aFunctor,myControlActor);
-      }else{
+      } else if (theMode == eLength){
+       my1DColorMode = e1DColored;
+       my1DExtActor->SetLength2DControlMode(aFunctor,myControlActor,myScalarBarActor,myLookupTable);
+      } else{
        if(myControlActor == my1DActor)
          my1DColorMode = e1DColored;
        myControlActor->SetControlMode(aFunctor,myScalarBarActor,myLookupTable);
@@ -988,8 +997,8 @@ void SMESH_Actor::SetVisibility(int theMode, bool theIsUpdateRepersentation){
     if(theIsUpdateRepersentation)
       SetRepresentation(GetRepresentation());
 
-    if(myColorMode != eNone){
-      if(my1DColorMode == e1DHighlited)
+    if(myControlMode != eNone){
+      if(my1DColorMode == e1DHighlited || myControlMode == eLength)
        my1DExtActor->VisibilityOn();
       else if(myControlActor->GetUnstructuredGrid()->GetNumberOfCells())
        myScalarBarActor->VisibilityOn();
@@ -1022,7 +1031,6 @@ void SMESH_Actor::SetVisibility(int theMode, bool theIsUpdateRepersentation){
   Modified();
 }
 
-
 namespace{
 
   inline bool UpdateEntityMode(unsigned int& theOutputMode, 
@@ -1071,7 +1079,6 @@ void SMESH_Actor::SetEntityMode(unsigned int theMode){
   myEntityMode = theMode;
 }
 
-
 void SMESH_Actor::SetRepresentation(int theMode){ 
   int aNbEdges = myVisualObj->GetNbEntities(SMESH::EDGE);
   int aNbFaces = myVisualObj->GetNbEntities(SMESH::FACE);
@@ -1139,15 +1146,22 @@ void SMESH_Actor::SetRepresentation(int theMode){
   my3DActor->SetRepresentation(aReperesent);
 
   my1DExtActor->SetVisibility(false);
-  switch(my1DColorMode){
-  case e1DColored: 
+//   switch(my1DColorMode){
+//   case e1DColored: 
+//     aProp = aBackProp = my1DProp;
+//     if(myRepresentation != ePoint)
+//       aReperesent = SMESH_DeviceActor::eInsideframe;
+//     break;
+//   case e1DHighlited: 
+//     my1DExtActor->SetVisibility(true);
+//     break;
+//   }
+  if (my1DColorMode == e1DColored){
     aProp = aBackProp = my1DProp;
     if(myRepresentation != ePoint)
       aReperesent = SMESH_DeviceActor::eInsideframe;
-    break;
-  case e1DHighlited: 
+  } else if (my1DColorMode == e1DHighlited || myControlMode == eLength){
     my1DExtActor->SetVisibility(true);
-    break;
   }
   
   my1DActor->SetProperty(aProp);
index 469fc6c07f6ff74b352fe28e84e6c178bfdcd336..9f81a891d5f378b4c4e174e80413e1588bf73eb7 100644 (file)
@@ -121,7 +121,7 @@ class SMESH_Actor : public SALOME_Actor{
 
   enum EReperesent { ePoint, eEdge, eSurface};
   virtual void SetRepresentation(int theMode);
-
+  
   enum EEntityMode { eEdges = 0x01, eFaces = 0x02, eVolumes = 0x04, eAllEntity = 0x07};
   unsigned int GetEntityMode() const { return myEntityMode;}
   void SetEntityMode(unsigned int theMode);
@@ -150,11 +150,11 @@ class SMESH_Actor : public SALOME_Actor{
   void SetCellsLabeled(bool theIsCellsLabeled);
   bool GetCellsLabeled(){ return myIsCellsLabeled;}
 
-  enum eControl{eNone, eLengthEdges, eFreeBorders, eFreeEdges, eMultiConnection, 
+  enum eControl{eNone, eLengthEdges, eLength, eFreeBorders, eFreeEdges, eMultiConnection, 
                eArea, eTaper, eAspectRatio, eMinimumAngle, eWarping, eSkew,
                eAspectRatio3D};
   void SetControlMode(eControl theMode);
-  eControl GetControlMode(){ return myColorMode;}
+  eControl GetControlMode(){ return myControlMode;}
 
   enum e1DControl{e1DNone, e1DColored, e1DHighlited};
   e1DControl Get1DControlMode(){ return my1DColorMode;}
@@ -192,7 +192,7 @@ class SMESH_Actor : public SALOME_Actor{
   SMESH_DeviceActor* myHighlitableActor;
   SMESH_DeviceActor* myNodeHighlitableActor;
 
-  eControl myColorMode;
+  eControl myControlMode;
   SMESH_DeviceActor* my2DActor;
   SMESH_DeviceActor* my3DActor;
   SMESH_DeviceActor* myControlActor;
index f66717e8d2583f25fc7e6044b10c3bc65c021c97..7713b03017fe09c6e5f69766fa1e9ca10d8c7db3 100644 (file)
@@ -24,7 +24,7 @@
 //  File   : SMESH_Actor.cxx
 //  Author : Nicolas REJNERI
 //  Module : SMESH
-//  $Header$
+//  $Header$Header: /home/server/cvs/SMESH/SMESH_SRC/src/OBJECT/SMESH_DeviceActor.cxx,v 1.5.2.1 2004/12/23 10:31:24 apo Exp $
 
 
 #include "SMESH_DeviceActor.h"
@@ -165,7 +165,7 @@ void SMESH_DeviceActor::SetUnstructuredGrid(vtkUnstructuredGrid* theGrid){
 
     myExtractUnstructuredGrid->SetInput(myExtractGeometry->GetOutput());
     myMergeFilter->SetGeometry(myExtractUnstructuredGrid->GetOutput());
-
+    
     theGrid = static_cast<vtkUnstructuredGrid*>(myMergeFilter->GetOutput());
 
     int anId = 0;
@@ -260,6 +260,86 @@ void SMESH_DeviceActor::SetControlMode(SMESH::Controls::FunctorPtr theFunctor,
   theScalarBarActor->SetVisibility(anIsInitialized);
 }
 
+void SMESH_DeviceActor::SetLength2DControlMode(SMESH::Controls::FunctorPtr theFunctor,
+                                              SMESH_DeviceActor* theDeviceActor,
+                                              vtkScalarBarActor* theScalarBarActor,
+                                              vtkLookupTable* theLookupTable)
+{
+  bool anIsInitialized = theFunctor;
+
+  using namespace SMESH::Controls;
+  if (anIsInitialized){
+    if (Length2D* aLength2D = dynamic_cast<Length2D*>(theFunctor.get())){
+      SMESH::Controls::Length2D::TValues aValues;
+
+      myVisualObj->UpdateFunctor(theFunctor);
+
+      aLength2D->GetValues(aValues);
+      vtkUnstructuredGrid* aDataSet = vtkUnstructuredGrid::New();
+      vtkUnstructuredGrid* aGrid = myVisualObj->GetUnstructuredGrid();
+
+      aDataSet->SetPoints(aGrid->GetPoints());
+      
+      vtkIdType aNbCells = aValues.size();
+      
+      vtkDoubleArray *aScalars = vtkDoubleArray::New();
+      aScalars->SetNumberOfComponents(1);
+      aScalars->SetNumberOfTuples(aNbCells);
+
+      vtkIdType aCellsSize = 3*aNbCells;
+      vtkCellArray* aConnectivity = vtkCellArray::New();
+      aConnectivity->Allocate( aCellsSize, 0 );
+      
+      vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
+      aCellTypesArray->SetNumberOfComponents( 1 );
+      aCellTypesArray->Allocate( aNbCells * aCellTypesArray->GetNumberOfComponents() );
+      
+      vtkIdList *anIdList = vtkIdList::New();
+      anIdList->SetNumberOfIds(2);
+      
+      Length2D::TValues::const_iterator anIter = aValues.begin();
+      int i = 0;
+      for(vtkIdType aVtkId; anIter != aValues.end(); anIter++,i++){
+       const Length2D::Value& aValue = *anIter;
+       int aNode[2] = {
+         myVisualObj->GetNodeVTKId(aValue.myPntId[0]),
+         myVisualObj->GetNodeVTKId(aValue.myPntId[1])
+       };
+       if(aNode[0] >= 0 && aNode[1] >= 0){
+         anIdList->SetId( 0, aNode[0] );
+         anIdList->SetId( 1, aNode[1] );
+         aConnectivity->InsertNextCell( anIdList );
+         aCellTypesArray->InsertNextValue( VTK_LINE );
+         aScalars->SetValue(i,aValue.myLength);
+       }
+      }
+      
+      vtkIntArray* aCellLocationsArray = vtkIntArray::New();
+      aCellLocationsArray->SetNumberOfComponents( 1 );
+      aCellLocationsArray->SetNumberOfTuples( aNbCells );
+      
+      aConnectivity->InitTraversal();
+      for( vtkIdType idType = 0, *pts, npts; aConnectivity->GetNextCell( npts, pts ); idType++ )
+       aCellLocationsArray->SetValue( idType, aConnectivity->GetTraversalLocation( npts ) );
+      
+      aDataSet->SetCells( aCellTypesArray, aCellLocationsArray,aConnectivity );
+      SetUnstructuredGrid(aDataSet);
+
+      aDataSet->GetCellData()->SetScalars(aScalars);
+      aScalars->Delete();
+      
+      theLookupTable->SetRange(aScalars->GetRange());
+      theLookupTable->Build();
+      
+      SetUnstructuredGrid(aDataSet);
+      
+      myMergeFilter->SetScalars(aDataSet);
+      aDataSet->Delete();
+    }
+  }
+  GetMapper()->SetScalarVisibility(anIsInitialized);
+  theScalarBarActor->SetVisibility(anIsInitialized);
+}
 
 void SMESH_DeviceActor::SetExtControlMode(SMESH::Controls::FunctorPtr theFunctor,
                                          SMESH_DeviceActor* theDeviceActor)
@@ -330,10 +410,12 @@ void SMESH_DeviceActor::SetExtControlMode(SMESH::Controls::FunctorPtr theFunctor
 
     SetUnstructuredGrid(aDataSet);
     aDataSet->Delete();
-  }    
+  }
 }
 
 
+
+
 unsigned long int SMESH_DeviceActor::GetMTime(){
   unsigned long mTime = this->Superclass::GetMTime();
   mTime = max(mTime,myExtractGeometry->GetMTime());
index 5de228b0bc0bea72d4212192bf4e5d36e46cade6..575aaab1c0768a91f5ed3a4084bb619269b8c4eb 100644 (file)
@@ -94,6 +94,10 @@ class SMESH_DeviceActor: public vtkLODActor{
   void SetControlMode(SMESH::Controls::FunctorPtr theFunctor,
                      vtkScalarBarActor* theScalarBarActor,
                      vtkLookupTable* theLookupTable);
+  void SetLength2DControlMode(SMESH::Controls::FunctorPtr theFunctor,
+                             SMESH_DeviceActor* theDeviceActor,
+                             vtkScalarBarActor* theScalarBarActor,
+                             vtkLookupTable* theLookupTable);
   void SetExtControlMode(SMESH::Controls::FunctorPtr theFunctor,
                         SMESH_DeviceActor* theDeviceActor);
 
index 53f39f51834c3551cdef9859cc82c56a7ebecfaa..c2ea23b044c13acd6135c91f01e1163a7b3004a5 100644 (file)
@@ -547,6 +547,10 @@ namespace{
            aTitle = QObject::tr( "LENGTH_EDGES" );
            aControl = SMESH_Actor::eLengthEdges;
            break;
+         case 6018:
+           aTitle = QObject::tr( "LENGTH2D_EDGES" );
+           aControl = SMESH_Actor::eLength;
+           break;
          case 6002:
            aTitle = QObject::tr( "FREE_EDGES" );
            aControl = SMESH_Actor::eFreeEdges;
@@ -2065,6 +2069,7 @@ bool SMESHGUI::OnGUIEvent(int theCommandID, QAD_Desktop * parent)
   case 6012:
   case 6011:
   case 6001:
+  case 6018:
   case 6002:
   case 6003:
   case 6004:    
@@ -2442,6 +2447,8 @@ bool SMESHGUI::CustomPopup(QAD_Desktop* parent, QPopupMenu* popup, const QString
              switch ( cMode ) {
              case SMESH_Actor::eLengthEdges:
                mi->popup()->setItemChecked( 6001, true ); break;
+             case SMESH_Actor::eLength:
+               mi->popup()->setItemChecked( 6018, true ); break;
              case SMESH_Actor::eFreeEdges:
                mi->popup()->setItemChecked( 6002, true );
                mi->popup()->removeItem( 201 );
@@ -2475,6 +2482,7 @@ bool SMESHGUI::CustomPopup(QAD_Desktop* parent, QPopupMenu* popup, const QString
              TVisualObjPtr aVisualObj = anActor->GetObject();
              if(aNbEdges == 0){
                mi->popup()->removeItem( 6001 );
+               mi->popup()->removeItem( 6018 );
                mi->popup()->removeItem( 6003 );
                mi->popup()->removeItem( 6004 );
              }