From: enk Date: Mon, 27 Dec 2004 06:10:34 +0000 (+0000) Subject: Bug PAL7334 DEVELOPMENT : Control Improvement X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=34ff0ddae5d8d4c4104c770f4ead8c1c6789c8c2;p=modules%2Fsmesh.git Bug PAL7334 DEVELOPMENT : Control Improvement --- diff --git a/src/OBJECT/SMESH_Actor.cxx b/src/OBJECT/SMESH_Actor.cxx index 0c57a09da..bcd45fd94 100644 --- a/src/OBJECT/SMESH_Actor.cxx +++ b/src/OBJECT/SMESH_Actor.cxx @@ -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); diff --git a/src/OBJECT/SMESH_Actor.h b/src/OBJECT/SMESH_Actor.h index 469fc6c07..9f81a891d 100644 --- a/src/OBJECT/SMESH_Actor.h +++ b/src/OBJECT/SMESH_Actor.h @@ -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; diff --git a/src/OBJECT/SMESH_DeviceActor.cxx b/src/OBJECT/SMESH_DeviceActor.cxx index f66717e8d..7713b0301 100644 --- a/src/OBJECT/SMESH_DeviceActor.cxx +++ b/src/OBJECT/SMESH_DeviceActor.cxx @@ -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(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(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()); diff --git a/src/OBJECT/SMESH_DeviceActor.h b/src/OBJECT/SMESH_DeviceActor.h index 5de228b0b..575aaab1c 100644 --- a/src/OBJECT/SMESH_DeviceActor.h +++ b/src/OBJECT/SMESH_DeviceActor.h @@ -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); diff --git a/src/SMESHGUI/SMESHGUI.cxx b/src/SMESHGUI/SMESHGUI.cxx index 53f39f518..c2ea23b04 100644 --- a/src/SMESHGUI/SMESHGUI.cxx +++ b/src/SMESHGUI/SMESHGUI.cxx @@ -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 ); }