mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2024-12-28 18:30:35 +05:00
22359: Body Fitting algorithm: grid orientation
Add labels to arrows
This commit is contained in:
parent
a62ca0b865
commit
494cae9236
@ -28,23 +28,26 @@
|
|||||||
#include "SMESHGUI_MeshEditPreview.h"
|
#include "SMESHGUI_MeshEditPreview.h"
|
||||||
|
|
||||||
#include "SMESHGUI_VTKUtils.h"
|
#include "SMESHGUI_VTKUtils.h"
|
||||||
|
#include "SMESH_Actor.h"
|
||||||
#include <SMESH_Actor.h>
|
#include "SMESH_ActorUtils.h"
|
||||||
#include <SMESH_ActorUtils.h>
|
|
||||||
|
|
||||||
// SALOME GUI includes
|
// SALOME GUI includes
|
||||||
#include <VTKViewer_CellLocationsArray.h>
|
#include <SVTK_Renderer.h>
|
||||||
#include <SVTK_ViewWindow.h>
|
#include <SVTK_ViewWindow.h>
|
||||||
|
#include <VTKViewer_CellLocationsArray.h>
|
||||||
|
|
||||||
// VTK includes
|
// VTK includes
|
||||||
#include <vtkPoints.h>
|
|
||||||
#include <vtkIdList.h>
|
|
||||||
#include <vtkCellArray.h>
|
#include <vtkCellArray.h>
|
||||||
|
#include <vtkCoordinate.h>
|
||||||
|
#include <vtkDataSetMapper.h>
|
||||||
|
#include <vtkIdList.h>
|
||||||
|
#include <vtkPoints.h>
|
||||||
|
#include <vtkProperty.h>
|
||||||
|
#include <vtkRenderer.h>
|
||||||
|
#include <vtkTextActor.h>
|
||||||
|
#include <vtkTextMapper.h>
|
||||||
#include <vtkUnsignedCharArray.h>
|
#include <vtkUnsignedCharArray.h>
|
||||||
#include <vtkUnstructuredGrid.h>
|
#include <vtkUnstructuredGrid.h>
|
||||||
#include <vtkUnstructuredGridWriter.h>
|
|
||||||
#include <vtkDataSetMapper.h>
|
|
||||||
#include <vtkProperty.h>
|
|
||||||
|
|
||||||
// Qt includes
|
// Qt includes
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
@ -88,7 +91,6 @@ SMESHGUI_MeshEditPreview::SMESHGUI_MeshEditPreview(SVTK_ViewWindow* theViewWindo
|
|||||||
aMapper->Delete();
|
aMapper->Delete();
|
||||||
|
|
||||||
myViewWindow->AddActor(myPreviewActor);
|
myViewWindow->AddActor(myPreviewActor);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//================================================================================
|
//================================================================================
|
||||||
@ -104,6 +106,12 @@ SMESHGUI_MeshEditPreview::~SMESHGUI_MeshEditPreview()
|
|||||||
myViewWindow->RemoveActor(myPreviewActor);
|
myViewWindow->RemoveActor(myPreviewActor);
|
||||||
myPreviewActor->Delete();
|
myPreviewActor->Delete();
|
||||||
|
|
||||||
|
for ( size_t iA = 0; iA < myLabelActors.size(); ++iA )
|
||||||
|
if ( myLabelActors[iA] )
|
||||||
|
{
|
||||||
|
myPreviewActor->GetRenderer()->RemoveActor( myLabelActors[iA] );
|
||||||
|
myLabelActors[iA]->Delete();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//================================================================================
|
//================================================================================
|
||||||
@ -235,7 +243,8 @@ void SMESHGUI_MeshEditPreview::SetData (const SMESH::MeshPreviewStruct* previewD
|
|||||||
void SMESHGUI_MeshEditPreview::SetArrowShapeAndNb( int nbArrows,
|
void SMESHGUI_MeshEditPreview::SetArrowShapeAndNb( int nbArrows,
|
||||||
double headLength,
|
double headLength,
|
||||||
double headRadius,
|
double headRadius,
|
||||||
double start)
|
double start,
|
||||||
|
const char* labels)
|
||||||
{
|
{
|
||||||
const int theNbPoints = 10; // in one arrow
|
const int theNbPoints = 10; // in one arrow
|
||||||
myUnitArrowPnts.reserve( theNbPoints );
|
myUnitArrowPnts.reserve( theNbPoints );
|
||||||
@ -286,7 +295,28 @@ void SMESHGUI_MeshEditPreview::SetArrowShapeAndNb( int nbArrows,
|
|||||||
myGrid->InsertNextCell( VTK_LINE, 2, conn );
|
myGrid->InsertNextCell( VTK_LINE, 2, conn );
|
||||||
}
|
}
|
||||||
|
|
||||||
myNbArrows = nbArrows;
|
myLabelActors.resize( nbArrows, ( vtkTextActor*) NULL );
|
||||||
|
char label[] = "X";
|
||||||
|
if ( labels )
|
||||||
|
for ( int iP = 0, iA = 0; iA < nbArrows; ++iA )
|
||||||
|
{
|
||||||
|
label[0] = labels[iA];
|
||||||
|
vtkTextMapper* text = vtkTextMapper::New();
|
||||||
|
text->SetInput( label );
|
||||||
|
vtkCoordinate* coord = vtkCoordinate::New();
|
||||||
|
|
||||||
|
myLabelActors[iA] = vtkTextActor::New();
|
||||||
|
//myLabelActors[iA]->SetMapper( text );
|
||||||
|
myLabelActors[iA]->SetInput( label );
|
||||||
|
myLabelActors[iA]->SetTextScaleModeToNone();
|
||||||
|
myLabelActors[iA]->PickableOff();
|
||||||
|
myLabelActors[iA]->GetPositionCoordinate()->SetReferenceCoordinate( coord );
|
||||||
|
|
||||||
|
text->Delete();
|
||||||
|
coord->Delete();
|
||||||
|
|
||||||
|
myPreviewActor->GetRenderer()->AddActor(myLabelActors[iA]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//================================================================================
|
//================================================================================
|
||||||
@ -302,7 +332,7 @@ void SMESHGUI_MeshEditPreview::SetArrows( const gp_Ax1* axes,
|
|||||||
{
|
{
|
||||||
vtkPoints* aPoints = myGrid->GetPoints();
|
vtkPoints* aPoints = myGrid->GetPoints();
|
||||||
|
|
||||||
for ( int iP = 0, iA = 0; iA < myNbArrows; ++iA )
|
for ( int iP = 0, iA = 0; iA < myLabelActors.size(); ++iA )
|
||||||
{
|
{
|
||||||
gp_Trsf trsf;
|
gp_Trsf trsf;
|
||||||
trsf.SetTransformation( gp_Ax3( axes[iA].Location(), axes[iA].Direction() ), gp::XOY() );
|
trsf.SetTransformation( gp_Ax3( axes[iA].Location(), axes[iA].Direction() ), gp::XOY() );
|
||||||
@ -313,6 +343,14 @@ void SMESHGUI_MeshEditPreview::SetArrows( const gp_Ax1* axes,
|
|||||||
p.Transform( trsf );
|
p.Transform( trsf );
|
||||||
aPoints->SetPoint( iP, p.X(), p.Y(), p.Z() );
|
aPoints->SetPoint( iP, p.X(), p.Y(), p.Z() );
|
||||||
}
|
}
|
||||||
|
if ( myLabelActors[iA] )
|
||||||
|
if ( vtkCoordinate* aCoord =
|
||||||
|
myLabelActors[iA]->GetPositionCoordinate()->GetReferenceCoordinate() )
|
||||||
|
{
|
||||||
|
double p[3];
|
||||||
|
aPoints->GetPoint( iP-1, p );
|
||||||
|
aCoord->SetValue( p );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
myGrid->Modified();
|
myGrid->Modified();
|
||||||
@ -327,6 +365,9 @@ void SMESHGUI_MeshEditPreview::SetArrows( const gp_Ax1* axes,
|
|||||||
void SMESHGUI_MeshEditPreview::SetVisibility (bool theVisibility)
|
void SMESHGUI_MeshEditPreview::SetVisibility (bool theVisibility)
|
||||||
{
|
{
|
||||||
myPreviewActor->SetVisibility(theVisibility);
|
myPreviewActor->SetVisibility(theVisibility);
|
||||||
|
for ( size_t iA = 0; iA < myLabelActors.size(); ++iA )
|
||||||
|
if ( myLabelActors[iA] )
|
||||||
|
myLabelActors[iA]->SetVisibility(theVisibility);
|
||||||
SMESH::RepaintCurrentView();
|
SMESH::RepaintCurrentView();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,9 +32,10 @@
|
|||||||
#include <gp_Ax1.hxx>
|
#include <gp_Ax1.hxx>
|
||||||
#include <gp_Pnt.hxx>
|
#include <gp_Pnt.hxx>
|
||||||
|
|
||||||
class SVTK_ViewWindow;
|
|
||||||
class vtkUnstructuredGrid;
|
|
||||||
class SALOME_Actor;
|
class SALOME_Actor;
|
||||||
|
class SVTK_ViewWindow;
|
||||||
|
class vtkTextActor;
|
||||||
|
class vtkUnstructuredGrid;
|
||||||
|
|
||||||
namespace SMESH
|
namespace SMESH
|
||||||
{
|
{
|
||||||
@ -52,7 +53,7 @@ class SMESHGUI_EXPORT SMESHGUI_MeshEditPreview
|
|||||||
SALOME_Actor* myPreviewActor;
|
SALOME_Actor* myPreviewActor;
|
||||||
|
|
||||||
std::vector<gp_Pnt> myUnitArrowPnts;
|
std::vector<gp_Pnt> myUnitArrowPnts;
|
||||||
int myNbArrows;
|
std::vector<vtkTextActor*> myLabelActors;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SMESHGUI_MeshEditPreview( SVTK_ViewWindow* );
|
SMESHGUI_MeshEditPreview( SVTK_ViewWindow* );
|
||||||
@ -66,7 +67,8 @@ public:
|
|||||||
void SetArrowShapeAndNb( int nbArrows,
|
void SetArrowShapeAndNb( int nbArrows,
|
||||||
double headLength,
|
double headLength,
|
||||||
double headRadius,
|
double headRadius,
|
||||||
double start=0.);
|
double start=0.,
|
||||||
|
const char* labels=0);
|
||||||
void SetArrows( const gp_Ax1* axes,
|
void SetArrows( const gp_Ax1* axes,
|
||||||
double length);
|
double length);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user