Dear Cory,
Following Your suggestion, I tried to modify my current plugin to include a new
representation. However, I'm lost on how to combine the two things together. The
example at the wiki and the one I found from Utkarsh
(http://public.kitware.com/pipermail/paraview/2011-July/022296.html) replace the
Mapper and not the actor. So I'm not sure where to place the
text-plydata-generation in that case. Can You help me to get going with this? My
current attempt is attached.
Many thanks for Your help
Roman
PS: I tried to compile Utkarsh's example but it stops because the
UpdateSuppressor seems to be gone:
/net/home/grothama/vtk/paraview_plugins/Representation/vtkMySpecialRepresentation.cxx:43:53:
error: ?class vtkMySpecialRepresentation? has no member named ?UpdateSuppressor?
Would vtkMySpecialRepresentation need to be derived from vtkPVUpdateSuppressor?
On 05/01/15 14:57, Cory Quammen wrote:
Hi Roman,
A representation plugin could probably do this. It would just need to
set its internal actor to an instance of vtkFollower and set the
camera from the view's renderer, which could be set by overriding the
AddToView(vtkView* view) method in your custom representation.
I hope that helps,
Cory
On Mon, Jan 5, 2015 at 8:24 AM, Dr. Roman Grothausmann
<[email protected]> wrote:
Dear Utkarsh,
Needing the same thing as Willi, I've created a paraview plugin written in
C++ doing basically the same as Your script. Would it be possible to achieve
something like vtkFollower does from within a c++ PV plugin such that the
text always faces the camera? An other idea would be to use Python in the
animation view to rotate the text as the camera orbits. This would be a
workaround only for animations, which would suffice for me. Do You thing
that should be possible if nothing else works?
Many thanks for looking into this.
Roman
On 26/09/13 19:52, Utkarsh Ayachit wrote:
Alas, that's not easy to do, if at all possible, with Python source.
On Thu, Sep 26, 2013 at 5:48 AM, Willi Karel <[email protected]
<mailto:[email protected]>> wrote:
Dear Utkarsh,
would it be possible to synchronize the transform of the rendered
texts
to the transform of the camera, such that the planes in which the
texts
lie stay normal to the viewing direction?
I'm aware of vtkFollower, but I'm not sure if it is applicable / how
to
make use of it in the context of ParaView / Programmable Source, as it
derives from vtkActor.
Many thanks!
Willi.
--
Dr. Roman Grothausmann
Tomographie und Digitale Bildverarbeitung
Tomography and Digital Image Analysis
Institut für Funktionelle und Angewandte Anatomie, OE 4120
Medizinische Hochschule Hannover
Carl-Neuberg-Str. 1
D-30625 Hannover
Tel. +49 511 532-9574
# This exercise demonstrates a filter plugin.
cmake_minimum_required(VERSION 2.6)
FIND_PACKAGE(ParaView REQUIRED)
INCLUDE(${PARAVIEW_USE_FILE})
# Use the PLUGIN macro to create a plugin.
ADD_PARAVIEW_PLUGIN(TextGlyphs3D "1.0"
SERVER_MANAGER_SOURCES TextGlyphs3D.cxx
SERVER_MANAGER_XML TextGlyphs3D.xml)
ADD_PARAVIEW_PLUGIN(Representation "1.0"
SERVER_MANAGER_XML Representation.xml
SERVER_MANAGER_SOURCES
vtkMySpecialPolyDataMapper.cxx
vtkMySpecialRepresentation.cxx)
<ServerManaerConfiguration>
<ProxyGroup name="representations">
<RepresentationProxy name="MySpecialRepresentation"
class="vtkMySpecialRepresentation"
processes="client|renderserver|dataserver"
base_proxygroup="representations"
base_proxyname="SurfaceRepresentation">
<Documentation>
This is the new representation type we are adding. This is identical to
the SurfaceRepresentation except that we are overriding the mapper with
our mapper.
</Documentation>
<!-- End of MySpecialRepresentation -->
</RepresentationProxy>
<Extension name="GeometryRepresentation">
<Documentation>
Extends standard GeometryRepresentation by adding
MySpecialRepresentation as a new type of representation.
</Documentation>
<!-- this adds to what is already defined in PVRepresentationBase -->
<RepresentationType subproxy="MySpecialRepresentation"
text="Special Mapper" subtype="Surface" />
<SubProxy>
<Proxy name="MySpecialRepresentation"
proxygroup="representations" proxyname="MySpecialRepresentation">
</Proxy>
<ShareProperties subproxy="SurfaceRepresentation">
<Exception name="Input" />
<Exception name="Visibility" />
<Exception name="Representation" />
</ShareProperties>
</SubProxy>
</Extension>
</ProxyGroup>
</ServerManaerConfiguration>
//////paraview plugin to render text from array data with z-depth
////
////based on ~/vtk/py/textOrigin_01.py
////based on https://github.com/Kitware/VTK/blob/master/Examples/Annotation/Python/textOrigin.py
//01: scale and translation working
//02: clean-up
//todo:
//add interaction like vtkFollower to orient text to camera in paraview
#include "TextGlyphs3D.h"
#include <vtkInformation.h>
#include <vtkInformationVector.h>
#include <vtkObjectFactory.h>
#include <vtkSmartPointer.h>
#include <vtkStringArray.h>
#include <vtkPointData.h>
#include <vtkVectorText.h>
#include <vtkTransformPolyDataFilter.h>
#include <vtkTransform.h>
#include <vtkAppendPolyData.h>
vtkStandardNewMacro(TextGlyphs3D);
//----------------------------------------------------------------------------
// Description:
TextGlyphs3D::TextGlyphs3D(){
this->TextArrayName= "text labels";
this->Scale= 1;
}
//----------------------------------------------------------------------------
int TextGlyphs3D::RequestData(
vtkInformation *vtkNotUsed(request),
vtkInformationVector **inputVector,
vtkInformationVector *outputVector){
// get the info objects
vtkInformation *inInfo0 = inputVector[0]->GetInformationObject(0);
vtkInformation *outInfo = outputVector->GetInformationObject(0);
// get the input and ouptut
vtkPolyData *input = vtkPolyData::SafeDownCast(
inInfo0->Get(vtkDataObject::DATA_OBJECT()));
vtkPolyData *output = vtkPolyData::SafeDownCast(
outInfo->Get(vtkDataObject::DATA_OBJECT()));
vtkStringArray* textArray= vtkStringArray::SafeDownCast(input->GetPointData()->GetAbstractArray(this->TextArrayName));
if(!textArray){
std::cerr << "Specified array could not be casted to vtkStringArray! Aborting." << std::endl;
return EXIT_FAILURE;
}
vtkSmartPointer<vtkVectorText> text3d= vtkSmartPointer<vtkVectorText>::New();
vtkSmartPointer<vtkTransformPolyDataFilter> tff= vtkSmartPointer<vtkTransformPolyDataFilter>::New();
tff->SetInputConnection(text3d->GetOutputPort());
vtkSmartPointer<vtkAppendPolyData> append= vtkSmartPointer<vtkAppendPolyData>::New();
for(vtkIdType i= 0; i < input->GetNumberOfPoints(); i++){
text3d->SetText(textArray->GetValue(i));
vtkSmartPointer<vtkTransform> tf= vtkSmartPointer<vtkTransform>::New();
tf->Translate(input->GetPoint(i));
tf->Scale(this->Scale, this->Scale, this->Scale);
tff->SetTransform(tf);
tff->Update();
vtkSmartPointer<vtkPolyData> outputCopy = vtkSmartPointer<vtkPolyData>::New();
outputCopy->ShallowCopy(tff->GetOutput());
append->AddInputData(outputCopy);
}
append->Update();
output->ShallowCopy(append->GetOutput());
//output->GetActor();
return 1;
//return EXIT_SUCCESS; //apparently not good for pv
}
//----------------------------------------------------------------------------
void TextGlyphs3D::PrintSelf(ostream& os, vtkIndent indent){
this->Superclass::PrintSelf(os,indent);
os << indent << "TextArrayName: " << this->TextArrayName << endl;
os << indent << "Scale: " << this->Scale << endl;
os << indent << endl;
}
// .NAME TextGlyphs3D - filter for paraview to render text from array data with z-depth
// .SECTION Description
#ifndef __TextGlyphs3D_h
#define __TextGlyphs3D_h
#include "vtkPolyDataAlgorithm.h"
class VTK_EXPORT TextGlyphs3D : public vtkPolyDataAlgorithm
{
public:
static TextGlyphs3D *New();
vtkTypeMacro(TextGlyphs3D,vtkPolyDataAlgorithm);
void PrintSelf(ostream& os, vtkIndent indent);
vtkSetMacro(TextArrayName, vtkStdString);
vtkGetMacro(TextArrayName, vtkStdString);
vtkSetMacro(Scale, double);
vtkGetMacro(Scale, double);
protected:
TextGlyphs3D();
~TextGlyphs3D() {};
int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *);
vtkStdString TextArrayName;
double Scale;
private:
TextGlyphs3D(const TextGlyphs3D&); // Not implemented.
void operator=(const TextGlyphs3D&); // Not implemented.
};
#endif
<ServerManagerConfiguration>
<ProxyGroup name="filters">
<SourceProxy name="TextGlyphs3D"
class="TextGlyphs3D"
label="Text Glyphs 3D">
<InputProperty command="SetInputConnection" name="Input">
<DataTypeDomain name="input_type">
<DataType value="vtkPolyData" />
</DataTypeDomain>
<Documentation>This property specifies the input image data.
</Documentation>
</InputProperty>
<StringVectorProperty name="YourStringVariable"
command="SetTextArrayName"
number_of_elements="1"
default_values="hkl-label">
</StringVectorProperty>
<DoubleVectorProperty name="TextScale"
command="SetScale"
number_of_elements="1"
default_values="1">
<DoubleRangeDomain name="range" />
</DoubleVectorProperty>
</SourceProxy>
</ProxyGroup>
</ServerManagerConfiguration>
/*=========================================================================
Program: ParaView
Module: $RCSfile$
Copyright (c) Kitware, Inc.
All rights reserved.
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "vtkMySpecialRepresentation.h"
#include "vtkObjectFactory.h"
#include "vtkPVLODActor.h"
#include "TextGlyphs3D.h"
#include <vtkFollower.h>
vtkStandardNewMacro(vtkMySpecialRepresentation);
//----------------------------------------------------------------------------
vtkMySpecialRepresentation::vtkMySpecialRepresentation(){
this->Mapper->SetInputConnection(TextGlyphs3D...);
// this->Actor->Delete();
// this->Actor = vtkFollower::New();
// this->Actor->SetCamera(this->Renderer->GetActiveCamera());
// this->SetupDefaults();
}
//----------------------------------------------------------------------------
virtual bool vtkMySpecialRepresentation::AddToView(vtkView *view){
vtkPVRenderView* rview = vtkPVRenderView::SafeDownCast(view);
if (rview){
//vtkActor follower= vtkFollower::New();
vtkPVLODActor follower= vtkFollower::New();
follower->SetCamera(rview->GetRenderer()->GetActiveCamera());
this->Actor->Delete();
this->Actor= follower;
rview->GetRenderer()->AddActor(follower);
}
return this->Superclass::AddToView(view);
}
//----------------------------------------------------------------------------
vtkMySpecialRepresentation::~vtkMySpecialRepresentation()
{
//this->TextureMapToPlane->Delete();
}
//----------------------------------------------------------------------------
void vtkMySpecialRepresentation::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os, indent);
}
/*=========================================================================
Program: ParaView
Module: $RCSfile$
Copyright (c) Kitware, Inc.
All rights reserved.
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// .NAME vtkMySpecialRepresentation
// .SECTION Description
//
#ifndef __vtkMySpecialRepresentation_h
#define __vtkMySpecialRepresentation_h
#include "vtkGeometryRepresentation.h"
class VTK_EXPORT vtkMySpecialRepresentation : public vtkGeometryRepresentation
{
public:
static vtkMySpecialRepresentation* New();
vtkTypeMacro(vtkMySpecialRepresentation, vtkGeometryRepresentation);
void PrintSelf(ostream& os, vtkIndent indent);
//BTX
protected:
vtkMySpecialRepresentation();
~vtkMySpecialRepresentation();
virtual bool AddToView(vtkView* view);
private:
vtkMySpecialRepresentation(const vtkMySpecialRepresentation&); // Not implemented
void operator=(const vtkMySpecialRepresentation&); // Not implemented
//ETX
};
#endif
_______________________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Please keep messages on-topic and check the ParaView Wiki at:
http://paraview.org/Wiki/ParaView
Search the list archives at: http://markmail.org/search/?q=ParaView
Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/paraview