X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSMESHGUI%2FSMESHGUI_MeshEditPreview.cxx;h=50fe4e59246f8db15af2859fbdb98c499f001f34;hb=18dade91d06a5b9964bb5604dbfdbc0ff4deef0a;hp=f80c0dc524c920be61a65379f7afbb6ecc6fd000;hpb=0eac807ec151becae655c3c3791c2ef5ed118ca7;p=modules%2Fsmesh.git diff --git a/src/SMESHGUI/SMESHGUI_MeshEditPreview.cxx b/src/SMESHGUI/SMESHGUI_MeshEditPreview.cxx index f80c0dc52..50fe4e592 100644 --- a/src/SMESHGUI/SMESHGUI_MeshEditPreview.cxx +++ b/src/SMESHGUI/SMESHGUI_MeshEditPreview.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE // // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -6,7 +6,7 @@ // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either -// version 2.1 of the License. +// version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -28,23 +28,26 @@ #include "SMESHGUI_MeshEditPreview.h" #include "SMESHGUI_VTKUtils.h" - -#include -#include +#include "SMESH_Actor.h" +#include "SMESH_ActorUtils.h" // SALOME GUI includes -#include +#include #include +#include // VTK includes -#include -#include #include -#include -#include -#include +#include #include +#include +#include #include +#include +#include +#include +#include +#include // Qt includes #include @@ -88,7 +91,6 @@ SMESHGUI_MeshEditPreview::SMESHGUI_MeshEditPreview(SVTK_ViewWindow* theViewWindo aMapper->Delete(); myViewWindow->AddActor(myPreviewActor); - } //================================================================================ @@ -101,9 +103,15 @@ SMESHGUI_MeshEditPreview::~SMESHGUI_MeshEditPreview() { myGrid->Delete(); + for ( size_t iA = 0; iA < myLabelActors.size(); ++iA ) + if ( myLabelActors[iA] ) + { + myPreviewActor->GetRenderer()->RemoveActor( myLabelActors[iA] ); + myLabelActors[iA]->Delete(); + } + myViewWindow->RemoveActor(myPreviewActor); myPreviewActor->Delete(); - } //================================================================================ @@ -118,8 +126,9 @@ vtkIdType getCellType( const SMDSAbs_ElementType theType, { switch( theType ) { + case SMDSAbs_Ball: return VTK_VERTEX; case SMDSAbs_Node: return VTK_VERTEX; - case SMDSAbs_Edge: + case SMDSAbs_Edge: if( theNbNodes == 2 ) return VTK_LINE; else if ( theNbNodes == 3 ) return VTK_QUADRATIC_EDGE; else return VTK_EMPTY_CELL; @@ -164,7 +173,7 @@ void SMESHGUI_MeshEditPreview::SetData (const SMESH::MeshPreviewStruct* previewD vtkPoints* aPoints = vtkPoints::New(); aPoints->SetNumberOfPoints(aNodesXYZ.length()); - for ( int i = 0; i < aNodesXYZ.length(); i++ ) { + for ( size_t i = 0; i < aNodesXYZ.length(); i++ ) { aPoints->SetPoint( i, aNodesXYZ[i].x, aNodesXYZ[i].y, aNodesXYZ[i].z ); } myGrid->SetPoints(aPoints); @@ -188,7 +197,7 @@ void SMESHGUI_MeshEditPreview::SetData (const SMESH::MeshPreviewStruct* previewD vtkIdList *anIdList = vtkIdList::New(); int aNodePos = 0; - for ( int i = 0; i < anElemTypes.length(); i++ ) { + for ( size_t i = 0; i < anElemTypes.length(); i++ ) { const SMESH::ElementSubType& anElementSubType = anElemTypes[i]; SMDSAbs_ElementType aType = SMDSAbs_ElementType(anElementSubType.SMDS_ElementType); vtkIdType aNbNodes = anElementSubType.nbNodesInElement; @@ -232,10 +241,11 @@ void SMESHGUI_MeshEditPreview::SetData (const SMESH::MeshPreviewStruct* previewD */ //================================================================================ -void SMESHGUI_MeshEditPreview::SetArrowShapeAndNb( int nbArrows, - double headLength, - double headRadius, - double start) +void SMESHGUI_MeshEditPreview::SetArrowShapeAndNb( int nbArrows, + double headLength, + double headRadius, + double start, + const char* labels) { const int theNbPoints = 10; // in one arrow myUnitArrowPnts.reserve( theNbPoints ); @@ -286,7 +296,28 @@ void SMESHGUI_MeshEditPreview::SetArrowShapeAndNb( int nbArrows, myGrid->InsertNextCell( VTK_LINE, 2, conn ); } - myNbArrows = nbArrows; + myLabelActors.resize( nbArrows, ( vtkTextActor*) NULL ); + char label[] = "X"; + if ( labels ) + for ( int 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 +333,7 @@ void SMESHGUI_MeshEditPreview::SetArrows( const gp_Ax1* axes, { vtkPoints* aPoints = myGrid->GetPoints(); - for ( int iP = 0, iA = 0; iA < myNbArrows; ++iA ) + for ( int iP = 0, iA = 0; iA < (int) myLabelActors.size(); ++iA ) { gp_Trsf trsf; trsf.SetTransformation( gp_Ax3( axes[iA].Location(), axes[iA].Direction() ), gp::XOY() ); @@ -313,6 +344,14 @@ void SMESHGUI_MeshEditPreview::SetArrows( const gp_Ax1* axes, p.Transform( trsf ); 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(); @@ -327,6 +366,9 @@ void SMESHGUI_MeshEditPreview::SetArrows( const gp_Ax1* axes, void SMESHGUI_MeshEditPreview::SetVisibility (bool theVisibility) { myPreviewActor->SetVisibility(theVisibility); + for ( size_t iA = 0; iA < myLabelActors.size(); ++iA ) + if ( myLabelActors[iA] ) + myLabelActors[iA]->SetVisibility(theVisibility); SMESH::RepaintCurrentView(); }