#include <vtkCommand.h>
#include <vtkPlane.h>
+#include <vtkPropCollection.h>
+#include <vtkProp.h>
+#include <vtkActor.h>
+#include <vtkMapper.h>
+#include <vtkPolyDataMapper.h>
+#include <vtkPolyData.h>
+#include <vtkTextMapper.h>
+#include <vtkTextActor.h>
+#include <vtkTextProperty.h>
+#include <vtkRenderer.h>
+
#include "utilities.h"
#ifdef _DEBUG_
static int MYDEBUG = 0;
#endif
+#include <vtkPropCollection.h>
+#include <vtkProp.h>
+#include <vtkActor.h>
+#include <vtkMapper.h>
+#include <vtkPolyDataMapper.h>
+#include <vtkPolyData.h>
+#include <vtkTextMapper.h>
+#include <vtkTextActor.h>
+#include <vtkTextProperty.h>
+#include <vtkRenderer.h>
+//
+class VISU_FPSTextActor : public vtkTextActor {
+public:
+ vtkTypeMacro( VISU_FPSTextActor, vtkTextActor);
+ static VISU_FPSTextActor* New();
+ virtual int RenderOpaqueGeometry(vtkViewport *theViewport);
+};
+//
+vtkStandardNewMacro(VISU_FPSTextActor);
+//
+//======================================================================
+// function: RenderOpaqueGeometry
+// purpose :
+//======================================================================
+int VISU_FPSTextActor::RenderOpaqueGeometry(vtkViewport *theViewport) {
+
+ vtkRenderer *pRenderer= dynamic_cast <vtkRenderer*>(theViewport);
+ if (pRenderer){
+ float aTS, aTol=1.e-6;
+ char buf[128]={"Divide by zero"};
+ //
+ aTS =pRenderer->GetLastRenderTimeInSeconds ();
+ if (aTS>aTol) {
+ vtkProp *pProp;
+ int iCount=0;
+ //
+ vtkPropCollection *pProps=pRenderer->GetProps();
+ pProps->InitTraversal();
+ for (; 1; ) {
+ pProp=pProps->GetNextProp();
+ if(!pProp) {
+ break;
+ }
+ vtkActor *pActor=dynamic_cast <vtkActor*>(pProp);
+ if (pActor){
+ if (pProp->GetVisibility()) {
+ vtkMapper *pMapper=pActor->GetMapper();
+ vtkPolyDataMapper *pPDMapper=dynamic_cast <vtkPolyDataMapper*>(pMapper);
+ if (pPDMapper){
+ vtkPolyData *pPolyData=pPDMapper->GetInput();
+ int aNbC=pPolyData->GetNumberOfCells();
+ iCount+=aNbC;
+ }
+ }
+ }
+ }
+ float aTS1=1./aTS;
+ sprintf(buf, "\n FPS: %.2f \nNbCells: %d ", aTS1, iCount);
+ }
+ SetInput(buf);
+ }
+ //
+ Superclass::RenderOpaqueGeometry(theViewport);
+}
//----------------------------------------------------------------------------
vtkStandardNewMacro(VVTK_Renderer1);
//aPlaneProperty->SetOpacity(aSelectedPlaneProperty->GetOpacity()*1.5);
myImplicitFunctionWidget->Delete();
+ //
+ vtkSmartPointer<vtkTextMapper>myTextMapper;
+ myTextMapper=vtkTextMapper::New();
+ myTextActor=VISU_FPSTextActor::New();
+ //
+ myTextMapper->Delete();
+ myTextActor->Delete();
+ //
+ vtkTextProperty *pTextProperty=myTextMapper->GetTextProperty();
+ pTextProperty->SetJustificationToRight();
+ pTextProperty->SetVerticalJustificationToTop();
+ pTextProperty->SetFontSize(10);
+ pTextProperty->SetOpacity (0.75);
+ //
+ myTextActor->SetMapper(myTextMapper.GetPointer());
+ myTextActor->SetPickable(false);
+ myTextActor->ScaledTextOff();
+ myTextActor->SetAlignmentPoint(8);
+ myTextActor->SetPosition2 (1., 1.);
+ //
+ vtkRenderer* pRenderer=GetDevice();
+ pRenderer->AddActor2D(myTextActor.GetPointer());
}
VVTK_Renderer1