virtual
int
RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *);
+
};
#endif
return aName.latin1();
}
-
//---------------------------------------------------------------
+
+/*vtkIdType
+VISU::TGaussSubMesh
+::GetElemObjID(vtkIdType theID) const
+{
+ return mySubProfile->GetElemObjID( theID );
+}
+
+
+vtkIdType
+VISU::TGaussSubMesh
+::GetElemVTKID(vtkIdType theID) const
+{
+ return mySubProfile->GetElemVTKID( theID );
+}*/
GetFieldOnMeshSize(const std::string& theMeshName,
const VISU::TEntity& theEntity,
const std::string& theFieldName) = 0;
-
+
//! Find MED FIELD container
virtual
const VISU::PField
return aString.latin1();
}
+ //--------------------------------------------------------------
+
+
//---------------------------------------------------------------
void
PrintCells(int& theStartId,
vtkIdType aNbCells = aSource->GetNumberOfCells();
for(vtkIdType aCell = 0; aCell < aNbCells; aCell++, aCellID++){
- anElemObj2VTKID[aSubProfile->GetElemObjID(aCell)] = aCellID;
+ vtkIdType anObjID = aSubProfile->GetElemObjID(aCell);
+ anElemObj2VTKID[anObjID] = aCellID;
}
aSubProfileArr[anInputID++] = aSubProfile;
TGaussPointID
GetObjID(vtkIdType theID) const = 0;
+ //! Gets VTK ID by its complex Gauss Point ID
+ virtual
+ vtkIdType
+ GetVTKID(const TGaussPointID& theID) const = 0;
+
//! Gets parent TNamedIDMapper, which contains reference mesh cells
virtual
TNamedIDMapper*
- GetParent() = 0;
+ GetParent() const = 0;
};
typedef MED::SharedPtr<TGaussPtsIDMapper> PGaussPtsIDMapper;
return theID;
}
+//---------------------------------------------------------------
+ vtkIdType
+ TMEDSubProfile
+ ::GetElemVTKID(vtkIdType theID) const
+ {
+ if ( myIsElemNum )
+ for ( size_t anId = 0; anId < (*myElemNum).size(); anId++ )
+ if ( (*myElemNum)[ anId ] == theID ) {
+ theID = anId;
+ break;
+ }
+
+ return TSubProfileImpl::GetElemVTKID( theID );
+ }
+
+//----------------------------------------------------------------
+
unsigned long int
TMEDSubProfile
::GetMemorySize()
TMEDGaussSubMesh
::GetObjID(vtkIdType theID) const
{
- TCellID aCellID = theID / myGauss->myNbPoints;
- TLocalPntID aLocalPntID = theID % myGauss->myNbPoints;
-
- if(myIsElemNum)
- aCellID = (*myElemNum)[aCellID];
+ vtkIdType aNbPoints = myGauss->myNbPoints;
+ TCellID aCellID = theID / aNbPoints;
+ TLocalPntID aLocalPntID = theID % aNbPoints;
+
+ if ( myIsElemNum )
+ aCellID = GetElemObjID(aCellID);
else
aCellID += myStartID;
return TGaussPointID(aCellID, aLocalPntID);
}
+ //---------------------------------------------------------------
+ vtkIdType
+ TMEDGaussSubMesh
+ ::GetVTKID(const TGaussPointID& theID,
+ vtkIdType theStartID) const
+ {
+ vtkIdType aResult = -1;
+
+ TCellID aCellID = theID.first;
+ TLocalPntID aLocalPntID = theID.second;
+
+ vtkIdType aNbPoints = myGauss->myNbPoints;
+ if ( aLocalPntID >= aNbPoints )
+ return aResult;
+
+ if ( myIsElemNum ) {
+ aCellID = GetElemVTKID( aCellID );
+ } else
+ aCellID -= theStartID;
+
+ return aCellID * aNbPoints + aLocalPntID + theStartID;
+ }
+
+
+ //---------------------------------------------------------------
+
unsigned long int
TMEDGaussSubMesh
::GetMemorySize()
virtual
vtkIdType
GetElemObjID(vtkIdType theID) const;
+
+ //! Reimplement the TSubProfileImpl::GetElemVTKID
+ virtual
+ vtkIdType
+ GetElemVTKID(vtkIdType theID) const;
//! Gets memory size used by the instance (bytes).
virtual
TGaussPointID
GetObjID(vtkIdType theID) const;
+ virtual
+ vtkIdType
+ GetVTKID(const TGaussPointID& theID,
+ vtkIdType theStartID) const;
+
//! Gets memory size used by the instance (bytes).
virtual
unsigned long int
//---------------------------------------------------------------
//! Define a basic class which corresponds to MED PROFILE entity
struct VISU_CONVERTOR_EXPORT TSubProfile: virtual TBaseStructure
- {};
+ {
+ //! Get object number of mesh cell by its VTK one
+ virtual
+ vtkIdType
+ GetElemObjID(vtkIdType theID) const = 0;
+
+ //! Get cell VTK ID for corresponding object ID
+ virtual
+ vtkIdType
+ GetElemVTKID(vtkIdType theID) const = 0;
+ };
//---------------------------------------------------------------
#include <vtkUnstructuredGrid.h>
#include <vtkPolyData.h>
#include <vtkCellType.h>
+#include <vtkCell.h>
namespace VISU
{
+ /* vtkIdType
+ VISUGeom2NbNodes(EGeometry theGeom)
+ {
+ switch(theGeom){
+#ifndef VISU_ENABLE_QUADRATIC
+ case VISU::eSEG3:
+ return 2;
+ case VISU::eTRIA6:
+ return 3;
+ case VISU::eQUAD8:
+ return 4;
+ case VISU::eTETRA10:
+ return 4;
+ case VISU::eHEXA20:
+ return 8;
+ case VISU::ePENTA15:
+ return 6;
+ case VISU::ePYRA13:
+ return 5;
+#endif
+ case VISU::ePOLYGONE:
+ case VISU::ePOLYEDRE:
+ return -1;
+ default:
+ return theGeom % 100;
+ }
+ }
+
+ vtkIdType
+ VISUGeom2VTK(EGeometry theGeom)
+ {
+ switch(theGeom){
+ case VISU::ePOINT1:
+ return VTK_VERTEX;
+ case VISU::eSEG2:
+ return VTK_LINE;
+ case VISU::eTRIA3:
+ return VTK_TRIANGLE;
+ case VISU::eQUAD4:
+ return VTK_QUAD;
+ case VISU::eTETRA4:
+ return VTK_TETRA;
+ case VISU::eHEXA8:
+ return VTK_HEXAHEDRON;
+ case VISU::ePENTA6:
+ return VTK_WEDGE;
+ case VISU::ePYRA5:
+ return VTK_PYRAMID;
+
+ case VISU::ePOLYGONE:
+ return VTK_POLYGON;
+ case VISU::ePOLYEDRE:
+ return VTK_CONVEX_POINT_SET;
+
+#ifndef VISU_ENABLE_QUADRATIC
+ case VISU::eSEG3:
+ return VTK_LINE;
+ case VISU::eTRIA6:
+ return VTK_TRIANGLE;
+ case VISU::eQUAD8:
+ return VTK_QUAD;
+ case VISU::eTETRA10:
+ return VTK_TETRA;
+ case VISU::eHEXA20:
+ return VTK_HEXAHEDRON;
+ case VISU::ePENTA15:
+ return VTK_WEDGE;
+ case VISU::ePYRA13:
+ return VTK_PYRAMID;
+
+#else
+
+ case VISU::eSEG3:
+#if defined(VTK_QUADRATIC_EDGE) && defined(VISU_USE_VTK_QUADRATIC)
+ return VTK_QUADRATIC_EDGE;
+#else
+ return VTK_POLY_LINE;
+#endif
+
+ case VISU::eTRIA6:
+#if defined(VTK_QUADRATIC_TRIANGLE) && defined(VISU_USE_VTK_QUADRATIC)
+ return VTK_QUADRATIC_TRIANGLE;
+#else
+ return VTK_POLYGON;
+#endif
+
+ case VISU::eQUAD8:
+#if defined(VTK_QUADRATIC_QUAD) && defined(VISU_USE_VTK_QUADRATIC)
+ return VTK_QUADRATIC_QUAD;
+#else
+ return VTK_POLYGON;
+#endif
+
+ case VISU::eTETRA10:
+#if defined(VTK_QUADRATIC_TETRA) && defined(VISU_USE_VTK_QUADRATIC)
+ return VTK_QUADRATIC_TETRA;
+#else
+ return VTK_CONVEX_POINT_SET;
+#endif
+
+ case VISU::eHEXA20:
+#if defined(VTK_QUADRATIC_HEXAHEDRON) && defined(VISU_USE_VTK_QUADRATIC)
+ return VTK_QUADRATIC_HEXAHEDRON;
+#else
+ return VTK_CONVEX_POINT_SET;
+#endif
+
+ case VISU::ePENTA15:
+#if defined(VTK_QUADRATIC_WEDGE) && defined(VISU_USE_VTK_QUADRATIC)
+ return VTK_QUADRATIC_WEDGE;
+#else
+ return VTK_CONVEX_POINT_SET;
+#endif
+
+ case VISU::ePYRA13:
+#if defined(VTK_QUADRATIC_PYRAMID) && defined(VISU_USE_VTK_QUADRATIC)
+ return VTK_QUADRATIC_PYRAMID;
+#else
+ return VTK_CONVEX_POINT_SET;
+#endif
+
+#endif //VISU_ENABLE_QUADRATIC
+
+ default:
+ return -1;
+ }
+ }*/
+
+
+ EGeometry
+ VTKGeom2VISU(vtkIdType theGeom)
+ {
+ switch(theGeom){
+ case VTK_VERTEX:
+ return VISU::ePOINT1;
+ case VTK_LINE:
+ return VISU::eSEG2;
+ case VTK_TRIANGLE:
+ return VISU::eTRIA3;
+ case VTK_QUAD:
+ return VISU::eQUAD4;
+ case VTK_TETRA:
+ return VISU::eTETRA4;
+ case VTK_HEXAHEDRON:
+ return VISU::eHEXA8;
+ case VTK_WEDGE:
+ return VISU::ePENTA6;
+ case VTK_PYRAMID:
+ return VISU::ePYRA5;
+
+ case VTK_POLYGON:
+ return VISU::ePOLYGONE;
+ case VTK_CONVEX_POINT_SET:
+ return VISU::ePOLYEDRE;
+
+#if defined(VISU_ENABLE_QUADRATIC) && defined(VISU_USE_VTK_QUADRATIC)
+ #if defined(VTK_QUADRATIC_EDGE)
+ case VTK_QUADRATIC_EDGE:
+ return VISU::eSEG3;
+ #endif
+
+ #if defined(VTK_QUADRATIC_TRIANGLE)
+ case VTK_QUADRATIC_TRIANGLE:
+ return VISU::eTRIA6;
+ #endif
+
+ #if defined(VTK_QUADRATIC_QUAD)
+ case VTK_QUADRATIC_QUAD:
+ return VISU::eQUAD8;
+ #endif
+
+ #if defined(VTK_QUADRATIC_TETRA)
+ case VTK_QUADRATIC_TETRA:
+ return VISU::eTETRA10;
+ #endif
+
+ #if defined(VTK_QUADRATIC_HEXAHEDRON)
+ case VTK_QUADRATIC_HEXAHEDRON:
+ return VISU::eHEXA20;
+ #endif
+
+ #if defined(VTK_QUADRATIC_WEDGE)
+ case VTK_QUADRATIC_WEDGE:
+ return VISU::ePENTA15;
+ #endif
+
+ #if defined(VTK_QUADRATIC_PYRAMID)
+ case VTK_QUADRATIC_PYRAMID:
+ return VISU::ePYRA13;
+ #endif
+
+#endif //VISU_ENABLE_QUADRATIC
+
+ default:
+ return EGeometry(-1);
+ }
+ }
+
//---------------------------------------------------------------
/*! Computes number of points by the given number of cells
* in assumption of regular hexahedral mesh structure
TSubProfileImpl
::GetElemObjID(vtkIdType theID) const
{
+ if ( !mySubMeshID.empty() )
+ return mySubMeshID[theID];
+
+ return theID;
+ }
+
+
+ vtkIdType
+ TSubProfileImpl
+ ::GetElemVTKID(vtkIdType theID) const
+ {
+ if ( !mySubMeshID.empty() )
+ for ( size_t anId = 0; anId < mySubMeshID.size(); anId++ )
+ if ( mySubMeshID[ anId ] == theID )
+ return anId;
+
return theID;
}
return TGaussPointID(aCellID, aLocalPntID);
}
+ vtkIdType
+ TGaussSubMeshImpl
+ ::GetVTKID(const TGaussPointID& theID) const
+ {
+ vtkIdType aResult = -1;
+
+ TCellID aCellID = theID.first;
+ TLocalPntID aLocalPntID = theID.second;
+
+ vtkIdType aNbPoints = myGauss->myNbPoints;
+ if ( aLocalPntID >= aNbPoints )
+ return aResult;
+
+ return ( aCellID - myStartID ) * aNbPoints + aLocalPntID;
+ }
+
+ vtkIdType
+ VISU::TGaussSubMeshImpl
+ ::GetElemObjID(vtkIdType theID) const
+ {
+ return mySubProfile->GetElemObjID( theID );
+ }
+
+
+ vtkIdType
+ VISU::TGaussSubMeshImpl
+ ::GetElemVTKID(vtkIdType theID) const
+ {
+ return mySubProfile->GetElemVTKID( theID );
+ }
+
vtkIdType
TGaussSubMeshImpl
::GetGlobalID(vtkIdType theID) const
return VISU::GetObjID(aFilter->GetOutput(), theID);
}
+ vtkIdType
+ TGaussMeshImpl
+ ::GetVTKID(const TGaussPointID& theID) const
+ {
+ vtkIdType aResult = -1;
+
+ TCellID aCellID = theID.first;
+
+ vtkIdType aVTKCellId = GetParent()->GetElemVTKID( aCellID );
+ if ( aVTKCellId < 0 )
+ return aResult;
+
+ vtkCell* aCell = GetParent()->GetElemCell( aCellID );
+ if ( !aCell )
+ return aResult;
+
+ EGeometry aVGeom = VISU::VTKGeom2VISU( aCell->GetCellType() );
+ if ( aVGeom < EGeometry(0) )
+ return aResult;
+
+ TGeom2GaussSubMesh::const_iterator anIter = myGeom2GaussSubMesh.find( aVGeom );
+ if ( anIter == myGeom2GaussSubMesh.end() )
+ return aResult;
+
+ size_t aSubMeshEnd = myGaussSubMeshArr.size();
+ const PAppendFilter& anAppendFilter = GetFilter();
+ const PGaussSubMeshImpl& aGaussSubMesh = anIter->second;
+ for ( size_t aSubMeshId = 0; aSubMeshId < aSubMeshEnd; aSubMeshId++ ) {
+ const PGaussSubMeshImpl& aSubMesh = myGaussSubMeshArr[aSubMeshId];
+ if ( aGaussSubMesh.get() == aSubMesh.get() ) {
+ return aGaussSubMesh->GetVTKID(theID);
+ }
+ }
+
+ return aResult;
+ }
+
vtkPolyData*
TGaussMeshImpl
::GetPolyDataOutput()
TNamedIDMapper*
TGaussMeshImpl
- ::GetParent()
+ ::GetParent() const
{
return myParent;
}
{
return myGaussPtsIDMapper->GetObjID(theID);
}
+
+ vtkIdType
+ TGaussPtsIDFilter
+ ::GetVTKID(const TGaussPointID& theID) const
+ {
+ return myGaussPtsIDMapper->GetVTKID(theID);
+ }
TNamedIDMapper*
TGaussPtsIDFilter
- ::GetParent()
+ ::GetParent() const
{
return myGaussPtsIDMapper->GetParent();
}
vtkIdType
GetElemObjID(int theVtkI) const;
+ //! Get cell VTK ID for corresponding object ID
+ virtual
+ vtkIdType
+ GetElemVTKID(vtkIdType theID) const;
+
//! Gets memory size used by the instance (bytes).
virtual
unsigned long int
virtual
TGaussPointID
GetObjID(vtkIdType theID) const;
+
+ //! To implement the TGaussPtsIDMapper::GetVTKID
+ virtual
+ vtkIdType
+ GetVTKID(const TGaussPointID& theID) const;
+
+ virtual
+ vtkIdType
+ GetElemObjID(vtkIdType theID) const;
+
+ virtual
+ vtkIdType
+ GetElemVTKID(vtkIdType theID) const;
virtual
vtkIdType
TGaussPointID
GetObjID(vtkIdType theID) const;
+ //! Reimplements the TGaussPtsIDMapper::GetVTKID
+ virtual
+ vtkIdType
+ GetVTKID(const TGaussPointID& theID) const;
+
//! Reimplement the TGaussPtsIDMapper::GetPolyDataOutput
virtual
vtkPolyData*
//! Reimplement the TGaussPtsIDMapper::GetParent
virtual
TNamedIDMapper*
- GetParent();
+ GetParent() const;
TNamedIDMapper* myParent; //!< Refer to parent mesh
TGaussSubMeshArr myGaussSubMeshArr; //!< Keeps sequence of TGaussSubMesh as they were added into TAppendFilterHolder
TGaussPointID
GetObjID(vtkIdType theID) const;
- //! Reimplement the TGaussPtsIDMapper::GetParent
+ //! Reimplements the TGaussPtsIDMapper::GetVTKID
+ virtual
+ vtkIdType
+ GetVTKID(const TGaussPointID& theID) const;
+
+ //! Reimplements the TGaussPtsIDMapper::GetParent
virtual
TNamedIDMapper*
- GetParent();
+ GetParent() const;
//! Reimplement the TNamedIDMapper::GetUnstructuredGridOutput
virtual
::ShallowCopyPL(VISU_PipeLine* thePipeLine)
{
myPipeLine->ShallowCopy(thePipeLine, true);
+ GetMapper()->Update();
}
//----------------------------------------------------------------------------
#endif
+namespace
+{
+ bool
+ CheckIsSameValue(vtkFloatingPointType theTarget,
+ vtkFloatingPointType theSource)
+ {
+ static vtkFloatingPointType TOL = 10.0 / VTK_LARGE_FLOAT;
+ return fabs(theTarget - theSource) < TOL;
+ }
+
+ bool
+ CheckIsSameVector(vtkFloatingPointType* theTarget,
+ vtkFloatingPointType* theSource,
+ size_t theLength)
+ {
+ for ( size_t anId = 0; anId < theLength; anId++ ) {
+ if ( !CheckIsSameValue( theTarget[ anId ], theSource[ anId ] ) )
+ return false;
+ }
+
+ return true;
+ }
+
+}
+
//============================================================================
vtkStandardNewMacro(VISU_GaussPtsAct);
myDeviceActor(VISU_GaussPtsDeviceActor::New()),
myWidgetCtrl(NULL),
myGaussPointsPL(NULL),
- myLastObjPointID(-1),
+ myLastPreHighlightObjID(-1),
myTextActor(VISU_FramedTextActor::New()),
myCursorPyramid(VISU_CursorPyramid::New()),
myCursorPyramidSelected(VISU_CursorPyramid::New()),
if(!theIsHighlight)
- myLastObjPointID = -1;
+ myLastPreHighlightObjID = -1;
Selection_Mode aSelectionMode = theSelectionEvent->mySelectionMode;
vtkIdType anObjId = GetNodeObjId( aVtkId );
myIsPreselected = (anObjId >= 0);
if(myIsPreselected){
- anIsChanged = (myLastObjPointID != anObjId);
+ anIsChanged = (myLastPreHighlightObjID != anObjId);
if(anIsChanged){
vtkFloatingPointType* aNodeCoord = GetNodeCoord(anObjId);
vtkDataSet* aDataSet = GetInput();
aNodeCoord,
aColor);
}
- myLastObjPointID = anObjId;
+ myLastPreHighlightObjID = anObjId;
}
myCursorPyramid->SetVisibility(true);
}
inline
void
ChangeZoom(VISU_PickingSettings *thePickingSettings,
- vtkInteractorStyle* theInteractorStyle,
- int theInitialHasIndex,
- int theCurrentHasIndex,
- const Handle(SALOME_InteractiveObject)& theIO)
+ vtkRenderer* theRenderer,
+ vtkIdType theInitialHasIndex,
+ vtkIdType theCurrentHasIndex)
{
if(theInitialHasIndex + theCurrentHasIndex == 1){
- vtkRenderer *aRenderer = theInteractorStyle->GetCurrentRenderer();
- vtkCamera *aCamera = aRenderer->GetActiveCamera();
+ vtkCamera *aCamera = theRenderer->GetActiveCamera();
+
vtkFloatingPointType aZoomFactor = thePickingSettings->GetZoomFactor();
double aScale = aCamera->GetParallelScale();
- if (!theInitialHasIndex && theCurrentHasIndex) {
- aCamera->SetParallelScale(aScale/aZoomFactor);
+ if ( !theInitialHasIndex && theCurrentHasIndex ) {
+ aCamera->SetParallelScale( aScale/aZoomFactor );
}
else {
- aCamera->SetParallelScale(aScale*aZoomFactor);
+ aCamera->SetParallelScale( aScale*aZoomFactor );
}
}
if ( !GetPickable() )
return false;
- int anInitialHasIndex = myIsHighlighted && mySelectionMode == GaussPointSelection;
+ // int anInitialHasIndex = myIsHighlighted && mySelectionMode == GaussPointSelection;
Handle(SALOME_InteractiveObject) anIO = getIO();
- myIsHighlighted = false;
+ // myIsHighlighted = false;
Selection_Mode aSelectionMode = theSelectionEvent->mySelectionMode;
if(!theIsHighlight && aSelectionMode == GaussPointSelection){
mySelector->RemoveIObject(anIO);
- ChangeZoom(myPickingSettings,
+ /* ChangeZoom(myPickingSettings,
theInteractorStyle,
anInitialHasIndex,
false,
- anIO);
+ anIO);*/
return true;
}
if(myPointPicker->GetActor() != this) {
mySelector->ClearIObjects();
- ChangeZoom(myPickingSettings,
+ /* ChangeZoom(myPickingSettings,
theInteractorStyle,
anInitialHasIndex,
false,
- anIO);
+ anIO);*/
return true;
}
if( aVtkId >= 0 && mySelector->IsValid( this, aVtkId, true ) && hasIO()) {
vtkIdType anObjId = GetNodeObjId( aVtkId );
if(anObjId >= 0){
- myIsHighlighted = true;
+ // myIsHighlighted = true;
// Update the Selector
if(mySelector->IsSelected(myIO))
mySelector->AddOrRemoveIndex(myIO,anObjId,theSelectionEvent->myIsShift);
mySelector->AddOrRemoveIndex(myIO,anObjId,theSelectionEvent->myIsShift);
mySelector->AddIObject(this);
}
- //
+ /*
vtkFloatingPointType* aNodeCoord = GetNodeCoord(anObjId);
//
// FlyTo
anInteractor->SetDolly(aDollyWas);
anInteractor->SetNumberOfFlyFrames(aNumberOfFlyFramesWas);
- anInteractor->InvokeEvent(SVTK::ChangeRotationPoint, aNodeCoord);
+ anInteractor->InvokeEvent(SVTK::ChangeRotationPoint, aNodeCoord);*/
mySelectionMode = aSelectionMode;
- ChangeZoom(myPickingSettings,
+ /* ChangeZoom(myPickingSettings,
theInteractorStyle,
anInitialHasIndex,
true,
- anIO);
+ anIO);*/
return true;
- //
}// if( anObjId >= 0 ) {
}//if( aVtkId >= 0 && mySelector->IsValid( this, aVtkId, true ) && hasIO())
}//if(!theSelectionEvent->myIsRectangle){
- ChangeZoom(myPickingSettings,
+ /* ChangeZoom(myPickingSettings,
theInteractorStyle,
anInitialHasIndex,
false,
- anIO);
+ anIO);*/
return false;
}
if(!mySelector.GetPointer())
return;
+ Selection_Mode aSelectionMode = mySelector->SelectionMode();
+
+ bool anInitialHasIndex = isHighlighted() && mySelectionMode == GaussPointSelection;
+
+ TColStd_IndexedMapOfInteger aMapIndex;
+ mySelector->GetIndex( getIO(), aMapIndex );
+ bool aCurrentHasIndex = aMapIndex.Extent() == 1;
+ bool anIsVisible = GetVisibility() && aCurrentHasIndex && theIsHighlight;
+
myOutlineActor->SetVisibility(false);
- myTextActor->SetVisibility(false);
- myCursorPyramidSelected->SetVisibility(false);
myCursorPyramid->SetVisibility(false);
- myCellActor->SetVisibility(false);
- GetScalarBarCtrl()->SetIsMarked(false);
- GetScalarBarCtrl()->Update();
+
+ myTextActor->SetVisibility(anIsVisible);
+ myCellActor->SetVisibility(anIsVisible);
+ GetScalarBarCtrl()->SetIsMarked(anIsVisible);
+ myCursorPyramidSelected->SetVisibility(anIsVisible);
+//GetScalarBarCtrl()->Update();
+
+ myIsHighlighted = aCurrentHasIndex;
+
+ // Zoom if necessary
+ ChangeZoom(myPickingSettings,
+ GetRenderer(),
+ anInitialHasIndex,
+ aCurrentHasIndex);
if(!theIsHighlight)
return;
- bool anIsVisible = GetVisibility();
+ if( aSelectionMode == ActorSelection ) {
+ Superclass::highlight(theIsHighlight);
+ return;
+ }
- Selection_Mode aSelectionMode = mySelector->SelectionMode();
+ if( aSelectionMode != GaussPointSelection )
+ return;
- if(aSelectionMode == ActorSelection)
- Superclass::highlight(theIsHighlight);
- else if(aSelectionMode != GaussPointSelection)
+ if ( !aCurrentHasIndex || !myBarVisibility )
return;
- TColStd_IndexedMapOfInteger aMapIndex;
+ // TColStd_IndexedMapOfInteger aMapIndex;
mySelector->GetIndex( getIO(), aMapIndex );
if(aMapIndex.Extent() != 1 || !myBarVisibility) {
return;
}
+
+ vtkRenderer *aRenderer = GetRenderer();
+ vtkCamera* aCamera = aRenderer->GetActiveCamera();
+
+ int anObjId = aMapIndex(1);
+ vtkFloatingPointType* aNodeCoord = GetNodeCoord(anObjId);
+
+ vtkFloatingPointType aFocalPnt[3];
+ aCamera->GetFocalPoint(aFocalPnt);
+
+ if ( CheckIsSameVector( aNodeCoord, aFocalPnt, 3 ) )
+ return;
+
+ // FlyTo
+ vtkRenderWindowInteractor* anInteractor = myInteractor;
+ vtkFloatingPointType aDollyWas = anInteractor->GetDolly();
+ int aNumberOfFlyFramesWas = anInteractor->GetNumberOfFlyFrames();
+
+ anInteractor->SetDolly(0.0);
+ anInteractor->SetNumberOfFlyFrames(myPickingSettings->GetStepNumber());
+ anInteractor->FlyTo(aRenderer, aNodeCoord);
+ aRenderer->ResetCameraClippingRange();
+ anInteractor->SetDolly(aDollyWas);
+ anInteractor->SetNumberOfFlyFrames(aNumberOfFlyFramesWas);
+ anInteractor->InvokeEvent(SVTK::ChangeRotationPoint, aNodeCoord);
//
std::ostringstream aStr;
- int anObjId = aMapIndex(1);
+ // int anObjId = aMapIndex(1);
aStr<<"Global ID: "<<anObjId;
//
vtkIdType aVtkId = GetNodeVTKID(anObjId);
if(vtkDataArray* aScalarArray = aDataSetAttributes->GetScalars()){
vtkFloatingPointType aVal = aScalarArray->GetTuple1(aVtkId);
//
- GetScalarBarCtrl()->SetIsMarked(true);
+ // GetScalarBarCtrl()->SetIsMarked(true);
GetScalarBarCtrl()->SetMarkValue(aVal);
GetScalarBarCtrl()->Update();
//
vtkSmartPointer<vtkPolyDataMapper> myMapper;
- vtkIdType myLastObjPointID;
+ vtkIdType myLastPreHighlightObjID;
vtkSmartPointer<VISU_FramedTextActor> myTextActor;
msgid "VisuGUI_Module::VISU_PICKING_PREF_STEP_NUMBER"
msgstr "Number of steps between two positions"
+msgid "VVTK_PickingDlg::DATA_POSITION"
+msgstr "Position"
+
+msgid "VVTK_PickingDlg::PARENT_ELEMENT"
+msgstr "Parent mesh element ID:"
+
+msgid "VVTK_PickingDlg::LOCAL_POINT"
+msgstr "Local Gauss Point ID:"
+
msgid "VisuGUI_Module::VISU_PICKING_PREF_PARENT_MESH_TTL"
msgstr "Parent mesh element"
#include "VISU_GaussPtsAct.h"
#include "VISU_GaussPtsSettings.h"
+#include "VISU_GaussPointsPL.hxx"
#include "SUIT_MessageBox.h"
#include "SUIT_ResourceMgr.h"
#include "SUIT_Session.h"
+#include "SVTK_Selector.h"
#include "SVTK_MainWindow.h"
#include "SVTK_RenderWindowInteractor.h"
+#include "VTKViewer_Algorithm.h"
+#include "SVTK_Functor.h"
+
#include <vtkActorCollection.h>
#include <vtkCallbackCommand.h>
#include <vtkObjectFactory.h>
#include <qlayout.h>
#include <qpushbutton.h>
#include <qvbox.h>
+#include <qvalidator.h>
#include "QtxAction.h"
#include "QtxDblSpinBox.h"
#include "LightApp_Application.h"
-using namespace std;
+namespace
+{
+ struct SelectorHelper
+ {
+ public:
+ SelectorHelper( SVTK_RenderWindowInteractor* theInteractor ):
+ myInteractor( theInteractor )
+ {}
+
+ bool
+ get()
+ {
+ bool aResult = false;
+ myMapIndex.Clear();
+ mySelector = NULL;
+ myPipeLine = NULL;
+ myActor = NULL;
+
+ if ( !myInteractor )
+ return aResult;
+
+ mySelector = myInteractor->GetSelector();
+ if ( !mySelector )
+ return aResult;
+
+ const SALOME_ListIO& aListIO = mySelector->StoredIObjects();
+ if ( aListIO.Extent() != 1 )
+ return aResult;
+
+ myIO = aListIO.First();
+ if ( mySelector->HasIndex( myIO ) )
+ mySelector->GetIndex(myIO, myMapIndex);
+
+ myActor = SVTK::Find<VISU_GaussPtsAct>(myInteractor->getRenderer()->GetActors(),
+ SVTK::TIsSameIObject<VISU_GaussPtsAct>( myIO ));
+ if ( !myActor )
+ return aResult;
+
+ myPipeLine = myActor->GetGaussPointsPL();
+
+ return true;
+ }
+
+ SVTK_RenderWindowInteractor* myInteractor;
+ TColStd_IndexedMapOfInteger myMapIndex;
+ Handle(SALOME_InteractiveObject) myIO;
+ SVTK_Selector* mySelector;
+
+ VISU_GaussPointsPL* myPipeLine;
+ VISU_GaussPtsAct* myActor;
+ };
+
+
+
+ class GaussPtsIDValidator: public QIntValidator
+ {
+ public:
+ GaussPtsIDValidator( SVTK_RenderWindowInteractor* theInteractor,
+ QObject * theParent ):
+ QIntValidator( 0, VTK_LARGE_ID, theParent ),
+ myHelper(theInteractor)
+ {}
+
+ virtual
+ State
+ validate ( QString & theInput, int & thePos ) const
+ {
+ if ( QIntValidator::validate( theInput, thePos ) == QValidator::Invalid)
+ return QValidator::Invalid;
+
+ if ( !myHelper.get() )
+ return QValidator::Invalid;
+
+ return QValidator::Acceptable;
+ }
+
+ protected:
+ mutable SelectorHelper myHelper;
+ };
+
+
+ class GaussCellIDValidator: public GaussPtsIDValidator
+ {
+ public:
+ GaussCellIDValidator( QLineEdit* theLocalPointLabel,
+ SVTK_RenderWindowInteractor* theInteractor,
+ QObject * theParent ):
+ GaussPtsIDValidator( theInteractor, theParent ),
+ myLocalPointLineEdit( theLocalPointLabel )
+ {}
+
+ virtual
+ State
+ validate ( QString & theInput, int & thePos ) const
+ {
+ if ( GaussPtsIDValidator::validate( theInput, thePos ) == QValidator::Invalid)
+ return QValidator::Invalid;
+
+ VISU::TCellID aCellID = theInput.toInt();
+ VISU::TLocalPntID aLocalPntID = myLocalPointLineEdit->text().toInt();
+ VISU::PGaussPtsIDMapper anIDMapper = myHelper.myPipeLine->GetGaussPtsIDMapper();
+ if ( anIDMapper->GetVTKID( VISU::TGaussPointID( aCellID, aLocalPntID ) ) < 0 )
+ return QValidator::Intermediate;
+
+ return QValidator::Acceptable;
+ }
+
+ private:
+ QLineEdit* myLocalPointLineEdit;
+ };
+
+
+ class GaussLocalPointIDValidator: public GaussPtsIDValidator
+ {
+ public:
+ GaussLocalPointIDValidator( QLineEdit* theParentElementLineEdit,
+ SVTK_RenderWindowInteractor* theInteractor,
+ QObject * theParent ):
+ GaussPtsIDValidator( theInteractor, theParent ),
+ myParentElementLineEdit( theParentElementLineEdit )
+ {}
+
+ virtual
+ State
+ validate ( QString & theInput, int & thePos ) const
+ {
+ if ( GaussPtsIDValidator::validate( theInput, thePos ) == QValidator::Invalid)
+ return QValidator::Invalid;
+
+ VISU::TLocalPntID aLocalPntID = theInput.toInt();
+ VISU::TCellID aCellID = myParentElementLineEdit->text().toInt();
+ VISU::PGaussPtsIDMapper anIDMapper = myHelper.myPipeLine->GetGaussPtsIDMapper();
+ if ( anIDMapper->GetVTKID( VISU::TGaussPointID( aCellID, aLocalPntID ) ) < 0 )
+ return QValidator::Intermediate;
+
+ return QValidator::Acceptable;
+ }
+
+ private:
+ QLineEdit* myParentElementLineEdit;
+ };
+}
+
+
+VVTK_ValidatedLineEdit::VVTK_ValidatedLineEdit( QWidget * parent, const char * name ):
+ QLineEdit( parent, name )
+{
+ connect( this, SIGNAL( textChanged( const QString& ) ), this, SLOT( MarkValidated( const QString& ) ) );
+}
+
+void VVTK_ValidatedLineEdit::MarkValidated( const QString& theText )
+{
+ if ( !validator() )
+ return;
+
+ int aPos;
+ QString aText( theText );
+ switch ( validator()->validate( aText, aPos ) ) {
+ case QValidator::Invalid:
+ case QValidator::Intermediate:
+ setPaletteForegroundColor( QColor( 255, 0, 0 ) );
+ break;
+ case QValidator::Acceptable:
+ setPaletteForegroundColor( QColor( 0, 0, 0 ) );
+ break;
+ }
+}
+
+//---------------------------------------------------------------------------------
VVTK_PickingDlg::VVTK_PickingDlg(QtxAction* theAction,
SVTK_MainWindow* theParent,
CameraGroupLayout->addWidget( myStepNumberSpinBox, 1, 1 );
// Display parent mesh element
- QGroupBox* ParentMeshGroup = new QGroupBox( tr( "PARENT_MESH_TITLE" ), aBox, "ParentMeshGroup" );
- ParentMeshGroup->setColumnLayout(0, Qt::Vertical );
- ParentMeshGroup->layout()->setSpacing( 0 );
- ParentMeshGroup->layout()->setMargin( 0 );
+ QGroupBox* PositionGroup = new QGroupBox( tr( "DATA_POSITION" ), aBox, "Position" );
+ PositionGroup->setColumnLayout(0, Qt::Vertical );
+ PositionGroup->layout()->setSpacing( 0 );
+ PositionGroup->layout()->setMargin( 0 );
+
+ QGridLayout* PositionGroupLayout = new QGridLayout (PositionGroup->layout());
+ PositionGroupLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft);
+ PositionGroupLayout->setSpacing(6);
+ PositionGroupLayout->setMargin(11);
+
+ QLabel* ParentElementLabel = new QLabel( tr( "PARENT_ELEMENT" ), PositionGroup );
+ PositionGroupLayout->addMultiCellWidget( ParentElementLabel, 0, 0, 0, 2 );
+
+ myParentElementLineEdit = new VVTK_ValidatedLineEdit( PositionGroup );
+ PositionGroupLayout->addMultiCellWidget( myParentElementLineEdit, 0, 0, 3, 3 );
- QGridLayout* ParentMeshGroupLayout = new QGridLayout (ParentMeshGroup->layout());
- ParentMeshGroupLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft);
- ParentMeshGroupLayout->setSpacing(6);
- ParentMeshGroupLayout->setMargin(11);
+ QLabel* LocalPointLabel = new QLabel( tr( "LOCAL_POINT" ), PositionGroup );
+ PositionGroupLayout->addMultiCellWidget( LocalPointLabel, 1, 1, 0, 2 );
- myDisplayParentMeshCheckBox = new QCheckBox( tr( "DISPLAY_PARENT_MESH" ), ParentMeshGroup );
- ParentMeshGroupLayout->addWidget( myDisplayParentMeshCheckBox, 0, 0 );
+ myLocalPointLineEdit = new VVTK_ValidatedLineEdit( PositionGroup );
+ PositionGroupLayout->addMultiCellWidget( myLocalPointLineEdit, 1, 1, 3, 3 );
+
+ myDisplayParentMeshCheckBox = new QCheckBox( tr( "DISPLAY_PARENT_MESH" ), PositionGroup );
+ PositionGroupLayout->addMultiCellWidget( myDisplayParentMeshCheckBox, 2, 2, 0, 3 );
// Common buttons ===========================================================
QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
connect( buttonApply, SIGNAL( clicked() ), this, SLOT( onClickApply() ) );
connect( buttonClose, SIGNAL( clicked() ), this, SLOT( onClickClose() ) );
connect( buttonHelp, SIGNAL( clicked() ), this, SLOT( onClickHelp() ) );
+
+ connect( myParentElementLineEdit, SIGNAL( textChanged( const QString& ) ), this, SLOT( onSelectionValidate() ) );
+ connect( myLocalPointLineEdit, SIGNAL( textChanged( const QString& ) ), this, SLOT( onSelectionValidate() ) );
+
}
VVTK_PickingDlg::~VVTK_PickingDlg()
onClickApply();
}
+void VVTK_PickingDlg::onSelectionValidate()
+{
+ myParentElementLineEdit->MarkValidated( myParentElementLineEdit->text() );
+ myLocalPointLineEdit->MarkValidated( myLocalPointLineEdit->text() );
+}
+
+void VVTK_PickingDlg::onSelectionEvent()
+{
+ SelectorHelper aHelper( myInteractor );
+ if ( !aHelper.get() )
+ return;
+
+ const TColStd_IndexedMapOfInteger& aMapIndex = aHelper.myMapIndex;
+ if ( aMapIndex.Extent() != 1 )
+ return;
+
+ int anObjId = aHelper.myMapIndex(1);
+
+ VISU::TGaussPointID aGaussPointID = aHelper.myPipeLine->GetObjID( anObjId );
+
+ VISU::TCellID aCellID = aGaussPointID.first;
+ myParentElementLineEdit->setText( QString::number( aCellID ) );
+
+ VISU::TLocalPntID aLocalPntID = aGaussPointID.second;
+ myLocalPointLineEdit->setText( QString::number( aLocalPntID ) );
+}
VISU_PickingSettings*
VVTK_PickingDlg
theInteractor->GetDevice()->AddObserver(vtkCommand::KeyPressEvent,
myEventCallbackCommand.GetPointer(),
myPriority);
+ theInteractor->GetDevice()->AddObserver(vtkCommand::EndPickEvent,
+ myEventCallbackCommand.GetPointer(),
+ myPriority);
+ {
+ QValidator* aValidator = new GaussCellIDValidator( myLocalPointLineEdit, theInteractor, myParentElementLineEdit );
+ myParentElementLineEdit->setValidator( aValidator );
+ }
+ {
+ QValidator* aValidator = new GaussLocalPointIDValidator( myParentElementLineEdit, theInteractor, myLocalPointLineEdit );
+ myLocalPointLineEdit->setValidator( aValidator );
+ }
}
-
void VVTK_PickingDlg::ProcessEvents(vtkObject* vtkNotUsed(theObject),
unsigned long theEvent,
void* theClientData,
case vtkCommand::KeyPressEvent:
self->KeyPressed();
break;
+ case vtkCommand::EndPickEvent:
+ self->onSelectionEvent();
+ break;
}
}
aColor[2] = aButtonColor.blue() / 255.0;
myPickingSettings->SetColor( aColor );
- myPickingSettings->InvokeEvent(VISU::UpdatePickingSettingsEvent,NULL);
+ myPickingSettings->InvokeEvent( VISU::UpdatePickingSettingsEvent,NULL );
+
+ SelectorHelper aHelper( myInteractor );
+ if ( !aHelper.get() )
+ return;
+
+ VISU::TCellID aCellID = myParentElementLineEdit->text().toInt();
+ VISU::TLocalPntID aLocalPntID = myLocalPointLineEdit->text().toInt();
+ VISU::PGaussPtsIDMapper anIDMapper = aHelper.myPipeLine->GetGaussPtsIDMapper();
+ vtkIdType anObjId = anIDMapper->GetVTKID( VISU::TGaussPointID( aCellID, aLocalPntID ) );
+ if ( anObjId < 0 )
+ return;
+
+ aHelper.myMapIndex.Clear();
+ aHelper.myMapIndex.Add( anObjId );
+ aHelper.mySelector->AddOrRemoveIndex( aHelper.myIO, aHelper.myMapIndex, false );
+ aHelper.myActor->Highlight( aHelper.myIO );
+ myInteractor->GetDevice()->CreateTimer( VTKI_TIMER_FIRST );
}
void VVTK_PickingDlg::onClickClose()
#include <vtkObject.h>
#include <vtkSmartPointer.h>
+#include <qlineedit.h>
class vtkActorCollection;
class vtkCallbackCommand;
class vtkImageData;
class QLabel;
+class QLineEdit;
class QComboBox;
class QCheckBox;
class QPushButton;
class SVTK_MainWindow;
class SVTK_RenderWindowInteractor;
+class VVTK_ValidatedLineEdit;
//! Picking Dialog.
/*!
void SetInteractor( SVTK_RenderWindowInteractor* );
protected slots:
+ void onSelectionEvent();
void onClickApply();
void onClickClose();
void onClickHelp();
void onColorButtonPressed();
+ void onSelectionValidate();
private:
static void ProcessEvents(vtkObject* theObject,
QtxAction* myAction;
vtkSmartPointer<VISU_PickingSettings> myPickingSettings;
+ VVTK_ValidatedLineEdit* myParentElementLineEdit;
+ VVTK_ValidatedLineEdit* myLocalPointLineEdit;
+
SVTK_RenderWindowInteractor* myInteractor;
float myPriority;
vtkSmartPointer<vtkCallbackCommand> myEventCallbackCommand;
};
+class VVTK_ValidatedLineEdit : public QLineEdit
+{
+ Q_OBJECT;
+public:
+ VVTK_ValidatedLineEdit( QWidget * parent, const char * name = 0 );
+
+public slots:
+ void
+ MarkValidated( const QString& theText );
+};
+
#endif