From: ouv Date: Wed, 27 May 2009 07:23:16 +0000 (+0000) Subject: Issue 0019818: EDF 703 SMESH VISU : Display Mesh Groups names in viewer (as a caption) X-Git-Tag: V5_1_main_20090528~3 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b72efbc8c240695bff8372b19c333a6a542cf909;p=modules%2Fvisu.git Issue 0019818: EDF 703 SMESH VISU : Display Mesh Groups names in viewer (as a caption) --- diff --git a/src/OBJECT/VISU_Actor.cxx b/src/OBJECT/VISU_Actor.cxx index 339499ad..c9b52260 100644 --- a/src/OBJECT/VISU_Actor.cxx +++ b/src/OBJECT/VISU_Actor.cxx @@ -33,6 +33,7 @@ #include "SVTK_Event.h" +#include "VTKViewer_FramedTextActor.h" #include "VTKViewer_ShrinkFilter.h" #include "VTKViewer_GeometryFilter.h" #include "VISU_ActorFactory.h" @@ -108,7 +109,7 @@ VISU_Actor myShrinkFilter(VTKViewer_ShrinkFilter::New()), myAnnotationMapper(vtkTextMapper::New()), myAnnotationActor(vtkTextActor::New()), - myTextActor(VISU_FramedTextActor::New()), + myTextActor(VTKViewer_FramedTextActor::New()), myIsFeatureEdgesAllowed(false), myIsFeatureEdgesEnabled(false), myFeatureEdges(vtkFeatureEdges::New()), diff --git a/src/OBJECT/VISU_Actor.h b/src/OBJECT/VISU_Actor.h index 78c6631a..65920a78 100644 --- a/src/OBJECT/VISU_Actor.h +++ b/src/OBJECT/VISU_Actor.h @@ -56,7 +56,7 @@ class vtkLabeledDataMapper; class vtkMaskPoints; class vtkActor2D; -class VISU_FramedTextActor; +class VTKViewer_FramedTextActor; namespace SVTK { @@ -375,7 +375,7 @@ class VISU_OBJECT_EXPORT VISU_Actor : public VISU_ActorBase vtkSmartPointer myAnnotationMapper; vtkSmartPointer myAnnotationActor; - vtkSmartPointer myTextActor; + vtkSmartPointer myTextActor; vtkSmartPointer myFeatureEdges; bool myIsFeatureEdgesAllowed; diff --git a/src/OBJECT/VISU_GaussPtsAct.cxx b/src/OBJECT/VISU_GaussPtsAct.cxx index 5dd12bbd..2fc55456 100644 --- a/src/OBJECT/VISU_GaussPtsAct.cxx +++ b/src/OBJECT/VISU_GaussPtsAct.cxx @@ -38,6 +38,7 @@ #include "VISU_Event.h" #include "SVTK_Actor.h" +#include "VTKViewer_FramedTextActor.h" #include #include diff --git a/src/OBJECT/VISU_GaussPtsAct.h b/src/OBJECT/VISU_GaussPtsAct.h index 891f391b..6e255ab0 100644 --- a/src/OBJECT/VISU_GaussPtsAct.h +++ b/src/OBJECT/VISU_GaussPtsAct.h @@ -50,7 +50,6 @@ class vtkInteractorStyle; class VISU_GaussPtsDeviceActor; class VISU_CursorPyramid; -class VISU_FramedTextActor; class vtkUnstructuredGrid; class vtkPolyDataMapper; diff --git a/src/OBJECT/VISU_GaussPtsDeviceActor.cxx b/src/OBJECT/VISU_GaussPtsDeviceActor.cxx index 2ea81b7f..1828a55c 100644 --- a/src/OBJECT/VISU_GaussPtsDeviceActor.cxx +++ b/src/OBJECT/VISU_GaussPtsDeviceActor.cxx @@ -547,294 +547,3 @@ VISU_CursorPyramid mySources[5]->SetCenter(0.0, 0.0, -aDisplacement); } - -//---------------------------------------------------------------------------- -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -//================================================================== -vtkCxxRevisionMacro(VISU_FramedTextActor, "$Revision$"); -vtkStandardNewMacro(VISU_FramedTextActor); - -//================================================================== -// function : VISU_FramedTextActor -// purpose : -//================================================================== -VISU_FramedTextActor::VISU_FramedTextActor() -{ - PositionCoordinate->SetCoordinateSystemToNormalizedViewport(); - - myTransparency=0.; - myBar = vtkPolyData::New(); - myBarMapper = vtkPolyDataMapper2D::New(); - myBarMapper->SetInput(myBar); - myBarActor = vtkActor2D::New(); - myBarActor->SetMapper(myBarMapper); - myBarActor->GetProperty()->SetOpacity(1.-myTransparency); - myBarActor->GetProperty()->SetColor(.5, .5, .5); - // - myTextProperty = vtkTextProperty::New(); - myTextProperty->SetFontSize(12); - myTextProperty->SetBold(0); - myTextProperty->SetItalic(0); - myTextProperty->SetShadow(1); - myTextProperty->SetFontFamilyToArial(); - // - myTextMapper=vtkTextMapper::New(); - myTextMapper->SetInput(""); - myTextMapper->GetTextProperty()->ShallowCopy(myTextProperty); - myTextActor=vtkActor2D::New(); - myTextActor->SetMapper(myTextMapper); - // - myBarActor->SetVisibility(1); - myTextActor->SetVisibility(1); - myBarActor->SetPickable(0); - myTextActor->SetPickable(0); - //---------------------------------------------------------- - myModePosition=0;// 0 -centered below the point - // 1 -top left corner of the 3D view window - // - for(int i=0; i<4; i++) { - myWorldPoint[i] = 0.; - } - myDistance=10.; - // -} -//================================================================== -// function : ~ -// purpose : -//================================================================== -VISU_FramedTextActor::~VISU_FramedTextActor() -{ - myTextActor->Delete(); - myTextMapper->Delete(); - myTextProperty->Delete(); - myBarActor->Delete(); - myBarMapper->Delete(); - myBar->Delete(); -} -//================================================================== -// function : SetVisibility -// purpose : -//================================================================== -void VISU_FramedTextActor::SetVisibility (int theVisibility) -{ - myBarActor->SetVisibility(theVisibility); - myTextActor->SetVisibility(theVisibility); -} -//================================================================== -// function : GetVisibility -// purpose : -//================================================================== -int VISU_FramedTextActor::GetVisibility() -{ - return myBarActor->GetVisibility(); -} -//================================================================== -// function : SetPickable -// purpose : -//================================================================== -void VISU_FramedTextActor::SetPickable (int thePickability) -{ - myBarActor->SetPickable(thePickability); - myTextActor->SetPickable(thePickability); -} -//================================================================== -// function : GetPickable -// purpose : -//================================================================== -int VISU_FramedTextActor::GetPickable() -{ - return myBarActor->GetPickable(); -} -//================================================================== -// function : SetTransparency -// purpose : -//================================================================== -void VISU_FramedTextActor::SetTransparency(const vtkFloatingPointType theTransparency) -{ - if (theTransparency>=0. && theTransparency<=1.){ - myTransparency=theTransparency; - myBarActor->GetProperty()->SetOpacity(1.-myTransparency); - Modified(); - } -} -//================================================================== -// function : GetTransparency -// purpose : -//================================================================== -vtkFloatingPointType VISU_FramedTextActor::GetTransparency()const -{ - return myTransparency; -} -//================================================================== -// function : SetText -// purpose : -//================================================================== -void VISU_FramedTextActor::SetText(const char* theText) -{ - myTextMapper->SetInput(theText); - Modified(); -} -//================================================================== -// function : GetText -// purpose : -//================================================================== -char* VISU_FramedTextActor::GetText() -{ - return myTextMapper->GetInput(); -} -//================================================================== -// function : SetModePosition -// purpose : -//================================================================== -void VISU_FramedTextActor::SetModePosition(const int theMode) -{ - myModePosition=theMode; - Modified(); -} -//================================================================== -// function : GetModePosition -// purpose : -//================================================================== -int VISU_FramedTextActor::GetModePosition()const -{ - return myModePosition; -} -//================================================================== -// function : SetWorldPoint -// purpose : -//================================================================== -void VISU_FramedTextActor::SetWorldPoint(const vtkFloatingPointType theWorldPoint[4]) -{ - for(int i = 0; i<4; ++i) { - myWorldPoint[i] = theWorldPoint[i]; - } - Modified(); -} -//================================================================== -// function : GetWorldPoint -// purpose : -//================================================================== -const vtkFloatingPointType* VISU_FramedTextActor::GetWorldPoint()const -{ - return myWorldPoint; -} -//================================================================== -// function : SetDistance -// purpose : -//================================================================== -void VISU_FramedTextActor::SetDistance(const vtkFloatingPointType theDistance) -{ - myDistance=theDistance; -} -//================================================================== -// function : GetDistance -// purpose : -//================================================================== -vtkFloatingPointType VISU_FramedTextActor::GetDistance()const -{ - return myDistance; -} -//================================================================== -// function : ReleaseGraphicsResources -// purpose : -//================================================================== -void VISU_FramedTextActor::ReleaseGraphicsResources(vtkWindow *win) -{ - myTextActor->ReleaseGraphicsResources(win); - myBarActor->ReleaseGraphicsResources(win); -} -//================================================================== -// function : RenderOverlay -// purpose : -//================================================================== -int VISU_FramedTextActor::RenderOverlay(vtkViewport *viewport) -{ - int renderedSomething = 0; - myBarActor->RenderOverlay(viewport); - renderedSomething +=myTextActor->RenderOverlay(viewport); - return renderedSomething; -} -//================================================================== -// function : RenderOpaqueGeometry -// purpose : -//================================================================== -int -VISU_FramedTextActor -::RenderOpaqueGeometry(vtkViewport *theViewport) -{ - int anIsRenderedSomething = 0; - int* aViewportSize = theViewport->GetSize(); - if(aViewportSize[0] == 1 || aViewportSize[1] == 1) - return anIsRenderedSomething; - - myBar->Initialize(); - - int aNbPoints = 4; - vtkPoints *aPoints = vtkPoints::New(); - aPoints->SetNumberOfPoints(aNbPoints); - myBar->SetPoints(aPoints); - aPoints->Delete(); - - vtkCellArray *aPolys = vtkCellArray::New(); - aPolys->Allocate(aPolys->EstimateSize(1,4)); - vtkIdType aPointsIds[4] = {0, 1, 3, 2}; - aPolys->InsertNextCell(4,aPointsIds); - myBar->SetPolys(aPolys); - aPolys->Delete(); - - int aTextSize[2]; - myTextMapper->GetSize(theViewport, aTextSize); - int aBarWidth = aTextSize[0]; - int aBarHeight = aTextSize[1]; - - if (myModePosition==0) { - theViewport->SetWorldPoint(myWorldPoint); - theViewport->WorldToDisplay(); - - vtkFloatingPointType aSelectionPoint[3]; - theViewport->GetDisplayPoint(aSelectionPoint); - vtkFloatingPointType u = aSelectionPoint[0]; - vtkFloatingPointType v = aSelectionPoint[1] - myDistance; - theViewport->ViewportToNormalizedViewport(u, v); - PositionCoordinate->SetValue(u, v); - // - myTextProperty->SetJustificationToCentered(); - myTextProperty->SetVerticalJustificationToTop(); - // - aBarWidth /= 2; - aPoints->SetPoint(0, -aBarWidth, 0.0, 0.0); - aPoints->SetPoint(1, -aBarWidth, -aBarHeight, 0.0); - aPoints->SetPoint(2, aBarWidth, 0.0, 0.0); - aPoints->SetPoint(3, aBarWidth, -aBarHeight, 0.0); - } - else {//if (myModePosition==1) { - PositionCoordinate->SetValue(0.0, 1.0); - myTextProperty->SetJustificationToLeft(); - myTextProperty->SetVerticalJustificationToTop(); - // - aPoints->SetPoint(0, 0.0, 0.0, 0.0); - aPoints->SetPoint(1, 0.0, -aBarHeight, 0.0); - aPoints->SetPoint(2, aBarWidth, 0.0, 0.0); - aPoints->SetPoint(3, aBarWidth, -aBarHeight, 0.0); - } - // - myTextMapper->GetTextProperty()->ShallowCopy(myTextProperty); - myBarActor ->GetPositionCoordinate()->SetReferenceCoordinate(PositionCoordinate); - myTextActor->GetPositionCoordinate()->SetReferenceCoordinate(PositionCoordinate); - // - myBuildTime.Modified(); - // - return anIsRenderedSomething; -} diff --git a/src/OBJECT/VISU_GaussPtsDeviceActor.h b/src/OBJECT/VISU_GaussPtsDeviceActor.h index d519780c..f01bdee2 100644 --- a/src/OBJECT/VISU_GaussPtsDeviceActor.h +++ b/src/OBJECT/VISU_GaussPtsDeviceActor.h @@ -233,76 +233,4 @@ protected: }; -//================================================================== -// class VISU_FramedTextActor -// -#include -// -class vtkViewport; -class vtkProp; -class vtkWindow; -class vtkPolyData; -class vtkPolyDataMapper2D; -class vtkActor2D; -class vtkTimeStamp; -class vtkTextProperty; -class vtkTextMapper; - -class VISU_FramedTextActor : public vtkActor2D -{ -public: - // vtks - vtkTypeRevisionMacro(VISU_FramedTextActor,vtkActor2D); - static VISU_FramedTextActor *New(); - // - virtual int RenderOpaqueGeometry(vtkViewport* viewport); - virtual int RenderTranslucentGeometry(vtkViewport*) { return 0; }; - virtual int RenderOverlay(vtkViewport* viewport); - virtual void ReleaseGraphicsResources(vtkWindow *); - virtual void SetVisibility (int ); - virtual int GetVisibility() ; - virtual void SetPickable (int ) ; - virtual int GetPickable(); - // - // selectors - void SetText(const char* theText); - char* GetText(); - // - void SetModePosition(const int theMode); - int GetModePosition()const; - // - void SetWorldPoint(const vtkFloatingPointType theWorldPoint[4]); - const vtkFloatingPointType* GetWorldPoint()const; - // - void SetDistance(const vtkFloatingPointType theDistance); - vtkFloatingPointType GetDistance()const; - // - void SetTransparency(const vtkFloatingPointType theTransparency); - vtkFloatingPointType GetTransparency()const; - // -protected: - VISU_FramedTextActor(); - ~VISU_FramedTextActor(); - -protected: - vtkPolyData *myBar; - vtkPolyDataMapper2D *myBarMapper; - vtkActor2D *myBarActor; - // - vtkTextProperty *myTextProperty; - vtkTextMapper *myTextMapper; - vtkActor2D *myTextActor; - // - vtkTimeStamp myBuildTime; - // - int myModePosition; - vtkFloatingPointType myWorldPoint[4]; - vtkFloatingPointType myDistance; - vtkFloatingPointType myTransparency; - -private: - VISU_FramedTextActor(const VISU_FramedTextActor&); // Not implemented. - void operator=(const VISU_FramedTextActor&); // Not implemented. -}; - #endif //VISU_GAUSS_PTS_DEVICE_ACTOR_H diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index 6334fd81..03cff4e0 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -3050,7 +3050,7 @@ VisuGUI // rename command QString aCurveAll = "'VISU::TTABLE' 'VISU::TCURVE' 'VISU::TCONTAINER' 'VISU::POINTMAP3D'"; - aRule = "selcount=1 and ($type in {'VISU::TVIEW3D' 'VISU::TMESH' 'VISU::TPOINTMAP3D' " + aCurveAll + " " + aPrsAll + "})"; + aRule = "selcount=1 and ($type in {'VISU::TVIEW3D' 'VISU::TPOINTMAP3D' " + aCurveAll + " " + aPrsAll + "})"; mgr->setRule( action( VISU_RENAME ), aRule ); // copy presentation command diff --git a/src/VISU_I/VISU_Mesh_i.cc b/src/VISU_I/VISU_Mesh_i.cc index c2983431..f07f2208 100644 --- a/src/VISU_I/VISU_Mesh_i.cc +++ b/src/VISU_I/VISU_Mesh_i.cc @@ -535,6 +535,12 @@ VISU::Mesh_i aResourceMgr->booleanValue("VISU", "show_non_manifold_edges", false) ); anActor->SetFeatureEdgesColoring( aResourceMgr->booleanValue("VISU", "feature_edges_coloring", false) ); + if (myType == VISU::TGROUP ) + { + anActor->SetIsDisplayNameActor( true ); + anActor->SetNameActorText( GetSubMeshName().c_str() ); + } + UpdateActor(anActor); }catch (...) { anActor->Delete(); diff --git a/src/VISU_I/VISU_ScalarMap_i.cc b/src/VISU_I/VISU_ScalarMap_i.cc index 5322effe..87a4760b 100644 --- a/src/VISU_I/VISU_ScalarMap_i.cc +++ b/src/VISU_I/VISU_ScalarMap_i.cc @@ -513,6 +513,20 @@ VISU::ScalarMap_i GetValLblFontColor( anRGB[ 0 ], anRGB[ 1 ], anRGB[ 2 ] ); aProp->SetColor( anRGB[ 0 ], anRGB[ 1 ], anRGB[ 2 ] ); } + + bool isOnGroups = myGroupNames.size() > 0; + if ( isOnGroups ) + { + QStringList aList; + TGroupNames::const_iterator anIter = myGroupNames.begin(); + for ( ; anIter != myGroupNames.end(); anIter++ ) + { + const std::string aGroupName = *anIter; + aList << QString( aGroupName.c_str() ); + } + anActor->SetNameActorText( aList.join( "\n" ).toLatin1().constData() ); + } + anActor->SetIsDisplayNameActor( isOnGroups ); } TSuperClass::UpdateActor(theActor); }