Attached Files | vtk_logo_widget.patch [^] (8,677 bytes) 2009-10-02 05:27 [Show Content] [Hide Content]diff -rupN vtk-5.4.2\Widgets\vtkLogoRepresentation.cxx vtk-5.4.2.patched\Widgets\vtkLogoRepresentation.cxx
--- vtk-5.4.2\Widgets\vtkLogoRepresentation.cxx Mon Apr 23 10:03:00 2007
+++ vtk-5.4.2.patched\Widgets\vtkLogoRepresentation.cxx Wed Sep 23 21:27:18 2009
@@ -20,7 +20,7 @@
#include "vtkPolyData.h"
#include "vtkPolyDataMapper2D.h"
#include "vtkProperty2D.h"
-#include "vtkActor2D.h"
+#include "vtkTexturedActor2D.h"
#include "vtkPolyData.h"
#include "vtkTexture.h"
#include "vtkPolyDataMapper2D.h"
@@ -70,20 +70,24 @@ vtkLogoRepresentation::vtkLogoRepresenta
tc->Delete();
this->TextureMapper = vtkPolyDataMapper2D::New();
this->TextureMapper->SetInput(this->TexturePolyData);
- this->TextureActor = vtkActor2D::New();
+ this->TextureActor = vtkTexturedActor2D::New();
this->TextureActor->SetMapper(this->TextureMapper);
- this->ImageProperty->SetOpacity(0.25);
+ this->TextureActor->SetTexture(this->Texture);
+ this->ImageProperty->SetOpacity(1.);
this->TextureActor->SetProperty(this->ImageProperty);
-
- // Set up parameters from thw superclass
+ this->TextureActor->GetPositionCoordinate()->SetCoordinateSystemToDisplay();
+ this->TextureActor->GetPosition2Coordinate()->SetCoordinateSystemToDisplay();
+ this->TextureActor->GetPosition2Coordinate()->SetReferenceCoordinate(0);
+ // Set up parameters from the superclass
double size[2];
this->GetSize(size);
this->Position2Coordinate->SetValue(0.04*size[0], 0.04*size[1]);
this->ProportionalResize = 1;
this->Moving = 1;
this->ShowBorder = vtkBorderRepresentation::BORDER_ACTIVE;
- this->PositionCoordinate->SetValue(0.9, 0.025);
- this->Position2Coordinate->SetValue(0.075, 0.075);
+ this->BWActor->VisibilityOff();
+ this->PositionCoordinate->SetValue(0.875, 0.875);
+ this->Position2Coordinate->SetValue(0.1, 0.1);
}
//-------------------------------------------------------------------------
@@ -120,58 +124,56 @@ inline void vtkLogoRepresentation::Adjus
imageSize[0] *= r0;
imageSize[1] *= r0;
}
-
- if ( imageSize[0] < borderSize[0] )
- {
- o[0] += (borderSize[0]-imageSize[0])/2.0;
- }
- if ( imageSize[1] < borderSize[1] )
- {
- o[1] += (borderSize[1]-imageSize[1])/2.0;
- }
+ o[0] = (borderSize[0]-imageSize[0])/2.0;
+ o[1] = (borderSize[1]-imageSize[1])/2.0;
}
//-------------------------------------------------------------------------
void vtkLogoRepresentation::BuildRepresentation()
{
- if ( this->GetMTime() > this->BuildTime ||
- (this->Renderer && this->Renderer->GetVTKWindow() &&
- this->Renderer->GetVTKWindow()->GetMTime() > this->BuildTime) )
+ if ( this->TextureActor )
{
+ int *p1 = this->PositionCoordinate->
+ GetComputedDisplayValue(this->Renderer);
+ int *p2 = this->Position2Coordinate->
+ GetComputedDisplayValue(this->Renderer);
+ this->TextureActor->GetPositionCoordinate()->SetValue(p1[0],p1[1]);
+ this->TextureActor->GetPosition2Coordinate()->SetValue(p2[0],p2[1]);
- // Determine and adjust the size of the image
- if ( this->Image )
+ if ( this->GetMTime() > this->BuildTime ||
+ this->TextureActor->GetMTime() > this->BuildTime )
{
- double imageSize[2], borderSize[2], o[2];
- imageSize[0] = 0.0;
- imageSize[1] = 0.0;
- this->Image->Update();
- if ( this->Image->GetDataDimension() == 2 )
+ // Determine and adjust the size of the image
+ if ( this->Image )
{
- int dims[3];
- this->Image->GetDimensions(dims);
- imageSize[0] = static_cast<double>(dims[0]);
- imageSize[1] = static_cast<double>(dims[1]);
+ double imageSize[2], borderSize[2], o[2];
+ imageSize[0] = 0.0;
+ imageSize[1] = 0.0;
+ this->Image->Update();
+ if ( this->Image->GetDataDimension() == 2 )
+ {
+ int dims[3];
+ this->Image->GetDimensions(dims);
+ imageSize[0] = static_cast<double>(dims[0]);
+ imageSize[1] = static_cast<double>(dims[1]);
+ }
+
+ borderSize[0] = p2[0] - p1[0];
+ borderSize[1] = p2[1] - p1[1];
+ o[0] = 0.0;
+ o[1] = 0.0;
+
+ // this preserves the image aspect ratio. The image is
+ // centered around the center of the bordered region.
+ this->AdjustImageSize(o,borderSize,imageSize);
+
+ // Update the points
+ this->Texture->SetInput(this->Image);
+ this->TexturePoints->SetPoint(0, o[0],o[1],0.0);
+ this->TexturePoints->SetPoint(1, o[0]+imageSize[0],o[1],0.0);
+ this->TexturePoints->SetPoint(2, o[0]+imageSize[0],o[1]+imageSize[1],0.0);
+ this->TexturePoints->SetPoint(3, o[0],o[1]+imageSize[1],0.0);
}
- int *p1 = this->PositionCoordinate->
- GetComputedDisplayValue(this->Renderer);
- int *p2 = this->Position2Coordinate->
- GetComputedDisplayValue(this->Renderer);
- borderSize[0] = p2[0] - p1[0];
- borderSize[1] = p2[1] - p1[1];
- o[0] = static_cast<double>(p1[0]);
- o[1] = static_cast<double>(p1[1]);
-
- // this preserves the image aspect ratio. The image is
- // centered around the center of the bordered ragion.
- this->AdjustImageSize(o,borderSize,imageSize);
-
- // Update the points
- this->Texture->SetInput(this->Image);
- this->TexturePoints->SetPoint(0, o[0],o[1],0.0);
- this->TexturePoints->SetPoint(1, o[0]+imageSize[0],o[1],0.0);
- this->TexturePoints->SetPoint(2, o[0]+imageSize[0],o[1]+imageSize[1],0.0);
- this->TexturePoints->SetPoint(3, o[0],o[1]+imageSize[1],0.0);
}
}
@@ -189,7 +191,7 @@ void vtkLogoRepresentation::GetActors2D(
//-------------------------------------------------------------------------
void vtkLogoRepresentation::ReleaseGraphicsResources(vtkWindow *w)
{
- this->Texture->ReleaseGraphicsResources(w);
+ //this->Texture->ReleaseGraphicsResources(w);
this->TextureActor->ReleaseGraphicsResources(w);
this->Superclass::ReleaseGraphicsResources(w);
}
@@ -201,10 +203,34 @@ int vtkLogoRepresentation::RenderOverlay
vtkRenderer* ren = vtkRenderer::SafeDownCast(v);
if (ren)
{
- this->Texture->Render(ren);
+ //this->Texture->Render(ren);
count += this->TextureActor->RenderOverlay(v);
}
return count;
+}
+
+//-------------------------------------------------------------------------
+int vtkLogoRepresentation::RenderOpaqueGeometry(vtkViewport *w)
+{
+ int count = this->Superclass::RenderOpaqueGeometry(w);
+ count += this->TextureActor->RenderOpaqueGeometry(w);
+ return count;
+}
+
+//-------------------------------------------------------------------------
+int vtkLogoRepresentation::RenderTranslucentPolygonalGeometry(vtkViewport *w)
+{
+ int count = this->Superclass::RenderTranslucentPolygonalGeometry(w);
+ count += this->TextureActor->RenderTranslucentPolygonalGeometry(w);
+ return count;
+}
+
+//-------------------------------------------------------------------------
+int vtkLogoRepresentation::HasTranslucentPolygonalGeometry()
+{
+ int result = this->Superclass::HasTranslucentPolygonalGeometry();
+ result |= this->TextureActor->HasTranslucentPolygonalGeometry();
+ return result;
}
//-------------------------------------------------------------------------
diff -rupN vtk-5.4.2\Widgets\vtkLogoRepresentation.h vtk-5.4.2.patched\Widgets\vtkLogoRepresentation.h
--- vtk-5.4.2\Widgets\vtkLogoRepresentation.h Sat Jul 01 16:45:00 2006
+++ vtk-5.4.2.patched\Widgets\vtkLogoRepresentation.h Wed Sep 23 20:28:56 2009
@@ -35,7 +35,7 @@ class vtkTexture;
class vtkPolyData;
class vtkPoionts;
class vtkPolyDataMapper2D;
-class vtkActor2D;
+class vtkTexturedActor2D;
class vtkProperty2D;
@@ -71,6 +71,9 @@ public:
virtual void GetActors2D(vtkPropCollection *pc);
virtual void ReleaseGraphicsResources(vtkWindow*);
virtual int RenderOverlay(vtkViewport*);
+ virtual int RenderOpaqueGeometry(vtkViewport*);
+ virtual int RenderTranslucentPolygonalGeometry(vtkViewport*);
+ virtual int HasTranslucentPolygonalGeometry();
protected:
vtkLogoRepresentation();
@@ -85,7 +88,7 @@ protected:
vtkPoints *TexturePoints;
vtkPolyData *TexturePolyData;
vtkPolyDataMapper2D *TextureMapper;
- vtkActor2D *TextureActor;
+ vtkTexturedActor2D *TextureActor;
// Helper methods
void AdjustImageSize(double o[2], double borderSize[2], double imageSize[2]);
|